akhauriyash/Code-Regression huggingface dataset:
from decimal import Decimal
N = int(input())
#numlist = [0] * (N + 1)
log2 = [0] * (N + 1)
log5 = [0] * (N + 1)
acc = [[0 for i in range(19)] for j in range(19)]
Ans = 0

for i in range(1,N+1):
  #numlist[i] = Decimal(input()) * 1000000000
  wk = Decimal(input())
  wk = int(wk * 1000000000)

  #wk = numlist[i]
  for cnt in range(1,19):
    if wk % 2 == 0:
      log2[i] += 1
      wk = wk // 2
    else:
      break

  for cnt in range(1,19):
    if wk % 5 == 0:
      log5[i] += 1
      wk = wk // 5
    else:
      break

  acc[log2[i]][log5[i]] += 1
    
for i in range(0,19):
  for j in range(0,19): 
    for k in range(i,19):
      for l in range(0,19):
        if (i + k) >= 18 and (j + l) >= 18 and (i < k or (i == k and j <= l)):
          if acc[i][j] > 0 and acc[k][l] > 0:
            Ans += acc[i][j] * acc[k][l]
            if i >= 9 and j >= 9 and i == k and j == l:
              Ans -= int((acc[i][j] * (acc[i][j] + 1)) / 2)

print(int(Ans))


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

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.begin(),a.end());
    vector<int> memo(a.back()+1);
    for(int i=0;i<n;i++){ 
        
        int index=1;
        while(index*a[i]<=a.back()){
            memo[index*a[i]]++;
            index++;
        }        
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(1==memo[a[i]]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8008
from collections import Counter

MOD = 10**9+7
N = int(input())

dp = [Counter() for i in range(N+1)]
dp[0]["TTT"] = 1


def ok(last4):
    bad = ["AGC", "ACG", "GAC", "AGGC", "ATGC", "AGTC"]
    for b in bad:
        if b in last4:
            return False
    return True

for i in range(N):
    for key, value in dp[i].items():
        for c in "AGCT":
            if ok(key+c):
                dp[i+1][key[1:]+c] += value % MOD

print(sum(dp[N].values()) % MOD)



Measured memory_bytes: 4196
fun main(args: Array<String>) = abc156d()

fun abc156d() {
    val (n, a, b) = readLine()!!.split(' ').map { it.toInt() }

    var answer = modPow(2, n.toLong())
    answer -= 1
    answer = (answer + MOD) % MOD
    answer -= comb(n, a)
    answer = (answer + MOD) % MOD
    answer -= comb(n, b)
    answer = (answer + MOD) % MOD

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

private fun modPow(n: Long, p: Long): Long {
    var x = n
    var y = p
    var result = 1L
    x %= MOD
    while (y > 0) {
        if (y % 2 == 1L)
            result = (result * x) % MOD
        y = y shr 1
        x = (x * x) % MOD
    }
    return result
}

private fun comb(n: Int, k: Int): Long {
    if (n < k) return 0
    val min = Math.min(k, n - k)
    var value = 1L
    for (i in 1L..min) {
        value *= n - i + 1
        value %= MOD
        value *= modPow(i, MOD - 2)
        value %= MOD
    }
    return value
}


Measured memory_bytes: 38208
#include<bits/stdc++.h>>
using namespace std;
int main()
{
   string s,t,u;

   int a,b;
 cin>>s>>t>>a>>b>>u;
 if(s==u)
    a=a-1;
 else
    b=b-1;

 cout<<a<<" "<<b<<endl;


    return 0;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
int n,m;
int k;
string s,t;
const ll mod=1e9+7;
ll pw(ll x,ll y){
	if(y==0) return 1;
	if(y%2) return x*pw(x,y-1)%mod;
	ll res=pw(x,y/2);
	return res*res%mod;
}
int main(){
	ios::sync_with_stdio(false);
	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	int f=a*60+b;
	int g=c*60+d;
	cout << g-f-e << endl;
}

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

int main(){
  string a;
  cin >> a;
  int cou,k;
  k = a.size();
  for(int i = 0; i < k; i++){
    if(a.substr(i,1) == "1"){
      cou++;
    }
  }
  cout << cou << endl;
}

Measured memory_bytes: 256
N=input()
K=int(input())
L=len(N)+1
dp=[[[0]*L for _ in range(4)] for _ in range(2)]
dp[0][0][0]=1
for l in range(1,L):
    dp[1][0][l]=1

# まずNをもとにdp[0]を処理する
cnt=0
for l in range(1,L):
    if int(N[l-1])!=0:
        cnt+=1
    if cnt>3:
        break
    else:
        dp[0][cnt][l]=1


# 次にdp[1]を処理。
# 遷移としては
# dp[1][j-1][i-1]からdp[1][j][i]へは'1'から'9'が選ばれ*9
# dp[1][j][i-1]からdp[1][j][i]へは'0'が選ばれ*1
#以下、N[i-1]!=0の条件付き
# dp[0][j][i-1]からdp[1][j][i]へは'0'が選ばれ*1
# dp[0][j-1][i-1]からdp[1][j][i]へは'N[i-1]-1'までが選ばれ*(N[i-1]-1)

for i in range(1,L):
    for j in range(1,4):
        dp[1][j][i]+=dp[1][j-1][i-1]*9
        dp[1][j][i]+=dp[1][j][i-1]
        if int(N[i-1])>0:
            dp[1][j][i]+=dp[0][j][i-1]
            dp[1][j][i]+=dp[0][j-1][i-1]*(int(N[i-1])-1)
            

print(dp[0][K][L-1]+dp[1][K][L-1])

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1001001001;

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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans;
    if(x > y) ans = min({a*x + b*y, 2*c*y+a*(x-y), 2*c*x});
    else ans = min({a*x + b*y, 2*c*x+b*(y-x), 2*c*y});
    cout << ans << endl;
}


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

const int N_MAX=1e6+10;

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

  sort(A.begin(),A.end(),greater<int>());
  int ans=0;
  for(int i=0;i<N;++i){
    if(ch[A[i]]==1){
    if(A[i]==1) ++ans;
    else{
    bool flag=true;
    if(ch[1]>0) flag=false;
    else{
    for(int j=2;j*j<=A[i];++j){
      if(A[i]%j==0){
        if(ch[j]>0 || ch[A[i]/j]>0) flag=false;
      }
    }
  }
  if(flag) ++ans;
  }
  }
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 8012
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,y,a=-1,b=-1,c=-1,i,j,tmp;
    cin >> n >> y;
    for(i=0;i<=n;i++){
        for(j=0;j<=n-i;j++){
            tmp=10000*i+5000*j+1000*(n-i-j);
            if(tmp==y){
                a=i;b=j;c=n-i-j;
            }
        }
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	string s;
	cin >> s;
	
	vector<int> bc(s.size(), 0);
	bc[0] = (s[0] == 'B' ? 1 : 0);
	for(int i = 1; i < bc.size(); ++i){
		bc[i] = bc[i-1] + (s[i] == 'B' ? 1 : 0);
	}
	
	ll ans = 0;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == 'W'){
			ans += bc[i];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 1412
import java.util.*;

class Main {
  public static int calculateSurface(int bottom, int height) {
    return bottom * height / 2;
  }
  
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    String line = scanner.nextLine();
    
    String[] values = line.split(" ", 0);
    
    int AB = Integer.parseInt(values[0]); 
    int BC = Integer.parseInt(values[1]);
    int CA = Integer.parseInt(values[2]);
    
    System.out.println(calculateSurface(BC, AB));
  }
}

Measured memory_bytes: 23760
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  vector <int> bell(3);
  cin >> bell[0] >> bell[1] >> bell[2];
  sort(bell.begin(), bell.end());
  cout << bell[0]+bell[1] << endl;
  return 0;
}


Measured memory_bytes: 3616
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i, n)  FOR(i,0,(n))
typedef vector<int> vec;


class AFiveVariables {
public:
    void solve(std::istream &in, std::ostream &out) {
      vec x(5);
      REP(i, 5) in >> x[i];
      REP(i, 5) {
        if (x[i] == 0) {
          out << i + 1 << endl;
        }
      }
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  AFiveVariables solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var aaa = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = aaa[0];
            var T = aaa[1];
            var min = 22220;

            for(var x=0; x<N; x++)
            {
                var bbb = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                if(bbb[1] <= T)
                {
                    if (min > bbb[0])
                        min = bbb[0];
                }               
            }
            if (min == 22220)
                Console.WriteLine("TLE");
            else
                Console.WriteLine(min);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
double ans=0;
void Main(){
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    double theta2 = 2 * M_PI * (m / 60);
    double theta1 = 2 * M_PI * (h / 12) + theta2 / 12;
    double dtheta = abs(theta2 - theta1);
    double ans2 = a*a + b*b - 2*a*b*cos(dtheta);
    ans=sqrt(ans2);
    //cout << theta2 <<endl << theta1 << endl;
    cout << fixed << setprecision(15) << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

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

int main (){
	int a, b;
	
	cin >> a >> b;
	if (a == b) cout << "Draw" << endl;
	else if (a == 1) cout << "Alice" << endl;
	else if (b == 1) cout << "Bob" << endl;
	else if (a>b) cout << "Alice" << endl;
	else if (a<b) cout << "Bob" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)a;i<=(sign)b;++i)
#define Fordown(i,a,b) for(register sign i=(sign)a;i>=(sign)b;--i)
const int N=100+5;
bool cmax(sign &a,sign b){return (a<b)?a=b,1:0;}
bool cmin(sign &a,sign b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
void file()
{
	#ifndef ONLINE_JUDGE
		freopen("a.in","r",stdin);
		freopen("a.out","w",stdout);
	#endif
}
int n,a[100];
int b[100];
void input()
{
	n=read<int>();
	For(i,1,n)a[i]=read<int>();
}
ll ans;
void cal()
{
	For(i,1,n)if(b[i]%2==0){++ans;return;}
}
void dfs(int dep)
{
	if(dep==n+1){cal();return;}
	For(i,max(0,a[dep]-1),a[dep]+1)
	{
		b[dep]=i;
		dfs(dep+1);
	}
}
int main()
{
	//file();
	input();
	dfs(1);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    
    for(int i=0; i<4; ++i){
        string ans(n, ' ');
        ans[0] = (i&1) ? 'S' : 'W';
        ans[1] = (i&2) ? 'S' : 'W';
        
        for(int j=1; j<n-1; ++j){
            if((ans[j] == 'W') ^ (s[j] == 'x'))
                ans[j+1] = 'S' + 'W' - ans[j-1];
            else
                ans[j+1] = ans[j-1];
        }
        
        if((ans[0] == 'W') ^ (s[0] == 'x') ^ (ans[n-1] != ans[1]))
            continue;
        if((ans[n-1] == 'W') ^ (s[n-1] == 'x') ^ (ans[n-2] != ans[0]))
            continue;
        
        cout << ans << endl;
        return 0;
    }
    
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
N = int(input())
S = input()
sum_b = [0]
sum_w = [0]
b = 0
w = 0

for s in S:
    if s == "#":
        b += 1
    else:
        w += 1
    # 白黒の累積和作る
    sum_b.append(b)
    sum_w.append(w)

ans = float("inf")
for i in range(N + 1):
    # i番目までにある黒をすべて白にし、それ以降の白をすべて黒にするのに必要な手数
    buf = sum_b[i] + (sum_w[-1] - sum_w[i])
    # 更新するか否か
    ans = min(ans, buf)

print(ans)

Measured memory_bytes: 67552
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	sc := newScanner()
	x := sc.nextInt()
	y := sc.nextInt()
	var xt, yt int
	a := [3][]int{{1, 3, 5, 7, 8, 10, 12}, {4, 6, 9, 11}, {2}}
	for i, t := range a {
		for _, n := range t {
			// log.Println(n)
			if x == n {
				xt = i
			}
			if y == n {
				yt = i
			}
		}
	}
	if xt == yt {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}

func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
ll = sorted([list(map(int,input().split())) for _ in range(n)])

ans = 0
for p, c in ll:
  ans += p*min(m,c)
  m -= c
  if m < 1:
    break

print(ans)

Measured memory_bytes: 28572
#include <iostream>

int main()
{
	int n = 0;
	std::cin >> n;

	for (int index = 0; index < n; ++index)
	{
		int a = 0;
		std::cin >> a;

		if (a % 2 != 0)
		{
			continue;
		}

		if (a % 3 != 0 && a % 5 != 0)
		{
			std::cout << "DENIED" << std::endl;
			return 0;
		}
	}

	std::cout << "APPROVED" << std::endl;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
connected = [list(map(int,input().split())) for _ in range(M)]
condition = list(map(int, input().split()))
ans = 0

for i in range(1<<N):
    count1 = 0
    for j,lst in enumerate(connected):
        count2 = 0
        for s in lst[1:]:
            if (i>>(s-1)) & 1:
                count2 += 1
        if count2 % 2 == condition[j]:
            count1 += 1
    if count1 == M:
        ans += 1

print(ans)

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

int main(){
    int n = 0;
    cin >> n;
    int a[n];
    
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    
    int minv = a[0],maxv = a[1] - a[0];
    
    for(int j = 1;j < n;j++){
        maxv = max(maxv,a[j]-minv);
        minv = min(minv,a[j]);
    }
    
    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}

int main(){
  int a,b;cin>>a>>b;
  if(b%a==0)cout<<a+b<<endl;
  else cout<<b-a<<endl;
}

Measured memory_bytes: 256
from sys import stdin
input = stdin.buffer.readline

def main():
    n, w = map(int, input().split())
    wv = [tuple(map(int, input().split())) for _ in range(n)]

    dp = [0] * (w + 1)
    for weight, value in wv:
        for i in range(w - weight + 1)[::-1]:
            if dp[i + weight] < dp[i] + value:
                dp[i + weight] = dp[i] + value

    print(dp[w])

main()

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

int getgcd(int n, int m)
{
int r;
if (n > m) {
int t = m;
m = n;
n = t;
}
while ((r = m % n) != 0) {
m = n;
n = r;
}
return n;
}

int main () {
   int N ; 
  cin >> N ;
  long long line[N] ;
  for(int i = 0 ; i < N ; i++ ) cin >> line[i] ;
  int pre = line[0] ;
  for( int i = 1 ; i < N ; i++ ){
    pre = getgcd(pre,line[i]) ;
  }
  cout << pre << endl ;
}

Measured memory_bytes: 1024
# 0028
array = []
while True:
    try:
        a = input()
        array.append(int(a))
    except EOFError:
        break
s = set(array)
mx = array.count(max(array, key = array.count))
for a in sorted(s):
    if array.count(a) == mx:
        print(a)

Measured memory_bytes: 7532
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    cout << n*(n+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(k, n):
        #print("i", i)
        j = i - k  # 比較対象
        #print("j", j)
        if A[i] > A[j]:
            print("Yes")
        else:
            print("No")




if __name__ == "__main__":
    resolve()

Measured memory_bytes: 31608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 0; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;

int  main()
{
	int n, m; cin >> n >> m;
	vector<long> x(m);
	priority_queue<long> q;
	rep( i , m)
		cin >> x[i];
	sort(x.begin(), x.end());
	long sum = 0;
	if (m > 1)
	{
		rep(i, m - 1)
		{
			q.push( abs(x[i] - x[i+1]) );
			sum += abs(x[i] - x[i+1]);
		}
	}
	rep(i, n-1)
	{
		if (!q.empty())
		{
			sum -= q.top();
			q.pop();
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 2168
#include<iostream>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    using namespace std;
    #define INF 10000000;
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define vec(n) vector<int> vec(n)
    #define vvec(m,n) vector<vector<int>> vec(m,vector(n))

    int main(){
      int n,m = 1;
      bool f = false;
      cin >> n;
      vector<int> a(n);
      rep(i,n){
        cin >> a[i];
      }

      rep(i,n){
        if(m == a[i]){
          m++;
          f = true;
      }
      }
      if(f)cout << n-m+1 <<endl;
      else cout << -1 <<endl;
    }
    

Measured memory_bytes: 1024
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
static const lint MOD = (lint)1e9+7;

lint Sum(lint N)
{
    return N*(N-1) / 2;
}

int main()
{
    lint N;
    cin >> N;
    lint s;
    s = Sum(N);
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define N      510
// #define inf    0x7f7f7f7f
#define int    long long
using namespace std;
int a[N][N] = {};
int read()
{
    int  s = 0, w = 1;
    char c = getchar();
    while ((c < '0' || c > '9') && c != '-')
        c = getchar();
    if (c == '-')
        c = getchar(), w = -1;
    while (c <= '9' && c >= '0')
        s = (s << 3) + (s << 1) + c - '0', c = getchar();
    return s * w;
}
int n;
int b[N][N] = {}, c[N][N] = {};
int f[N][N] = {};
signed main()
{
    n = read();
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            if (i != j)
                a[i][j] = read();
    for (int i = 1; i <= n; ++i)
        for (int j = n; j >= i + 1; --j)
        {
            b[i][j] = b[i][j + 1];
            for (int k = 1; k <= i; ++k)
                b[i][j] += a[j][k];
        }
    for (int i = 1; i <= n; ++i)
        for (int j = i + 1; j <= n + 1; ++j)
        {
            c[i][j] = c[i][j - 1];
            for (int k = i; k <= j - 1; ++k)
                c[i][j] += a[k][j];
        }
    memset(f, 0x3f, sizeof(f));
    f[0][0] = 0;
    for (int i = 0; i <= n; ++i)
        for (int j = i; j <= n; ++j)
            if (f[i][j] < 1e18)
                for (int k = j + 1; k <= n + 1; ++k)
                    f[j][k] = min(f[j][k], f[i][j] + c[j + 1][k] + b[j][k + 1] - b[i][k + 1]);
    int minn = 1e18;
    for (int i = 0; i <= n; ++i)
        minn = min(minn, f[i][n + 1]);
    printf("%lld\n", minn);
    return 0;
}


Measured memory_bytes: 8320
N = int(input())
A, B = [], []
for i in range(N):
    ai, bi = map(int, input().split())
    A.append(ai)
    B.append(bi)

if A == B:
    print(0)
    exit()

bmin = float('inf')
for a, b in zip(A, B):
    if a > b and bmin > b:
        bmin = b

print(sum(A) - bmin)


Measured memory_bytes: 4852
#include<iostream>
#include<unordered_map>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<tgmath.h>
#include<stdlib.h>
#include<assert.h>
#include<stdio.h>



#define ll long long


/*
_
_._ _..._ . - ',     _.._(`))
'-. `     ' / -._. - '    ', /
)         \            '.
/ _    _ | \
| a    a    /              |
\   . - .;
'-('' ).-', '       ;
'-;           |      .'
\           \    /
| 7.__  _. - \   \
| |  |  ``/ / `  /
/, _|  |   /, _/   /
/, _ / '`-'
*/
using namespace std;




int main()
{
	ll n,k;
	cin >> n >> k;
	ll i;
	ll sum = 0;
	const ll mod = 1000000000+7;
	for (i = k; i <= n + 1; ++i) {
		sum = (sum + (ll)i * n - (ll)i * i + i + 1)%mod;
	}
	cout << sum;
}

		



Measured memory_bytes: 3636
import math
A, B, H, M = map(int, input().split())

wa = 360/12
wb = 360/1
t = H + M/60
theta = math.radians((wa*t)%360 - (wb*t)%360)
print(math.sqrt(A**2 + B**2 -2*A*B*math.cos(theta)))

Measured memory_bytes: 62060
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  int a[200000];
  int b[200000] = {};
  vector< int > p;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    p.push_back(i+1);
  }
  // vector< vector<int> > t(n);
  // for(int i = 0; i < n ; i++){
  //   int k = n-i;
  //   for(int j = p.size()-1; j >= 0; j--){
  //     if(p[j] <= k) break;
  //     if(p[j] % k == 0){
  //       t[k-1].push_back(p[j]);
  //       p.erase(p.begin()+j);
  //     }
  //   }
  //   // for(int j = 0; j < t[k-1].size(); j++){
  //   //   cout << t[k-1][j] << " ";
  //   // }
  //   // cout << endl;
  // }
  //
  // for(int i = 0; i < n ; i++){
  //   for(int j = 0; j < t[n-i-1].size(); j++){
  //     b[n-i-1] = b[n-i-1] ^ b[t[n-i-1][j]-1];
  //   }
  //   b[n-i-1] = b[n-i-1] ^ a[n-i-1];
  // }

  for(int i = 0; i < n ; i++){
    for(int j = 2; (n-i) * j <= n; j++){
      b[n-i-1] = b[n-i-1] ^ b[(n-i)*j-1];
    }
    b[n-i-1] = b[n-i-1] ^ a[n-i-1];
  }


  int c = 0;
  for(int i = 0; i < n ; i++){
    if(b[i] == 1) c++;
  }
  cout << c << endl;
  for(int i = 0; i < n ;i++){
    if(b[i] == 1) cout << i+1 << " ";
  }
  cout << endl;
}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod = 1e9+9;
const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    vi vec(n);
    rep(i,n) cin >> vec[i];

    sort(vec.rbegin(), vec.rend());
    int A_MAX = vec[0];
    double r = (double)A_MAX / 2;
    double res = 1e9;
    int index;
    rep(i,n){
        if (fabs(vec[i] - r) < res && A_MAX > vec[i]){
            res = abs(vec[i] - r);
            index = vec[i];
        }
    }
    printf("%d %d\n", A_MAX, index);
    return 0;
}


Measured memory_bytes: 3704
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	vi v(3);
	rep(i, 3) cin >> v[i];
	sort(all(v));
	if (v[0] == 5 && v[1] == 5 && v[2] == 7) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)

	height := scanIntSlice(n)
	routes := map[int][]int{}

	for j := 1; j <= m; j++ {
		var a, b int
		fmt.Scanf("%d %d", &a, &b)
		if _, ok := routes[a]; !ok {
			routes[a] = []int{}
		}
		if _, ok := routes[b]; !ok {
			routes[b] = []int{}
		}
		routes[a] = append(routes[a], b)
		routes[b] = append(routes[b], a)
	}

	count := 0
	for i := 1; i <= n; i++ {
		good := true
		if _, ok := routes[i]; ok {
			for _, n := range routes[i] {
				if height[i-1] <= height[n-1] {
					good = false
				}
			}
		}
		if good {
			count++
		}
	}

	fmt.Printf("%d\n", count)
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 18976
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int k,s;
  cin>>k>>s;
  int count=0;
  for(int a=0;a<=k;a++){
    for(int b=0;b<=k;b++){
      if(s-a-b>=0&&s-a-b<=k){
        count++;
      }
    }
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int D[10]={0},N;

bool takeDigit(ll num){
  while(num!=0){
    if(D[num%10]==1) break;
    num/=10;
  }
  if(num!=0) return false;
  else return true;
}

int main(){
  int K,data;
  cin>>N>>K;
  for(int i=0;i<K;i++){
    cin>>data;
    D[data]++;
  }

  ll ans=N;

  while(true){
    if(takeDigit(ans)) break;
    ans++;
  }

  cout<<ans<<endl;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
//const int MOD =  (int)1e9 + 7;
const int MOD = 998244353;
const double EPS = 1e-9;

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

	int N;
	cin >> N;
	vector<string> S(N);
	vector<pair<int, pii>> PV;
	rep(i, 0, N)
	{
		cin >> S[i];
		int L = 0, R = 0;
		rep(j, 0, SZ(S[i]))
		{
			if (S[i][j] == '(')R++;
			else
			{
				if (R > 0)R--;
				else L++;
			}
		}
		PV.push_back(mp(R - L, mp(-L, R)));
	}

	sort(all(PV), greater<pair<int,pii>>());

	int lidx = -1, ridx = -1;
	rep(i, 0, N)
	{
		if (PV[i].second.first == 0)
		{
			lidx = i;
			break;
		}
	}
	rrep(i, 0, N)
	{
		if (PV[i].second.second == 0)
		{
			ridx = i;
			break;
		}
	}

	if (lidx == -1 || ridx == -1 || lidx == ridx)
	{
		cout << "No" << endl;
		return 0;
	}

	int R = PV[lidx].second.second;
	rep(i, 0, N)
	{
		if (i == lidx || i == ridx)continue;
		R += PV[i].second.first;
		if (R < 0)
		{
			cout << "No" << endl;
			return 0;
		}
		R += PV[i].second.second;
	}
	R += PV[ridx].second.first;
	if (R == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 59064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Inarr(a,n) for(ll i=0;i<n;i++)cin>>a[i]
const ll INF=1e18;
int main(){
    ll n,ans=0;
    cin>>n;
    vector<ll>b(n);
    Inarr(b,n-1);
    ans=2*b[0];
    for(int i=1;i<n-1;i++){
        if(b[i-1]>b[i]){
            ans-=b[i-1];
            ans+=b[i];
        }
        ans+=b[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>

#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong A,B,C;
    cin >> A >> B >> C;
    llong ans=0;
    llong total = 0;
    while(1){
        ans++;
        total = total + A;
        if(ans%7==0){
            total = total + B;
        }
        if(total>=C){
            break;
        }
    }
    cout << ans << endl;
    return 0;
}






Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N>>M;
    vector<vector<ll>>s(M);
    vector<ll>p(M);

    rep(i,M){
        ll k;
        cin>>k;
        rep(j,k){
            ll a;
            cin>>a;
            a--;
            s[i].pb(a);
        }
    }

    rep(i,M){
        cin>>p[i];
    }
    ll ans =0;
    rep(bit,1<<N){
        vector<bool>S(N);
        rep(i,N){
            if((bit>>i)&1){
                S[i]=1;
            }
        }

        rep(i,M){
            bool now=0;
            rep(j,s[i].size()){
                now ^= S[s[i][j]];
            }
            if(now!=p[i]){
                break;
            }
            if(i==M-1){
                ans++;
            }
        }

    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3580
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long, long long>;

ll gcd(ll a,ll b){
  if(a%b==0)return b;
  return gcd(b,a%b);
}

using namespace std;

vector<ll> list_mod_inverse(ll n, ll m)
{
    vector<ll> inv(n + 1);
    inv[1] = 1;
    for (int i = 2; i <= n; ++i)
        inv[i] = inv[m % i] * (m - m / i) % m;
    return inv;
}

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

  ll n;
  std::cin>>n;

  ll prev;
  std::cin>>prev;
  std::vector<ll> x(n-1);
  rep(i,0,n-1){
    ll temp;
    std::cin>>temp;
    x[i]=(temp-prev)%MOD;
    prev=temp;
  }

  std::vector<ll> inv=list_mod_inverse(n+2,MOD);

  std::vector<ll> sum(n+2);

  sum[1]=inv[1];
  rep(i,2,n+2)sum[i]=(sum[i-1]+inv[i])%MOD;

  ll ans=0;

  rep(i,1,n){
    ll temp=x[i-1];
    temp=(temp*sum[i])%MOD;
    ans=(ans+temp)%MOD;
  }

  rep(i,1,n)ans=(ans*i)%MOD;

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define FTEST int testcase;fin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define plii pair<ll,pii>
#define no {cout<<"no"<<endl;return;}
#define yes {cout<<"yes"<<endl;}
#define rep(i,N) for(int i=0;i<N;i++)
const int maxn=1e6;
const int mod=998244353;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve(){

    string s;cin>>s;
    int n=s.size();
    if(s[n-1]=='s') s+="es";
    else s+='s';
    cout<<s;
    return;
}

int main(){
    IO
    solve();

    return(0);
}



Measured memory_bytes: 3648
#include<iostream>

using namespace std;

int main (void){
    int a,b,c,x;
    int count=0;
    cin>>a>>b>>c>>x;
    
    for(int i=0;i<=a;i++){
        int ans=x;
        ans=ans-500*i;
        if(ans==0)count++;
     //   cout<<ans<<endl;
        if(ans>0){
            for(int j=0;j<=b;j++){
                ans=x-500*i;
                ans=ans-100*j;
            //    cout<<ans<<endl;
                if(ans==0)count++;
                if(ans>0){

                
                    for(int k=0;k<=c;k++){
                        ans=x-500*i-100*j;
                        ans=ans-50*k;
                        if(ans==0)count++;
                      //   cout<<ans<<endl;
                    }
                }
            }
        }
     
    }

    cout<<count;

    return 0;
}

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

using namespace std;

int X[110],Y[110],H[110];
int G[110][110];
int main()
{
    int N;
    cin >> N;
    for(int x = 0 ; x <= 100 ; x++)
    {
        for(int y = 0 ; y <= 100 ; y++)
        {
            G[x][y] = -1;
        }
    }
    for(int i = 0 ;i < N ; i++)
    {
        cin >> X[i] >> Y[i] >> H[i];
        G[X[i]][Y[i]] = H[i];
    }
    int ansx,ansy,ansh;
    for(int x = 0 ; x <= 100 ; x++)
    {
        for(int y = 0 ; y <= 100 ; y++)
        {
            if(G[x][y] == 0){
                continue;
            }
            int h,ans = 0;
            //
            bool can = true;
            for(int i = 0 ; i < N ; i++)
            {
                if(H[i] == 0)continue;
                if(ans == 0){
                    ans =  H[i] + abs(x-X[i]) + abs(y-Y[i]);
                }
                h = H[i] + abs(x-X[i]) + abs(y-Y[i]);
                if(h!=ans)
                {
                    can = false;
                }
            }
            if(can)
            {
                for(int i = 0 ; i < N ; i++)
                {
                    if(H[i] == 0)
                    {
                        if(h-abs(X[i]-x)-abs(Y[i]-y)>0)
                        {
                            can = false;
                        }
                    }
                }
            }
            if(can)
            {
                ansx = x;
                ansy = y;
                ansh = h;
            }
        }
    }
    cout<<ansx<<" "<<ansy<<" "<<ansh<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define EPS 1e-10
using namespace std;
typedef long long ll;

struct point { double x, y; };
struct line { point p, q; };

int N;
line L[100];

bool intersect(line l1, line l2) {
  double ax = l1.p.x, ay = l1.p.y;
  double bx = l1.q.x, by = l1.q.y;
  double cx = l2.p.x, cy = l2.p.y;
  double dx = l2.q.x, dy = l2.q.y;
  double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
  double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
  double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
  double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
  return tc * td < 0 && ta * tb < 0;
}

double distance(line l, point p) {
  double ux = l.q.x - l.p.x;
  double uy = l.q.y - l.p.y;
  double vx = p.x - l.p.x;
  double vy = p.y - l.p.y;
  double cross = abs(ux * vy - uy * vx);
  double ul = sqrt(ux * ux + uy * uy);
  return cross / ul;
}

double distance(point p, point q) {
  double dx = q.x - p.x;
  double dy = q.y - p.y;
  return sqrt(dx * dx + dy * dy);
}

int main(void) {
  while(cin >> N, N) {
    REP(i, 0, N) cin >> L[i].p.x >> L[i].p.y >> L[i].q.x >> L[i].q.y;

    ll ans = 1;
    REP(i, 0, N) {
      vector<point> v;
      ll p = 0;
      REP(j, 0, i) if(intersect(L[i], L[j])) {
        double a = distance(L[i], L[j].p);
        double b = distance(L[i], L[j].q);
        double c = a / (a + b);
        double d = b / (a + b);
        double x = L[j].p.x * d + L[j].q.x * c;
        double y = L[j].p.y * d + L[j].q.y * c;
        point z = (point) { x, y };
        bool f = true;
        REP(k, 0, v.size()) if(distance(v[k], z) <= EPS) {
          f = false;
          break;
        }
        if(f) {
          v.push_back(z);
          p++;
        }
      }
      ans += p + 1;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3212
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String word  = sc.next();
        String targetWord = word;
        int count = 0;
        while(!(word.equals("END_OF_TEXT"))){
            word = sc.next();
            if(word.equalsIgnoreCase(targetWord)){
                count++;
            }
        }
        System.out.println(count);
        sc.close();
    }
}


Measured memory_bytes: 26140
#include <stdio.h>
#include <string.h>

#define MOD (100000007);
typedef long long ll;

ll dp[6][100001];

ll divide(char prev, int count)
{
    int limit;
    ll ans;
    
    limit = 5;
    
    if (prev == '0' || prev == '8'){
        limit = 3;
    }
    
    ans = 0;
    
    while (count > 0){
        ans = (ans + dp[limit][count]) % MOD;
        count -= limit;
    }
    
    return (ans);
}

int main()
{
	static char str[100001];
	int i, j;
	int count;
	char prev;
	ll ans;
	
    dp[3][0] = dp[5][0] = 1;
    
    for (i = 1; i <= 100000; i++){
        for (j = 1; j <= 5; j++){
            if (i - j >= 0){
                dp[5][i] = (dp[5][i] + dp[5][i - j]) % MOD;
            }
        }
        for (j = 1; j <= 3; j++){
            if (i - j >= 0){
                dp[3][i] = (dp[3][i] + dp[3][i - j]) % MOD;
            }
        }
    }
    
	while (1){
		scanf("%s", str);
		if (str[0] == '#'){
			break;
		}
		
		ans = 1;
		prev = str[0];
		count = 1;
		i = 1;
		
		while (str[i] != '\0'){
			if (str[i] == prev){
				count++;
			}
			else {
				ans = (ans * divide(prev, count)) % MOD;
				prev = str[i];
				count = 1;
			}
			i++;
		}
        
		ans = (ans * divide(prev, count)) % MOD;
		printf("%lld\n", ans);
	}
	return (0);
}

Measured memory_bytes: 2076
#include<iostream>
using namespace std;
int main(){
  int X,Y,N;
  bool flag=false;
  cin >> N;

  for(int i=0;i<26;++i){
    for(int j=0;j<15;++j){
      if(4*i+7*j==N && flag == false){
        cout << "Yes" << endl;
        flag = true;
      }
    }
  }

  if(flag==false){
    cout <<"No"<<endl;
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll pow(ll n,ll k){
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    mod_build(202020);
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    --n;--m;
    --b;
    ll ans=comb(n+m,m);
    rep(i,a){
        ans+=mod-comb(b+n-i,b)*comb(m-b+i-1,m-b-1)%mod;
    }
    cout<<ans%mod<<endl;
    return 0;
}

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

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

  vector<vector<int>> jobs(m);

  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    if (a > m) continue;
    jobs.at(a - 1).push_back(b);
  }
    
  
  priority_queue<int> gain;
  int ans = 0;
  for (int i = 0; i < m; ++i) {
    for (auto x : jobs.at(i))
      gain.push(x);
    if (gain.empty()) continue;
    ans += gain.top();
    gain.pop();
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5632
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws ParseException {
    try (Scanner sc = new Scanner(System.in);) {
      String input = sc.next();

      SimpleDateFormat sdFormat1 = new SimpleDateFormat("yyyy/MM/dd");
      Date date = sdFormat1.parse(input);

      SimpleDateFormat sdFormat2 = new SimpleDateFormat("yyyy/MM/dd");
      Date heiseiDate = sdFormat2.parse("2019/04/30");

      String answer = heiseiDate.compareTo(date) < 0 ? "TBD" : "Heisei";
      System.out.println(answer);
    }
  }
}

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> x(n);
  for (int i = 0; i < n; i++)
    cin >> x[i];
  vector<int> s = x;
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++)
    if (x[i] < s[(n + 1) / 2])
      cout << s[(n + 1) / 2] << endl;
    else
      cout << s[(n + 1) / 2 - 1] << endl;

  return 0;
}


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

using namespace std;

bool Compare(pair<pair<string,int>,int> front, pair<pair<string,int>, int> back) {
	if (front.first.first == back.first.first) {
		return front.first.second > back.first.second;
	}
	else {
		return front.first.first < back.first.first;
	}
}

int main() {
	int n,i;
	cin >> n;
	vector<pair<pair<string, int>,int>> sp(n);
	for (i = 0; i < n; i++) {
		cin >> sp[i].first.first >> sp[i].first.second;
		sp[i].second = i + 1;
	}
	sort(sp.begin(), sp.end(), Compare);
	for (i = 0; i < n; i++) {
		cout << sp[i].second << endl;
	}
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())
a = abs(a)
if b*c <= a:
    print(a-b*c)
else:
    kaisuu = a//c
    saisyo = a % c
    b = b-kaisuu
    if b % 2 == 1:
        print(abs(c-saisyo))
    else:
        print(abs(saisyo))


Measured memory_bytes: 61740