akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>

using namespace std;

class person
{
public:
	int start, end, weight;
	person(int start=0, int end=0, int weight = 0):start(start),end(end),weight(weight){};
	bool operator< (const person& per) const
	{
		if(start != per.start) return start < per.start;
		if(end != per.end) return end < per.end;
		if(weight != per.weight) return weight < per.weight;
		return false;
	}
};

int n;
vector<person> data;

const int INF = 1 << 29;

int main(void)
{
	while(cin >> n && n)
	{
		data.resize(n);
		for (int i = 0; i < n; i++)
		{
			int m, a, b;
			cin >> m >> a >> b;
			data[i] = person(a, b, m);
		}

		sort(data.begin(), data.end());
		vector<person> cur;
		bool ok = true;
		int time = data[0].start;
		cur.push_back(data[0]);
		int weights = data[0].weight;
		for (int i = 1; i < n; i++)
		{
			time = data[i].start;
			for (int j = 0; j < cur.size(); j++)
			{
				if(time >= cur[j].end)
				{
					weights -= cur[j].weight;
					cur.erase(cur.begin() + j);
					j--;
				}
			}
			cur.push_back(data[i]);
			weights+=data[i].weight;
			if(weights > 150)
			{
				ok = false;
				break;
			}
		}
		cout << (ok ? ("OK") : ("NG")) << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int cnt[n+1];fill(cnt,cnt+n+1,0);
  for(int i=0;i<m;i++){
    int a,b;cin>>a>>b;
    cnt[a]++;
    cnt[b]++;
  }
  for(int i=1;i<=n;i++){
    if(cnt[i]%2==1){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 640
n = int(input())
li = []

for i in range(n):
    s,p = input().split()
    p = int(p)
    li.append([s,p,i])

li.sort(key = lambda x:x[1],reverse = True)
li.sort(key = lambda x:x[0])

for i in range(n):
    print(li[i][2]+1)


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

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

    int n;
    cin >> n;

    long long cur = 0, res = 0;
    for (int i = 1; i <= n; i++) {
        cur += i;
        res += cur;
    }

    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        res -= u * 1ll * (n + 1 - v);
    }
    cout << res;

    return 0;
}


Measured memory_bytes: 3664
import java.lang.Math

fun main(args: Array<String>) {
    val (H, W, K) = readInputLine().split(" ").map { it.toInt() }

    val cake = Array(H) { readInputLine().toCharArray() }

    val sum = Array(H + 1) { IntArray(W + 1) }

    for (i in 0 until H) {
        for (j in 0 until W) {
            sum[i + 1][j + 1] += sum[i + 1][j]
            if (cake[i][j] == '1') {
                sum[i + 1][j + 1]++
            }
        }
    }

    for (i in 0 until H) {
        for (j in 0 until W) {
            sum[i + 1][j + 1] += sum[i][j + 1]
        }
    }

    var ans = H + W

    for (i in 0 until (1 shl H)) {
        val splitNum = mutableListOf<Int>()
        for (j in 1 until H) {
            if ((i shr (j - 1)) % 2 == 1) {
                splitNum.add(j)
            }
        }
        splitNum.add(H)
        var splitCnt = splitNum.size - 1

        var befSplitW = 0
        var unSplittable = false
        for (j in 1..W) {
            var befSplitV = 0
            var split = false
            for (sp in splitNum) {
                val areaCnt = sum[sp][j] - sum[befSplitV][j] - sum[sp][befSplitW] + sum[befSplitV][befSplitW]
                if (areaCnt > K) {
                    split = true
                }
                befSplitV = sp
            }
            if (split) {
                if (j - 1 == befSplitW) {
                    unSplittable = true
                    break
                }
                befSplitW = j - 1
                splitCnt++
            }
        }

        if (unSplittable) {
            continue
        }

        ans = Math.min(ans, splitCnt)
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 47708
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

template <typename T>
void vecin(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n - 1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}

int main()
{
    int n;
    cin >> n;
    vint p(n);
    vector<pll> p2(n);
    vecin(p);
    REP(i,n){
        p2[i].FI = p[i];
        p2[i].SE = i + 1;
    }
    sort(ALL(p2));
    reverse(ALL(p2));
    multiset<int> se;
    se.emplace(0);
    se.emplace(n + 1);
    se.emplace(0);
    se.emplace(n + 1);
    ll ans = 0;
    REP(i, n)
    {
        int now = p2[i].SE;
        auto ite = se.lower_bound(now);
        ll y = *ite++;
        ll z = *ite--;
        --ite;
        ll x = *ite--;
        ll w = *ite;
        ans += p2[i].FI * ((x - w) * (y - now) + (now - x) * (z - y));
        se.emplace(now);
    }
    cout << ans << endl;
}

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

using Int = long long;
using ll = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b)a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b)a=b;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);};

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

  vector<vector<edge> > G;
  vector<int> level, iter;

  Dinic(){}
  Dinic(int n):G(n), level(n), iter(n){}

  int add_edge(int from, int to, T cap){
    G[from].emplace_back(to, cap, G[to].size());
    G[to].emplace_back(from, directed?0:cap, G[from].size() - 1);
    return G[to].back().rev;
  }

  void bfs(int s){
    fill(level.begin(), level.end(), -1);
    queue<int> que;

    level[s] = 0;
    que.emplace(s);

    while(!que.empty()){
      int v = que.front(); que.pop();
      for(int i=0;i<(int)G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap > 0 && level[e.to] < 0){
          level[e.to] = level[v] + 1;
          que.emplace(e.to);
        }
      }

    }
  }

  T dfs(int v, int t, T f){
    if(v == t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++){
      edge &e = G[v][i];
      if(e.cap > 0 && level[v] < level[e.to]){
        T d = dfs(e.to, t, min(f, e.cap));
        if(d == 0) continue;
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
    return 0;
  }

  T flow(int s, int t, T lim){
    T fl = 0;
    while(1){
      bfs(s);
      if(level[t] < 0 || lim == 0) break;
      fill(iter.begin(), iter.end(), 0);

      while(1){
        T f = dfs(s, t, lim);
        if(f == 0) break;
        fl += f;
        lim -= f;
      }
    }
    return fl;
  }

  T flow(int s, int t){
    return flow(s, t, numeric_limits<T>::max()/2);
  }
};

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

  int n,m,s,t,u,v;
  cin>>n>>m>>s>>t>>u>>v;
  s--;t--;u--;v--;

  Dinic<int, false> G(n+2),H(n+2);
  int S=n,T=n+1;
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    G.add_edge(x,y,1);
    H.add_edge(x,y,1);
  }
  const int INF = 1e8;
  G.add_edge(S,s,INF);
  G.add_edge(S,u,INF);
  G.add_edge(t,T,INF);
  G.add_edge(v,T,INF);

  H.add_edge(S,s,INF);
  H.add_edge(S,v,INF);
  H.add_edge(t,T,INF);
  H.add_edge(u,T,INF);

  cout<<min(G.flow(S,T),H.flow(S,T))<<endl;
  return 0;
}



