akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main() {
  
    string a,b ;
    cin>>a>>b ;
    
    if(a.size()<b.size()){
        cout << "LESS" << endl ;
        return 0 ;
    } 
    else if(a.size()>b.size()){
        cout << "GREATER" <<endl;
        return 0 ;
    } 
    else{
        for (int i = 0; i < a.size(); i++)
        {
            if(a[i]>b[i]){
                cout << "GREATER" << endl ;
                return 0 ;
            } 
            else if(a[i]<b[i]){
            cout << "LESS" << endl ;
            return 0 ;
            } 
        }
    } 
    
    cout << "EQUAL" << endl ;

return 0 ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int maxn = 200200;
const int mod = 998244353;
typedef long long ll;
inline ll pow(ll a,int b,ll ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1) ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
inline void reduce(int & x){ x += x >> 31 & mod; }
inline void link(int x,int y) {
	std::cout << x << ' ' << y << '\n';
}
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
int n;
int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	if(n & n - 1) {
		std::cout << "Yes" << '\n';
		link(1, n + 2);
		link(n + 2, 3);
		link(3, n + 1);
		link(n + 1,2);
		link(2,n + 3);
		for(int i = 4;i < n;i += 2) {
			link(n + 1, i), link(i, n + i + 1);
			link(n + 1,i + 1), link(i + 1,n + i);
		}
		if(n % 2 == 0) {
			int t = 1 << __builtin_ctz(n);
			link(n, t), link(n + n,n ^ t ^ 1);
		}
	} else {
		puts("No");
	}
}


Measured memory_bytes: 2816
#include <algorithm>
#include <iostream>
using namespace std;
static const int MAX = 100000;

struct Card {
  char suit;
  int value;
  bool operator<=(const Card &right) const { return value <= right.value; }
};

Card sentinel = Card{1, 1000000000};

int merge(Card A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  Card L[n1 + 1], R[n2 + 1];
  for (int i = 0; i < n1; i++)
    L[i] = A[left + i];
  for (int i = 0; i < n2; i++)
    R[i] = A[mid + i];
  L[n1] = sentinel;
  R[n2] = sentinel;

  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

int mergeSort(Card A[], int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(Card A[], int p, int r) {
  // A[p ... q-1] [q] [q+1 ... r]
  Card x = A[r];
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j] <= x) {
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i + 1], A[r]);
  return i + 1;
}

int quicksort(Card A[], int p, int r) {
  if (p < r) {
    int q = partition(A, p, r);
    quicksort(A, p, q - 1);
    quicksort(A, q + 1, r);
  }
}

int main() {
  Card data[MAX];
  Card data2[MAX];
  int n;
  char suit;
  int value;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> suit >> value;
    data[i].suit = data2[i].suit = suit;
    data[i].value = data2[i].value = value;
  }
  quicksort(data, 0, n - 1);
  mergeSort(data2, 0, n);

  bool isStable = true;
  for (int i = 0; i < n; i++) {
    if (data[i].suit != data2[i].suit) {
      isStable = false;
      break;
    }
  }
  cout << (isStable ? "Stable" : "Not stable") << endl;

  for (int i = 0; i < n; i++) {
    cout << data[i].suit << " " << data[i].value << endl;
  }
}

Measured memory_bytes: 5436
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys

hw = []
h,w = map(int, input().split())
while h+w > 0:
  hw.append([h,w])
  h,w = map(int, input().split())

for i in range(len(hw)):
  for h in range(hw[i][0]):
    for w in range(hw[i][1]):
      if (h+w) % 2 == 0:
        print("#", end="")
      else:
        print(".", end="")
    print()
  print()  


