akhauriyash/Code-Regression huggingface dataset:
use proconio::input;
use std::collections::BinaryHeap;
use std::cmp::Reverse;

struct Node {
    edge: Vec<(usize, i64)>
}

struct Graph
{
    node: Vec<Node>,
}

impl Node {
    fn new() -> Self {
        Node {
            edge: Vec::new(),
        }
    }
}

impl Graph {
    fn new(n: usize) -> Self {
        Graph {
            node: (0..n).map(|_| Node::new()).collect::<Vec<Node>>(),
        }
    }

    fn add_edge(&mut self, a: usize, b: usize, dist: i64) {
        self.node[a].edge.push((b, dist));
        self.node[b].edge.push((a, dist));
    }

    fn dijkstra(&self, start: usize, goal: usize) -> i64 {
        let inf = 1i64 << 60;
        let mut cost = vec![inf; self.node.len()];
        cost[start] = 0;

        let mut q = BinaryHeap::new();
        q.push(Reverse((0, start)));

        while let Some(Reverse((cst, idx))) = q.pop() {
            if cost[idx] < cst {
                continue;
            }
            for &(nxt, dist) in self.node[idx].edge.iter() {
                let cst = dist + cst;
                if cost[nxt] <= cst {
                    continue;
                }
                cost[nxt] = cst;
                q.push(Reverse((cst, nxt)));
            }
        }

        cost[goal]
    }
}