Measured memory_bytes: 16164
meter, houses_number = gets.split.map {|item| item.to_i}
home_position = gets.split.map {|item| item.to_i}
home_position.push(home_position[0] + meter)
result = Array.new

(0...home_position.size - 1).each do |i|
    result.push(home_position[i + 1] - home_position[i])
end

result.delete_at(result.index(result.max))
puts result.inject(:+)


Measured memory_bytes: 17084
import java.util.*;class Main{public static void main(String[]a){for(Scanner s=new Scanner(System.in);s.hasNext();){char[]x=s.nextLine().toCharArray();for(;!new String(x).matches(".*th(e|is|at).*");)for(int i=x.length;i-->0;)if(x[i]!=32&&x[i]!=46)x[i]=(char)((x[i]-96)%26+97);System.out.println(new String(x));}}}

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

#include <iostream>


#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> SP;

auto f=[]()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
};


int main()
{
	f();
	int arr[3][3];
		
	for(auto i=0;i<3;++i)
	{
		for(auto j=0;j<3;++j)
		{
			cin>>arr[i][j];
		}
	}

	int n;cin>>n;
	while(n--)
	{
		int num;cin>>num;
		for(auto i=0;i<3;++i)
		{
			for(auto j=0;j<3;++j)
			{
				if(arr[i][j]==0)continue;
				if(arr[i][j]==num){
					arr[i][j]=0;
					break;
				}
			}
		}
	}

	
	bool f=false;
	for(auto i=0;i<3;++i)
	{
		if(arr[i][0]==0 && arr[i][1]==0 && arr[i][2]==0)
			f=true;
		if(f)
			break;
	}

	if(f){
		cout<<"Yes\n";
		return 0;
	}

	for(auto i=0;i<3;++i)
	{
		if(arr[0][i]==0 && arr[1][i]==0 && arr[2][i]==0)
			f=true;
		if(f)
			break;
	}

	if(f){
		cout<<"Yes\n";
		return 0;
	}

	if(arr[0][0]==0 && arr[1][1]==0 && arr[2][2]==0 && !f)
		f=true;

	if(arr[2][0]==0 && arr[1][1]==0 && arr[0][2]==0 && !f)
		f=true;
	
	cout<<(f?"Yes\n":"No\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w;
    cin >> h >> w;
    while(h != 0){
        int mn = inf;
        int H=inf,W=inf;
        for(int i=1; i<=150; i++){
            for(int j=i+1; j<=150; j++){
                if(h*h+w*w < i*i+j*j){
                    if(chmin(mn,i*i+j*j)){
                        H = i;
                        W = j;
                    }else if(mn == i*i+j*j){
                        if(chmin(H,i)){
                            W = j;
                        }
                    }
                }else if(h*h+w*w == i*i+j*j){
                    if(i > h){
                        if(mn != i*i+j*j){
                            H = i;
                            W = j;
                        }else{
                            if(chmin(H,i)){
                                W = j;
                            }
                        }
                        mn = i*i+j*j;
                        
                    }
                }
            }
        }
        cout << H << " " << W << endl;
        cin >> h >> w;
    }
    return 0;
}


Measured memory_bytes: 3232
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            var o = ReadAndParseIntArr();
            int n = o[0];
            int k = o[1];
            int[] a = ReadAndParseIntArr();
            var dic = new Dictionary<int, int>();
            for(int i=0;i<a.Length;++i)
            {
                if( dic.ContainsKey(a[i]))
                {
                    dic[a[i]]++;
                }else
                {
                    dic.Add(a[i], 1);
                }
            }
            int ans = 0;
            if( k >= dic.Count)
            {
                // 何もしない
            }
            else
            {
                var list = new List<int>();
                foreach(var p in dic)
                {
                    list.Add(p.Value);
                }
                list.Sort();
                int m = dic.Count - k;
                for(int i=0;i<m;++i)
                {
                    ans += list[i];
                }
            }
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 33372
#include <stdio.h>
int main(void){
    float xa,ya,xb,yb,xc,yc,xd,yd;
    
    while(scanf("%f %f %f %f %f %f %f %f",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF){
        if((xa-xb)*(xc-xd)+(ya-yb)*(yc-yd)==0){
            puts("YES");
        }
        else puts("NO");
    }
    return 0;
}

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

string str[100000];
int main() 
{
    int a;
    cin >> a;
    int b = sqrt(a);
    b = b > 9 ? 9 : b;
    rep(i,1,b+1)
    {
        if(a % i == 0 && a / i <= 9)
        {
            cout << "Yes" << endl;
            //cin >> a;
            return 0;
        }
    }
    cout << "No" << endl;
    //cin >> a;
    return 0;
}

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

class IDONTKNOWCSHARP
{
    public static void Main()
    {
        string[] values = Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
        int X = int.Parse(values[0]);
        int N = int.Parse(values[1]);

        int[] nums = Convert(Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries));

        int kouho1, kouho2;

        int temp = 0;
        while (true)
        {
            if (!nums.Contains(X - temp))
            {
                kouho1 = X - temp;
                break;
            }

            temp++;
        }

        temp = 0;
        while (true)
        {
            if (!nums.Contains(X + temp))
            {
                kouho2 = X + temp;
                break;
            }

            temp++;
        }

        if (Math.Abs(kouho1 - X) > Math.Abs(kouho2 - X))
        {
            Console.WriteLine(kouho2 );
        }
        else
        {
            Console.WriteLine(kouho1 );

        }
    }

    static int[] Convert(string[] v)
    {
        var temp = new int[v.Length];

        for (int i = 0; i < temp.Length; i++)
        {
            temp[i] = int.Parse(v[i]); 
        }

        return temp;
    }

}

Measured memory_bytes: 27824
using System;

namespace question2
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Run();
        }

        void Run()
        {
            var line1 = Console.ReadLine();
            var line2 = Console.ReadLine();
            var line3 = Console.ReadLine();

            var n = int.Parse(line1);
            var t = int.Parse(line2.Split(' ')[0]);
            var a = int.Parse(line2.Split(' ')[1]);

            var ret = -1;
            var mindiff = double.MaxValue;

            for (int i = 0; i < n; i++)
            {
                var hi = int.Parse(line3.Split(' ')[i]);
                var ai = t - hi * 0.006;
                var diff = Math.Abs(a - ai);

                if (mindiff >= diff)
                {
                    ret = i;
                    mindiff = diff;
                }
            }

            Console.WriteLine(ret + 1);
        }
    }
}