Measured memory_bytes: 7016
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
ll s1[1005][1005];
string s[1005];
ll h,w;
std::vector<ll> v[1000004];
ll dep[1000002];
ll vis[1000002];
void dfs(ll l,ll r,ll zz)
{
    s1[l][r]=zz;
    s[l][r]='1';
    if(l-1>=0 && s[l-1][r]=='.')
    {
        dfs(l-1,r,zz);
    }
    if(l+1<h && s[l+1][r]=='.')
    {
        dfs(l+1,r,zz);
    }
    if(r-1>=0 && s[l][r-1]=='.')
    {
        dfs(l,r-1,zz);
    }
    if(r+1<w && s[l][r+1]=='.')
    {
        dfs(l,r+1,zz);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>h>>w;
    ll ch,dh,cw,dw;
    cin>>ch>>cw>>dh>>dw;
    for (int i = 0; i < h; ++i)
    {
        cin>>s[i];
    }
    for (int i = 0; i < 1002; ++i)
    {
        for (int j = 0; j < 1002; ++j)
        {
            s1[i][j]=-1;
        }
    }
    ll co=0;
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            if(s[i][j]=='.')
            {
                dfs(i,j,co);
                co++;
            }
        }
    }
    set<pair<ll,ll>> ss;
    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            if(s[i][j]=='#')
                continue;
            for(int k=max(i-2,0);k<min((ll)(i+3),h);k++)
            {
                for(int l=max(j-2,0);l<min((ll)(j+3),w);l++)
                {
                    if(s1[k][l]!=-1 && s1[i][j]!=s1[k][l])
                    {
                        ll x1=s1[i][j];
                        ll x2=s1[k][l];
                        ss.insert(mp(min(x1,x2),max(x1,x2)));
                    }
                }
            }
        }
    }
    ll so=s1[ch-1][cw-1];
    ll de=s1[dh-1][dw-1];
   
    for(auto i:ss)
    {
        // cout<<i.first<<" "<<i.second<<'\n';
        v[i.first].pb(i.second);
        v[i.second].pb(i.first);
    }
    queue<ll> qq;
    qq.push(so);
   
    for (int i = 0; i <=1000001; ++i)
    {
        dep[i]=1e9;
        vis[i]=0;
    }
    dep[so]=0;
    vis[so]=1;
    while(!qq.empty())
    {
        ll x=qq.front();
        qq.pop();
        for (auto i:v[x])
        {
            if(vis[i]==0)
            {
                dep[i]=dep[x]+1;
                qq.push(i);
                vis[i]=1;
            }
        }
    }
    if(dep[de]==1e9)
    {
        cout<<"-1"<<'\n';
    }
    else
    {
        cout<<dep[de]<<'\n';
    }
}


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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

ll n;
ll a[17][17];
ll dp[1<<17];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;

    rep(i,n)
    {
        rep(j,n)
        {
            cin >> a[i][j];
        }
    }

    rep(mask,1<<n)
    {
        fr(j,0,n-2)
        {
            fr(k,j+1,n-1)
            {
                if(mask&(1<<j) && (mask&(1<<k)))
                {
                    dp[mask] = dp[mask] + a[j][k];
                }
            }
        }
        dp[mask] = max((ll)0, dp[mask]);
    }

    rep(mask,1<<n)
    {
        for(ll mask2 = mask; mask2!=0; mask2 = (mask2-1)&(mask))
        {
            dp[mask] = max(dp[mask], dp[mask2] + dp[mask-mask2]);
        }
    }

    cout << dp[(1<<n)-1] << endl;
}


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

