akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
struct Graph
{
    Graph(const std::size_t v) : V{v}, edge(v), rev_edge(v) {}
    void addEdge(const std::size_t from, const std::size_t to) { edge[from].push_back(to), rev_edge[to].push_back(from); }
    const std::size_t V;
    std::vector<std::vector<std::size_t>> edge, rev_edge;
};
std::pair<bool, std::vector<std::size_t>> TopSort(const Graph& g)
{
    std::vector<std::size_t> srt, used(g.V, 0);
    auto dfs = [&](auto&& self, const std::size_t s) -> bool {
        if (used[s] == 1) {
            return false;
        } else if (used[s] == 0) {
            used[s] = 1;
            for (const std::size_t to : g.edge[s]) {
                if (not self(self, to)) { return false; }
            }
            used[s] = 2, srt.push_back(s);
        }
        return true;
    };
    for (std::size_t i = 0; i < g.V; i++) {
        if (not dfs(dfs, i)) { return {false, srt}; }
    }
    std::reverse(srt.begin(), srt.end());
    return {true, srt};
}
constexpr int MOD = 1e9 + 7;
int main()
{
    int H, W;
    std::cin >> H >> W;
    Graph g(H * W);
    std::vector<std::string> F(H);
    for (int i = 0; i < H; i++) { std::cin >> F[i]; }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (F[i][j] == '#') { continue; }
            if (i < H - 1 and F[i + 1][j] == '.') { g.addEdge(i * W + j, i * W + j + W); }
            if (j < W - 1 and F[i][j + 1] == '.') { g.addEdge(i * W + j, i * W + j + 1); }
        }
    }
    std::vector<int> dp(H * W, 0);
    dp[0] = 1;
    const auto ord = TopSort(g).second;
    for (const int s : ord) {
        for (const int to : g.edge[s]) { (dp[to] += dp[s]) %= MOD; }
    }
    std::cout << dp[H * W - 1] << std::endl;
    return 0;
}


Measured memory_bytes: 138220
#include <bits/stdc++.h> 
using namespace std; 
const int maxn = 1e5 + 100; 
const int maxm = 1 << 15 + 10;  

int n, ans, state, tot; 
int val[maxn], cnt[20], f[maxm], s[maxn], sum[maxm]; 
// sum表示每个集合的异或值
int main() {
	scanf("%d", &n); 
	for (int i = 1; i < n; ++i) {
		int x, y, z; 
		scanf("%d%d%d", &x, &y, &z); 
		x++, y++; 
		val[x] ^= z, val[y] ^= z; 
	}
	for (int i = 1; i <= n; ++i) cnt[val[i]]++; 
	ans = n; ans -= cnt[0]; 
	for (int i = 1; i <= 15; ++i) {
		ans -= cnt[i] / 2 ; 
		state |= (cnt[i] & 1) << (i - 1); 
	}
	tot = 1 << 15; 
	for (int i = 0; i < tot; ++i) {
		int tmp = 0; 	
		for (int j = 1; j <= 15; ++j) {
			if ((i >> (j - 1)) & 1) tmp ^= j; 
		}
		sum[i] = tmp; 
	}
	for (int i = 1; i < tot; ++i) {
		for (int j = i; j; j = (j - 1) & i) {
			if (!sum[i]) f[i] = max(f[i], f[i ^ j] + 1); 
		}
	}
	ans -= f[state]; 
	printf("%d\n", ans); 
	return 0; 
}

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

pair<ll,ll> factorize(ll n){
    pair<ll,ll> res(1,n);
    for(ll i = 2;i*i <=n;i++){
        if(n % i == 0){
            ll p1 = i, p2 = n/i;
            if(abs(res.first+res.second) > abs(p1+p2)){
                res = make_pair(p1,p2);
            }
        }
    }
    return res;
}

int main() {
    ll n;
    cin >> n;
    pair<ll,ll> cell = factorize(n);
    cout << cell.first+cell.second-2 << endl;
}

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

for i in range(q):
    l,r=map(int,input().split())
    print(a[r-1]-a[l-1])

Measured memory_bytes: 13080
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d,e,f,g;
  while(1){
    int a,b,c=0,d=0,e,f,g;
    cin >>a;
    if(a==0) break;
    for(int n=0;n<a;n++){
      cin >>b;
      if(b>0) c++;
      if(d==0&&b>1) d++;
    }
    if(d==1) cout <<c+1<<'\n';
    else  cout <<"NA\n";
  }
  return (0);
}



Measured memory_bytes: 3132
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    ullong Q = static_cast<ullong>(1e9 + 7);
    ullong N;
    cin >> N;

    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }

    ullong not0 = 1, not0and9 = 1;
    ullong total = 1;
    for (uint i=1; i<=N; ++i) {
        not0 *= 9;
        not0 %= Q;
        not0and9 *= 8;
        not0and9 %= Q;

        total *= 10;
        total %= Q;
    }
    ullong not0or9 = (not0 + not0 + Q - not0and9) % Q;
    ullong ans = (total + Q - not0or9) % Q;
    cout << ans << endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<cd> vcd;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 2e5 + 6, K = 26;
const double pi = acos(-1);
int n, a[maxn], ans[maxn], xr = 0;

void solve(){
	int i, j, k, l, r; cin >> n;
	for1(i, 1, n){
		cin >> a[i]; xr ^= a[i];
	}
	for1(i, 1, n){
		ans[i] = xr ^ a[i];
	}
	for1(i, 1, n){
		cout << ans[i] << ' ';
	}
	
}