Measured memory_bytes: 33800
#include<stdio.h>
int main(void)
{
  int X;
  int n,m;
  scanf("%d",&X);
  n = X / 500;
  X = X % 500;
  m = X / 5;
  X = (n*1000)+(m*5);
  printf("%d", X);
  
  return 0;
}

Measured memory_bytes: 1696
import sys

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')
N, K = list(map(int, input().split()))
V = np.array(list(map(int, input().split())))
Vminus = np.minimum(V, 0)

ans = 0
for take in range(min(N, K) + 1):
    discards = min(K - take, take)
    for t in range(take + 1):
        v = sum(V[:take - t]) + sum(V[N - t:])
        minuses = list(sorted(np.concatenate([Vminus[:take - t], Vminus[N - t:]])))
        ans = max(ans, v - sum(minuses[:discards]))
print(ans)


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define us unordered_set
#define um unordered_map
#define ms multiset
#define mm multimap
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)2e18);
const int ninf=((int)-2e18);
const int mod=1000000007;

using namespace std;

int power(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

bool vowel(char c)
{
    return(c=='a' or c=='e' or c=='i' or c=='o' or c=='u' or c=='A' or c=='E' or c=='I' or c=='U' or c=='O');
}

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);
    
    string s;
    cin>>s;
    int n=s.size();
    loop(i,0,n) cout<<"x";
    
    return 0;
}


