akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int n, m;
	long inf = 1000000000000000000;
	scanf("%d %d", &n, &m);
	vector<long> cost(n, inf);
	vector<pair<long, pair<int, int>>> a(m);
	cost[0] = 0;
	for(int i = 0; i < m; i++)
	{
		scanf("%d %d %ld", &a[i].second.first, &a[i].second.second, &a[i].first);
		a[i].first *= -1;
		a[i].second.first--;
		a[i].second.second--;
	}
	for(int update = false, count = 0; ; update = false, count++)
	{
		for(int i = 0; i < m; i++)
		{
			if(cost[a[i].second.first] != inf && cost[a[i].second.second] > cost[a[i].second.first] + a[i].first)
			{
				cost[a[i].second.second] = cost[a[i].second.first] + a[i].first;
				update = true;
				if(count >= n - 1 && a[i].second.second == n - 1)
				{
					printf("inf\n");
					return 0;
				}
			}
		}
		if(!update || count >= 2 * n - 2)
		{
			printf("%ld\n", -cost[n - 1]);
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"


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

  // std::string A;
  // std::cin >> A;
  // std::cout << A[0] << '\n';
  //
  // int NN;
  // std::cin >> NN;
  // std::cout << NN*NN << '\n';

  int x1, y1, x2, y2;

  std::cin >> x1>>y1>>x2>>y2;

  int vx = x2 - x1, vy = y2 - y1;

  int x3, x4, y3, y4;

  x3 = x2 - vy;
  y3 = y2 + vx;

  x4 = x3 - vx;
  y4 = y3 - vy;

  std::cout << x3 << " "<<y3<< " "<<x4<< " "<<y4 << '\n';


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
 
long long s=0;
int n;
int a[200005];
int cmp(const void *a,const void *b)
{
	int x=*(int *)a;
	int y=*(int *)b;
	if (x>y)
	{
	    return 1; 
	} 
	else
	{
		return -1;
	} 
}
int main()
{
    int i;
    long long b;
    cin>>n;
    for (i=1;i<=n;i++)
    {
    	scanf ("%d",&a[i]);
    	a[i]=a[i]-i; 
	}
	qsort (a+1,n,sizeof(a[1]),cmp);
	if (n%2==0)
	{
		b=a[n/2];
	}
	else
	{
		b=a[(n+1)/2];
	}
	for (i=1;i<=n;i++)
    {
    	a[i]-=b;
    	if (a[i]>0)
    	{
    		s+=a[i];
		}
		else
		{
			s-=a[i];
		}
	}
	cout<<s<<endl;
	return 0;
}
 


Measured memory_bytes: 1788
#include <iostream>
#include <string>
using namespace std;
int n,m,l;
string s1, s2;
void input() {
	cin >> s1;
	if (s1 == ".")return;
	cin >> s2;
}
void output() {
	cout << endl;
}
void prep() {
	n = s1.length();
	m = s2.length();
	s1 = s1 + "$";
	s2 = s2 + "$";
}
void solve() {
	int i = 0;
	int j = 0;
	int h = 1;
	int cnt = 0;
	while (i+j<m+n-1) {
		h = 1 - h;
		string c1 = "";
		string c2 = "";
		while (i < n) {
			c1=c1+s1[i];
			if (s1[i] == '"')break;
			i++;
		}
		i++;
		while (j < m) {
			c2=c2+s2[j];
			if (s2[j] == '"')break;
			j++;
		}
		j++;
		if (c1!=c2) {
			if (h == 0) {
				cout << "DIFFERENT";
				return;
			}
			cnt++ ;
			if (cnt == 2) {
				cout << "DIFFERENT";
				return;
			}
		}
	}
	if (cnt == 0)cout << "IDENTICAL"; else cout << "CLOSE";
}
int main() {
	while (true) {
		input();
		if (s1 == ".")break;
		prep();
		solve();
		output();
	}
}



Measured memory_bytes: 3144
n = int(input())
a=int(n/4)+1
b=int(n/7)+1
ans=0
for i in range(a+1):
  for j in range(b+1):
    if 4*i+7*j==n:
      ans+=1
if ans==0:
  print("No")
else:
  print("Yes")

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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long;
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)


int main(){
	string a,b;
	cin>>a>>b;
	sort(all(a));
	sort(all(b),greater<int>());
	if(a<b)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


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

int main() {
string T;
cin>>T;
int s=T.size();
for(int i=0; i<s; i++){
    if(T[i]=='?' || T[i]=='D') cout<<'D';
   if(T[i]=='P') cout<<'P';
  
}
    
}



Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
  sort(a.rbegin(), a.rend());
  int alice = 0;
  int bob = 0;
  for (int i = 0; i < N; i++)
  {
    if (i % 2 == 0)
      alice += a[i];
    else
      bob += a[i];
  }
  cout << alice - bob << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int nmax=500005;
ll fac[nmax],finv[nmax],inv[nmax];
 
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<nmax;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;
  }
}
ll com(int n,int k){
  if(n<k||n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(){
    ll n,k;cin >> n >> k;
    COMinit();
    if(n<=k){
      cout << com(n+n-1,n-1) << endl;
    }
    else{
      ll ans=0;
      for(int i=0;i<=k;i++){
        ans+=com(n,i)*com(i+n-i-1,n-i-1)%mod;
        ans%=mod;
      }
      cout << ans << endl;
    }
}

Measured memory_bytes: 11904
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def main():
    N = I()
    P = LI()

    a = [45000*i + 1 for i in range(N)]
    b = [45000*(N-1-i) + 1 for i in range(N)]

    for i in range(N):
        a[P[i]-1] += i
        b[P[i]-1] += i

    print(" ".join(map(str,a)))
    print(" ".join(map(str,b)))






if __name__ == "__main__":
    main()


Measured memory_bytes: 47940
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(){
  int n,i,x,y=0,j=0;
  char c;
    
  
  scanf("%c",&c);

  if((c>='a') && (c<='z'))
    printf("a\n");
  else
    printf("A\n");
  return 0;
}

Measured memory_bytes: 1588
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,m,i,j,k,a,b,an=0;
	int h[100005],ans[100005]={0};
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
		ans[i]=0; 
	}
	for(i=1;i<=m;i++)
	{
		scanf("%d %d",&a,&b);
		if(h[a]>=h[b])ans[b]=1;
		if(h[a]<=h[b])ans[a]=1;
	}
	for(i=1;i<=n;i++)
	{
		if(ans[i]==0)an++;
	}
	printf("%d",an);
	return 0;
}