int main(){
    int n;
    cin >> n;
    int t[110000],x[110000],y[110000];
    t[0] = x[0] = y[0] = 0;
    for(int i = 1;i <= n;i++) cin >> t[i] >> x[i] >> y[i];

    bool can = true;
    for (int i = 1;i <= n;i++){
        int dt = t[i] - t [i-1];
        int dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        if (dt <dist) can =false;
        if (dist % 2 != dt % 2) can = false;
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;


int main(){
    int n, a, b;
    cin >> n >> a >> b;

    cout << min(b, n * a) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = (int) Math.pow(2,n);
    int max = 0;
    ArrayList<ArrayList<Integer>> a = new ArrayList<ArrayList<Integer>>();
    for (int i=0;i<n;i++){
      int g = scan.nextInt();
      ArrayList<Integer> b = new ArrayList<Integer>();
      for (int k = 0;k<g;k++){
        int c = scan.nextInt();
        int d = scan.nextInt();
        if (d == 0){
          c = -c;
        }
        b.add(c);
      }
      a.add(b);
    }

    for (int j=0;j<m;j++){
      int[] dd = find(j,n);
      int l = check(dd,a);
      if (l>max){
        max = l;
      }
    }


    System.out.println(max);
  }

  static int[] find(int a, int b){
    int[] g = new int[b];
    int f = 0;
    while (a > 0){
      int t = a%2;
      g[f] = t;
      a -= t;
      a = (int) a/2;
      f++;
    }
    return g;
  }

  static int check(int[] a, ArrayList<ArrayList<Integer>> h){
    int sum = 0;
    int n = a.length;
    boolean [] b = new boolean[n];
    for (int i=0;i<n;i++){
      b[i] = false;
      if (a[i] == 1){
        sum += 1;
        b[i] = true;
      }
    }

    for (int j=0;j<n;j++){
      if (a[j] == 0){
        continue;
      }
      ArrayList<Integer> t = h.get(j);
      for (int k=0;k<t.size();k++){
        int p = t.get(k);
        if (p<0){
          int ff = -p;
          ff -= 1;
          if (b[ff] == true){
            return 0;
          }
        }
        else{
          p -= 1;
          if (b[p] == false){
            return 0;
          }
        }
      }
    }
    return sum;
  }
}


Measured memory_bytes: 41412
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin >> a[i];
  sort(a.rbegin(), a.rend());

  int x = 0, y = 0;
  for(;;){
    int nx = x + 1, ny = y + 1;
    if(nx >= N || ny >= a[nx]){
      break;
    }
    ++x, ++y;
  }
  int tx = x;
  for(;;){
    int nx = tx + 1, ny = y;
    if(nx >= N || ny >= a[nx]){
      break;
    }
    ++tx;
  }
  int ty = a[x] - 1;
  bool res = (tx - x) % 2 == 0 && (ty - y) % 2 == 0;
  cout << (res ? "Second" : "First") << endl;
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  
  int ans = 0;
  for(int i = 0; i < 4; i ++){
    if(s.at(i) == '+') ans++;
    else ans--;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long

int32_t main()
{
    rapido;
  int n;cin>>n;
  vector<int>arr(n);
  map<int,int>mp;
  int sum=0;
  for(int i=0;i<n;i++)
  {
      cin>>arr[i];
      mp[arr[i]]++;
      sum+=arr[i];
  }
  int q;cin>>q;
  while(q--)
  {
      int b;int c;cin>>b>>c;
      sum=sum-(b*mp[b])+(c*mp[b]);
      mp[c]+=mp[b];mp[b]=0;
      cout<<sum<<endl;
  }
    
  
}


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

long long int ary[150][21]={};
int inp[150];

int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>inp[i];
	}
	ary[0][inp[0]]=1;
	for(int mjk=1;mjk<N-1;mjk++){
		for(int i=0;i<=(20-inp[mjk]);i++){
			ary[mjk][i+inp[mjk]]+=ary[mjk-1][i];
		}
		for(int i=20;i>=inp[mjk];i--){
			ary[mjk][i-inp[mjk]]+=ary[mjk-1][i];
		}
	}
	cout<<ary[N-2][inp[N-1]]<<endl;
	return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
lli x, arr[2050];
const lli mod = 1e9 + 7;
int main()
{
	cin >> x;
	if(x < 3)
	{
		cout << 0 << '\n';
		return 0;
	}
	lli dp[x + 50] = {0};
	dp[3] = 1;
	for(int i=4; i <= x; i++)
	{
		for(int j=3; j <= i - j && j + 3 <= i; j ++)
		{
			if(j != i - j) dp[i] = (dp[i] + dp[j] + dp[i - j]) % mod;
			else		   dp[i] = (dp[i] + dp[j]) % mod;
		}
		dp[i] = (dp[i] + 1) % mod;
	}
	cout << dp[x] << '\n';
	return 0;
}

Measured memory_bytes: 3624
// atcoder/cf16-final/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int n;
  while (cin >> n) {
    lli i;
    for (i = 1; i * (i + 1) / 2 < n; i++) ;
    vec<int> v;
    for (int j = i; 0 <= j && n; --j) {
      if (j <= n) {
        v.push_back(j);
        n -= j;
      }
    }
    sort(v.begin(), v.end());
    each (i, v) cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};






int main() {

    int a, b, c;
    cin >> a >> b >> c;

    if (a <= c && c <= a + b) cout << "YES" << endl;
    else cout << "NO" << endl;


    return 0;
}






Measured memory_bytes: 256
// E - Sequence Sum
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	long long n, x, m, c = 0, l = 0;
	cin >> n >> x >> m;
	long long ans = 0;
	map<long long, int> s;
	for (c = 0; c < n; c++) {
		if (s.count(x) > 0) {
			l = c - s[x];
			break;
		}
		ans += x;
		s[x] = c;
		x = (x * x) % m;
	}

	long long z = 0;
	for (long long t = x, i = 0; i < l; i++, t = (t * t) % m) z += t;

	if (l > 0) {
		ans += (n - c) / l * z;
		for (long long i = 0, t = x; i < (n - c) % l; i++, t = (t * t) % m)
			ans += t;
	}

	cout << ans << endl;

	return 0;
}


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

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

	long long ans = 0;
	int MaxNum = 0;
	for (int i = 0; i < N-1; i++)
	{
      if(A[i]>=A[i+1]){
		ans += A[i]-A[i+1];
        A[i+1]=A[i];
      }
	}

	cout << ans << endl;
}