signed main() {
    //freopen(".INP", "r", stdin);
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}


Measured memory_bytes: 6668
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}

signed _main(){
  int A,P; cin >> A >> P;
  cout << (A*3+P)/2 << endl;
  return 0;
}


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

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		call(n);
	}

	private static void call(int n) {
		StringBuilder sb = new StringBuilder();
		for(int i = 1;i <= n;i++){
			if(i % 3 == 0 || String.valueOf(i).indexOf("3") != -1){
				sb.append(" ");
				sb.append(i);
			}
		}
		System.out.println(sb.toString());
	}

}

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

///Author:Refat(BSMRSTU)///

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
const int N = 1e5 + 5;
const int M = 1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}
int main() {
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);
    int test=1;
    double a,b,x,y,ans;
    ///scanf("%d",&test);
    for(int cs=1; cs<=test; cs++) {
        scanf("%lf %lf %lf",&a,&b,&x);
        y=x/a;
        if(y<=(a*b)/2) {
            ans=atan((2.0*x)/(a*b*b));
            ans*=180.0;
            //cout<<ans;
            ans/=pi;
            //cout<<pi<<endl;
        } else {
            ans=atan((a*a)/(2.0*((a*b)-(x/a))));
            ans*=180.0;
            //cout<<ans<<endl;
            ans/=pi;
        }
        printf("%.10f\n",90-ans);
    }
    return 0;
}



Measured memory_bytes: 256
//package Atcoder;
import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++)
		{
			int a=fs.nextInt();
			int b=fs.nextInt();
			if(a==b)
				arr[i]=1;
			else
				arr[i]=0;
		}
		//System.out.println(Arrays.toString(arr));
		int c=0,max=0;
		for(int i=0;i<n-1;i++)
		{
			if(arr[i]==arr[i+1] && arr[i]==1)
			{
				c++;
			}
			else
			{
				max=Math.max(max,c+1);
				c=0;
			}
		}
		max=Math.max(max, c+1);
		System.out.println(max>=3 ? "Yes":"No");
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