Measured memory_bytes: 2512
// Problem : D - RGB Triplets
// Contest : AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
    	int n;
    	cin>>n;
    	string s;
    	cin>>s;
    	unordered_map<char,vector<int>> mp;
    	for(int i=0;i<n;++i)
    	{
    		mp[s[i]].push_back(i);
    	}
    	int ans = 0;
    	for(int i=0;i<n;++i)
    	{
    		
    		for(int j=i+1;j<n;++j)
    		{
    			
    			set<char> st;
    			st.insert(s[i]);
    			st.insert(s[j]);
    			if(st.size()!=2)
    			{
    				st.clear();
    				continue;
    			}
    			if(s[i]!='R'&&s[j]!='R')
    			{
    			   int x  = (int)mp['R'].size() - (upper_bound(mp['R'].begin(),mp['R'].end(),j)- mp['R'].begin());
    			   if(x)
    			   {
    			   	ans+=x;
    			   	if(binary_search(mp['R'].begin(),mp['R'].end(),2*j-i))
    			   	ans--;
    			   }
    			}
    			if(s[i]!='G'&&s[j]!='G')
    			{
    				int x  = (int)mp['G'].size() - (upper_bound(mp['G'].begin(),mp['G'].end(),j)- mp['G'].begin());
    			   if(x)
    			   {
    			   	ans+=x;
    			   	if(binary_search(mp['G'].begin(),mp['G'].end(),2*j-i))
    			   	ans--;
    			   }
    			}
    			if(s[i]!='B'&&s[j]!='B')
    			{
    				int x  = (int)mp['B'].size() - (upper_bound(mp['B'].begin(),mp['B'].end(),j)- mp['B'].begin());
    			   if(x)
    			   {
    			   	ans+=x;
    			   	if(binary_search(mp['B'].begin(),mp['B'].end(),2*j-i))
    			   	ans--;
    			   }
    			}
    			
    		}
    	}
    	cout<<ans<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3732
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int INF = INT_MAX / 2;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> p(n), t(n);
        for(int i=0; i<n; ++i)
            cin >> p[i] >> t[i];

        vector<int> dp(4, INF);
        dp[0] = 0;
        int currPos = 0;
        int currTime = 0;
        bool ng = false;
        for(int i=0; i<n; ++i){
            vector<int> nextDp(4, INF);
            for(int j=0; j<4; ++j){
                int dist = abs(p[i] - currPos);
                if(j < 3 && dist * (j+1) <= t[i] - currTime)
                    nextDp[j+1] = min(nextDp[j+1], dp[j] + dist);
                dist = currPos + p[i];
                if(currPos * (j+1) + p[i] <= t[i] - currTime)
                    nextDp[1] = min(nextDp[1], dp[j] + dist);
            }

            dp.swap(nextDp);
            currPos = p[i];
            currTime = t[i];

            if(count(dp.begin(), dp.end(), INF) == 4){
                cout << "NG " << (i+1) << endl;
                ng = true;
                break;
            }
        }

        if(!ng){
            int ret = INF;
            for(int i=0; i<4; ++i)
                ret = min(ret, dp[i] + currPos);
            cout << "OK " << ret << endl;
        }
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define repi(i,x,n) for(int i = x; i < n; i++)
#define rep(i,n) repi(i,0,n)
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
map<string, int> mp;
map<string, vector<string>> G;
map<string, int> used;
int dfs(string s, int &sz)
{
    int res = mp[s];
    sz++;
    for(int u = 0; u < (int)G[s].size(); u++)
    {
        if(used[G[s][u]]) continue;
        used[G[s][u]] = 1;
        res = min(res, dfs(G[s][u], sz));
    }
    return res;
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<string> s;
    for(int i = 0; i < n; i++)
    {
        string a; cin >> a;
        s.push_back(a);
        int x; cin >> x;
        mp[a] = x;
    }
    int m; cin >> m;
    for(int i = 0; i < m; i++)
    {
        string s, t; cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(used[s[i]]) continue;
        used[s[i]] = 1;
        int sz = 0;
        ans += dfs(s[i], sz) * sz;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 4648
s=input()

if s[0]=="A":
    pass
else:
    print("WA")
    exit()

k=s[2: -1]
if k.count("C")==1:
    pass
else:
    print("WA")
    exit()

new_string=s.replace("A", "")
new_string=new_string.replace("C", "")

if new_string.islower():
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

ll pow(ll x, int n) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x;
        x *= x;
        n >>= 1;
    }

    return ret;
}