Measured memory_bytes: 4008
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;

int main(){
    int d[26];
    REP(i,26)d[i]=10000000;
    CASET{
        string s;
        int a[26]={};
        cin>>s;
        REP(i,SZ(s))a[s[i]-'a']++;
        REP(i,26)d[i]=min(d[i],a[i]);
    }
    REP(i,26){
        REP(j,d[i])putchar('a'+i);
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
#define MAXN 200000+5

typedef long long ll;

const int INF=0x7fffffff;

using namespace std;

int a[MAXN];
int sit[MAXN];
struct NUM{
	int number,time;
}; 

vector<NUM> c;
bool cmp(NUM N,NUM M){
	return N.time>M.time;//出现次数的的拍在前面 
}
int main() {
	int n,k,num=0;
	scanf("%d %d",&n,&k); 
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(a[x]==0){//来了一个新的数 
			//记录开始的位置 
			sit[x]=num;
			num++;
			//插入新元素 
			NUM k;
			k.number=x;
			k.time=1;
			c.push_back(k);
		}
		else {
			c[sit[x]].time++;
		}
		a[x]++;
	}
	if(n<=k){
		printf("0");
		return 0;
	} 
	sort(c.begin(),c.end(),cmp); 
	int ans=0;
	for(int i=0;i<k&&i<num;i++){
		ans+=c[i].time;
	}
	printf("%d",n-ans);
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> as(N);
  int sum = 0;
  rep(i, N) {
    cin >> as[i];
    sum += as[i];
  };
  double a = (double)sum / 4.0 / (double)M;
  int count = 0;
  rep(i, N) {
    if (a <= as[i]) {
      count++;
    }
  }
  if (M <= count) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    char str[6];
    int flag;
    while(~scanf("%s",str)){
        flag=1;
        for(int i=0;i<=5;i++){
            if(str[i]<'a'||str[i]>'z'){
                break;
                flag=0;
            }
        }
        if(flag=0){
            printf("No\n");
            break;
        }
        if(str[2]!=str[3]||str[4]!=str[5]){
            printf("No\n");
        }
        else
            printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 256
s = input()
a = [c for c in s]

if a[0]=='1':
        a[0] = '9'
else:
        a[0] = '1'

if a[1]=='1':
        a[1] = '9'
else:
        a[1] = '1'

if a[2]=='1':
        a[2] = '9'
else:
        a[2] = '1'

print(int(a[0]+a[1]+a[2]))


Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-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; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  int ans = 0;
  string str = "ATCG";
  for(int i=0; i<S.size(); i++){
    int cnt = 0;
    for(int j=i; j<S.size(); j++){
      bool ok = false;
      for(int k=0; k<4; k++){
        if(str[k] == S[j]) ok = true;
      }
      if(ok){
        cnt++;
      }else{
        break;
      }
    }
    chmax(ans,cnt);
  }
  cout << ans << "\n";
  return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

struct edge { int to,cost; };
const int MOD=1e9+7;

ll N,M,R;
vector<vector<ll>> d;

void warshall_floyd() {
  REP(k,N)REP(i,N)REP(j,N) {
    d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
  }
}

int main() {
  // それぞれのポイント
  // ワーシャルフロイトで全ての点から点の最短距離を計算
  // 次に順列でどの順番が一番短いか
  cin>>N>>M>>R;
  vector<int> rs(R);
  REP(i,R) cin>>rs[i];

  d.resize(N,vector<ll>(N,LLONG_MAX/4));
  REP(i,N) d[i][i] = 0;
  REP(i,M) {
    int A,B,C;cin>>A>>B>>C;
    A--;B--;
    d[A][B]=d[B][A]=C;
  }
  warshall_floyd();

  sort(ALL(rs));
  ll ans = LLONG_MAX/4;
  do {
    ll tmp = 0;
    FOR(i,1,R) {
      tmp += d[rs[i]-1][rs[i-1]-1];
    }
    ans = min(ans,tmp);
  } while (next_permutation(ALL(rs)));

  OUT(ans);

  return 0;
}

Measured memory_bytes: 512
package main

import "fmt"

var buf float64

func main() {
	var N int
	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		buf += float64(1) / float64(a)
	}
	fmt.Println(1 / buf)
}


Measured memory_bytes: 512
use self::dsu::Dsu;
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(Usize1, Usize1); m],
    };
    let mut dsu = Dsu::new(n);
    for &(a_i, b_i) in ab.iter() {
        dsu.merge(a_i, b_i);
    }
    let ans = dsu.groups().len() - 1;
    println!("{}", ans);
}

