akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> colors(N);
  for (int i = 0; i < N; ++i) {
    cin >> colors[i];
  }

  int current_color = colors[0];
  int sum = 0;
  bool next_could_be_same_color = true;
  for (int i = 1; i < N; ++i) {
    if (next_could_be_same_color && current_color == colors[i]) {
      ++sum;
      next_could_be_same_color = false;
    } else {
      next_could_be_same_color = true;
    }
    current_color = colors[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);

ll K;
const ll N = 50;
ll a[50];

int main() {

	cin >> K;
	ll d = K / N;
	ll m = K % N;
	rep(i, N){
		a[i] = N - 1 + d;
	}

	rep(mm, m){
		rep(i, N){
			if(i == mm) a[i] += N;
			else a[i]--;
		}
	}

    cout << N << endl;
	rep(i, N){
		cout << a[i];
		if(i == N-1) cout << endl;
		else cout << " ";
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<int> ts;
vector<int> xs;
vector<int> ys;

bool solve(const int N) {
    for (int i = 1; i <= N; i++) {
        int diff_t = ts[i] - ts[i - 1];
        int diff_x = abs(xs[i] - xs[i - 1]);
        int diff_y = abs(ys[i] - ys[i - 1]);
        // printf("diff_t: %d, diff_x: %d, diff_y: %d\n", diff_t, diff_x, diff_y);

        if (diff_t < diff_x + diff_y) {
            return false;
        }
        if (abs(diff_x + diff_y - diff_t) % 2 != 0) {
            return false;
        }
    }

    return true;
}

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

    ts.resize(N + 1);
    xs.resize(N + 1);
    ys.resize(N + 1);
    ts[0] = 0;
    xs[0] = 0;
    ys[0] = 0;
    for (int i = 1; i <= N; i++) {
        int t, x, y;
        cin >> t >> x >> y;
        ts[i] = t;
        xs[i] = x;
        ys[i] = y;
    }

    if (solve(N)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 4232
#include <stdio.h>
#include <iostream>
#include <functional>
#include <vector>
#define lp(i, b) for(int i = 0; i < b; ++i) 
using namespace std;
void init_is_prime(int n, vector<int>& is_prime)
{
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i <= sqrt(n); ++i)
	{
		if (!is_prime[i]) continue;
		for (int j = i * i; j < n; j += i)
			is_prime[j] = 0;
	}
}
int main()
{
	vector<int> is_prime(pow(10, 5), 1);
	init_is_prime(pow(10, 5), is_prime);
	vector<int> prime2017(pow(10, 5), 0);
	int n = 0;
	function<bool(int)> judge = [&](int x)
	{
		if (is_prime[x] && is_prime[(x + 1) / 2])
		{
			return true;
		}
		return false;
	};
	lp(i, pow(10, 5))
	{
		if (!judge(i)) prime2017[i] = n;
		else
		{
			prime2017[i] = ++n;
		}
	}
	int m;
	int l, r;
	cin >> m;
	lp(i, m)
	{
		cin >> l >> r;
		cout << prime2017[r] - prime2017[l - 1] << endl;
	}
}

Measured memory_bytes: 3404
n,k = [int(i) for i in input().split()]
s = [0 for i in range(n)]
ans = 0

for i in range(k):
    d = int(input())
    a = [int(j) for j in input().split()]
    for m in range(d):
        s[a[m]-1] += 1
        
for i in range(n):
    if s[i]==0:
        ans += 1

print(ans)


Measured memory_bytes: 9188
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	bool flag = false; 
	while(1)
	{
		c -= b;
		if(c <= 0)
			break;
		a -= d;
		if(a <= 0)
		{
			flag = true;
			break;
		}
	}
	cout<<(flag?"No":"Yes");
	return 0;
}

Measured memory_bytes: 3596
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])
ans = 0
c = 0
for a,b in AB:
    if b + c >= M:
        ans += a*(M-c)
        print(ans)
        exit()
    else:
        ans += a*b
        c += b

Measured memory_bytes: 29028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
int main(){   
	/*int T;
	scanf("%d",&T);
	while(T--){
		
		
		
		
		printf("\n");
	}*/
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b||b==c||a==c){
		if(a==b&&b==c) printf("No");
		else printf("Yes");
	}
	else printf("No");

	
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

using namespace std;

typedef long long ll;

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

	int n, k;
	cin >> n >> k;

	if (k > (n - 2) * (n - 1) / 2) {
		cout << -1 << endl;
		return 0;
	}

	int tok = (n-1)*(n-2)/2;
	vector<int> as,bs;
	rep1(i, n - 1) {
		as.push_back(n);
		bs.push_back(i);
	}

	//頂点対を減らす。
	bool end = false;
	rep1(i, n - 1) {
		for (int j = i + 1; j <= n - 1; ++j) {
			if (k == tok) { end = true; break; }
			tok--;
			as.push_back(i);
			bs.push_back(j);
		}
		if (end) break;
	}
	cout << as.size() << endl;
	rep(i,as.size()) cout << as[i] << " " << bs[i] << endl;
}