fn main()
{
    input! {
    n:usize,
    v:[[i64;n];n],
    }

    let mut dist = Vec::new();
    for i in 0..n {
        for j in i + 1..n {
            dist.push((v[i][j], i, j));
        }
    }
    dist.sort();
    let mut graph = Graph::new(n);
    let mut ans = 0;
    for (d, a, b) in dist {
        let dist = graph.dijkstra(a, b);
        if dist < d {
            ans = -1;
            break;
        }

        if dist > d {
            graph.add_edge(a, b, d);
            ans += d;
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 5100
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::vector<std::string> s(n);
  for (int i = 0; i < n; ++i)
    std::cin >> s.at(i);

  std::map<std::string, int> m{};
  for (int i = 0; i < n; ++i) {
    m[s[i]]++;
  }

  std::vector<std::pair<std::string, int>> mv;
  for (auto it = m.begin(); it != m.end(); ++it)
    mv.push_back(*it);

  std::sort(mv.begin(), mv.end(), [](const auto &a, const auto &b) {
    if (a.second == b.second)
      return a.first < b.first;
    return a.second > b.second;
  });

  int count = -1;
  for (auto it : mv) {
    if (count == -1 || count == it.second) {
      std::cout << it.first << std::endl;
      count = it.second;
      continue;
    }
    break;
  }
}


Measured memory_bytes: 30576
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	text := stdin.Text()
	textSlice := strings.Split(text, " ")
	a, _ := strconv.Atoi(textSlice[0])
	b, _ := strconv.Atoi(textSlice[1])
	if b%a == 0 {
		fmt.Println(a + b)
	} else {
		fmt.Println(b - a)
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
using namespace std;
using ll = long long int;

int n;
vector<pair<string, int>> sp;

int main(void) {
	cin >> n;
	vector<int> ret;
	for (int i = 0; i < n; i++) {
		string s; int p;
		cin >> s >> p;
		sp.emplace_back(s, p);
		ret.push_back(i + 1);
	}

	pair<string, int> tmp;
	for (int i = 0; i < n; i++) {
		tmp = sp[i];
		int min = i;
		for (int j = i + 1; j < n; j++) {
			if (tmp.first > sp[j].first) {
				tmp = sp[j];
				min = j;
			}
			else if (tmp.first == sp[j].first) {
				if (tmp.second < sp[j].second) {
					tmp = sp[j];
					min = j;
				}
			}
		}
		swap(sp[i], sp[min]);
		swap(ret[i], ret[min]);
	}

	for (int i = 0; i < n; i++) {
		cout << ret[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(u == s) a--;
    if(u == t) b--;
    cout << a << " " << b << endl;
    return 0;
}


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

using namespace std;

int main(void)
{
    string input, input1;
    string res;
    cin >> input;
    cin >> input1;
    do
    {
        if (input.length() + 1 != input1.length())
        {
            res = "No";
            break;
        }
        bool is_match = true;
        for (int i = 0; i < input.length(); i++)
        {
            if (input[i] != input1[i])
            {
                is_match = false;
                break;
            }
        }
        if (!is_match)
        {
            res = "No";
        }
        else
        {
            res = "Yes";
        }

        break;
    } while (false);

    cout << res;
}

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

int main()
{
    int n , x , y , t , t1 , px=0, py=0,pt=0 , r;
    bool b=true;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t>>x>>y;
        t1=t;
        t=t-pt;
        r=fabs(y-py)+fabs(x-px);
        //cout<<r<<endl;
        if(r>t){
            b=false;
        }
        else if(r<t){
            if(r-t%2!=0){
                b=false;
            }
        }
        px=x;
        py=y;
        pt=t1;;

    }
    if(b){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

    return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

const string YES = "Yes";
const string NO  = "No";

string s;
bool ACDC[5000];

int main() {
  cin >> s;
  while( (int)s.size() > 3 ) {
    memset(ACDC,false,sizeof ACDC);
    REP(i,1,(int)s.size()-1) if( s[i] == 'B' ) {
      if( s[i-1] == 'A' && s[i+1] == 'C' ) {
	ACDC[i-1] = ACDC[i] = ACDC[i+1] = true;
	++i;
      }
    }
    set<char> next;
    rep(i,(int)s.size()) if( !ACDC[i] ) {
      next.insert(s[i]);
    }
    if( (int)next.size() != 2 ) { 
      cout << NO << endl;
      return 0;
    }
    string ns = "";

    bool found[3] = {false,false,false};
    for(set<char>::iterator itr=next.begin();itr!=next.end();++itr) {
      found[*itr-'A'] = true;
    }
    char replace_c = '$';
    rep(k,3) {
      if( !found[k] ) {
	replace_c = (char)('A'+k);
      }
    }

    rep(i,(int)s.size()) {
      if( !ACDC[i] ) {
	ns += s[i];
      } else {
	ns += string(1,replace_c);
	i += 2;
      }
    }
    s = ns;
    //cout << s << endl;
  }
  cout << ( ( s == "ABC" ) ? YES : NO ) << endl;
  return 0;

}

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef unsigned long long int lli;
typedef pair<int, int> pi;

int main()
{
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int N, M, Q, ans;
vector<vector<int>> q(51, vector<int>(4));

void dfs(vector<int> A){
    if(A.size() == N+1) {
        int s = 0;
        rep(i, 0, Q){
            int a = q[i][0], b = q[i][1], c = q[i][2], d = q[i][3];
            if(A[b]-A[a] == c) s += d;
        }
        chmax(ans, s);
        return;
    }

    A.push_back(A.back());
    while(A.back() <= M){
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> N >> M >> Q;
    rep(i, 0, Q) rep(j, 0, 4){
        cin >> q[i][j];
    }
    dfs(vector<int>(1, 1));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3160
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def ok(i,j):
        for ii in range(m):
            if aa[ii+i][j:j+m]!=bb[ii]:return False
        return True

    n,m=MI()
    aa=[[c=="#" for c in input()] for _ in range(n)]
    bb=[[c=="#" for c in input()] for _ in range(m)]
    for i in range(n-m+1):
        for j in range(n-m+1):
            if ok(i,j):
                print("Yes")
                exit()
    print("No")

main()

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;

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

    int b_real = b;
    int b_dig = 0;

    while(b_real > 0){
        b_real /= 10;
        b_dig += 1;
    }

    for(int i = 0; i < b_dig; i++)
    {
        a = a * 10;
    }

    int num = a + b;

    int s = sqrt(num);
    s = s * s;

    if (num == s) {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define m_p make_pair
#define pb push_back 
#define ppb pop_back
#define f first
#define s second
#define pii pair<int,int>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define double long double
const double pi=3.14159265358979;
int lim=1e12;
const   int  mod=1e9+7;
int foobar=0;
//freopen("filename","r", stdin);
int takemod(int a,int mod){return ((a%mod)+mod)%mod;}
//int  bs(int  a[], int  l, int  r, int  x){if(r>=l){ int  mid=(l+r)/2;if(a[mid]==x)return mid;else if(a[mid]>x)return bs(a,l,mid-1,x); else return bs(a,mid+1,r,x);}return -1;}
int  power(int  b, int  p){if(p==0)return 1;else if(p%2==0){int q=power(b,p/2);return ((q)*(q));}else return ((b)*(power(b,p-1)));}
int  powerm(int  b, int  p){if(p==0)return 1;else if(p%2==0){int q=powerm(b,p/2);return ((q%mod)*(q%mod))%mod;}else return ((b%mod)*(powerm(b,p-1)%mod))%mod;}
bool isprime( int  n){if(n==1)return false;if(n==2 or n==3)return true; int  lim=sqrt(n); int  i=2;while(i<=lim){if(n%i==0)return false; i++;}return true;}
vector< int > factors( int  n){vector< int > a;a.pb(1); int  lim=sqrt(n),i=2;while(i<=lim){if(n%i==0){a.pb(i);if(i!=n/i)a.pb(n/i);}i++;}if(n!=1)a.pb(n);sort(a.begin(),a.end());return a;}
vector<pii> pf_with_count(int  b){ pii p;vector<pii>pf;int  count=0;while(b%2==0){b/=2;count++;}if(count>0){p.f=2;p.s=count;pf.pb(p);}int i=3;while(i<=sqrt(b)){count=0;while(b%i==0){b/=i;count++;}if(count>0){p.f=i;p.s=count;pf.pb(p);}i+=2;}if(b>2) {p.f=b;p.s=1;pf.pb(p);}return pf;}
int  bs_t_i(string s){int  l=strtoull(s.c_str(),NULL,2);return l;}
string  i_to_bs(int  n){string s = bitset< 4 >( n ).to_string();return s;}

signed main()
{
   ios;
   string s;
   int a;
   cin>>a>>s;
   if(a>=3200)cout<<s;
   else cout<<"red";

}




Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N = int(input())
S = list(input())[:-1]
table = [0]*(N+5)
table[1] = 1
for i in range(2,N+3):
    num = i
    cnt = 0
    while num != 0:
        a = num % 2
        num = num // 2
        cnt += a
    p = i % cnt
    table[i] = table[p]+1
c = 0
for s in S:
    if s == "1":
        c += 1
p = 0
q = 0

for i in range(N):
    ss = S[N-1-i]
    p += int(ss)*pow(2,i,c+1)
    if c != 1:
        q += int(ss)*pow(2,i,c-1)
    p %= (c+1)
    if c != 1:
        q %= (c-1)
for i in range(N):
    ss = S[i]
    if ss == "0":
        ans = (p+pow(2,N-1-i,c+1))%(c+1)
        print(table[ans]+1)
    else:
        if c == 1:
            print(0)
        else:
            if c != 1:
                ans = (q-pow(2,N-1-i,c-1))%(c-1)
                print(table[ans]+1)
            else:
                print(0)
        


Measured memory_bytes: 13604
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = -1; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;


int main() {

	int a, b, c, d;

	cin >> a >> b >> c >> d;

	int cnt = 1;
	bool ans = false;

	while (a > 0 && b > 0) {
		if (cnt % 2 == 1) {
			c -= b;
		}
		else if (cnt % 2 == 0) {
			a -= d;
		}
		cnt++;
	}
	if (c <= 0) { ans = true; }

	puts(ans ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    ll a, b, c; cin >> a >> b >> c;
    ll d = c - a - b;
    if (d > 0 && d * d > 4 * a * b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){ 
    int person[4][3][10] ={};
    int building,floor,room,number,n,j;
    cin >> n;
    for(int i=0;i<n;i++){
    	cin >> building >> floor >> room >> number;
    	person[building-1][floor-1][room-1]+= number;
	}
	for(int i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(int k=0;k<9;k++){
				cout << " " << person[i][j][k];
			}
			cout << " " << person[i][j][9]	<< endl;
		}
		if(i<3){
			cout << "####################" << endl;
		}
	}
} 


Measured memory_bytes: 3100
antena = [int(input()) for i in range(5)]
k = int(input())
ans = 1
for i in antena:
    for j in antena:
        if i != j and abs(i - j) > k:
            ans = -1
            break
    if ans == -1:
        break

if ans == 1:
    print("Yay!")
else:
    print(":(")

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    string head_s;
    string tail_s = s;
    rep(i, q){
        int a;
        cin >> a;
        if(a == 1){
            swap(head_s, tail_s);
        }else{
            int f;
            char c;
            cin >> f >> c;
            if(f == 1) head_s.push_back(c);
            else tail_s.push_back(c);
        }
    }
    reverse(head_s.begin(), head_s.end());
    s = head_s + tail_s;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 4348
n,m = map(int,input().split())
dp = [0 for i in range(n+1)]

for i in range(m):
    j = int(input())
    dp[j] = -1

dp[0] = 1
if dp[1] != -1:
    dp[1] = 1 
else:
    dp[1] = 0

for i in range(2,n+1):
    if dp[i] == -1:
        dp[i] = 0
        continue
    dp[i] = (dp[i-1] + dp[i-2])%1000000007
    
print(dp[n])

Measured memory_bytes: 7064
#include<stdio.h>
  
int main(void)
{
    char num[1000];
    int count,tmp,sum;
    while(1){
        scanf("%s", num);
        if(num[0]=='0') break;
        count=0;
        sum=0;
        while(1){
            if(num[count]=='\0') break;
            tmp=(int)num[count++]-48;
            sum+=(tmp%10)+(tmp/10);
        }
        printf("%d\n",sum);
    }
    return 0;   
}   




Measured memory_bytes: 2048
n,m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
ans = Array.new(n,0);
m.times do |i|
    a,b = gets.split.map(&:to_i)
    if h[a-1] <= h[b-1]
        ans[a-1] = 1
    end
    if h[a-1] >= h[b-1]
        ans[b-1] = 1
    end
end
ans.delete(1)
puts ans.length


Measured memory_bytes: 22532
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

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

	vector<int32_t> d(N);
	for (int32_t i = 0; i < N; i++)
		cin >> d[i];

	sort(d.begin(), d.end());

	cout << (d[N / 2] - d[N / 2 - 1]) << endl;

	return 0;
}


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

int main()
{
	int a, b, c;
	bool check = true;
	cin >> a >> b;
	if (a == b)
	{
		cout << a << endl;
		return 0;
	}
	while (check)
	{
		if (a > b)
		{
			c = a % b;
			if (b%c == 0)
				check = false;
			a = c;
		}
		else
		{
			c = b % a;
			if (a%c == 0)
				check = false;
			b = c;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3092
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll n;
vector<ll> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    map<ll,ll> m;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        m[temp]++;
    }
    if(n%2==1){
        if(m[0]!=1){
            return cout<<0<<"\n",0;
        }
        for(int i=2;i<n;i+=2){
            if(m[i]!=2){
                return cout<<0<<"\n",0;
            }
        }
    }
    else{
        for(int i=1;i<n;i+=2){
            if(m[i]!=2){
                return cout<<0<<"\n",0;
            }
        }
    }
    ll ans=1;
    for(int i=1;i<=n/2;i++){
        ans*=2;
        ans%=MOD;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 4224
import java.util.*;


public class Main {
	
	int n, m, k, start, goal, r;
	int[][] cost, time;
	
	final int INF = Integer.MAX_VALUE;
	int[] min;
	
	int dijkstra(int[][] V) {
		int[] min = new int[m + 1];
		Arrays.fill(min, INF);
		min[start] = 0;
		
		Queue<int[]> que = new LinkedList<int[]>();
		que.offer(new int[]{start, 0});
		while (!que.isEmpty()) {
			int[] p = que.poll();
			int from = p[0];
			if (min[from] < p[1]) continue;
			for (int to = 1; to <= m; to++) {
				int v = V[from][to];
				if (v != INF && min[from] + v < min[to]) {
					min[to] = min[from] + v;
					que.offer(new int[]{to, min[to]});
				}
			}
		}
		return min[goal];
	}
	
	int solve() {
		if (r == 0) {
			return dijkstra(cost);
		} else {
			return dijkstra(time);
		}
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		String output = "";
		while (sc.hasNext()) {
			n = sc.nextInt();
			m = sc.nextInt();
			if (n == 0 && m == 0) {
				break;
			} else {
				cost = new int[m + 1][m + 1];
				time = new int[m + 1][m + 1];
				for (int i = 1; i <= m; i++) {
					Arrays.fill(cost[i], INF);
					Arrays.fill(time[i], INF);
				}
				for (int i = 0; i < n; i++) {
					int a = sc.nextInt();
					int b = sc.nextInt();
					int c = sc.nextInt();
					int t = sc.nextInt();
					cost[a][b] = c;
					cost[b][a] = c;
					time[a][b] = t;
					time[b][a] = t;
				}
				k = sc.nextInt();
				for (int i = 0; i < k; i++) {
					start = sc.nextInt();
					goal = sc.nextInt();
 					r = sc.nextInt();
					output += solve() + "\n";
				}
			}
		}
		sc.close();
		System.out.print(output);
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 158088
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int A, B, C;
	cin >> A >> B >> C;

	map<int, int> m;
	m[A] += 1;
	m[B] += 1;
	m[C] += 1;

	if( m[A] == 2 || m[B] == 2 || m[C] == 2 ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

vector<vector<int>> G;
vector<int> ans;

void dfs(int v, int k = 0) {
    ans[v] = max(ans[v], k);
    for (auto u : G[v]) {
        dfs(u, k + 1);
    }
}

int main() {
    string s;
    cin >> s;
    int n = s.size() + 1;
    G.resize(n);
    ans.resize(n,0);
    vector<bool> in(n,false);
    REP(i, n - 1) {
        if (s[i] == '<') {
            G[i].push_back(i + 1);
            in[i + 1] = true;
        }
        else {
            G[i + 1].push_back(i);
            in[i] = true;
        }
    }
    REP(i, n) {
        if (!in[i]) {
            dfs(i);
        }
    }
    ll res = 0;
    REP(i, n) {
        res += ans[i];
    }
    cout << res << endl;
    return 0;
}

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

int main() {
  while (true) {
    int n, t, l, b;
    cin >> n >> t >> l >> b;
    if (n == 0 && t == 0 && l == 0 && b == 0) return 0;

    bool lose[n + 1];
    bool back[n + 1];

    for (int i = 0; i < n + 1; i++) {
      lose[i] = false;
      back[i] = false;
    }
    
    for (int i = 0; i < l; i++) {
      int temp;
      cin >> temp;
      lose[temp] = true;
    }

    for (int i = 0; i < b; i++) {
      int temp;
      cin >> temp;
      back[temp] = true;
    }

    double dp[n + 1], dpl1[n + 1], dpl2[n + 1], tmp[n + 1];
    bool flag[n + 1];
    for (int i = 0; i < n + 1; i++) {
      dp[i] = 0.0;
      dpl1[i] = 0.0;
      dpl2[i] = 0.0;
      tmp[i] = 0.0;
      flag[i] = false;
    }

    dp[0] = 1.0;
    for (int i = 0; i < t; i++) {
      for (int j = 0; j < n; j++) {
	if (lose[j]) {
	  dp[j] += dpl2[j];
	  dpl2[j] = dpl1[j];
	  dpl1[j] = 0.0;
	}
      }
      for (int j = 0; j < n; j++) {
	double temp = dp[j] / 6.0;
	dp[j] = 0.0;
	for (int k = 1; k <= 6; k++) {
	  int index;
	  if (j + k <= n) {
	    index = j + k;
	  } else {
	    index = n - (k - (n - j));
	  }

	  if (lose[index]) {
	    dpl1[index] += temp;
	  } else if (back[index]) {
	    tmp[0] += temp;
	  } else {
	    tmp[index] += temp;
	  }
	}
      }

      for (int j = 0; j <= n; j++) {
	dp[j] += tmp[j];
	tmp[j] = 0.0;
      }
    }

    printf("%.6f\n", dp[n]);
    //for (int i = 0; i < n; i++) {
    //  cout << dp[i] << " ";
    //}
    //cout << endl;
  }
}

Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;

vector< vector< int > > grid_bfs(vector< string > &s, char start, const string &wall = "#") {
    const int vx[] = {0, 1, 0, -1}, vy[] = {1, 0, -1, 0};
    vector< vector< int > > min_cost(s.size(), vector< int >(s[0].size(), -1));
    queue< pair< int, int > > que;
    for(int i = 0; i < s.size(); i++) {
        for(int j = 0; j < s[i].size(); j++) {
        if(s[i][j] == start) {
            que.emplace(i, j);
            min_cost[i][j] = 0;
        }
        }
    }
    while(!que.empty()) {
        auto p = que.front();
        que.pop();
        for(int i = 0; i < 4; i++) {
        int ny = p.first + vy[i], nx = p.second + vx[i];
        if(nx < 0 || ny < 0 || nx >= s[0].size() || ny >= s.size()) continue;
        if(min_cost[ny][nx] != -1) continue;
        if(wall.find(s[ny][nx]) != string::npos) continue;
        min_cost[ny][nx] = min_cost[p.first][p.second] + 1;
        que.emplace(ny, nx);
        }
    }
    return min_cost;
}
int main(void) {
    int H, W;
    cin >> H >> W;
    int cnt = 0;
    vector<string> grid(H);
    for(int i=0; i<H; i++) {
        cin >> grid[i];
        cnt += count(grid[i].begin(), grid[i].end(), '#');
    }
    grid[0][0] = 's';
    auto ans = grid_bfs(grid, 's');
    if(ans[H-1][W-1] == -1) {
        cout << -1 << endl;
    } else {
        cout << H*W - ans[H-1][W-1] - cnt - 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 764
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    dp = [0] * n
    for i in range(1, n):
        h = a[i]
        dp[i] = min([dp[j] + abs(h - a[j]) for j in range(max(0, i-k), i)])

    print(dp[n-1])

main()

Measured memory_bytes: 84976
n,k = map(int,input().split())

if k == 0:
    print(n*n)
    import sys
    sys.exit()

ans = 0
for i in range(k+1,n+1):
    a = n // i
    ans += (i-k) * a
    if k <= n % i and n % i != 0:
        ans += n % i - k + 1
print(ans)



Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=100005;
int pre[maxn],vis[maxn];
int find(int x)
{
	int r=x;
	while(!vis[r]&&r!=pre[r])
	{
		r=pre[r];
	}
	return r;
}
int main()
{
	int n,m;
	while(scanf("%d%d",&n,&m),n|m)
	{
		memset(vis,0,sizeof(vis));
		pre[1]=1;
		for(int i=2;i<=n;++i)
		{
			scanf("%d",&pre[i]);
		}
		ll ans=0;
		while(m--)
		{
			char s[10];int x;
			scanf("%s%d",s,&x);
			if(s[0]=='Q')
			{
				ans+=find(x);
			}
			else
			{
				vis[x]=1;
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

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

  vector<int> a(n);
  rep(i,n) cin >> a.at(i);

  int q;
  cin >> q;

  vector<int> b(q);
  vector<int> c(q);
  rep(i, q) cin >> b.at(i) >> c.at(i);

  ll sum=0;
  vector<int> count(100005);

  rep(i,n){
    sum += a.at(i);
    int now =  a.at(i);
    count.at(now)++;
  }

  rep(i,q){
    int now = b.at(i);
    int change = c.at(i);
    int c = count.at(now);
    count.at(now) = 0;
    count.at(change) += c;

    sum +=  (change-now)*c;
    cout << sum << endl;
  }
}

Measured memory_bytes: 4836
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

const long long mod = pow(10, 9) + 7;

int main() {
	string a, b; int N; cin >> N >> a >> b;
	for (int i = 0; i < N; i++) {
		cout << a[i] << b[i];
	}
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

using ipair = pair<int, int>;

ll INF = 1e16+7;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}

const int SIZE = 2001;

int H, W;
int LEFT[SIZE][SIZE], RIGHT[SIZE][SIZE], UP[SIZE][SIZE], DOWN[SIZE][SIZE];
char field[SIZE][SIZE];

void init(){
  // left
  rep(i, H){
    int cur = 0;
    rep(j, W){
      if(field[i][j]=='#'){
        cur=0;
      }else{
        cur++;
      }
      LEFT[i][j] = cur;
    }
  }
  // right
  rep(i, H){
    int cur = 0;
    rep(j, W){
      if(field[i][W-1-j]=='#'){
        cur=0;
      }else{
        cur++;
      }
      RIGHT[i][W-1-j] = cur;
    }
  }
  // down
  rep(j, W){
    int cur = 0;
    rep(i, H){
      if(field[i][j]=='#'){
        cur=0;
      }else{
        cur++;
      }
      DOWN[i][j] = cur;
    }
  }
  // up
  rep(j, W){
    int cur = 0;
    rep(i, H){
      if(field[H-1-i][j]=='#'){
        cur=0;
      }else{
        cur++;
      }
      UP[H-1-i][j] = cur;
    }
  }
}

int calc(int h, int w){

  if(field[h][w] == '#') return 0;

  int ret = LEFT[h][w] + RIGHT[h][w] + UP[h][w] + DOWN[h][w] - 3;

  return ret;
}

int main(){
  // Input
  cin >> H >> W;

  rep(i, H){
    string str;
    cin >> str;
    rep(j, W){
      field[i][j] = str[j];
    }
  }

  init();

  int ans = 0;
  rep(i, H) rep(j, W){
    if(field[i][j] != '.') continue;
    ans = max(ans, calc(i, j));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 66688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, k;
  cin >> a >> b >> c;
  cin >> k;
  int ans = 0;
  for(int i = 0; i < 4; i++){
    if(a < b) break;
    b = b*2;
    ans++;
  }
  for(int i = 0; i < 4; i++){
    if(b < c) break;
    c = c*2;
    ans++;
  }
  if(ans <= k) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3544
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
using namespace std;

const int num = 653;

int main() {
  string s, c;
  cin >> s;
  
  int l = s.size(), ans = 0, minAns = num, p;
  
  for(int i = 0; i < l - 2; ++i)
  {
    c = s.substr(i, 3);
    stringstream str(c);
    str >> ans;
    p = abs(ans - 753);
    if(p < minAns)
      minAns = p;
  }
  cout << minAns;
  return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int n, m;
	cin >> n >> m;
	
	vector< string > A(n), B(m);
	for_(i,0,n) cin >> A[i];
	for_(i,0,m) cin >> B[i];
	
	for_(sy,0,n-m+1) for_(sx,0,n-m+1) {
		bool match = true;
		for_(dy,0,m) for_(dx,0,m) match &= (A[sy + dy][sx + dx] == B[dy][dx]);
		if (match) {
			puts("Yes");
			return 0;
		}
	}
	
	puts("No");
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
typedef long long ll;

int main(){
  int A, B;cin >> A >> B;
  for(int i = 1;i <= 1250;++i){
    if(int(i * 0.08) == A && int(i * 0.1) == B){
      cout << i;
      return 0;
    }
  }
  cout << -1;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a=0,b=0,ab=0,o=0,dum;
  char str[3];
  while(scanf("%d,%s",&dum,str)>0){
    if(str[0]=='A'){if(str[1]=='B') ab++; else a++;}
    if(str[0]=='O') o++;
    if(str[0]=='B') b++;
  }
  printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long ll;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
using std::string;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a[3],k,l,t;
  cin>>a[0]>>a[1]>>a[2]>>k;
  SORT(a,3);
  REP(i,k){
    a[2]*=2;
  }
  cout << a[0]+a[1]+a[2] << '\n';



  return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

const MOD: i64 = 1e9 as i64 + 7;

fn calc(vs: &mut Vec<i64>) -> i64 {
    let n = vs.len();
    vs.sort();

    let min_v = vs[0];
    for i in 0..n {
        vs[i] = vs[i] - min_v;
    }

    let mut acm = vec![0; n+1];
    for i in 0..n {
        acm[i+1] = acm[i] + vs[i];
        acm[i+1] %= MOD;
    }

    let mut ret = 0;
    for i in 0..n {
        let mut temp = (acm[n] + MOD - acm[i+1]) + MOD - ((n-i-1) as i64 * vs[i]) % MOD;
        temp %= MOD;
        // debug!(i, temp, acm[n]-acm[i]);
        ret += temp;
        ret %= MOD;
    }
    ret
}

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      m: usize,
      mut xs: [i64; n],
      mut ys: [i64; m],
    }
    let v1 = calc(&mut xs);
    let v2 = calc(&mut ys);
    puts!("{}\n", v1*v2%MOD);
}


Measured memory_bytes: 8444
//wawando's template

#include <iostream>
#include <string>
#include <fstream>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>  //clock_t , clock() , CLOCKS_PER_SEC
#include <cstring>
#include <cctype>
#include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

//MACROS
#define pb              push_back
#define mp              make_pair
#define INF             1000000000     //1 billion safer for floyd warshall, avoid overflow

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

bool cmp(pair<string, int> a, pair<string, int> b) {
  if(a.first == b.first) return (a.second > b.second);
  else return (a.first < b.first);
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios::sync_with_stdio(false); cin.tie(0);

  int N,X,L[120];
  cin >>N >>X;

  for(int i = 0; i < N; i++) {
    cin >>L[i];
  }
  int D = 0;
  int ans = 0;
  for(int i = 0; i <= N; i++) {
    if(i > 0) D = D + L[i-1];
    if(D <= X) ans++;
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 256
/*
很神奇的题
首先可以想到同时减1，范围变为{0,1,2}
分类讨论
只有0和1，算1对答案的贡献
只有0和2，同除以2，化为0和1，最后答案乘以2
只有1和2，同减1，化为0和1
都有，2变为0，化为0和1
*/


#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 1e6+5;
char s[maxn];
int a[maxn],f[maxn],c0,c1,c2;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n>>s+1;
    for(int i=1;i<=n;i++)
    {
        a[i]=s[i]-'1';
        if(a[i]==0) c0=1;
        if(a[i]==1) c1=1;
        if(a[i]==2) c2=1;
    }
    for(int i=2;i<=n;i++)
    {
        f[i] = f[i-1];
        int ii=i;
        while(!(ii&1)) {f[i]++;ii>>=1;}
    }
    int t=1,ans=0;
    if(c0 && c1 && c2)
    {
        for(int i=1;i<=n;i++) a[i]=a[i]==2?0:a[i];
    }
    else if(c0 && c2) t=2;
    else if(c1 && c2)
    {
        for(int i=1;i<=n;i++) a[i]--;
    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]) ans += (f[n-1]-f[i-1]-f[n-i]==0);
    }
    ans %= 2;
    cout<<ans*t<<endl;
    return 0;
}


Measured memory_bytes: 9088
# -*- coding: utf-8 -*-
N, M = map(int, input().split(' '))
graph = [[float('inf') for _ in range(N)] for _ in range(N)]

edges = [list(map(int, input().split(' '))) for _ in range(M)]
for a, b, c in edges:
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c


for k in range(N):
    for i in range(N):
        for j in range(N):
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

ans = 0
for a, b, c in edges:
    a -= 1
    b -= 1
    if graph[a][b] < c:
        ans += 1

print(ans)



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

static const long MM = 998244353;
static const long MAX = 200000;
long a[MAX], b[MAX], Mm[MAX];
long N, M, K;

long power(long n, long m){
    long ans = 1;
    if(m > 0){
        ans = power(n, m / 2);
        if(m % 2 == 0) ans = (ans * ans) % MM;
        else ans = (((ans * ans) % MM) * n) % MM;
    }
    return ans;
}

void setab(){
    a[0] = 1; b[0] = 1;
    for(long i = 1; i < N; i++){
        a[i] = a[i - 1] * i % MM;
        b[i] = b[i - 1] * power(i, MM - 2) % MM;
    }
    return;
}

void setMm(){
    Mm[0] = 1;
    for(long i = 1; i < N; i++){
        Mm[i] = Mm[i - 1] * (M - 1) % MM;
    }
    return;
}

int main(){
    cin >> N >> M >> K;
    setab(); setMm();
    long ans = 0;
    for(int i = 0; i < K + 1; i++){
        ans = (ans + (((((((a[N - 1] * b[i]) % MM) * b[N - 1 - i]) % MM) * M) % MM) * Mm[N - 1 - i])) % MM;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8224
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  int ans = 0;
  rep(i,n) {
    int l = v[i] - 0;
    int r = abs(v[i] - k);
    int u = min(l, r);
    ans += 2 * u;
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

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

int main(){
ll n,q; cin>>n>>q;
  string s; cin>>s;
  vector<ll>cnt(n);
  cnt[0]=0;
  for(int i=1;i<n;i++){
 if(s.substr(i-1,2)=="AC")cnt[i]=cnt[i-1]+1;
 else cnt[i]=cnt[i-1];
 }
  rep(i,q){
  ll l,r; cin>>l>>r;
    cout<<cnt[r-1]-cnt[l-1]<<endl;
  }
  
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;



int main()
{
	int n;
	
	while(cin >> n,n)
	{
		int w,h,s,t,ret = 0;
		int x[n+1],y[n+1];
		cin >> w >> h;
		
		REP(i,n)
		{
			cin >> x[i] >> y[i];;
		}
		
		cin >> s >> t;
		
		REP(i,w)REP(j,h)
		{
			int tmp = 0;
			int ux = i + 1,uy = j + 1;
			int tx = i + s,ty = j + t;
			REP(a,n)
			{
				if(x[a] >= ux && x[a] <= tx && y[a] >= uy && y[a] <= ty)tmp++;
			}
			
			ret = max(ret,tmp);
			
		}

		
		cout << ret <<endl;
		
		
			
	}
	
	return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    REP(i, N) { cin >> A[i]; }
    map<long long, int> m;
    REP(i, N) { m[A[i]]++; }
    vector<long long> res;
    res.push_back(0);
    res.push_back(0);
    for(auto x : m) {
        if(x.second >= 2) {
            REP(i, x.second / 2) { res.push_back(x.first); }
        }
    }
    sort(res.begin(), res.end(), greater<long long>());
    cout << res[0] * res[1] << endl;
    return 0;
}

Measured memory_bytes: 7296
# use faster method than input()
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def manhattan(pos1, pos2):
    return abs(pos1[0]-pos2[0]) + abs(pos2[1]-pos1[1])


H, W, D = map(int, input().split())
A = [(0, 0)]*(H*W)
for r in range(H):
    l = list(map(int, input().split()))
    for c in range(W):
        A[l[c]-1] = (r, c)

dist = [0]*(H*W)
for i in range(D, H*W):
    dist[i] = dist[i-D]+manhattan(A[i], A[i-D])


Q = int(input())
L = []

ans_list = [0]*Q
for i in range(Q):
    ans = 0
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    ans = dist[b]-dist[a]
    ans_list[i] = ans

for ans in ans_list:
    print(ans)


Measured memory_bytes: 20148
n = int(input())
a = list(map(int, input().split()))
l = [[a[i], i] for i in range(n)]
l = sorted(l)
ans = ""
for i in range(n):
    if(i != n-1):
        ans += str(l[i][1]+1)
        ans += " "
    else:
        ans += str(l[i][1]+1)

print(ans)


Measured memory_bytes: 22124
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
    while(1){
	int n,m;
	cin>>n>>m;
	if(n==0)break;
	vector<vector<mp> > g(n);
	for(int i=0;i<m;i++){
		int a,b,c;
		cin>>a>>b>>c;
		g[a].push_back(mp(c,b));
		g[b].push_back(mp(c,a));
	}
	priority_queue<mp,vector<mp>,greater<mp> > q;
	for(int i=0;i<g[0].size();i++)q.push(g[0][i]);
	int sum = 0;
	vector<bool> used(n,false);
	used[0] = true;
	//cout<<"ok"<<endl;
	while(!q.empty()){
		mp now = q.top();
		q.pop();
		int nn = now.second;
		int cost = now.first;
		if(used[nn])continue;
	//	cout<<nn<<' '<<cost<<endl;
		used[nn] = true;
		sum+=cost;
		for(int i=0;i<g[nn].size();i++){
		    	if(used[g[nn][i].second])continue;
			q.push(g[nn][i]);
		}

	}
	cout<<sum<<endl;
	}
	return 0;
}



Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define sp ' '
#define nl '\n'
void sc(){}template<class T,class...A>void sc(T&t,A&...a){cin>>t,sc(a...);}
void pr(){}template<class T,class...A>void pr(T t,A...a){cout<<t,pr(a...);}
int n, k, a[101];
bool dp[100001];
int main(){
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("", "r", stdin); freopen("", "w", stdout);
    sc(n, k);
    for (int i = 0; i < n; i++) sc(a[i]);
    for (int i = 1; i <= k; i++){
        for (int j = 0; j < n; j++){
            if (a[j] <= i && !dp[i - a[j]]){
                dp[i] = 1;
            }
        }
    }
    pr(dp[k] ? "First" : "Second");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

llong nijou(llong n){
    return n*n;
}

int main(){
    int n,d,x[20][20],ans=0;
    cin >> n >> d;
    rep(i,n) rep(j,d) cin >> x[i][j];
    rep(i,n) for(int j=i+1;j<n;j++){
        int sum=0;
        rep(k,d) sum += nijou(x[i][k]-x[j][k]);
        double y = sqrt(sum);
        int z = (int)y;
        if(y-z==0) ans++;
    }
    cout << ans << endl;
}


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

public class Program
{
	public static void Main()
	{
		string[] vowels = { "a", "e", "i", "o", "u" };
		var c = Console.ReadLine();
		Console.WriteLine(vowels.Any(i => i == c) ? "vowel" : "consonant");
	}
}

Measured memory_bytes: 2776
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;


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


void solve(){
	ll n;
	cin >> n;
	string ans = "";
	while(n>0){
		int r= n%26;
		if(r==0){
			ans+='z';
			n/=26;
			n--;
		}
		else{
			ans+='a'+(r-1);
			n/=26;
		}
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
}

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

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define mod 998244353
#define maxn 1000000
using namespace std;
int n,a,f[maxn+5],ans,sum,inv[maxn+5];
int p[maxn+5],prime[maxn+5],miu[maxn+5],cnt;

int read(){
	int x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}

int main(){
	n=read();
	for(int i=1;i<=n;i++) a=read(),(f[a]+=a)%=mod,(sum+=a)%=mod;
	for(int i=1;i<=maxn;i++){
		for(int j=i+i;j<=maxn;j+=i) (f[i]+=f[j])%=mod;
	}
	for(int i=1;i<=maxn;i++) f[i]=1ll*f[i]*f[i]%mod;
	miu[1]=1;
	for(int i=2;i<=maxn;i++){
		if(p[i]==0){prime[++cnt]=i;miu[i]=-1;}
		for(int j=1;j<=cnt&&i*prime[j]<=maxn;j++){
			p[i*prime[j]]=1;
			if(i%prime[j]==0){miu[i*prime[j]]=0;break;}
			miu[i*prime[j]]=-miu[i];
		}
	}
	for(int i=1;i<=maxn;i++) (miu[i]+=mod)%=mod;
	inv[1]=1;for(int i=2;i<=maxn;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=maxn;i++){
		for(int j=1;j<=maxn/i;j++) (ans+=1ll*miu[j]*f[i*j]%mod*inv[i]%mod)%=mod;
	}
	printf("%d\n",1ll*(ans-sum+mod)*inv[2]%mod);

	return 0;
}

Measured memory_bytes: 19712
function area(input) {
	var a = Number(input.split("\n")[0]);
	var b = Number(input.split("\n")[1]);
	var h = Number(input.split("\n")[2]);
	var S = (a+b)*h/2.0;
	console.log(S);
	return S;
}

area(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a;
	string s;
	cin>>a>>s;
	if(a>=3200){
		cout <<s;
	}
	else{
		cout << "red";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256