// https://raw.githubusercontent.com/rust-lang-ja/ac-library-rs/ad148b05b07e3ac59cbc2987b8834742ef3d497a/src/dsu.rs
pub mod dsu {
    /// Implement (union by size) + (path compression)
    /// Reference:
    /// Zvi Galil and Giuseppe F. Italiano,
    /// Data structures and algorithms for disjoint set union problems
    pub struct Dsu {
        n: usize,
        // root node: -1 * component size
        // otherwise: parent
        parent_or_size: Vec<i32>,
    }

    impl Dsu {
        // 0 <= size <= 10^8 is constrained.
        pub fn new(size: usize) -> Self {
            Self {
                n: size,
                parent_or_size: vec![-1; size],
            }
        }
        pub fn merge(&mut self, a: usize, b: usize) -> usize {
            assert!(a < self.n);
            assert!(b < self.n);
            let (mut x, mut y) = (self.leader(a), self.leader(b));
            if x == y {
                return x;
            }
            if -self.parent_or_size[x] < -self.parent_or_size[y] {
                std::mem::swap(&mut x, &mut y);
            }
            self.parent_or_size[x] += self.parent_or_size[y];
            self.parent_or_size[y] = x as i32;
            x
        }

        pub fn same(&mut self, a: usize, b: usize) -> bool {
            assert!(a < self.n);
            assert!(b < self.n);
            self.leader(a) == self.leader(b)
        }
        pub fn leader(&mut self, a: usize) -> usize {
            assert!(a < self.n);
            if self.parent_or_size[a] < 0 {
                return a;
            }
            self.parent_or_size[a] = self.leader(self.parent_or_size[a] as usize) as i32;
            self.parent_or_size[a] as usize
        }
        pub fn size(&mut self, a: usize) -> usize {
            assert!(a < self.n);
            let x = self.leader(a);
            -self.parent_or_size[x] as usize
        }
        pub fn groups(&mut self) -> Vec<Vec<usize>> {
            let mut leader_buf = vec![0; self.n];
            let mut group_size = vec![0; self.n];
            for i in 0..self.n {
                leader_buf[i] = self.leader(i);
                group_size[leader_buf[i]] += 1;
            }
            let mut result = vec![Vec::new(); self.n];
            for i in 0..self.n {
                result[i].reserve(group_size[i]);
            }
            for i in 0..self.n {
                result[leader_buf[i]].push(i);
            }
            result
                .into_iter()
                .filter(|x| !x.is_empty())
                .collect::<Vec<Vec<usize>>>()
        }
    }
}


Measured memory_bytes: 10544
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        // 2つの文字の固まりを整数値と想定して読み込む
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a == b) {
            System.out.println("a == b");
        } else if (a > b) {
            System.out.println("a > b");
        }

    }
}


Measured memory_bytes: 26332
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll p=1000000007;
  int n;
  cin >> n;
  ll o=0;
  ll b=0;
  rep(i,n){
    ll a;
    cin >> a;
    o=(o+a*a)%p;
    b=(b+a)%p;
  }
  b=(b*b+p-o)%p;
  if(b%2==0){
    cout << b/2 << endl;
  }
  else cout << (b+p)/2 << endl; 
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int i,ans=0;
  string n;
  
  cin >> n;
  
  for (i=0;i<4;i++){
    if (n[i]=='2') ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        double num = Double.parseDouble(str);
        double area;
        double lap;
        
        area = num *  num * Math.PI;
        lap = num * 2.0 * Math.PI;
        
        String s = String.format("%.6f",area);
        String t = String.format("%.6f",lap);
        System.out.println(s + " " + t);


    }

  
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
  
}