Measured memory_bytes: 384
//
//  main.cpp
//  ABC155B
//
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    int A;
    bool c=false;
    for (int i=0; i<N; i++) {
        cin>>A;
        if(A%2==0){
            if((A%3==0)||(A%5==0)){ // 偶数なら3または5で割り切れなければならない
                c=true;
            } else {
                cout<<"DENIED"<<endl; // 割り切れない時、DENIED
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl; // 最後までたどり着けたらAPPROVED
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
 {
 	int n,m;
 	cin>>n>>m;
 	if(n==1 && m==1)
 	{
 		cout<<1<<endl;
 		return 0;
 	}
 	char a[n+1][m+1];
 	long long int v[n+1][m+1];
 	memset(v,0,sizeof(v));
 	for(int i=1;i<=n;i++)
 		for(int j=1;j<=m;j++)
 			cin>>a[i][j];
  	for(int i=1;i<=m;i++)
    {
    	if(a[1][i]=='.')
          v[1][i]=1;
      	else
          break;
    }
  	for(int i=1;i<=n;i++)
    {
    	if(a[i][1]=='.')
          v[i][1]=1;
      	else
          break;
    }
 	for(int i=2;i<=n;i++)
 	{
 		for(int j=2;j<=m;j++)
 		{
 		    if(a[i][j]!='#')
 			{
 			    if(a[i][j-1]=='.')
     			{
     			    v[i][j]=v[i][j-1]%1000000007;
     			}
     			if(a[i-1][j]=='.')
     			    v[i][j]=(v[i][j]+v[i-1][j])%1000000007;
 			}
 		}
 	}
 	cout<<v[n][m]%1000000007<<endl;
 	return 0;
 }


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

#define R register
#define LL long long
#define U unsigned
#define FOR(i,a,b) for(R int i = a;i <= b;++i)
#define RFOR(i,a,b) for(R int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

namespace fastIO{
    #define BUF_SIZE 100000
    #define OUT_SIZE 100000
    #define ll long long
    bool IOerror=0;
    inline char nc(){
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline void read(int &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    inline void read(ll &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    #undef ll
    #undef OUT_SIZE
    #undef BUF_SIZE
};
using namespace fastIO;

const int MAXN = 300 + 5;
int N,M;
int a[MAXN][MAXN];
bool ban[MAXN];
int num[MAXN];
int ans,maxid;


int main(){
    read(N);read(M);
    FOR(i,1,N) FOR(j,1,M) read(a[i][j]);
    FOR(i,1,N) num[a[i][1]]++;
    ans = INT_MAX;
    FOR(i,1,M){
        CLR(num,0);
        int max=0;
        FOR(j,1,N){
            FOR(k,1,M){
                if(!ban[a[j][k]]){
                    num[a[j][k]]++;
                    break;
                }
            }
        }
        int sum=0,maxid;
        FOR(j,1,M){
            if(sum < num[j]){
                sum = num[j];
                maxid = j;
            }
        }
        ban[maxid] = true;
        ans = std::min(ans,sum);
    }
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

int64_t solve(int n, int k) {
  int64_t ret = 0;
  for (int a = 1; a <= n; a++) {
    int b = 1;
    if ((a + b) % k) {
      b += k - (a + b) % k;
    }
    if (b > n) {
      continue;
    }
    int c = 1;
    if ((b + c) % k) {
      c += k - (b + c) % k;
    }
    if ((a + c) % k) {
      continue;
    }
    if (c > n) {
      continue;
    }
    int64_t const bOthers = (n - b) / k;
    int64_t const cOthers = (n - c) / k;
    ret += (1 + bOthers) * (1 + cOthers);
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n, k;
  std::cin >> n >> k;
  std::cout << solve(n, k) << std::endl;
  return 0;
}


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

int main(){ 
    int n,m,c;
    cin>>n>>m>>c;
    int a=0;
    int b=0;
    vector<vector<int>> d(n+1, vector<int>(m));
  for (int i = 0; i < n+1; i++) {
    for (int j = 0; j < m; j++) {
      cin >> d.at(i).at(j);
    }
  }
  for(int i=1;i<n+1;i++){
  for(int j=0;j<m;j++){
      a+=d[0][j]*d[i][j];
  }
  if(a+c>0){
      b++;
  }
  a=0;
  }
  cout<<b;
    return 0;
}


Measured memory_bytes: 256
# import matplotlib.pyplot as plt
import math
 
def lcm(x, y):
   if x > y:
       z = x
   else:
       z = y
 
   while(True):
       if((z % x == 0) and (z % y == 0)):
           lcm = z
           break
       z += 1
 
   return lcm

X = int(input())
print(int(lcm(X, 360) / X))

Measured memory_bytes: 9180
def _gcd(a, b)
    return a if b == 0
    gcd(b, a % b)
end

def gcd(a, b)
    if a < b
        tmp = a
        a = b
        b = tmp
    end
    
    _gcd(a, b)
end

a, b = gets.chomp.split.map(&:to_i)

puts gcd(a, b)


Measured memory_bytes: 6872
#! /usr/bin/python
# -*- encoding: utf-8 -*-

import sys

if __name__ == '__main__':
    inputN = int(input())
    inputList = list(map(int, input().split()))
    #
    flag = False
    before = 0
    for k in range(inputN):
        if before >= inputList[k]:
            flag = True
        before = inputList[k]
    
    #
    if not flag:
        sys.stdout.write("YES")
        sys.exit()
    
    #  
    for i in range(inputN):
        for j in range(inputN):
            if i != j:
                changeList = inputList[:]
                swap = changeList[i]
                changeList[i] = changeList[j]
                changeList[j] = swap
          
                #
                flag = False
                before = 0
                for k in range(inputN):
                    if before >= changeList[k]:
                        flag = True
                    before = changeList[k]
          
                #
                if not flag:
                    sys.stdout.write("YES")
                    sys.exit()


    sys.stdout.write("NO")
          
    
    
    

Measured memory_bytes: 3064
def frog2(N,h,k):
    dp=[0]*(N)
    dp[0]=0
 
    for i in range(1,N):
        mn=float('inf')
        for j in range(1,k+1):
            if i-j>=0:
                mn=min(mn,abs(h[i]-h[i-j])+dp[i-j])
        dp[i]=mn
    return dp[N-1]
 
 
 
N,k=map(int,input().split())
h=list(map(int,input().split()))
print(frog2(N,h,k))

Measured memory_bytes: 52448
import sys
for line in sys.stdin:
    a, op, b = line.split()
    if op == '?':
        break
    a = int(a)
    b = int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    else:
        print(a // b)
        

Measured memory_bytes: 7716
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

vector<ll> divisor;
void find_divisor(ll N) {
  for(int i=1; i<=sqrt(N); i++) {
    if(N % i == 0)
      divisor.push_back(i);
  }
  int n = divisor.size();
  for(int i=n-1; i>=0; i--) {
    if(N != (ll)pow(divisor[i], 2))
      divisor.push_back(N / divisor[i]);
  }
}
int digit(ll N) {
  ll n = N;
  int ret = 0;
  while(n > 0) {
    ret++;
    n /= 10;
  }
  return ret;
}

int main(){
  ll N;
  cin >> N;
  find_divisor(N);
  int n = divisor.size();
  for(int i=0; i<n; i++)
    divisor[i] = digit(divisor[i]);
  int ret = 100;
  for(int i=0; i<(n+1)/2; i++) {
    if(divisor[n-1-i] < ret)
      ret = divisor[n-1-i];
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int line = sc.nextInt();
	    long a = 0;
	    for (int i = 1; i <= line; i++) {
		    if (i % 3 != 0 && i % 5 != 0) {
		        a+= i;
		    }
		}
		System.out.println(a);
    }
}

Measured memory_bytes: 35668
#include <iostream>

int main() {
  std::string s;
  unsigned long long k;

  std::cin >> s >> k;
  k--; // 1..indexed -> 0..indexed

  unsigned long long i = 0;
  while (s[i] == '1' && i < k) i++;
  if (s[i] == '\0') std::cout << '1' << std::endl;
  else std::cout << s[i] << std::endl;
  return 0;
}


Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline()[:-1]

H, W = map(int, input().split())
s = [input() for _ in range(H)]
tate = [[0 for _ in range(W)] for _ in range(H)]
yoko = [[0 for _ in range(W)] for _ in range(H)]
for h in range(H):
	ba, fr = 0, 0
	while ba < W:
		if s[h][ba] == "#":
			ba += 1
			fr += 1
		while fr < W and s[h][fr] == ".":
			fr += 1
		for w in range(ba, fr):
			yoko[h][w] = fr-ba
		ba = fr
#print(yoko, sep="\n")
for w in range(W):
	ba, fr = 0, 0
	while ba < H:
		if s[ba][w] == "#":
			ba += 1
			fr += 1
		while fr < H and s[fr][w] == ".":
			fr += 1
		for h in range(ba, fr):
			tate[h][w] = fr-ba
		ba = fr
#print(tate, sep="\n")
ans = 1
for h in range(H):
	for w in range(W):
		ans = max(ans, yoko[h][w]+tate[h][w]-1)
print(ans)

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int M; cin >>M;
    cout << 48-M << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<complex>
#include<numeric>
#include<bitset>
#define INF 1001001001
#define EPS 1e-8

using namespace std;
typedef vector<int> vint;
typedef vector<vint>  vvint;
typedef pair<int,int> pint;

int p[1000010];

void primes(int n){
	p[0]=p[1]=0;
	for(int i=2;i<n;i++) p[i]=i;
	for(int i=2;i*i<n;i++) if(p[i]) for(int j=i*i;j<n;j+=i) p[j]=0;
}

int main(){
	primes(1000000);
	int a,d,n;
	while(cin >> a >> d >> n){
		if(a==0 && d==0 && n==0) break;
		int c=0;
		for(;;a+=d){
			if(p[a]!=0) c++;
			if(c==n){
				cout << a << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){

  long n,ans=0;
  cin >>n;
  
  if(n%2!=0) cout << 0 << endl;
  else{
  	long na=n/10;
  	while(na>0){
      	ans+=na;
    	na/=5;
    }
    
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int N;
  cin >> N;
  unordered_map<string, int> hashMap;
  string s;
  for (int i = 0; i < N; ++i) {
    cin >> s;
    hashMap[s]++;
  }
  int max_count = 0;
  for (auto m : hashMap) {
    max_count = max(max_count, m.second);
  }
  vector<string> res;
  for (auto m : hashMap) {
    if (m.second == max_count) {
      res.push_back(m.first);
    }
  }
  sort(res.begin(), res.end());
  for (const string& str : res) {
    cout << str << endl;
  }
  return 0;
}


Measured memory_bytes: 25284
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, A) for (auto & a : A)
#define all(a) (a).begin (), (a).end ()
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+6+7;

int main ()
{
	int i, j, n, k;
	scanf ("%d %d", &n, &k);
	vector <int> A (n);
	trav (a, A) scanf ("%d", &a);
	int ans = 0, wind;
	for (i = 0; i < k; ++i) ans += A[i];
	wind = ans;
	for (i = k; i < n; ++i)
	{
		wind += A[i]; wind -= A[i - k];
		ans = max (ans, wind);
	}
	ans += k;
	printf ("%.9lf\n", (double)ans/2);

	return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("hard1.txt","r",stdin)
#define OUT freopen("hard1.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 1000005
#define FastIO  ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii ;

#define maxn 1000005
#define mod 1000000007LL
#define lim 1000000000
#define INF 4500000000000000000LL

int a[305][305] ;
int yes[305] , cnt[305] ;

int main()
{
    int n , m ;
    scanf("%d %d",&n,&m) ;

    for(int i=1 ; i<=n ; i++)
    {
        for(int j=1 ; j<=m ; j++) scanf("%d",&a[i][j]) ;
    }

    int ans = n ;

    for(int i=1; i<=m ; i++) yes[i] = 1 ;

    for( ; ; )
    {
        memset(cnt,0,sizeof(cnt)) ;
        int fl = 0 ;
        for(int i=1 ; i<=m ; i++)
        {
            if(yes[i]) fl = 1 ;
        }
        if(!fl) break ;
        for(int i=1; i<=n ; i++)
        {
            for(int j=1 ; j<=m ; j++)
            {
                if(yes[ a[i][j] ])
                {
                    cnt[ a[i][j] ]++ ;
                    break ;
                }
            }
        }
        int mx = 0 ;
        for(int i=1 ; i<=m ; i++) mx = max(cnt[i],mx) ;
        ans = min(mx,ans) ;
        for(int i=1 ; i<=m ; i++)
        {
            if( cnt[i]==mx ) yes[i] = 0 ;
        }
    }

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

    return 0 ;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := next()

	if N[1] == N[2] && (N[0] == N[1] || N[2] == N[3]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
x, n = map(int,input().split())
if n >0:
    p = list(map(int,input().split()))

    p.sort()
    gap = 10**1000
    ans =10**1000
    for i in range(0,1000):
        if not x-i in p:
            print(x-i)
            break
        elif not x+i in p:
            print(x+i)
            break
else:
    print(x)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define int long long
const int MOD=1e9+7;
using pii=std::pair<int,int>;
using namespace std;

int n, k, d, a;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    set<int> rem;
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        rem.insert(i);
    for(int i = 0; i < k; i++)
    {
        cin >> d;
        for(int j = 0; j < d; j++)
        {
            cin >> a;
            rem.erase(a);
        }
    }
    cout << rem.size() << "\n";
    return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

ll L, R;

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  cin >> L >> R;
  
  ll answer;
  if (R >= L + 2018) {
    answer = 0;
  }else {
    answer = 2018;
    for (ll i = L; i <= R; i++) {
      for (ll j = i+1; j <= R; j++) {
	ll x = (i*j) % 2019;
	answer = min(answer, x);
      }
    }
  }
  cout << answer << endl;

  return 0;
}



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

using namespace std;

int seq[100050];

bool cmp(int a,int b)
{
	return a > b;
}

int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 1;i <= n; ++ i) scanf("%d",&seq[i]);
	sort(seq + 1,seq + 1 + n,cmp);
	int ps = 0;
	for(int i = 1;i <= n; ++ i)
	{
		if(seq[i] < i)
		{
			ps = i - 1;
			break;
		}
	}
	if(!ps) ps = n;
	long long d1 = seq[ps] - ps;
	int vl = ps; ps ++;
	long long d2 = 0;
	while(seq[ps] >= vl && ps <= n) d2 ++,ps ++;
	if((d2 & 1) || (d1 & 1)) printf("First\n");
	else printf("Second\n");
}

Measured memory_bytes: 768
import java.awt.List;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext())
		{
			int a = sc.nextInt();
			String b = sc.next();
			if (a < b.length())
			{
				System.out.println(b.substring(0,a)+"...");
				
			} else
			{
				System.out.println(b);

			}
		}

	}

}

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

int main() {
    int n;
    cin >> n;
    string ans = "Yes";
    int t = 0, x = 0, y = 0;
    for (int i = 0; i < n; i++) {
        int nt, nx, ny;
        cin >> nt >> nx >> ny;
        int d = abs(nt - t) - abs(nx - x) - abs(ny - y);
        if (d < 0 || d % 2 != 0) ans = "No";
        t = nt, x = nx, y = ny;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
void func(int);

int main(void)
{
	int n,i,j,a[100],minj,cnt;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	cnt=0;
	for(i=0;i<n;i++)	{
		minj=i;
		for(j=i;j<n;j++)	{
			if(a[j]<a[minj])	minj=j;
		}
		if(i!=minj)	{
			swap(a[i],a[minj]);
			cnt++;
		}
	}
	printf("%d",a[0]);
	for(i=1;i<n;i++)	printf(" %d",a[i]);
	printf("\n");
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2692
# 解説
from collections import Counter

s = input()

ctr = Counter(s)
ctr.update({c: 0 for c in 'abc'})

cond = max(ctr.values()) - min(ctr.values()) <= 1

print('YES' if cond else 'NO')

# 偶数文字の回文には2文字の回文が含まれる
# 奇数文字の回文には3文字の回文が含まれる
# 2/3文字の回文が含まれないようにできればよい
# 同じ文字同士の間隔を2文字以上離せばよい
# abcabc...しかない
# 3文字のブロックと余りのブロックで各文字の出現数の差は1以下の必要がある


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  long ans = 0;
  int mi = 0;
  for (int i=0; i<N; i++) {
    cin >> A[i];
  }
  for (int i=0; i<N; i++) {
    if (A[i] < 0) {
      mi++;
      A[i] = A[i] * -1;
    }
    if (A[i] == 0) {
      mi = 0;
      break;
    }
  }
  if (mi % 2 == 0) {
    for (int i=0; i<N; i++) {
      ans += abs(A[i]);
    }
  }
  else {
    sort(A.begin(),A.end());
    ans -= A[0]*2;
    for (int i=0; i<N; i++) {
      ans += abs(A[i]);
    }
  }
  cout << ans << endl;
}

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

int main() {
  string s; cin >> s;
  
  vector<int> stones(s.size(), 0);
  for (int i = 0; i < s.size(); i++) if (s.at(i) == 'B') stones.at(i) = 1;
  
  vector<ll> ps_black(s.size(), 0);
  partial_sum(stones.begin(), stones.end(), ps_black.begin());
  
  ll answer = 0;
  for (int i = 0; i < s.size(); i++) if (s.at(i) == 'W') answer += ps_black.at(i);
  
  cout << answer << endl;
}

Measured memory_bytes: 2948
# coding: utf-8
# Your code here!

N = int(input())
a=[i for i in range(N)]
b=[i for i in range(N)]
c=[i for i in range(N)]

for i in range(N):
    a[i],b[i],c[i] = list(map(int,input().split()))

dp = [[0,0,0] for i in range(N)]
dp[0] = [a[0],b[0],c[0]]

for i in range(N-1):
    dp[i+1] = [a[i+1] + max(dp[i][1], dp[i][2]), b[i+1] + max(dp[i][0], dp[i][2]), c[i+1] + max(dp[i][1], dp[i][0])]

print(max(dp[N-1]))

Measured memory_bytes: 34588
MOD = 10**9 + 7
L = input()

N = len(L)

dp = [[0]*2 for i in range(N+1)]

dp[1][0] = 2
dp[1][1] = 1
for n in range(2,N+1):
	bit = L[n-1]
	if bit == '1':
		dp[n][0] = 2*dp[n-1][0] % MOD
		dp[n][1] = (dp[n-1][0] + 3*dp[n-1][1]) % MOD
	else:
		dp[n][0] = dp[n-1][0] % MOD
		dp[n][1] = dp[n-1][1]*3 % MOD

print((dp[N][0] + dp[N][1]) % MOD)




Measured memory_bytes: 19700
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String str = reader.readLine();
		int N = Integer.parseInt(str);
		int ans = 0;
		boolean flag = false;
		for (int i = 1; i <= N; i++) {
			if ((int)Math.floor(i * 1.08) == N) {
				ans = i;
				flag = true;
				break;
			}
		}
		if (flag) {
			System.out.println(ans);
		}
		else {
			System.out.println(":(");
		}
	}
}

Measured memory_bytes: 21332
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Beaker struct {
	Water           float64
	Sugar           float64
	SugarSaturation float64
	Cap             float64
}

func (b *Beaker) addWater(w float64) bool {
	if (w + b.Water + b.Sugar) > b.Cap {
		return false
	}
	b.Water += w
	return true
}

func (b *Beaker) addSugar(s float64) bool {

	if (s + b.Water + b.Sugar) > b.Cap {
		return false
	}

	if (s + b.Sugar) > (b.SugarSaturation * b.Water / 100.0) {
		return false
	}

	b.Sugar += s
	return true
}

func (b *Beaker) concentration() float64 {
	if (b.Sugar + b.Water) == 0 {
		return 0.0
	}
	return b.Sugar / (b.Water + b.Sugar) * 100.0
}

func (b *Beaker) sugarWater() float64 {
	return b.Sugar + b.Water
}
func main() {
	sc.Split(bufio.ScanWords)

	a := nextInt()
	b := nextInt()
	c := nextInt()
	d := nextInt()
	e := nextInt()
	f := nextInt()

	maxDense := 0.0
	maxW := 100 * a
	maxS := 0
	// var maxBeaker Beaker

	for i := 0; 100*a*i <= f; i++ {
		for j := 0; 100*b*j <= f-100*a*i; j++ {
			w := 100 * (a*i + b*j)
			cap := e * (a*i + b*j)
			for k := 0; c*k <= cap && c*k <= f-w; k++ {
				for l := 0; d*l <= cap-c*k && d*l <= f-w-c*k; l++ {
					sal := c*k + d*l
					var den float64
					if k == 0 && l == 0 {
						den = 0.0
					} else {
						den = float64(sal) / float64(w+sal)
					}
					if maxDense < den {
						maxDense = den
						maxW = w + sal
						maxS = sal
					}
				}

			}
		}
	}

	fmt.Printf("%d %d\n", maxW, maxS)
	// for i := 0; i <= f/a; i++ {

	// 	beaker := Beaker{
	// 		Water:           0.0,
	// 		Sugar:           0.0,
	// 		SugarSaturation: float64(e),
	// 		Cap:             float64(f),
	// 	}

	// 	if !beaker.addWater(float64(a * i)) {
	// 	}

	// 	for j := 0; j <= f/b; j++ {
	// 		if !beaker.addWater(float64(b * j)) {
	// 		}

	// 		if beaker.Water != 0 {

	// 			for k := 0; k <= f/c; k++ {
	// 				if !beaker.addSugar(float64(c * k)) {
	// 				}
	// 				for l := 0; l <= f/d; l++ {
	// 					if !beaker.addSugar(float64(d * l)) {

	// 						fmt.Printf("操作1を%d回\n", i)
	// 						fmt.Printf("操作2を%d回\n", j)
	// 						fmt.Printf("操作3を%d回\n", k)
	// 						fmt.Printf("操作4を%d回\n", l)
	// 						fmt.Printf("%+v\n", beaker)
	// 						fmt.Printf("容量:%f\n", beaker.sugarWater())
	// 						fmt.Printf("濃度:%f(％)\n", beaker.concentration())
	// 						if max < beaker.concentration() {
	// 							max = beaker.concentration()
	// 							maxBeaker = beaker
	// 						}

	// 					}

	// 				}
	// 			}
	// 		}
	// 	}
	// }

	// fmt.Printf("%+v\n", maxBeaker)
	// fmt.Printf("容量:%f\n", maxBeaker.sugarWater())
	// fmt.Printf("濃度:%f(％)\n", maxBeaker.concentration())

	// fmt.Printf("%d %d\n", int(maxBeaker.sugarWater()), int(maxBeaker.Sugar))
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}


int main(){
   string s;
   cin >> s;

   int ans = 0;
   if(s[0] == '1'){
      for(int i = 1; i < s.size(); i++){
         if(i % 2 == 0 && s[i] == '0'){
            ans++;
         }
         else if(i % 2 != 0 && s[i] == '1'){
            ans++;
         }
      }
   }
   else{
      for(int i = 1; i < s.size(); i++){
         if(i % 2 == 0 && s[i] == '1'){
            ans++;
         }
         else if(i % 2 != 0 && s[i] == '0'){
            ans++;
         }
      }
   }
   cout << ans << endl;
   return 0;
}

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

int main(){
  int k;
  int a[100010];
  cin >> k;
  for(int i = 0;i < k;i++) cin >> a[k-i-1];

  if(a[0] != 2){
    cout << -1 << endl;
    return 0;
  }

  long long min = 2;
  long long max = 3;

  for(int i = 1;i < k;i++){
    min = min + (min % a[i] != 0 ? (a[i] - min % a[i]) : 0);
    if(min > max){
      cout << -1 << endl;
      return 0;
    }

    max = max-(max%a[i])+(a[i]-1);
  }
  cout << min << " " << max << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#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 EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

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

//v.erase(unique(v.begin(),v.end()),v.end());


long double foo(long double a,long double b){
	long double s=a/2.0+b;
	long double ret=sqrt(s*(s-a)*(s-b)*(s-b));
	return ret;
}

int main(){
	long double a,l,x;
	while(cin>>a>>l>>x){
		long double ans=foo(a,l);
		ans+=foo(l,(l+x)/2.0)*2.0;
		printf("%.10Lf\n",ans);
	}
}

Measured memory_bytes: 1240
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())
a = [int(x) for x in input().split()]
ans = 0
for i in range(1, n):
    if a[i] < a[i - 1]:
        ans += a[i - 1] - a[i]
        a[i] = a[i - 1]
print(ans) 

Measured memory_bytes: 94016
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		double x1 = sc.nextDouble();
		double y1 = sc.nextDouble();
		double x2 = sc.nextDouble();
		double y2 = sc.nextDouble();

		double rr = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
		double r = Math.sqrt(rr);

		System.out.printf("%.5f", r);

	}

}

Measured memory_bytes: 28248
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

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

int R, C;
int N;
int r[100010], c[100010];
ll a[100010];
vector<point> V[100010];
map<int, ll> W[100010];
ll mini[100010];
int ind[100010];

void merge(int p, int q, ll sub) {
  if (W[p].size() > W[q].size()) {
    merge(q, p, -sub);
  } else {
    for (auto x : W[p]) {
      int col = x.first;
      ll val = x.second;
      ind[col] = q;
      W[q][col] = val + sub;
    }
    mini[q] = min(mini[q], mini[p] + sub);
  }
}

bool issame(int p, int q) {
  return (ind[p] == ind[q]);
}

ll calc_sa(int p, int q) {
  return W[ind[q]][q] - W[ind[p]][p];
}

int main() {
  cin >> R >> C;
  cin >> N;
  for (auto i = 0; i < N; i++) {
    cin >> r[i] >> c[i] >> a[i];
    r[i]--; c[i]--;
    V[r[i]].push_back(make_pair(c[i], a[i]));
  }
  for (auto i = 0; i < C; i++) {
    W[i].insert(make_pair(i, 0));
    ind[i] = i;
  }
  fill(mini, mini+N, 0);
  for (auto i = 0; i < R; i++) {
    /*
    cerr << "i = " << i << endl;
    bool visited[100010];
    fill(visited, visited+100010, false);
    for (auto i = 0; i < C; i++) {
      int v = ind[i];
      if (!visited[v]) {
        visited[v] = true;
        cerr << "v = " << v << ", ";
        for (auto x : W[v]) {
          cerr << x.first << ":" << x.second << " ";
        }
        cerr << ", mini = " << mini[v] << endl;
      }
    }
    */
    if (V[i].empty()) continue;
    int col = V[i][0].first;
    ll val = V[i][0].second;    
    for (auto it = V[i].begin()+1; it != V[i].end(); it++) {
      int ncol = (*it).first;
      ll nval = (*it).second;
      if (issame(col, ncol)) {
        if (calc_sa(col, ncol) == nval - val) {
          // nothing
        } else {
          /*
          cerr << "calc_sa(" << col << ", " << ncol << ") = "
               << calc_sa(col, ncol) << endl;
          cerr << "nval - val = " << nval << " - " << val << endl;
          */
          cout << "No" << endl;
          return 0;
        }
      } else {
        ll desired = calc_sa(col, ncol) - (nval - val);
        merge(ind[col], ind[ncol], desired);
      }
    }
  }
  for (auto i = 0; i < R; i++) {
    if (V[i].empty()) continue;
    int col = V[i][0].first;
    ll val = V[i][0].second;
    if (mini[ind[col]] - W[ind[col]][col] + val < 0) {
      // cerr << mini[ind[col]] << " - " << W[ind[col]][col] << endl;
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 36864
#include <iostream>
#include <map>
#include <string>

int main(){
  int N = 0;
  std::cin >> N;
  
  std::map<std::string, int> map_get;
  
  
  for(int i = 0; i < N ; i++){
    std::string str;
    std::cin >> str;
    
    if(map_get.count(str) == false){
      map_get[str] = 1;
    }
  }
  
  std::cout << map_get.size() << std::endl;
  
  return 0;
}

Measured memory_bytes: 19120
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

typedef pair<int,int> mypair;


int dak(int st, int gl, int n, int m, vector<vector<int> > zct){
	vector<int> mct(n+1,1<<22);
	vector<bool> use(n+1,false);
	mct[st]=0;
	priority_queue<mypair, vector<mypair>, greater<mypair> > pq;
	pq.push(mypair(0,st));
	while(!pq.empty()){
		int ct = pq.top().first;
		int to = pq.top().second;
		pq.pop();
		if(use[to]) continue;
		use[to]=true;
		
		rep(i,m){
			if( mct[i] > mct[to]+ zct[to][i]){
					mct[i] = mct[to] + zct[to][i];
				pq.push(mypair(mct[i],i));
			}
		}
	}
	return mct[gl];

}

int main(void){

int n,m;
int a,b,c,d;
int x1,x2,y1,y2;
char k;
	cin >> n >> m;
	vector<vector<int> > zct(n+1,vector<int>(n+1,1<<20));
	rep(i,m){
		cin >>a >>k >>b >>k >>c >>k >>d;
		a--;  b--;
		zct[a][b]=c; zct[b][a]=d;
	}
	cin >>x1 >>k >>x2 >>k >>y1 >>k >>y2;
	x1--; x2--;
	int ans = y1 - (y2 +dak(x1,x2,n,m,zct) + dak(x2,x1,n,m,zct));
	cout << ans << endl;

	return 0;
	
}

Measured memory_bytes: 1220
package main

import "fmt"

var N int
var C, S, F []int

func main() {
	fmt.Scan(&N)
	var c, s, f int
	C = make([]int, N+1)
	S = make([]int, N+1)
	F = make([]int, N+1)
	for i := 1; i < N; i++ {
		fmt.Scan(&c, &s, &f)
		C[i] = c
		S[i] = s
		F[i] = f
	}

	n := 0
	t := 0
	for i := 1; i < N; i++ {
		t = 0
		n = i
		for n != N {
			//			fmt.Println("S", i, t, n)
			t, n = getFastestNex(t, n)
			//	fmt.Println("E", i, t, n)
		}
		fmt.Println(t)
	}
	fmt.Println("0")
}

func getFastestNex(t, i int) (int, int) {
	if t <= S[i] {
		return S[i] + C[i], i + 1
	} else {
		if (t-S[i])%F[i] == 0 {
			return int((t-S[i])/F[i])*F[i] + S[i] + C[i], i + 1
		} else {
			return int(((t-S[i])/F[i])+1)*F[i] + S[i] + C[i], i + 1
		}
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

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


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

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

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}


////////////////////////////////////////////////////////////////////

int main(){
ll n;
cin>>n;
ll ans=n*(n-1)/2;
cout<<ans<<endl;
return 0;




}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll k;
	cin >> k;

	
	ll n = 50;
	cout << n << endl;

	ll a = k / n - k % n + n - 1;
	// 最終的に数列のすべての項がn-1となる
	rep(i,n) cout << (i < k % n ? a + n + 1 :  a) << " "; 
	cout << endl;
}

Measured memory_bytes: 256
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    # 負の閉路を持つ場合は'NEGATIVE CYCLE'を、そうでない場合には(i,j)成分に
    # 頂点iから頂点jへの最短経路の距離を格納するdist_listをprintする関数
    def warshall_floyd(v_num, dist_lst):
        # 負の閉路を持つか
        negative_cycle_flag = False
    
        # 頂点iから頂点jへの経路と、頂点kを経由した場合の経路とを比較して
        # よりコストの合計が小さい方を配列に入れる動的計画法
        for k in range(v_num):
            for i in range(v_num):
                for j in range(v_num):
                    # i→k→jがつながっててしかもi→jルートよりもイケてるなら更新
                    if dist_lst[i][k] != INF and dist_lst[k][j] != INF:
                        if dist_lst[i][j] > dist_lst[i][k] + dist_lst[k][j]:
                            dist_lst[i][j] = dist_lst[i][k] + dist_lst[k][j]
    
        for v in range(v_num):
            # dist_lstに負の数が格納されているとは、
            # グラフが負の閉路を持つことを意味する
            if dist_lst[v][v] < 0:
                negative_cycle_flag = True
    
        return dist_lst
    
    
    # 頂点の数と辺の数

    v_num, e_num ,R= map(int, input().split())
    r=list(map(int,input().split()))
    
    # 配列dist_lst[a][b]には頂点a,b間の辺のコストを入れておき、
    # a=bの時は0を、a,b間の辺が存在しないときはINFを入れておく。
    INF = 10 ** 20
    dist_lst = [[INF] * v_num for _ in range(v_num)]
    
    for _ in range(e_num):
        s, t, dist = map(int, input().split())
        dist_lst[s-1][t-1] = dist
        dist_lst[t-1][s-1] = dist

    
    for v in range(v_num):
        dist_lst[v][v] = 0
    
    ll=warshall_floyd(v_num, dist_lst)
    minans=10**10
    for i in permutations(r):
        ans=0
        for j in range(len(i)-1):
            if ll[i[j]-1][i[j+1]-1]==INF or ll[i[j]-1][i[j+1]-1]==0:
                break
            else:
                ans+=ll[i[j]-1][i[j+1]-1]
        minans=min(minans,ans)
    print(minans)


    
      
    
resolve()

Measured memory_bytes: 74064
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD =1e9 + 7;

ll rep_power_modM(ll a, ll n, ll M = MOD){
	if(n == 0)return 1;
	if(n%2 == 0){ll tmp = rep_power_modM(a,n/2,M); return tmp*tmp%M;}
	return a*rep_power_modM(a,n-1,M)%M;
}

ll inv(ll t){
	return rep_power_modM(t, MOD-2);
}

map<ll, ll> prime_factor(ll n){
    map<ll,ll> com;
    for(ll i = 2LL; i*i<=n; ++i){
        while(n%i==0LL){
            com[i]++;
            n /= i;
        }
    }
    if(n != 1LL)com[n]++;
    return com;
}

int main(){
	int N;
	cin >> N;
	vector<ll> A(N);
	map<ll, ll> lcms;
	rep(i,N){
		cin >> A[i];
		map<ll, ll> k = prime_factor(A[i]);
		for(auto x:k){
			lcms[x.first] = max(lcms[x.first], x.second);
		}
	}
	ll lcm = 1;
	for(auto x:lcms){
		lcm *= rep_power_modM(x.first, x.second);
		lcm %= MOD;
	}
	ll ans = 0;
	rep(i,N){
		ll t = lcm * inv(A[i]) % MOD;
		ans += t;
		ans %= MOD;
	}
	if(ans < 0)ans += MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4132
#include <iostream>

using namespace std;

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

  for (int i = 1; i <= n; ++i) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
      continue;
    } else {
      while (x) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x /= 10;
      }
    }
  }

  cout << endl;
}


Measured memory_bytes: 3080
dice = tuple(map(int,input().split()))

def rot(dice,rotation):
    if rotation == "E":
        dice = (dice[3],dice[1],dice[0],dice[5],dice[4],dice[2])
    elif rotation == "W":
        dice = (dice[2],dice[1],dice[5],dice[0],dice[4],dice[3])
    elif rotation == "N":
        dice = (dice[1],dice[5],dice[2],dice[3],dice[0],dice[4])
    elif rotation == "S":
        dice = (dice[4],dice[0],dice[2],dice[3],dice[5],dice[1])
    return dice

def make_all_pattern(dice):
    pattern = {dice}
    pattern2 = pattern
    while True:
        pattern2 = pattern.union({rot(d,r) for d in pattern for r in list("NEWS")})
        if pattern2 == pattern:
            break
        pattern = pattern2
    return pattern

dice2 = tuple(map(int,input().split()))

if dice2 in make_all_pattern(dice):
    print("Yes")
else:
    print("No")

    

Measured memory_bytes: 7716