Measured memory_bytes: 32780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, j) for(int i = 0; i < (int)(j); i++)
constexpr int INF = 1 << 28;
using EdgeList = vector<vector<int>>;
using pii = pair<int, int>;
// ?????£?????????????????°?????? E ???????????????
// O(N + M) N: ????????°, M: ?????°
vector<pii> enumerate_bridges(const EdgeList &E) {
    int N = E.size();
    vector<int> ord(N, -1), low(N);
    int cnt = 0;
    vector<pii> bridges;
    function<void(int, int)> dfs = [&] (int now, int pre) {
        ord[now] = cnt++;
        low[now] = ord[now];
        for(int nxt : E[now]) {
            if(ord[nxt] < 0) {
                // not visited
                dfs(nxt, now);
                low[now] = min(low[now], low[nxt]);
                if(ord[now] < low[nxt]) {
                    bridges.emplace_back(min(now, nxt), max(now, nxt));
                }
            } else if(nxt != pre) {
                // visited
                low[now] = min(low[now], ord[nxt]);
            } 
        }
    };
    // ??£?????°????????????dfs(0)????????§OK?????????
    rep(i, N) if(ord[i] < 0) dfs(i, -1);
    return bridges;
}
// ?????£?????????????????°?????? E ?????¢??????????????????????????????
// O(N + M) N: ????????°, M: ?????°
vector<int> enumerate_articulations(const EdgeList &E) {
    int N = E.size();
    vector<int> ord(N, -1), low(N);
    int cnt = 0;
    vector<int> articulations;
    function<void(int, int)> dfs = [&] (int now, int pre) {
        ord[now] = cnt++;
        low[now] = ord[now];
        
        bool is_articulation = false;
        int dfs_children = 0;
        
        for(int nxt : E[now]) {
            if(ord[nxt] < 0) {
                // not visited
                dfs_children++;
                dfs(nxt, now);
                low[now] = min(low[now], low[nxt]);
                if(pre >= 0 and ord[now] <= low[nxt]) {
                    is_articulation = true;
                }
            } else if(nxt != pre) {
                // visited
                low[now] = min(low[now], ord[nxt]);
            } 
        }
        if(pre < 0 and dfs_children > 1) is_articulation = true;
        if(is_articulation) articulations.push_back(now);
    };
    // ??£?????°????????????dfs(0)????????§OK?????????
    rep(i, N) if(ord[i] < 0) dfs(i, -1);
    return articulations;
}
int main() {
    int N, M; cin >> N >> M;
    EdgeList E(N);
    rep(i, M) {
        int a, b; cin >> a >> b;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    auto ans = enumerate_articulations(E);
    sort(begin(ans), end(ans));
    for(int a : ans) cout << a << endl;
    return 0;
}

Measured memory_bytes: 4756
let readInt () = stdin.ReadLine() |> int
let readCharArray () = stdin.ReadLine().ToCharArray()
let choice ok ng bool = if bool then ok else ng

readInt ()
|> fun x ->
    if x % 2 = 1 then
        "No"
    else
        readCharArray ()
        |> fun y ->
            let pre = y |> Array.take (x / 2) |> System.String

            let post =
                y
                |> Array.rev
                |> Array.take (x / 2)
                |> Array.rev
                |> System.String

            (pre = post) |> choice "Yes" "No"
|> printfn "%s"


Measured memory_bytes: 29680
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


import java.util.*;

/**
 *
 * @author nai
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        
        //Scanner sc = new Scanner(System.in);
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int nvlist[] = new int[N+1];
        
        int maxvalue = 1;
        
        for(int i = 0; i< N ;i ++){
            nvlist[Integer.parseInt(sc.next())] = i;
        }
        int temp=1;
        //nvlist tansaku
        for(int i = 2; i <= N ;i ++){
            if( nvlist[i-1] > nvlist[i] ){
                temp = 1;
            }
            else{
                temp++ ;
            }
            maxvalue = Math.max(maxvalue,temp);
        }
        
        System.out.println(N - maxvalue);
        
        
        
    }
    
}

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

int main(){

  while(1){
    int card,x;
    cin >> card >> x;
    if(card==0 && x == 0) break;
    int p[100];
    for(int i = 1; i <= card;i++){
      p[card-i+1] = i;
    } 
    for(int i = 1;i <= card;i++){
      //   cout << p[i] << endl;
    }
    for(int i = 0; i < x;i++){
      int a,b;
      cin >> a >> b;
      int tmp[200]={};
      for(int j = 1 ; j < a ; j++){
	tmp[j]= p[j];
      } 
      for(int j = 1; j <= b; j++){
	p[j] = p[a+j-1];
      }
      for(int j = b+1; j <= a+b-1; j++){
	p[j] = tmp[j-b];
      }
    }
    for(int i = 1;i <= card;i++){
      //  cout << p[i] << endl;
    }
    cout << p[1] << endl;

  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = int long long;
map <int ,int> mpa,mpb;

int main(){
  int N;
  cin >> N;
  int A[N+5]={0}, B[N+5]={0};
  ll sum=0;
  ll t=0;
  A[0]=0, B[0]=0,B[N+1]=0,A[N+1]=0;
  for(int i=1;i<=N;i++){
    cin >> A[i];
  }
  for(int i=0;i<=N;i++){
    B[i]=abs(A[i+1]-A[i]);
    sum+=B[i];
  }

  for(int i=1;i<=N;i++){
    t=sum;
    t-=B[i-1]+B[i];
		t+=abs(A[i+1]-A[i-1]);
		cout<<t<<endl;
  }
  return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    vector <int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    int ans = 0;
    for(int i=1;i<n-1;i++){
        if((p[i-1] < p[i]&&p[i]< p[i+1]) ||(p[i+1] < p[i]&&p[i]< p[i-1])) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
  int i, alen, blen, flag = 0;
  char a[200] = {};
  char b[100] = {};
  char *pa;
  char *pb;
  pa = &a[0];
  pb = &b[0];
  scanf("%s", &a);
  scanf("%s", &b);
  alen = strlen(a);
  blen = strlen(b);
  for(i = 0; i < alen; i++) {
    a[alen + i] = a[i];
  }
  for(i = 0; i < alen * 2 - 1; i++) {
    if(strncmp(pa++, pb, blen) == 0) {
      flag = 1;
    }
  }
   if(flag == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i=0;i<(n); ++i)
using namespace std;
typedef long long ll;


int main()
{
	ll n,a=0,b=0;
	cin >> n;
	a = (ll)sqrt(n);
	while (n % a != 0)--a;
	a = max(a, n / a);
	cout << to_string(a).length() << endl;
}

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

long long ma(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int main(){
    long long N,M,a,b,d,cnt;
    cin >> N >> M;
    vector<pair<long long , long long >> people(N);
    vector<pair<long long , long long >> point(M);
    for(int i=0;i<N;i++){
        cin >> a >> b;
        people[i]=make_pair(a,b);
    }
    for(int i=0;i<M;i++){
        cin >> a >> b;
        point[i]=make_pair(a,b);
    }

    for(int i=0;i<N;i++){
        d=ma(people[i],point[0]);
        cnt=1;
        for(int j=1;j<M;j++){
            if(d>ma(people[i],point[j])){
                d=ma(people[i],point[j]);
                cnt=j+1;
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
int main() {
	int A, B, M;
	cin >> A >> B >> M;
	int a[A];
	int amin = INT_MAX;
	for (int i = 0; i < A; i++) {
		cin >> a[i];
		if (a[i] < amin) {
			amin = a[i];
		}
	}
	int b[B];
	int bmin = INT_MAX;
	for (int j = 0; j < B; j++) {
		cin >> b[j];
		if (b[j] < bmin) {
			bmin= b[j];
		}

	}
	int ans = amin + bmin;
	for (int i = 0; i < M; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		if (a[x-1] + b[y-1] - c < ans) {
			ans = a[x-1] + b[y-1] - c;
			
		}
	}

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


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

int main (){
  int N,A;
  cin >> N >> A;
  if (N % 500 == 0){
    cout << "Yes" << endl;
  }
  else if (N % 500 <= A){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

    

Measured memory_bytes: 3560
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
buf = abs(a - t + h[0]*0.006)
ans = 0
for i in range(n):
    if abs(a - t + h[i]*0.006) < buf:
        ans = i
        buf = abs(a - t + h[i]*0.006)
print(ans+1)


Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;
 
class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
            int number=sc.nextInt();
            int max=100000000;
            
            
            int[] initial=new int[number+1];
            int[][] graph=new int[number+1][number+1];
            Arrays.fill(initial, max); //setting up the graph and filling
            //starter array with max values
            for(int i=0; i<number; i++) {
                int u=sc.nextInt();
                int k=sc.nextInt();
                
                for(int j=0; j<k; j++){
                    int v=sc.nextInt();
                    int c=sc.nextInt();
                    
                    graph[u][v]=c;//Filling in the graph
                }
            }
            initial[0]=0;
            
            for(int t=0; t<number; t++) {
                boolean update=false;
                
                for(int i=0; i<number; i++) {
                    for(int j=0; j<number; j++) {
                    	
                        if(initial[i]<max && graph[i][j]>0) {
                            if(initial[j]>initial[i]+graph[i][j]) {//Updating the max value
                                initial[j]=initial[i]+graph[i][j]; //And updating to least
                                					//later.
                                update=true;
                            }
                        }
                    }
                }
                if(! update) break;
            }
            //Print Answer
            for(int i=0; i<number; i++) {
                System.out.println(i+" "+initial[i]);
            }
        }
    }


Measured memory_bytes: 40428
/**
 *    Author  : Ador
 *    Created : 24.07.2020
**/
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cctype>
typedef long long int ll ;
typedef unsigned long long int ull ;
using namespace std ;
int main(void)
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
        //freopen("input.txt", "r", stdin) ;
        //freopen("output.txt", "w", stdout) ;
    ll n , a , b , i , result = pow(2 , 60) , flag = 0 ; cin >> n ;
    for(i = 2 ; i <= sqrt(n) ; ++i)
    {
        if(!(n % i))
        {
            a = i ;
            b = n / i ;
            flag = 1 ;
            result = min(result , ((a - 1) + (b - 1))) ;
        }
    }
    if(flag) cout << result << "\n" ;
    else cout << n - 1 << "\n" ;
    return 0 ;
}


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