int main() {
    int n, p;
    bool odd = false;
    cin >> n >> p;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x % 2 != 0) odd = true;
    }

    if (odd){
        cout << pow(2, n - 1) << endl;
    }else{
        if (p == 0) cout << pow(2, n) << endl;
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
A - Train
https://atcoder.jp/contests/abc107/tasks/abc107_a

"""
import sys


def solve(N, i):
    return N - i + 1


def main(args):
    N, i = map(int, input().split())
    ans = solve(N, i)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

#define MAX 100001

int main(){
  vector<bool> f(MAX, true);
  f.at(1) = false;
  for(int i = 2; i < MAX; i++){
    if(f.at(i) == true){
      for(int j = i+i; j < MAX; j += i){
        f.at(j) = false;
      }
    }
  }
  vector<int> q(MAX, 0);
  for(int i = 1; i < MAX; i++){
    if(i > 1)q.at(i) = q.at(i-1);
    if(f.at(i) == true && f.at((i+1)/2)==true)q.at(i)++;
  }
  int Q, l, r;
  cin >> Q;
  for(int i = 0; i < Q; i++){
    cin >> l >> r;
    cout << q.at(r) - q.at(l-1) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] data = new int[N];
		for(int i = 0 ; i<N; i++){
			data[i] = sc.nextInt();
		}
		Arrays.sort(data);
		long max = 0;
		long max2 = 0;
		for(int i = N-1; i>0; i--){
			if(data[i] == data[i-1]){
				if(max == 0){
					max = data[i];
					i--;
				}
				else{
					max2 = data[i];
					break;
				}
			}
		}
		long res = max*max2;
		System.out.println(res);
	}
}


Measured memory_bytes: 50248
//B - Ordinary Number
//20190913

using System;
using System.Linq;


namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            int n = int.Parse(Console.ReadLine());
            int[] p = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int count=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]))
                {
                    count++;
                }
            }

            Console.WriteLine(count);

        }
    }
}


Measured memory_bytes: 13268
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
//#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

template <class A, class B> inline int Max(const A &a, const B &b){ return (a < b ? b : a); }
template <class A, class B> inline int Min(const A &a, const B &b){ return (a > b ? b : a); }

int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}


signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int r;
    cin >> r;

    cout << r * 2 * M_PI << '\n';

    return 0;
}


Measured memory_bytes: 3808
#include <cstdlib>
#include <iostream>
#define rep(S, L) for (int i = S; i < L; ++i)
using namespace std;

int main() {
  string s;
  cin >> s;
  int l = s.size();
  bool ok = false;
  if (s[0] != 'A') {
    ok = false;
  } else {
    bool match = false;
    for (int i = 1; i < l; ++i) {
      if (i == 1 || i == l - 1) {
        if (!islower(s[i])) {
          match = false;
          break;
        }
      }
      if (s[i] == 'C') {
        if (match) {
          match = false;
          break;
        }
        match = true;
      }
    }
    if (match) {
      ok = true;
    }
  }

  if (ok) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }
  return 0;
}


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

int main()
{
	int n;
	cin>>n;
	long long int arr[n],count=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	count+=arr[0]-1;
	long long int check=1;
for(int i=1;i<n;i++)
{
	if(arr[i]==check+1)
		check++;
	else
		count+=(arr[i]-1)/(check+1);
}
	cout<<count<<endl;


	return 0;
}

Measured memory_bytes: 1152
A = []
B = []
for _ in range(3):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

counter = [-1, 0, 0, 0, 0]
for a in A:
    counter[a] += 1
for b in B:
    counter[b] += 1

for count in counter[1:]:
    if count == 3:
        print("NO")
        exit(0)

print("YES")


Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	long n,m;
	cin >> n >> m;
	if(n>2 && m>2)
		P((n-2)*(m-2));
	else{
		if( n > m )
			swap(n,m);

		if( n == 1 ){
			if(m == 1)
				P(1);
			else if(m == 2)
				P(0);
			else
				P(m-2);
		}
		else{
			P(0);
		}
	}
	ret 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

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

int ten[2222][2222];
int edgeH[2222][2222];
int edgeW[2222][2222];

int main(){
	
	int n,m,q;cin >> n >> m >> q;
	
	for(int i = 1; i <= n;i++){
		string str;cin >> str;
		for(int j = 1;j <= m;j++){
			if(str[j-1] == '1')ten[i][j] = 1; 
		}
	}
	
	for(int i = 1; i <= n;i++){
		for(int j = 1;j <= m;j++){
			if(ten[i][j]){
				edgeH[i][j] = ten[i-1][j];
				edgeW[i][j] = ten[i][j-1];
			}
		}
	}
	
	for(int i = 1; i <= n;i++){
		for(int j = 1;j <= m;j++){
			ten[i][j+1] += ten[i][j];
			edgeH[i][j+1] += edgeH[i][j];
			edgeW[i][j+1] += edgeW[i][j];
		}
	}
	
	for(int i = 1; i <= n;i++){
		for(int j = 1;j <= m;j++){
			ten[i+1][j] += ten[i][j];
			edgeH[i+1][j] += edgeH[i][j];
			edgeW[i+1][j] += edgeW[i][j];
		}
	}
		
	REP(i,q){
		int y1, x1, y2, x2;
		cin >> y1 >> x1 >> y2 >> x2;
		int ten_no_kazu = ten[y2][x2] - ten[y1-1][x2] - ten[y2][x1-1] + ten[y1-1][x1-1];
		int tatehen_no_kazu = edgeH[y2][x2] - edgeH[y1][x2] - edgeH[y2][x1-1] + edgeH[y1][x1-1];
		int yokohen_no_kazu = edgeW[y2][x2] - edgeW[y1-1][x2] - edgeW[y2][x1] + edgeW[y1-1][x1];
		int hen_no_kazu = tatehen_no_kazu + yokohen_no_kazu;
		cout << ten_no_kazu - hen_no_kazu << endl;
	}

	return 0;
}


Measured memory_bytes: 59136
#line 2 "../../library/template.cpp"

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';
#line 2 "d3.cpp"

void dfs(ll now, ll p, ll dis, const vector<vector<pl>>& g, vl& ans) {
  ans[now] = dis;

  for (auto&& i : g[now]) {
    if (i.first != p) {
      dfs(i.first, now, dis^i.second%2, g, ans);
    }
  }
}

int main() {
  ll n;
  cin >> n;
  vector<vector<pl>> g(n);
  rep(i, n-1) {
    ll u, v, w;
    cin >> u >> v >> w;
    g[u-1].emplace_back(v-1, w);
    g[v-1].emplace_back(u-1, w);
  }

  vl ans(n);
  dfs(0, -1, 0, g, ans);

  for (auto&& i : ans) {
    cout << i << el;
  }
  cout << flush;
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define F(i, j, k) for(ll i = j; i <= k; ++i)
#define pp pair<ll, ll>
#define mp make_pair
const ll maxn = 2e5+5;
ll n, m, x;
ll a, b, c, d;
int main() {
#ifdef orz
    //freopen("input", "r", stdin);
#endif
    cin >> a >> b >> c >> d >> n;
    m = 4 * a;
    m = min(m, 2 * b);
    m = min(m, c);
    cout << min(n * m, (n / 2) * d + (n & 1) * m);
    return 0;  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string s;
  cin>>s;
  auto calc = [&](int x){
    return x*(x-1)/2;
  };
  int c[26]={};
  for(int i=0;i<(int)s.size();i++){
    c[s[i]-'a']++;
  }
  int ans=1+calc(s.size());
  for(int i=0;i<26;i++) ans-=calc(c[i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
        println(a * b)
    } else {
        println(-1)
    }
}

Measured memory_bytes: 31520
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;

fn main() {
	let stdin = stdin();
	let mut scan = InputScanner::new(stdin.lock(),256);

	let a:usize = scan.next();
	let b:usize = scan.next();
	let x:usize = scan.next();

	let r = if a % x == 0 {
		b / x - a / x + 1
	} else {
		b / x - a / x
	};

	println!("{}",r);
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}


Measured memory_bytes: 4352
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        d: i64,
        p : [(i64,i64);n],
    }

    let ans = p.iter().filter(|x| x.0*x.0 + x.1*x.1 <= d*d).count();
    println!("{}",ans);
}


Measured memory_bytes: 7768
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M = map(int,input().split())
AB= [list(map(int,input().split())) for _ in range(M)]

uf = UnionFind(N)
for ab in AB:
    uf.union(ab[0]-1,ab[1]-1)
print(uf.group_count()-1)




Measured memory_bytes: 29412
import java.util.Scanner;
     
     
    public class Main {
        

        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n =sc.nextInt();
            int m =sc.nextInt();
            int x =sc.nextInt();
           
           if (n%m==0){
            System.out.println((n/m)*x);
               }else{
                System.out.println((n/m+1)*x);
               }           
            
           } 
       }
        
    


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

template <typename Abelian>
struct BIT0based {
  BIT0based(int n, const Abelian UNITY = 0) : n(n), UNITY(UNITY), dat(n, UNITY) {}

  void add(int idx, Abelian val) {
    while (idx < n) {
      dat[idx] += val;
      idx |= idx + 1;
    }
  }

  Abelian sum(int idx) const {
    Abelian res = UNITY;
    --idx;
    while (idx >= 0) {
      res += dat[idx];
      idx = (idx & (idx + 1)) - 1;
    }
    return res;
  }

  Abelian sum(int left, int right) const {
    return left < right ? sum(right) - sum(left) : UNITY;
  }

  Abelian operator[](const int idx) const { return sum(idx, idx + 1); }

  int lower_bound(Abelian val) const {
    if (val <= UNITY) return 0;
    int res = 0, exponent = 1;
    while (exponent <= n) exponent <<= 1;
    for (int mask = exponent >> 1; mask > 0; mask >>= 1) {
      if (res + mask - 1 < n && dat[res + mask - 1] < val) {
        val -= dat[res + mask - 1];
        res += mask;
      }
    }
    return res;
  }

private:
  int n;
  const Abelian UNITY;
  vector<Abelian> dat;
};

int main() {
  int n, q; cin >> n >> q;
  vector<int> c(n); REP(i, n) cin >> c[i], --c[i];
  vector<int> l(q), r(q);
  vector<vector<int>> query(n);
  REP(i, q) {
    cin >> l[i] >> r[i]; --l[i]; --r[i];
    query[r[i]].emplace_back(i);
  }
  vector<int> ans(q), ball(n, -1);
  BIT0based<int> bit(n);
  REP(i, n) {
    if (ball[c[i]] != -1) bit.add(ball[c[i]], -1);
    bit.add(i, 1);
    ball[c[i]] = i;
    for (int idx : query[i]) ans[idx] = bit.sum(l[idx], i + 1);
  }
  REP(i, q) cout << ans[i] << '\n';
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++){
    cin >> vec.at(i);
  }
  int f = 0;
  for (int i = 0; i < n; i++) {
    if (vec.at(i) != i+1) {
      f++;
      if (f > 2) {
        cout << "NO";
        return 0;
      }
      if (vec.at(vec.at(i)-1) != i+1) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
string s;
int k;
int INFi=1000000000;
ll INFl=1000000000000000;

int main(){
    int N;cin>>N;
    set<int> s;
    for(int i=0;i<N;i++){
        int d;cin>>d;
        s.insert(d);
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 888
#include<stdio.h>
#include<math.h>

struct Point{ double x,y; };

void koch(int n,Point a,Point b){
    if(n==0) return;
    
    Point s,t,u;
    double th=M_PI*60.0/180.0;
    
    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
    
    koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,b);
}

int main(){
    Point a,b;
    int n;
    
    scanf("%d",&n);
    
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;
    
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);
    
    return 0;
}


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

int main() {
  int n; cin>>n;
  vector<int> a(n);
  rep(i, n) cin>>a[i];
  
  sort(a.begin(), a.end());
  int r=0;
  rep(i, n) if (abs(2*a[i]-a[n-1])<abs(2*r-a[n-1])) r=a[i];
  printf("%d %d\n", a[n-1], r);
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

struct edge {
    long to,cost;
    edge(long _to, long _cost): to(_to), cost(_cost){}
};

vector<long long> dijkstra(long long n, long long s, vector<vector<edge>> g) {
    typedef pair<long long,long long> P;
    vector<long long> d(n+1,LONG_MAX);
    priority_queue<P, vector<P>,greater<P>> q;
    q.push(make_pair(0,s));
    d[s] = 0;

    while (! q.empty()) {
        long long cost,u;
        tie(cost,u) = q.top();
        q.pop();
        if (d[u] < cost) continue;
        for (auto e : g[u]) {
            if (d[e.to] > d[u] + e.cost) {
                d[e.to] = d[u] + e.cost;
                q.push( P(d[e.to], e.to));
            }
        }
    }
    return d;
}

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

    vector<vector<edge>> g(n+1);

    for (int i=0; i<n-1; i++) {
        g[i+1].push_back(edge(i,0));
    }

    for (int i=0; i<m; i++) {
        int l,r,c;
        cin >> l >> r >> c;
        g[l].push_back(edge(r,c));
        g[r].push_back(edge(l,c));
    }

    vector<long long> ans =  dijkstra(n,1,g);
    if (ans[n] == LONG_MAX) ans[n] = -1;

    cout << ans[n] << endl;
}

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

#define X first
#define Y second
#define mp make_pair
#define pb pop_back
#define eb emplace_back
#define sz(v) (int) v.size()

using namespace std;

typedef long long LL;
typedef long double LD;

void solve() {
	int a, b;
	cin >> a >> b;
	cout << max(max(a - b, a + b), a * b) << "\n";
}

signed main() {
// #define TASK ""
#if !defined(LOCAL) && defined(TASK)
	// freopen(TASK".in", "r", stdin);
	// freopen(TASK".out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int tests = 1;
	// cin >> tests;
	while (tests--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;


int main(){

  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> minl(n),maxr(n);
  REP(i,n){
    cin >> a[i];
  }
  minl[0] = a[0];
  maxr[n-1] = a[n-1];
  for(int i = 1; i < n; i++){
    if(minl[i-1] > a[i]){
      minl[i] = a[i];
    }else{
      minl[i] = minl[i-1];
    }
  }
  for(int i = n-2; i >= 0; i--){
    if(maxr[i+1] < a[i]){
      maxr[i] = a[i];
    }else{
      maxr[i] = maxr[i+1];
    }
  }
  
  ll ans = a[1]-a[0];
  for(int i = 0; i < n-1; i++){
    //cout << maxr[n-i-1] << "," << minl[n-i-1] << "," << maxr[n-i-1] - minl[n-i-2]<< endl;
    ans = max(ans, maxr[n-i-1] - minl[n-i-2]);
  }
  cout << ans << endl;
  
  return 0;
} 



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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int h, w, k; cin >> h >> w >> k;
	vector<vector<char>> C(h, vector<char>(w));
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			cin >> C[i][j];
		}
	}
	int ret = 0;
	for (int bit=0; bit < (1<<h); ++bit) {
		for (int bitw=0; bitw < (1<<w); ++bitw) {
			int cnt = 0;
			for (int i=0; i<h; i++) {
				for (int j=0; j<w; j++) {
					if ((bit & (1<<i)) || (bitw & (1<<j))) continue;
					if (C[i][j]=='#') cnt++;
				}
			}
			if (cnt==k) ret++;
		}
	}
	cout << ret << endl;
	return 0;
}

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

using namespace std;

int main()
{

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

	long long int n, val, ans = 0;
	vector<int> arr;
	cin >> n;
	for (int j = 0; j < n; j++) {
		cin >> val;
		arr.push_back(val);
	}

	for (int i = 0; i < n - 1; i++) {
		if (arr[i] > arr[i + 1]) {
			ans += arr[i] - arr[i + 1];
			arr[i + 1] = arr[i];
		}
	}

	cout << ans;


	return 0;
}

Measured memory_bytes: 4192
#include <iostream>
#include <map>
#include <set>
using namespace std;
int main(){
	int a,b;
	char c;
	map <int,int>x;
	set <int> y;
	while (1){
		cin>>a>>c>>b;
		if (a==0&&b==0) break;
		x[a]=b;
		y.insert(b);
	}
	while (cin>>a){
		b=1;
		set<int>::reverse_iterator it=y.rbegin();
		while (*it!=x[a]){
			it++;
			b++;
		}
		cout<<b<<endl;
	}
}

Measured memory_bytes: 1196
from random import randrange

def score(c,s,t):
    ans = 0
    scorelast = [0] * 26
    for i in range(d,365):
        ans += s[i][t[i]]
        scorelast[t[i]] = i + 1
        for j in range(26):
            ans -= c[j] * (i + 1 - scorelast[j])
    return ans

def diffscore(old,q,c,s,t):
    cq = c[q]
    scorelast = [0] * 2
    diff = 0
    for i in range(365):
        if t[i] == q:
            diff += s[i][q]
            scorelast[0] = i + 1
        elif t[i] == old:
            diff += s[i][old]
            scorelast[1] = i + 1
        diff -= cq * (i + 1 - scorelast[0])
        if cq != old:
            diff -= c[old] * (i + 1 - scorelast[1])

    return diff
D = int(input())
c = list(map(int,input().split()))
s = []
for i in range(D): s.append(list(map(int,input().split())))
d = 0
t = []
last = [-1] * 26
for i in range(D):
    maximum = 0
    maxs = 0
    for j in range(26):
        if maximum < s[i][j] + c[j] * (i - last[j]):
            maxs = j
            maximum = s[i][j] + c[j] * (i - last[j])
    last[maxs] = i
    t.append(maxs)

for i in range(100000):
    d = randrange(D)
    q = randrange(26)
    old = t[d]
    before = diffscore(old,q,c,s,t)
    t[d] = q
    if before > diffscore(old,q,c,s,t): t[d] = old
for i in t: print(i + 1)


Measured memory_bytes: 82728
#include <iostream>

using namespace std;

int main(){
        int n,x;
        while(true){
                int ans=0;
                cin>>n>>x;
                if(n==0 && x==0) break;

                for(int i=1; i<n-1; i++){
                        for(int j=i+1; j<n; j++){
                                if(j<x-i-j && x-i-j<=n) ans++;
                        }
                }

                cout<<ans<<endl;
        }

        return 0;
}



Measured memory_bytes: 3108
import sys
sys.setrecursionlimit(10**8)

def gcd(p,q): #p<q
    if q%p==0:
        return p
    return gcd(q%p,p)

x = int(input())

ans=0

for a in range(1,x+1):
    for b in range(1,a+1):
        for c in range(1,b+1):
            gcd1=gcd(a,b)
            gcd2=gcd(gcd1,c)
            if a==b and b==c:
                ans += gcd2
            elif a==b or b==c or c==a:
                ans += 3*gcd2
            else:
                ans += 6*gcd2

print(ans)

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");
        Arrays.sort(s);
        if (s[0].equals(s[1]) && s[2].equals(s[3]) && !s[0].equals(s[2])) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 20692
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

const long double EPS = 1e-30; //要検証
long double add(long double x, long double y){
    if(abs(x + y) < EPS * (abs(x) + abs(y)) ) return 0;
    return x + y;
}
struct PL{
    long double x, y;
    PL() {}
    PL(long double x, long double y) : x(x), y(y) {
    }
    PL operator + (PL p){
        return PL(add(x, p.x), add(y, p.y));
    }
    PL operator - (PL p){
        return PL(add(x, -p.x), add(y, -p.y));
    }
    PL operator * (long double d){
        return PL(x * d, y * d);
    }
    long double dot(PL p){
        return add(x * p.x, y * p.y);
    }
    long double det(PL p){
        return add(x * p.y, -y * p.x);
    }
};
/*bool cmp_x(const PL &p, const PL &q){
    if(p.x != q.x) return p.x < q.x;
    return p.y < q.y;
}*/
vector<PL> qs(101);
vec convex_hull(int n, vector<PL> &plot, vec &ord){
    int k = 0;
    vec res(101);
    rep(i,n){
        while(k > 1 && (qs[k-1] - qs[k-2]).det(plot[ord[i]] - qs[k - 1]) <= 0) --k;
        qs[k] = plot[ord[i]];
        res[k++] = ord[i];
    }
    for(int i = n - 2, t = k; i >= 0; --i){
        while(k > t && (qs[k - 1] - qs[k - 2]).det(plot[ord[i]] - qs[k - 1]) <= 0) --k;
        qs[k] = plot[ord[i]];
        res[k++] = ord[i];
    }
    qs.resize(k - 1);
    res.resize(k - 1);
    return res;
}

const long double pi = 3.14159265359;
long double pct(PL b, PL n, PL f){
    PL u = n - b, v = f - n;
    long double cs = u.dot(v);
    cs /= sqrt(u.dot(u));
    cs /= sqrt(v.dot(v));
    //cout<<acos(cs)<<endl;
    return (cs - EPS < -1.0 ? pi : acos(cs));
}

int main(){
    cin>>N;
    if(N == 2){
        cout<<0.5<<endl;
        cout<<0.5<<endl;
        return 0;
    }
    vector<PL> plot(0);
    vec ord(N);
    rep(i,N){
        long double x, y;
        cin>>x>>y;
        plot.emplace_back(x, y);
        ord[i] = i;
    }
    sort(ALL(ord), [&](int u, int v){
        PL p = plot[u], q = plot[v];
        if(p.x != q.x) return p.x < q.x;
        return p.y < q.y;
    });
    vec con_ord = convex_hull(N, plot, ord);
    vector<long double> ans(N,0.0);
    int sz = con_ord.size();
    rep(i, sz){
        ans[con_ord[i]] = pct(qs[(i + sz - 1)%sz], qs[i], qs[(i + 1)%sz]) / (pi * 2.0);
        //cout<<qs[i].x<<' '<<qs[i].y<<' '<<con_ord[i]<<endl;
    }
    rep(i,N) cout<<fixed<<setprecision(10)<<ans[i]<<endl;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if(a>b){
    for(int i=0; i<a; ++i) cout << b;
  }
  else{
    for(int i=0; i<b; ++i) cout << a;
  }
  return 0;
}


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

int main()
{
	string n;
	int s = 0;
	cin >> n;
	for (int i = 0; i < n.size(); i++) {
		switch (n[i]) {
		case '0':s += 0; break;
		case '1':s += 1; break;
		case '2':s += 2; break;
		case '3':s += 3; break;
		case '4':s += 4; break;
		case '5':s += 5; break;
		case '6':s += 6; break;
		case '7':s += 7; break;
		case '8':s += 8; break;
		case '9':s += 9; break;
		}
	}
	if (atoi(n.c_str())%s == 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define int long long int
using namespace std;
signed main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   /* freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    int n,k; cin>>n>>k;
    int a[n+1], b[n+1];
    
    for(int i=1;i<n+1; i++){
    	cin>>a[i]; b[i]=0;
    } 
    int x=1,y=2, c=0, d=1;
    //cout<<b[x]<<endl;
    
    while(b[x]==0){
    	
        y=x;
        //cout<<"x "<<x<<endl;
        b[x]=1;
        x= a[x]; c++;
        d +=1;
        
        //y = a[y]; d +=2;
    }
    
    if(k < c){
         int m = k;
        c=0;
        int ans =1;
         
        while(c < m){
            ans = a[ans];
            c++;

        }
       
        cout<<ans<<endl;
    }
    else{
        k -=c;
        
        c=0;
        int z=a[x];
        //cout<<x<<endl;
        while(z !=x){
        //	cout<<"dd "<<z<<endl;
            c++;
            z = a[z];
        }
        c++;
         
        int m = k%c;
        ///cout<<m<<" ssH"<<endl;
        c=0;
        int ans =x;
        
        while(c < m){
        //	cout<<ans<<"gg"<<endl;
            ans = a[ans];
            c++;

        }
        cout<<ans<<endl;

    }


}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }



void solve()
{
    ll n;
    cin >> n;
    map<string , ll> mp;
    rep(i, n)
    {
        string s; cin >> s; sort(all(s)); mp[s]++;
    }
    ll ans = 0;
    itr(it, mp)
    {
        ans += (it->sd * (it->sd-1))/2;
    }
    cout << ans;
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 11264
#include <stdio.h>
int main(){
	int input1,input2,input3;
	scanf ("%d %d %d", &input1,&input2,&input3);
	if (input3>input1&&input3<input2|| input3==input1&&input3==input2&&input2==input1){
		printf ("Yes\n");
	}else printf  ("No\n");
	return 0;
}

Measured memory_bytes: 128
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	
	int n;
	cin>>n;
	int x = (n/2)+(n%2);

	cout<<(double)((double)x/(double(n)))<<endl;

	

	return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int a[maxn];
int main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    printf("%d\n",a[n/2+1]-a[n/2]);
}


Measured memory_bytes: 640
import math

def calc_dist(point1, point2):
  total = 0
  for x1, x2 in zip(point1, point2):
    total += (x1-x2)*(x1-x2)
  return math.sqrt(total)

N, D = map(int, input().split())
points = [list(map(int, input().split())) for i in range(N)]

ans = 0
for i  in range(0,N-1):
  for j in range(i+1,N):
    dist = calc_dist(points[i], points[j])
    if float(int(dist)) == dist:
      ans += 1    
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
		int A, B;
		cin >> A >> B;
		if (A <= 5) {
				cout << "0" << endl;
		} else if(A <= 12) {
				cout << B / 2 << endl;
		} else {
				cout << B << endl;
		}
		return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
a = list(map(int,input().split()))
flag = 1
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            flag = 0
            break
if flag:
    print('APPROVED')
else:
    print('DENIED')

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


signed main(){
    int Kuti,moti,tokura;
    cin  >> Kuti >> moti >> tokura;
    if(Kuti+moti>=tokura){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n;
    cin>>n;
    int p[n+5];
    int i;
    vi dif;
    FOR(i, 1, n+1)
    {
        cin>>p[i];
        if(p[i] != i) dif.pb(i);
    }
    if(dif.size() > 2)
        cout<<"NO";
    else cout<<"YES";
    
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}


Measured memory_bytes: 256