Measured memory_bytes: 3620
import sys
sys.setrecursionlimit(1000000)
class Node:
    def __init__(self):
        self.next=[]
    def get_data(self,new_next,weight=1):
        self.next.append({new_next:weight})


def BFS():
    total=0
    check_node=tmp_node
    #print(check_node)
    now=min(check_node)
    tmp=[now]
    check_node.remove(now)
    ans=N-len(check_node)
    new_tmp=[]
    while len(check_node)>0:
        #print("tmp:{}".format(tmp))
        if tmp==[]:
            ans+=1
            tmp.append(check_node[0])
            check_node.remove(check_node[0])
        total+=1
        for each in tmp:
            #print("each:{}".format(each))
            for i in node[each].next:
                k=list(i.keys())[0]
                if k in check_node:
                    #print("append :{}".format(k))
                    new_tmp.append(k)
                    check_node.remove(k)
        #print("new_tmp:{}".format(new_tmp))
        #print("check_node:{}".format(check_node))
        tmp=new_tmp
        new_tmp=[]
    #print("end")
    #print("loop time:{}".format(total))
    #print("ans:{}".format(ans))
    print(ans)


def rec_BFS(i):
    tmp=[list(j.keys())[0] for j in i]
    for each in tmp:
        if not check_node[each]:
            check_node[each]=True
            rec_BFS(node[each].next)






        
        

N,M=list(map(int,input().split()))
node=[Node() for _ in range(N)]
#ans=[[100 for _ in range(N)]for _ in range(N)]
tmp_node=[]
for i in range(M):
    tmp_p,tmp_n,tmp_w=list(map(int,input().split()))
    #if not tmp_p-1 in tmp_node:
    #    tmp_node.append(tmp_p-1)
    #if not tmp_n-1 in tmp_node:
    #    tmp_node.append(tmp_n-1)
    node[tmp_p-1].get_data(tmp_n-1)
    node[tmp_n-1].get_data(tmp_p-1)
#BFS()
s=0
check_node=[False for _ in range(N)]
for i in range(N):
    if not check_node[i]:
        check_node[i]=True
        s+=1
        rec_BFS(node[i].next)
print(s)




Measured memory_bytes: 198568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll n;
    cin>>n;
    ll ans=0,c=0;
    vector<ll>h(n);
    rep(0,i,n){
        cin>>h[i];
        if(i!=0&&h[i-1]>=h[i])++c;
        else c=0;
        ans=max(c,ans);
    }
    cout<<ans;
}


Measured memory_bytes: 4008
#include <iostream>
#include <array>