const int MAX = 1000010;
const ll MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}


int main(){
    ll n,k;cin>>n>>k;
    init();
    rep(i,1,k+1){
        if(i>n-k+1)cout<<0<<endl;
        else{
            ll a=(fac[n-k+1]*finv[i]%MOD)*finv[n-k+1-i]%MOD;
            ll b=(fac[k-1]*finv[i-1]%MOD)*finv[k-i]%MOD;
            cout<<a*b%MOD<<endl;
        }
    }
}







Measured memory_bytes: 23680
#include <stdio.h>

int main(void) {
    int n, m, np, p[100001] = {0}, ac = 0, wa = 0, watmp[100001] = {0};
    char s[2];
    int i, err;

    err = scanf("%d", &n);
    err = scanf("%d", &m);

    for (i = 0; i < m; i++) {
        err = scanf("%d %s", &np, s);
        if (!p[np]) {
            if (s[0] == 'A') {
                ac++;
                p[np] = 1;
            } else {
                watmp[np]++;
            }
        }
        //printf("%d %d\n", ac, wa);
    }

    for (i = 1; i <= n; i++) {
        if (p[i]) {
            wa += watmp[i];
        }
    }

    printf("%d %d\n", ac, wa);

    return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <cstdint>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <tuple>

static constexpr size_t di[] = {0, 1};
static constexpr size_t dj[] = {1, 0};
static constexpr int MOD = 1e9+7;

int main() {
  size_t H, W;
  scanf("%zu %zu", &H, &W);

  std::vector<std::string> a(H+1);
  for (size_t i = 0; i < H; ++i) {
    char buf[1024];
    scanf("%s", buf);
    a[i] = buf;
    a[i] += '#';
  }
  a[H] = std::string(W+1, '#');

  std::queue<std::pair<size_t, size_t>> q;
  std::vector<std::vector<int>> res(H, std::vector<int>(W));
  std::vector<std::vector<bool>> vis(H, std::vector<bool>(W));
  res[0][0] = 1;
  q.emplace(0, 0);
  while (!q.empty()) {
    size_t i, j;
    std::tie(i, j) = q.front();
    q.pop();
    if (vis[i][j]) continue;
    vis[i][j] = true;
    for (int k = 0; k < 2; ++k) {
      size_t ni = i + di[k];
      size_t nj = j + dj[k];
      if (a[ni][nj] == '#') continue;
      (res[ni][nj] += res[i][j]) %= MOD;
      q.emplace(ni, nj);
    }
  }
  printf("%d\n", res[H-1][W-1]);
}


Measured memory_bytes: 6400
//
// ~oisín~ C++ Template
//

#include                <bits/stdc++.h>
#define MX_N            5001
#define mp              make_pair
#define mod7            1000000007
#define modpi           314159
#define PI              3.141592653589793238
#define pb              push_back
#define FastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define All(a)          a.begin(),a.end()
#define fi              first
#define se              second
#define ll              long long int
#define ull             unsigned long long int

int kx[8]  =            {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8]  =            {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] =            {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] =            {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] =            {+0, +0, +1, -1};
int dy4[4] =            {+1, -1, +0, +0};

ll gcd(ull a, ull b){
    return (a==0)?b:gcd(b%a,a);
}

ll lcm(ull a, ull b){
    return a*(b/gcd(a,b));
}

const long long INF = 1e18;

using namespace std;

ll binpow(ll base, int expo){
    if(expo == 0){
        return 1LL;
    }
    if(expo == 1){
        return base;
    }
    ll tmp = binpow(base, expo/2);
    tmp *= tmp;
    if(expo % 2 == 1){
        tmp *= base;
    }
    return tmp;
}

int main(){
    ll x;
    cin >> x;
    ll n = 26;
    ll offset = 0;
    vector<ll> ans;
    for(ll i=0;true;++i){
        if((x - (offset + 1)) < 0){
            break;
        }
        ans.pb( ( ( x - (offset + 1) ) % binpow(n, i+1) ) / (binpow(n, i)));
        offset += binpow(n, i+1);
    }
    reverse(All(ans));
    for(ll c : ans){
        cout << (char)(c+'a');
    }
    cout << endl;
}


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

bool isPrime(int a) {
    if (a == 1) return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0) return false;
        if (i > 2) i++;
    }
    return true;
}

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

    int n;
    int cnt = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (isPrime(a)) cnt++;
    }
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <map>
using namespace std;
struct union_find{
    vector<int> par; 
    map<int,int> size;
    //1からnまで初期化:par[i] = i(1<=i<=n)
    union_find(int n){
        par.push_back(0);
        for(int i = 1;i<=n;i++){
            par.push_back(i);
            size[i] = 1;
        }
    }
    int root(int a){
        if (par[a] == a) return a;
        par[a] = root(par[a]);
        return root(par[a]);
    }
    void unite(int a,int b){
        if (root(a) == root(b)) return;
        size[root(b)]+=size[root(a)];
        par[root(a)] = root(b);
    }
    bool same(int a,int b){
        return (root(a) == root(b));
    }
    int treesize(int a){
        return size[root(a)];
    }
};
int main(){
    long long n,m;
    cin >> n >> m;
    long long a[m],b[m];
    for(int i = 0;i<m;i++){
        cin >> a[i] >> b[i];
    }
    long long ans[m];
    ans[m-1] = n*(n-1)/2;
    union_find tree(n);
    for(int i = m-2;i>=0;i--){
        if(!tree.same(a[i+1],b[i+1])){
            ans[i] = ans[i+1]-(tree.treesize(a[i+1])*tree.treesize(b[i+1]));
        }
        else{
            ans[i] = ans[i+1];
        }
        tree.unite(a[i+1],b[i+1]);
    }
    for(int i = 0;i<m;i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 8696
//abc113_d.cpp
//Mon May 11 20:54:08 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll h,w,k;
	cin >> h >> w >> k;

	if (w==1){
		cout << 1 << endl;
		return 0;
	}

	ll dp[h+1][w];
	for (int i=0;i<h+1;i++){
		for (int j=0;j<w;j++){
			dp[i][j] = 0;
		}
	}

	dp[0][0] = 1;
	for (int i=0;i<h;i++){
		for (int j=0;j<1<<(w-1);j++){
			int flag = 1;
			for (int k=0;k<w-2;k++){
				if (j>>k&1 && j>>(k+1)&1){
					flag = 0;
					break;
				}
			}
//			cout << j << " " << flag << endl;
			if (flag){
				if (j>>0&1){
					dp[i+1][1] = (dp[i+1][1]+dp[i][0])%MOD;
				}else {
					dp[i+1][0] = (dp[i+1][0]+dp[i][0])%MOD;
				}
				if (j>>(w-2)&1){
					dp[i+1][w-2] = (dp[i+1][w-2]+dp[i][w-1])%MOD;
				}else {
					dp[i+1][w-1] = (dp[i+1][w-1]+dp[i][w-1])%MOD;
				}

				for (int k=1;k<w-1;k++){
					if (j>>(k-1)&1){
						dp[i+1][k-1] = (dp[i+1][k-1]+dp[i][k])%MOD;
					}else if (j>>k&1){
						dp[i+1][k+1] = (dp[i+1][k+1]+dp[i][k])%MOD;
					}else{
						dp[i+1][k] = (dp[i+1][k]+dp[i][k])%MOD;
					}
				}
			}
//			for (int k=0;k<w;k++){
//				cout << dp[i+1][k] << " ";
//			}
//			printf("\n");
		}
	}

	cout << dp[h][k-1] << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 764
#include<iostream>

using namespace std;

int main() {

	char pass[5];
	cin >> pass;

	if (pass[0] == pass[1] || pass[1] == pass[2] || pass[2] == pass[3] || pass[3] == pass[4]) {
		cout << "Bad";
	}
	else {
		cout << "Good";
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n], b[n], c[n];
  int dp[3][n] = {{}};
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  dp[0][0] = a[0];
  dp[1][0] = b[0];
  dp[2][0] = c[0];  
  for(int i=1;i<n;i++){
    dp[0][i] = max(dp[1][i-1] + a[i], dp[2][i-1] + a[i]);
    dp[1][i] = max(dp[0][i-1] + b[i], dp[2][i-1] + b[i]);
    dp[2][i] = max(dp[0][i-1] + c[i], dp[1][i-1] + c[i]);
  }
  cout << max({dp[0][n-1], dp[1][n-1], dp[2][n-1]}) << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <iterator>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <cstring>
#include <stack>
#include <vector>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <limits>
#include <utility>
#define EPS (1e-10)
#define REP(i,n) for(int i=0;i<n;i++)
#define equals(a,b) (fabs((a) - (b)) < EPS)
#define ll long long
using namespace std;

//typedef pair<int,int> P;
//const ll MOD = 1000000007;
//const ll INF = 100000000;

const int max_N = 100;
int N, K, A[max_N];

//stack<int> stack;
//queue<int> que;
//priority_queue<int> pque;
//set<int> s; set<int>::iterator ite;
//multiset<int> ms; multiset<int>::iterator ite;
//map<int, int> m; map<int, int>::iterator ite;
//multimap<int, int> mm; multimap<int, int>::iterator ite;

//int dp[][];
//int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, -1, 0, 1};
//int dx[8] = {1, 1, 1, 0, -1, -1, -1, 0};
//int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};

void solve() {
  int d, a, ans=0;
  for(int i = 0; i < K; i++) {
    scanf(" %d\n", &d);
    for (int j = 0; j < d; j++) {
      scanf(" %d\n", &a);
      A[a-1] = 1;
    }
  }

  REP(i,N) if(A[i] == 0) ans++;

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

}

int main(int argc, char const *argv[]) {

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

  REP(i,N) A[i] = 0;

  solve();
  return 0;
}


Measured memory_bytes: 3828
S = input()
ans = ''


def calc(i, s, num):
    if i == 3:
        if num == 7:
            global ans
            ans = s + '=7'
    else:
        calc(i+1, s+'+'+S[i+1], num+int(S[i+1]))
        calc(i+1, s+'-'+S[i+1], num-int(S[i+1]))


def solve():
    calc(0, S[0], int(S[0]))
    print(ans)


if __name__ == '__main__':
    solve()

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

typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()


int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) scanf("%d", &a[i]);
    rep(i, n) scanf("%d", &b[i]);
    rep(i, n) scanf("%d", &c[i]);
    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));

    ll res = 0;
    for (auto&& i : b) {
        ll l = lower_bound(ALL(a), i) - a.begin();
        ll r = c.end() - upper_bound(ALL(c), i);
        res += l * r;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int a,b,c,k;
  cin>>a>>b>>c>>k;
  long long int ans=0;
  if(a>=k){
    ans+=k;
  }else if(a+b>=k){
    ans+=a;
  }else{
    ans+=a-(k-a-b);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <list>

int main()
{
	int n; std::cin >> n;
	for (int i=0; i<n; i++) {
		std::string input;
		std::cin >> input;
		std::list<char> cars;
		cars.push_back(input[0]);
		std::list<char>::iterator it = cars.begin();
		for (int k=3; k<input.length(); k+=3) {
			char c = input[k];
			bool right = (input.substr(k-2,2) == "->");
			if (right) {
				++it;
				if (it == cars.end()) {
					cars.push_back(c); it = cars.end(); --it;
				}
			}
			else {
				if (it == cars.begin()) {
					cars.push_front(c); it = cars.begin();
				}
				else --it;
			}
		}
		for (it = cars.begin(); it != cars.end(); ++it) {
			std::cout << *it;
		}
		std::cout << std::endl;
	}
				
	return 0;
}




Measured memory_bytes: 3032
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll a[105][105]={{}};
  ll b[105][105]={{}};
  int n,m,l;
  int i,j,k;
  cin >> n >> m >> l;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      cin >> b[i][j];
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      ll o=0;
      for(k=0;k<m;k++){
	o+=a[i][k]*b[k][j];
      }
      if(j==0) cout << o;
      else cout << " " << o; 
    }
    cout << endl;
  }
  return 0;
}



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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  int k;
  cin >> k;
  
  if ( k < 2 ){
    cout << 1 << endl;
  }else if ( k >= 2 && k < 4 ){
    cout << 2 << endl;
  }else if ( k >= 4 && k < 8 ){
    cout << 4 << endl;
  }else if ( k >= 8 && k < 16 ){
    cout << 8 << endl;
  }else if ( k >= 16 && k < 32 ){
    cout << 16 << endl;
  }else if ( k >= 32 && k < 64 ){
    cout << 32 << endl;
  }else{
    cout << 64 << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
  ll x,a; cin >> x >> a;
  if(x<a){
    cout << 0 << endl;
  }else{
    cout << 10 << endl;
  }
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, L;
	cin >> L >> N;
	vector<int> X(N);
	for (int i = 0; i < N; ++i) {
		cin >> X[i];
	}
	vector<long long> S(N + 1);
	for (int i = 0; i < N; ++i) {
		S[i + 1] = S[i] + X[i];
	}
	long long ans = 0;
	for (int i = 0; i <= N; ++i) {
		// cut to [0, i) and [i, N)
		// left-ending
		if (i >= 1) {
			int al = min(i, N - i + 1);
			int ar = min(i, N - i);
			long long as = -X[i - 1];
			as += (S[i] - S[i - al]) * 2;
			as += (1LL * L * ar - (S[i + ar] - S[i])) * 2;
			ans = max(ans, as);
		}
		if (i <= N - 1) {
			int al = min(N - i, i + 1);
			int ar = min(N - i, i);
			long long as = -(L - X[i]);
			as += (S[i] - S[i - ar]) * 2;
			as += (1LL * L * al - (S[i + al] - S[i])) * 2;
			ans = max(ans, as);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>

int main(void){
        int n;
        if(scanf("%d",&n)<1){
                printf("Error in scanf");
                exit(1);
        }
        int a[n];
        for(int i=0;i<n;i++){
                if(scanf("%d",&a[i])<1){
                        printf("Error in scanf");
                        exit(1);
                }
        }

        if(n%2==0){
                for(int m=n-1;m>0;m-=2){
                        printf("%d ",a[m]);
                }
                printf("%d",a[0]);

                for(int m=2;m<n;m+=2){
                        printf(" %d",a[m]);
                }
                printf("\n");
        }else{
                for(int m=n-1;m>=0;m-=2){
                        printf("%d ",a[m]);
                }

                for(int m=1;m<n;m+=2){
                        printf(" %d",a[m]);
                }
                printf("\n");
        }
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
long long a,b,k;
main()
{
    cin>>k>>a>>b;
    if(k<=a) {cout<<"1"<<endl;return 0;}
    else if(a<=b){cout<<"-1"<<endl;return 0;}
    printf("%lld\n",((k-a)/(a-b)+bool((k-a)%(a-b)))<<1|1);
    
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
ans = max(A)
def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y) 

for i in range (0,N-1):
  x = gcd(A[i],A[i+1])
  ans = min(ans,x)
print(ans)

Measured memory_bytes: 15020
using System;
using System.Linq;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            int w = Convert.ToInt32(data[0]);
            int h = Convert.ToInt32(data[1]);
            int x = Convert.ToInt32(data[2]);
            int y = Convert.ToInt32(data[3]);
            int r = Convert.ToInt32(data[4]);

            if (r <= x - 0 && r <= y - 0 && r <= w - x && r <= h - y)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 9092
#include <iostream>
#include <math.h>
using namespace std;

int main(){
	double x1, y1, x2, y2, x3, y3, xp, yp;
	double d_12, d_13, d_23, d_p1, d_p2, d_p3;
	double t1, t2, t3, t4, s1, s2, s3, s4;
	
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
		
		d_12 = sqrt(pow((x2-x1), 2)+pow((y2-y1), 2));
		d_13 = sqrt(pow((x3-x1), 2)+pow((y3-y1), 2));
		d_23 = sqrt(pow((x3-x2), 2)+pow((y3-y2), 2));
		
		d_p1 = sqrt(pow((xp-x1), 2)+pow((yp-y1), 2));
		d_p2 = sqrt(pow((xp-x2), 2)+pow((yp-y2), 2));
		d_p3 = sqrt(pow((xp-x3), 2)+pow((yp-y3), 2));
		
		t1 = (d_12 + d_p1 + d_p2) / 2;
		t2 = (d_13 + d_p1 + d_p3) / 2;
		t3 = (d_23 + d_p2 + d_p3) / 2;
		t4 = (d_12 + d_13 + d_23) / 2;
		
		s1 = sqrt(t1*(t1-d_12)*(t1-d_p1)*(t1-d_p2));
		s2 = sqrt(t2*(t2-d_13)*(t2-d_p1)*(t2-d_p3));
		s3 = sqrt(t3*(t3-d_23)*(t3-d_p2)*(t3-d_p3));
		s4 = sqrt(t4*(t4-d_12)*(t4-d_13)*(t4-d_23));
		
		if(fabs((s1+s2+s3)-s4) < 1.0E-10){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 1220
import sys


def resolve(in_, out):
    n = int(in_.readline())
    b = [0] * (n + 1)
    for a in map(int, in_.readline().split()):
        b[a] += 1
    out.write('\n'.join(map(str, b[1:])))


def main():
    resolve(sys.stdin.buffer, sys.stdout)


if __name__ == '__main__':
    main()

Measured memory_bytes: 26236
#include <stdio.h>

int main(void)
{
    int S;
    int jadge = 0;
    scanf("%d", &S);

    int kami  = S / 100;
    int shimo = S % 100;
    int jk = 0;
    int js = 0;

    if (kami >= 1 && kami <= 12)
    {
        jadge += 1;
        jk += 1;
    }
    if (shimo >= 1 && shimo <= 12)
    {
        jadge += 1;
        js += 1;
    }
    switch (jadge)
    {
    case 0:
        printf("NA\n");
        break;
    case 1:
        if(jk == 1){
            printf("MMYY\n");
        }
        if(js == 1){
            printf("YYMM\n");
        }
        break;
    case 2:
        printf("AMBIGUOUS\n");
        break;
    default:
        break;
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n;
int stones[100010];
bool checked[100010];
int dp[100010];
int frog(int i)
{
    if(i==n-1)
        return 0;
    if(checked[i])return dp[i];
    
    if(i<n-2)
    {
        dp[i]=min(frog(i+1)+abs(stones[i]-stones[i+1]),frog(i+2)+abs(stones[i]-stones[i+2]));
        checked[i]=true;
        return dp[i];
    }
    else{
        dp[i]=frog(i+1)+abs(stones[i]-stones[i+1]);
        checked[i]=true;
        return dp[i];
    }
        
}

int main() {
   
   cin>>n;
   for(int i=0;i<n;i++)
   {
       cin>>stones[i];
   }
   cout<<frog(0)<<endl;
   
   
    return 0;
}

Measured memory_bytes: 2688
import math
n= int(input())
lis = list(map(int,input().split()))
a = math.floor(sum(lis)/n)
b = math.ceil(sum(lis)/n)
cou = 0
co = 0
for i in range(n):
  cou += abs(lis[i] - a) ** 2
  co += abs(lis[i] - b ) ** 2
print(min(cou,co))

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXMASK=(1<<19);
const int mod=1e9+7;
const int MAXN=25;
int pow_mod(int a,int b)
{
	int ret=1;
	for(;b;b>>=1,a=1LL*a*a%mod)if(b&1)ret=1LL*ret*a%mod;
	return ret;
}
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
vector<int> nxt[MAXN];
void ins(int x,int y){nxt[x].emplace_back(y);}
int f[MAXMASK],g[MAXMASK],E[MAXMASK];
int n,m,bin[25],ex[MAXN*MAXN],ey[MAXN*MAXN],mask[MAXN*MAXN],Log[MAXMASK];
int rt[MAXN];
int findrt(int x){return rt[x]==x?rt[x]:rt[x]=findrt(rt[x]);}
int lowbit(int x){return x&-x;}
int pre[MAXN*MAXN],inv[MAXN*MAXN];

map<int,int> mp[MAXN];
int get_edge(int x,int fa,int ed)
{
	if(x==ed)return 0;
	for(auto y:nxt[x])if(y^fa)
	{
		int t=get_edge(y,x,ed);
		if(t!=-1)return t|bin[mp[x][y]-1];
	}return -1;
}

int H[MAXMASK];
inline void FMT(int *y,int len){for(int i=1;i<len;i<<=1)for(int x=0;x<len;x++)if(!(x&i))ad(y[x|i],y[x]);}

int main()
{
	pre[0]=1;for(int i=1;i<MAXN*MAXN;i++)pre[i]=1LL*pre[i-1]*i%mod;
	inv[MAXN*MAXN-1]=pow_mod(pre[MAXN*MAXN-1],mod-2);
	for(int i=MAXN*MAXN-2;i>=0;i--)inv[i]=1LL*inv[i+1]*(i+1)%mod;
	bin[0]=1;for(int i=1;i<=20;i++)bin[i]=bin[i-1]<<1;
	for(int i=0;(1<<i)<MAXMASK;i++)Log[1<<i]=i;
	n=read();m=read();
	for(int i=1;i<=m;i++)
	{
		ex[i]=read(),ey[i]=read();
		if(i<n)ins(ex[i],ey[i]),ins(ey[i],ex[i]),mp[ex[i]][ey[i]]=mp[ey[i]][ex[i]]=i;
	}
	for(int i=n;i<=m;i++)mask[i]=get_edge(ex[i],0,ey[i]),++H[mask[i]];
	FMT(H,bin[n-1]);
	for(int i=0;i<bin[n-1];i++)
		E[i]=(m-n+1)-H[(bin[n-1]-1)^i];
//		for(int j=n;j<=m;j++)E[i]+=(mask[j]&i)>0;
	g[0]=1;
	for(int i=0;i<bin[n-1];i++)if(g[i])
	{
		int t=__builtin_popcount(i);
		for(int S=(bin[n-1]-1)^i;S;S^=lowbit(S))
		{
			int u=lowbit(S),newe=E[i|u]-E[i],pree=E[i]+t;
			
			int newg=1LL*g[i]*pre[pree+newe]%mod*inv[pree]%mod;
			int newf=1LL*f[i]*pre[pree+newe+1]%mod*inv[pree+1]%mod;
			ad(newf,1LL*(t+1)*newg%mod);
			
			ad(g[i|u],newg);ad(f[i|u],newf);
		}
	}
	pr2(f[bin[n-1]-1]);
	return 0;
}



Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

template<typename T>
struct Max_Flow{
    struct edge{
        int to; T cap; int rev;
        edge(int to, T cap, int rev) : to(to), cap(cap), rev(rev) {}
    };

    vector<vector<edge>> es;
    vector<bool> used;
    const T INF_T;

    Max_Flow(int n) : INF_T(numeric_limits<T>::max()){
        es.resize(n), used.resize(n);
    }

    void add_edge(int from, int to, T cap, bool directed = true){
        es[from].eb(to, cap, sz(es[to]));
        es[to].eb(from, directed? 0 : cap, sz(es[from])-1);
    }

    T dfs(int now, int t, T flow){
        if(now == t) return flow;
        used[now] = true;
        for(auto &e: es[now]){
            if(!used[e.to] && e.cap > 0){
                T f = dfs(e.to, t, min(flow, e.cap));
                if(f > 0){
                    e.cap -= f;
                    es[e.to][e.rev].cap += f;
                    return f;
                }
            }
        }
        return 0;
    }

    T max_flow(int s, int t){
        T flow = 0;
        for(;;){
            fill(all(used), false);
            T f = dfs(s, t, INF_T);
            if(f == 0) return flow;
            flow += f;
        }
    }
};

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int a[N], b[N];
    bool used[N];
    fill(used, used+N, false);
    int ans = 0;
    rep(i, N){
        cin >> a[i] >> b[i];
        a[i] -= b[i];
        int tmp = abs(a[i]);
        if(tmp <= A || (B <= tmp && tmp <= 2*A)) ans++, used[i] = true;
    }
    Max_Flow<int> G(2*N+2);
    int s = 2*N, t = 2*N+1;
    rep(i, N) G.add_edge(s, i, 1), G.add_edge(N+i, t, 1);
    rep(i, N){
        if(used[i] || a[i] < 0) continue;
        rep(j, N){
            if(used[j]) continue;
            int tmp = abs(a[i]+a[j]);
            if(tmp <= A || (B <= tmp && tmp <= 2*A)) G.add_edge(i, N+j, 1);
        }
    }
    cout << ans+G.max_flow(s, t) << endl;
}


Measured memory_bytes: 4296