Measured memory_bytes: 26608
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
    int dif1 = x2-x1;
    int dif2 = y2-y1;
    int x3 = x2-dif2;
    int y3 = y2+dif1;
    //cout<<y3<<endl;
    //cout<<x3<<endl;
    int x4 = x3-dif1;
    int y4 = y3-dif2;
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<"\n";
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    lint N, A, B;
    cin >> N >> A >> B;
    lint ans = N / (A + B) * A;
    N %= A + B;
    cout << ans + min(N, A) << endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<map>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

map<int, int> va, vb;

signed main() {
    int N;
    cin >> N;
    rep(i, N) {
        int v;
        cin >> v;
        if (i % 2)va[v]++;
        else vb[v]++;
    }
    pii fia = pii(0, 0), sea = pii(0, 0);
    for (auto x:va) {
        int key = x.first, value = x.second;
        if (pii(value, key) > fia) {
            sea = fia;
            fia = pii(value, key);
        } else if (pii(value, key) > sea) {
            sea = pii(value, key);
        }
    }
    pii fib = pii(0, 0), seb = pii(0, 0);
    for (auto x:vb) {
        int key = x.first, value = x.second;
        if (pii(value, key) > fib) {
            seb = fib;
            fib = pii(value, key);
        } else if (pii(value, key) > seb) {
            seb = pii(value, key);
        }
    }
    if (fia.second != fib.second) {
        cout << N - fia.first - fib.first << endl;
    } else {
        int ans = min(N - fia.first - seb.first, N - sea.first - fib.first);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
    double a,b,c,d,e,f;
    double x, y;
    while (cin>>a>>b>>c>>d>>e>>f) {
        x = (c-(f-(d/a)*c)/(e-(d/a)*b)*b)/a;
        y = (f-(d/a)*c)/(e-(d/a)*b);
        cout << fixed << setprecision(3) << x << " " << y << endl;
    }
}

Measured memory_bytes: 1284
// atcoder/abc164/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int a, b, c, d;
  while (cin >> a >> b >> c >> d) {
    while (true) {
      c -= b;
      unless (0 < a && 0 < c) break;
      a -= d;
      unless (0 < a && 0 < c) break;
    }
    if (0 < a) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3596
<?php
fscanf(STDIN, "%d", $N);
 
$a = [0, 1, 2, 2, 3, 3, 3,  4,  5,  5,  5,  6,  6,  7,  8];
$b = [0, 1, 3, 3, 7, 7, 7, 14, 22, 22, 22, 33, 33, 46, 60];
 
$h = intdiv($N, 15);
$m = $N % 15;

printf("%d", $h * ($h * 60 + $a[$m] * 15) + $b[$m]);

Measured memory_bytes: 16156
S = input()

keyence = "keyence"

isKey = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            isKey = True
            break
    if isKey:
        break

if isKey:
    print("YES")
else:
    print("NO")



Measured memory_bytes: 2940
//*-- ILSH --*//
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define viii vector < vii >
#define vlll vector < vll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=200000+6;
const ll inf=1e17;
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
void solve() {
	int n,k;
	cin>>n>>k;
	int arr[n];
	for (int i=0;i<n;i++)
		cin>>arr[i];
	ll brr[n];
	brr[0]=0;
	for ( int i=1;i<n;i++)
		brr[i]=inf;
	for ( int i=1;i<n;i++)
		for ( int j=i-1;j>=0&&j>=i-k;j--)
			brr[i]=std::min(brr[i],brr[j]+abs(arr[i]-arr[j]));
	cout<<brr[n-1]<<'\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    int t=1;
    // cin>>t;
    while ( t-- )
    	solve();    
}

Measured memory_bytes: 1408
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

long[] calc(int x) {
    long p = 1;
    long[] Ret;
    for (int i = 0; i < x; i++) {
        Ret ~= p;
        p *= 10;
    }
    return Ret;
}
static P10 = calc(11);

int N;

long at(long x, long i) {
    return x % P10[i + 1] / P10[i];
}

long reverse(long x, size_t from, size_t to) {
    //long len = countUntil!((a) => x < a)(P10);
    //writeln([x, len, from, to]);
    long len = N;
    long y = (x % P10[len - from] / P10[len - to]);
    long z = 0;
    foreach (i; 0 .. (to - from)) {
        z += (y % P10[i + 1] / P10[i]) * P10[to - from - i - 1];
    }
    static if (false) {
        writeln("a: ", x / P10[len - from] * P10[len - from]);
        writeln("b: ", z * P10[len - to]);
        writeln("c: ", x / P10[len - to]);
    }
    return x / P10[len - from] * P10[len - from] + z * P10[len - to] + x % P10[len - to];
}

void main() {
    scanf("%d\n", &N);
    string A = cast(string)(readln.chomp.split(" ").map!((x) => cast(char)(x.to!int - 1 + '0')).array);

    bool[long] step(in bool[long] x) {
        bool[long] Ret;
        foreach (k; x.keys) {
            foreach (i; 0 .. N) {
                foreach (j; i + 2 .. N + 1) {
                    long s = reverse(k, i, j);
                    Ret[s] = true;
                }
            }
        }
        return Ret;
    }

    long x1 = A.to!long;
    long y1 = (iota(0, N, 1).map!((c) => cast(char)(c + '0')).array).to!long;

    //writeln([x1, y1]);

    bool[long] a = [x1: true],
               b = [y1: true];

    bool check() {
        if (a.length > b.length) {
            foreach (k, v; b) {
                if (k in a) return true;
            }
        } else {
            foreach (k, v; a) {
                if (k in b) return true;
            }
        }
        return false;
    }

    for (int i = 0; i < 4; i++) {
        if (check) {
            writeln(i * 2);
            return;
        }
        a = step(a);
        if (check) {
            writeln(i * 2 + 1);
            return;
        }
        b = step(b);
    }
    writeln(9);

    //writeln([a.length, b.length]);

}

Measured memory_bytes: 39832
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#define INF (1<<30)
#define COST 0
#define TIME 1

using namespace std;

typedef pair<int, int> p;

vector<p> costs[105], times[105];
int dist[105];
void dijkstra(vector<p> *edge, int s){
	fill(dist, dist + 105, INF);
	dist[s] = 0;
	priority_queue<p, vector<p>, greater<p> > q;
	q.push(p(0, s));
	while(!q.empty()){
		p tmp = q.top();q.pop();
		int d = tmp.first, from = tmp.second;
		if(dist[from] < d)continue;		
		for(int i = 0; i < edge[from].size(); i++){
			int to = edge[from][i].first, c = edge[from][i].second;
			if(dist[to] < dist[from] + c)continue;
			dist[to] = dist[from] + c;
			q.push(p(dist[to], to));
		}
	}
}

int main(){
	while(true){
		int n, m;
		cin >> n >> m;
		if(!n && !m)
			break;
		for(int i = 0; i < 105; i++){
			costs[i].clear();
			times[i].clear();
		}
		for(int i = 0; i < n; i++){
			int a, b, c, t;
			cin >> a >> b >> c >> t;
			costs[a].push_back(p(b, c));
			costs[b].push_back(p(a, c));
			times[a].push_back(p(b, t));
			times[b].push_back(p(a, t));
		}
		int k;
		cin >> k;
		for(int i = 0; i < k; i++){
			int p, q, r;
			cin >> p >> q >> r;
			if(r == COST){
				dijkstra(costs, p);
			}else{
				dijkstra(times, p);
			}
			cout << dist[q] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1320
import sys

sys.setrecursionlimit(1000000)

import itertools


def d(p1, p2):
    return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])


def dx(p1, p2):
    return abs(p1[0] + p2[0]) // 2


def dy(p1, p2):
    return abs(p1[0] - p2[0]) // 2


def slow_solve(N, XYs):
    ans = 0
    for points in itertools.combinations(XYs, 2):
        ans = max(ans, d(points[0], points[1]))
    return ans


def solve(N, XYs):
    def transrate(XYs):
        return [(A[0] - A[1], A[0] + A[1]) for A in XYs]

    XYs = transrate(XYs)

    # x_max = max(XYs, key=lambda x: x[0])
    # x_min = min(XYs, key=lambda x: x[0])
    # tans = d(x_min, x_max)
    #
    # y_max = max(XYs, key=lambda x: x[1])
    # y_min = min(XYs, key=lambda x: x[1])
    # tans2 = d(y_min, y_max)

    def candidates():
        return [
            # max(XYs, key=lambda x: (x[0], x[1])),
            # max(XYs, key=lambda x: (x[0], -x[1])),
            # max(XYs, key=lambda x: (x[1], x[0])),
            # max(XYs, key=lambda x: (x[1], -x[0])),
            # max(XYs, key=lambda x: (-x[0], x[1])),
            # max(XYs, key=lambda x: (-x[0], -x[1])),
            # max(XYs, key=lambda x: (-x[1], x[0])),
            # max(XYs, key=lambda x: (-x[1], -x[0])),
            max(XYs, key=lambda x: x[0]),
            min(XYs, key=lambda x: x[0]),
            max(XYs, key=lambda x: x[1]),
            min(XYs, key=lambda x: x[1]),
        ]

    XYs.sort(key=lambda p: p[0], reverse=True)
    xmax = XYs[0][0] - XYs[-1][0]
    XYs.sort(key=lambda p: p[1], reverse=True)
    ymax = XYs[0][1] - XYs[-1][1]
    return max(xmax, ymax)
#
#
# assert (solve(4, [(5, 6), (6, 1), (6, 5), (4, 3)]) == 6)
#
# import random
#
#
# def create_rand(N):
#     X = 6
#     return [(random.randint(1, X), random.randint(1, X)) for _ in range(N)]
#
#
# N = 4
# for case in range(10000):
#     points = create_rand(N)
#     actual = solve(N, points)
#     expected = slow_solve(N, points)
#     if actual != expected:
#         print("NG!!!")
#         print(N)
#         print(points)
#         print(f"actual : {actual}")
#         print(f"expected : {expected}")
#         exit(0)
# print("OK")

if __name__ == "__main__":
    N = int(input())
    XYs = [tuple(map(int, input().split(" "))) for _ in range(N)]

    print(solve(N, XYs))


Measured memory_bytes: 65936
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,n,a) for (int i = n - 1; i >= a; i--)
using namespace std;

int N;
int A[50];
int h;
int main(void) {
    cin >> N;
    rep(n, 0, N) {
        cin >> A[n];
        if (abs(A[n]) > abs(A[h])) h = n;
    }
    cout << 2 * N - 1 << endl;
    rep(i, 0, N) {
        cout << h + 1 << " " << i + 1 << endl;
    }
    if (A[h] > 0) {
        rep(i, 0, N - 1) {
            cout << i + 1 << " " << i + 2 << endl;
        }
    } else {
        for (int i = N; i > 1; i--) {
            cout << i << " " << i - 1 << endl;
        }
    }
}

Measured memory_bytes: 256
masu = [[0 for x in range(10)] for y in range(10)]

syou = [[-1,0], [0,-1], [0,0], [0,1], [1,0]]
tyuu = [[-1,-1], [-1,1], [1,-1], [1,1]] + syou
dai = [[-2,0], [0,-2], [0,2], [2,0]] + tyuu



def drop(x,y,s):
	if s == 1: l = syou
	elif s == 2: l = tyuu
	elif s == 3: l = dai

	for dx,dy in l:
		nx = x + dx
		ny = y + dy
		if nx in range(10) and ny in range(10):
			masu[ny][nx] += 1



while True:
	try:
		x,y,s = map(int, input().split(','))
		drop(x,y,s)
	except EOFError:
		break

max = cnt = 0
for y in range(10):
	for x in range(10):
		if masu[y][x] == 0: cnt += 1
		if max < masu[y][x]: max = masu[y][x]

print(cnt)
print(max)

Measured memory_bytes: 7652
n = int(input())
mod = 10 ** 9 + 7
A = list(map(int, input().split()))
A = [0] + A
ans = 0
sm = 0
for i, a in enumerate(A[1:]):
    sm += A[i]
    sm %= mod
    ans += a * sm
    ans %= mod
print(ans)

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

#define ll long long
int main()
{
    int N, A[101][101], ans = 0, sum = 0;
    cin >> N;

    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < N; i++)
    {
        sum = 0;
        for (int j = 0; j <= i; j++)
        {
            sum += A[0][j];
        }

        for (int j = i; j < N; j++)
        {
            sum += A[1][j];
        }

        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

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

    int max_val = 0;
    repi(i, 1, n-1){
        string split_str[] = {inp.substr(0, i), inp.substr(i, n-i)};

        set<char> counts[2];
        rep(j, 2){
            rep(place, split_str[j].size()){
                counts[j].insert(split_str[j][place]);
            }
        }

        vector<char> seki;
        set_intersection(all(counts[0]), all(counts[1]), inserter(seki, seki.end()));
        max_val = max(max_val, (int)seki.size());
    }

    cout << max_val << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
	double r;
	const double pi = acos(-1);
	
	scanf("%lf", &r);
	
	double area = r * r * pi;
	double len = 2 * pi * r;

	printf("%lf %lf\n", area, len);

	return 0;
}

Measured memory_bytes: 2748