int main()
{
	std::array<double, 4> x;
	std::array<double, 4> y;
	char comma;
	while (std::cin >> x[0] >> comma >> y[0]) {
		for (std::size_t i = 1; i < 4; ++i) {
			std::cin >> comma >> x[i] >> comma >> y[i];
		}
		if ((((y[1] - y[0]) * (x[0] - x[2]) - (y[0] - y[2]) * (x[1] - x[0])) *
			 ((y[3] - y[0]) * (x[0] - x[2]) - (y[0] - y[2]) * (x[3] - x[0])) < 0) and
			(((y[0] - y[1]) * (x[1] - x[3]) - (y[1] - y[3]) * (x[0] - x[1])) *
			 ((y[2] - y[1]) * (x[1] - x[3]) - (y[1] - y[3]) * (x[2] - x[1])) < 0)) {
			std::cout << "YES" << std::endl;
		}
		else {
			std::cout << "NO" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1212
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;

int main()
{
    int x1, y1, x2, y2, x3, y3, x4, y4;

    cin >> x1 >> y1 >> x2 >> y2;

    int v1x, v1y, v2x, v2y, v3x, v3y;

    v1x = x2 - x1;
    v1y = y2 - y1;

    v2x = -v1y;
    v2y = v1x;

    x3 = x2 + v2x;
    y3 = y2 + v2y;

    v3x =-v2y;
    v3y = v2x;

    x4 = x3 + v3x;
    y4 = y3 + v3y;

    cout << x3 << " "<<y3 <<" "<< x4 <<" "<< y4 << endl;

    return 0;

}



Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;    
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
#define PI 3.1415926535897932384626433832795
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define trav(x,v) for (auto &x : v)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define pv(v) trav(x, v) cout << x << " "; cout << endl; // print vector/array
#define pvv(vv) trav(xx, vv){pv(xx);} // print 2-d vector/2-d array
#define pm(m) trav(x, m) cout << x.F << ":" << x.S << " "; cout << endl; //print map/lookup table

const int MOD = 1000000007;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    char v[n][m];
    F0R(i,n)
        F0R(j,m)
            cin >> v[i][j];
    ll dp[n][m];
    memset(dp, 0, sizeof(dp));
    F0R(i, n){
        F0R(j, m){
            if(i==0 && j==0) dp[i][j] = 1;
            else if(i==0 && v[i][j] != '#') dp[i][j] = dp[i][j-1];
            else if(j==0 && v[i][j] != '#') dp[i][j] = dp[i-1][j];
            else{
                if(v[i][j] != '#')
                    dp[i][j] = dp[i-1][j] + dp[i][j-1];     
            }
            dp[i][j] = dp[i][j] % MOD;
        }
    }
    cout << dp[n-1][m-1];
    return 0;
}

Measured memory_bytes: 12408
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> S(H * W);
	for (int i = 0; i < H * W; i++) {
		cin >> S[i];
		if (S[i] == "snuke") {
			cout << (char)(65 + i % W);
			cout << (i / W) + 1 << endl;
		}
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
const int N=303, mod=1e9+7;
struct dabt{ int next,to,dis; }e[N];
int head[N],k,n,m,dp[N][N][N],ans;
inline void add(int from,int to,int d){e[++k]=(dabt){head[from],to,d}; head[from]=k;}
inline int read(){
	char ch=getchar(); int x=0, f=1;
	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;}
inline int mx(int a,int b){return a>b ? a : b;}
inline bool chek(int i,int j,int l)
{
	int r=mx(i,mx(j,l));
	for(int ii=head[r];ii;ii=e[ii].next)
	{
		int v=e[ii].to, d=e[ii].dis, tt=(i>=v)+(j>=v)+(l>=v);
		if(tt!=d) return 0;
	}
	return 1;
}
int main()
{
//	freopen("RGB Sequence.in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(); m=read();
	for(int i=1,a,b,c;i<=m;i++)
	{
		a=read(); b=read(); c=read();
		add(b,a,c);
	}
	dp[0][0][0]=1;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int l=0;l<=n;l++)
			{
				int r=mx(i,mx(j,l)); int &tt=dp[i][j][l];
				
				if(!tt || (i+j && i==j) || (j+l && j==l) || (i+l && i==l)) continue;
//				if(l==1) printf("asdas%d %d %d\n",i,j,dp[i][j][l]);
				if(!chek(i,j,l))
				{
					tt=0;
					continue;
				}
//				printf("%d %d %d (%d)\n",i,j,l,dp[i][j][l]);
				(dp[r+1][j][l]+=tt)%=mod;
				(dp[i][r+1][l]+=tt)%=mod;
				(dp[i][j][r+1]+=tt)%=mod;
//				printf("(%d)\n",dp[i][j][l+1]);
				if(r==n) (ans+=tt)%=mod;
			}
		}
	}
	printf("%d",ans);
	//fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 108800
import itertools

k = int(input())

area = [["."]*8 for i in range(8)]

X = set(range(8))
Y = set(range(8))
A = set()
B = set()

for i in range(k):
    x, y = map(int, input().split())
    area[x][y] = "Q"

    X.remove(x)
    Y.remove(y)
    A.add(x-y)
    B.add(x+y)
for v in itertools.permutations(Y):
    ok = 1
    A_ = A.copy()
    B_ = B.copy()
    for x, y in zip(X, v):
        if x-y in A_ or x+y in B_:
            ok = 0
            break

        A_.add(x-y)
        B_.add(x+y)
    
    if ok:
        for x, y in zip(X, v):
            area[x][y] = "Q"
        break

for i in range(8):
    print("".join(area[i]))



Measured memory_bytes: 5660
#include <stdio.h>

int main(){

 int n = 0;
 int ary[1000];
 int i=0;
 int count = 0;


 scanf("%d",&n);
 for(i=0;i<n;i++){scanf("%d",&ary[i]);}

 for(i=1;i<n-1;i++){
        if((ary[i-1] > ary[i] && ary[i+1] < ary[i] )||(ary[i-1] < ary[i] && ary[i+1] > ary[i] )){
                count++;
        }
 }

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

 return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>


using namespace std;

int main(){
   long long d, n, m;
   double ans;

   cin >> n >> m >> d;

   if (d == 0)
      ans = n;
   else
      ans =  2*n - 2*d;

   ans /= n*n;

   ans *= m-1;

//   cout << ans << endl;
   printf("%0.10lf\n", ans);


   return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll n;
  cin >> n;
  vl v(n), c(n);
  rep(i, n) cin >> v[i];
  rep(i, n) cin >> c[i];
  ll ans = 0;
  for (int x = 1; x < (1 << 20); x++) {
    ll tv = 0, tc = 0;
    rep(k, n) {
      if ((x >> k) & 1) {
        tv += v[k];
        tc += c[k];
      }
    }
    ans = max(ans, tv - tc);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<set>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int existart[26];

void strncpy(char *s0,char *s1,int n)
{
    int i;
    for(i=0;i<n;i++)
        s0[i]=s1[i];
    s0[n]=0;
    return;
}
struct str
{
    string s0;
}rec[50000];

bool cmp(str s1,str s2)
{
    return s1.s0<s2.s0;
}
int main()
{
    set<string> s1;
    int i,j,kk,k,temp,len,k_,cnt=0;
    for(i=0;i<26;i++)
        existart[i]=-1;
    char s[10000];
    char temps[10];
    scanf("%s%d",s,&k);
    for(i=0;s[i];i++)
    {
        if(existart[s[i]-'a']==-1)
            existart[s[i]-'a']=i;
    }
    len=i;
    for(k_=temp=0,j=0;k_<k;temp=0,j++)
    {
        while(-1==existart[j])
        {
            j++;
        }
        while(existart[j]+temp<len && k_<k)
        {
            temp++;
            k_++;
        }
        for(i=existart[j];i<len;i++)
        {
            if(s[i]==j+'a')
            {
                for(kk=1;kk<=temp && i+kk<=len;kk++)
                {
                    strncpy(temps,s+i,kk);
                  //  cout << temps << endl;
                    if(s1.count(temps)==0)
                    {
                        s1.insert(temps);
                        rec[cnt].s0=temps;
                        cnt++;
                    }
                }
            }
        }
    }
  //  for(i=0;i<cnt;i++)
 //   {
 //       cout << rec[i].s0 << endl;
 //   }
    sort(rec,rec+cnt,cmp);
    cout << rec[k-1].s0 << endl;
    return 0;
}


Measured memory_bytes: 768
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, G):
    v = e = 0
    for i in range(N):
        v += (i + 1) * (N - i)
        for j in G[i]:
            if j < i: continue
            e += (i + 1) * (N - j)
    print(v - e)

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        x, y = map(int, input().split())
        x, y = x - 1, y - 1
        G[x].append(y)
        G[y].append(x)
    main(N, G)


Measured memory_bytes: 105968
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int h;
	while(cin>>h,h){
		vvint vv;
		initvv(vv,h,5);
		rep(i,h) rep(j,5){
			cin>>vv[i][j];
		}
		int ans = 0;
		rep(i,h) rep(j,5) ans += vv[i][j];
		bool update = true;
		int cnt = 0;
		while(1){
			update=false;
			vvint ww;
			if(cnt++>100) break;
			initvv(ww,h,5,0);
			rep(i,h){
				rep(j,3){
					if(vv[i][j]&&vv[i][j]==vv[i][j+1]&&vv[i][j]==vv[i][j+2]){
						ww[i][j]=ww[i][j+1]=ww[i][j+2]=1;
						update=true;
					}
				}
			}
			rep(i,h) rep(j,5){
				if(ww[i][j]) vv[i][j]=0;
			}
			for(int i=h-1;i>=0;i--){
				rep(j,5){
					if(vv[i][j]==0){
						int p = i-1;
						while(p >= 0){
							if(vv[p][j]){
								vv[i][j]=vv[p][j];
								vv[p][j]=0;
								break;
							}
							p--;
						}
					}
				}
			}
		}
		int tmp = 0;
		rep(i,h){
			rep(j,5){
				tmp += vv[i][j];
			}
		}
		cout<<ans-tmp<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 3140
bool debug=false;
#include <string.h>
#include <stdio.h>
#include <queue>
#include <vector>
#include <utility>
using namespace std;
#define F first
#define S second
#define PB push_back
const int INF=1e9+10;
const int N=1e2+10;
pair<int,int> graph[N][N];
pair<int,int> dis[N];
int from[N];
int n;
int min(int a,int b){return a>b?b:a;}
pair<int,int> mcmf(int s,int t){
	for(int i=1;i<n;i++)dis[i]={INF,0};
	dis[s]={0,INF};
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
	pair<int,int> nxt;
	int temp;
	pq.push({0,s});
	from[s]=s;
	while(!pq.empty()){
		nxt=pq.top();
		pq.pop();
		if(debug)printf("nxt=%d %d\n",nxt.F,nxt.S);
		if(dis[nxt.S].F<nxt.F)continue;
		for(int i=0;i<n;i++)if(graph[nxt.S][i].S>0&&nxt.F+graph[nxt.S][i].F<dis[i].F){
			dis[i]={nxt.F+graph[nxt.S][i].F,min(dis[nxt.S].S,graph[nxt.S][i].S)};
			pq.push({dis[i].F,i});
			from[i]=nxt.S;
		}else if(debug)printf("graph[%d][%d]=%d %d\n",nxt.S,i,graph[nxt.S][i].F,graph[nxt.S][i].S);
	}
	if(dis[t].S==0)return {-1,-1};
	temp=t;
	while(temp!=s){
		graph[temp][from[temp]].S+=dis[t].S;
		graph[from[temp]][temp].S-=dis[t].S;
		temp=from[temp];
	}	
	graph[temp][from[temp]].S+=dis[t].S;
	graph[from[temp]][temp].S-=dis[t].S;
	return dis[t];
}

int main(){
	int l,r,cost,cap,m,ans=0,f;
	pair<int,int> temp;
	scanf("%d%d%d",&n,&m,&f);
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)graph[i][j]={INF,0};
	while(m--){
		scanf("%d%d%d%d",&l,&r,&cap,&cost);
		graph[l][r]={cost,cap};
		graph[r][l]={-cost,0};
	}
	while(f>0){
		temp=mcmf(0,n-1);
		if(debug)printf("f=%d temp=(%d,%d)\n",f,temp.F,temp.S);
		if(temp.S<=0){
			printf("-1\n");
			return 0;
		}
		if(temp.S>f){
			ans+=temp.F*f;
			f=0;
		}
		else{
			ans+=temp.F*temp.S;
			f-=temp.S;
		}
	}
	printf("%d\n",ans);
}




Measured memory_bytes: 2780
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  unsigned long n,k;
  cin >> n >> k;

  unsigned long a,b;
  a = n % k;
  b = (a <= k - a) ? a : k - a;
  cout << b << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const int INF = 100000; 

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

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

    sort(l.begin(), l.end(), greater<int>());

    int ans = 0;
    for(int i = 0; i < k; i++){
        ans += l[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int[] a = new int[n];
	for(int i = 0; i < n; i++) {
		a[i] = sc.nextInt();
	}
	int cout = 0;
	HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();
	for(int i = 0; i < n; i++) {
		if(hm.containsKey(a[i])) {
			cout = hm.get(a[i]) +1;
			hm.put(a[i], cout);
		} else {
			hm.put(a[i], 1);
		}
	}
	cout = 0;
	for(int key : hm.keySet()) {
		if(hm.get(key) >= key) {
			cout +=  hm.get(key) - key;
		} else {
			cout += hm.get(key);
		}
	}
	System.out.println(cout);
}
}


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

using namespace std;

int main(){
    int a,b;
    string op;
    while(true){
        cin >> a >> op >> b;
        if(op == "+"){
            cout << a+b << endl;
        } else if(op == "-"){
            cout << a-b << endl;
        } else if(op == "*"){
            cout << a*b << endl;
        } else if(op == "/"){
            cout << a/b << endl;
        } else if(op == "?"){
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
using namespace std;

int main(){
    string S;
    cin >> S;
    int length = S.length();
    for(int i=0; i<length; i++){
        S[i] = 'x';
    }
    cout << S;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
ll const VMAX = 100000;
double pi = 3.141592653589793238;

int main() {
  ll n, w;
  cin >> n >> w;
  vector<ll> vs(n), ws(n);
  rep(i, n) cin >> ws[i] >> vs[i];

  vector<vector<ll>> dp(n+1, vector<ll>(VMAX+1, INF));
  dp[0][0] = 0;

  rep(i, n) {
    rep(j, VMAX+1) {
      if (j-vs[i] >= 0)
        chmin(dp[i+1][j], dp[i][j-vs[i]] + ws[i]);

      chmin(dp[i+1][j], dp[i][j]);
    }
  }

  ll ans = 0;

  rep(i, VMAX+1) {
    if (dp[n][i] <= w) ans = i;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 80256
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    S = input().rstrip()
    if len(set(S))==3:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import math
while True:
    n=int(input())

    if n==0:
        break
    b=n//5
    c=n//(5**2)
    d=n//(5**3)
    e=n//(5**4)
    f=n//(5**5)
    g=n//(5**6)
    print(b+c+d+e+f+g)


Measured memory_bytes: 5644
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

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

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

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

    cout << (N - 1) * (M - 1) << endl;
    return 0;
}


Measured memory_bytes: 3612
<?php

list($n) = explode(' ', trim(fgets(STDIN)));

$c = array_fill(
    0,
    10,
    array_fill(0, 10, 0)
);

for ($k = 1; $k <= $n; ++$k) {
    $i = substr($k, 0, 1);
    $j = substr($k, -1);
    ++$c[$i][$j];
}

$answer = 0;
for ($i = 0; $i <= 9; ++$i) {
    for ($j = 0; $j <= 9; ++$j) {
        $answer += $c[$i][$j] * $c[$j][$i];
    }
}

echo $answer;


Measured memory_bytes: 5112
import sys

def solve(a, b):
    ans = 0
    cur = int(a * b)

    left = 1
    right = cur + 1
    while left < right:
        mid = int((left + right)/2)
        z = int(mid/2)
        mx = z * (mid - z)
        if mx <= cur:
            ans = mid
            left = mid + 1
        else:
            right = mid

    if int(ans/2) * (ans - int(ans/2)) == cur and a != b:
        ans -= 1
    return ans

n = int(sys.stdin.readline())
for i in range(n):
    x = sys.stdin.readline()
    y = [int(z) for z in x.split()]
    print(max(int(solve(y[0], y[1]))-2, 0))


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N;
	cin >>N;
	Rep0(i, N) {
		int A;
		cin >>A;
		if (A%2==1)
			continue;
		if (0==A%3)
			continue;
		if (0==A%5)
			continue;
		cout <<"DENIED" <<endl;
		return 0;
	}
	cout <<"APPROVED" <<endl;
	return 0;
}



Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

  //  Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    double[] num = new double[n];
    double sum = 0;
    for (int i=0;i<n;i++) {
      int in = cin.nextInt();
      sum += in;
      num[i] = in;
    }

    double mean = sum / n;
    for (int i = 0;i<n;i++) {
      num[i] = Math.abs(num[i]-mean);
    }
    int pos = 0;
    double min = Integer.MAX_VALUE;
    for (int i=0;i<n;i++) {
      if (num[i]<min) {
        pos = i;
        min = num[i];
      }
    }

    System.out.println(pos);

  }

}

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

int main()
{
    ll x;
    cin >> x ;
    ll q = x/500;
    ll r1 = x%500;
    ll q2 = r1/5;
    ll ans =q*1000+q2*5;
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
int count(int x){
	if(x==0) return 1;
	int ans=0;
	while(x){
		ans++;
		x/=10;
	}
	return ans;
}
int s[20],c[20];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++) cin>>s[i]>>c[i];
	int ans=-1;
	for(int i=0;i<1000;i++){
		vector<int> now;
		if(count(i)==n){
			int p=i;
			if(p==0) now.pb(0);
			else{
				while(p){
					now.pb(p%10);
					p/=10;
				}
			}
			reverse(now.begin(),now.end());
			bool ok=1;
			for(int j=1;j<=m;j++){
				if(now[s[j]-1]!=c[j]) ok=0;
			}
			if(ok==1){
				cout<<i<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
     int i,j,k,n,m;
     scanf("%d",&n);
     m=n;
     k=0;
     while(m>9)
     {
          k=k+m%10;
          m=m/10;
     }
     k=k+m;
     if(n%k==0)
          printf("Yes\n");
     else
          printf("No\n");
     return 0;
}


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

using namespace std;

#define int long long

int n;
int a[200010];
int f[200010];

main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    a[n] = -1;
    int lo = -1;
    int an = 0;
    for(int i = 0; i <= n; i++){
        if(a[i] == 0){
            if(lo == -1) lo = i;
        }
        else{
            if(lo == -1) continue;
            for(int j = lo; j < i; j++) f[j] = i - 1;
            lo = -1;
        }
    }
    for(int i = 0; i < n; i++){
        int s = 0, x = 0;
        for(int r = i; r < n; r++){
            if(a[r] == 0){
                an += f[r] - r + 1;
                r = f[r];
            }
            else{
                s += a[r];
                x ^= a[r];
                if(s == x) an++;
                else break;
            }
        }
    }
    cout << an << endl;
}


Measured memory_bytes: 3328
#include<stdio.h>

int main(){
  long long x = 0;
  long long y = 0;
  long long n = 0;
  long long a = 0;
  scanf("%lld %lld",&x,&y);
  a = x;
  n = 1;
  while(1){
    a = a * 2;
    if(a > y){
      break;
    }else{
      n++;
    }
  }
  //printf("%lld/",a);
  //printf("%lld/%lld/",x,y);
  printf("%lld",n);
  return 0;
}

Measured memory_bytes: 128