akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
station = [nil]

(n-1).times do
  station.push(gets.chomp.split(' ').map(&:to_i).unshift(nil))
end
arr = []
for i in 1..(n-1)
  station[i]
  time = 0
  # 出発駅の待ち時間を足す
  time+=station[i][2]
  # 次の駅に向かう
  time+=station[i][1]
  # i+1からn-1まで駅操作を繰り返す
  for j in (i+1)..(n-1)
    # 時間が当駅の出発時間に満たなかったとき、時間を出発時間に変更
    time = station[j][2] if time < station[j][2]
    unless time%station[j][3] == 0
     # 発車間隔まで待つ
     time+=station[j][3]-time%station[j][3]
    end
    time+= station[j][1]
  end
  arr.push(time)
end

arr.push(0)
arr.each{|a|puts a}

Measured memory_bytes: 1916
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    N = Scanner.int()

    S = N * (N + 1) // 2
    a = N // 3
    A = a * (a + 1) // 2 * 3
    b = N // 5
    B = b * (b + 1) // 2 * 5
    c = N // 15
    C = c * (c + 1) // 2 * 15
    print(S - A - B + C)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10572
A = list(map(int, input().split())) 
B = A[0]
C = A[1]

BB = []
CB = []

def myfunc(X, XX):
  for num in range(2, X+1):
    if(X%num == 0):
      XX.append(num)
      BA = int(X/num)
      myfunc(BA, XX)
      break

myfunc(B, BB)
myfunc(C, CB)

for num1 in BB:
  for num2 in range(len(CB)):
    if num1 == CB[num2]:
      CB.pop(num2)
      break

BB.extend(CB)

ANSWER = 1

for num in BB:
  ANSWER = num * ANSWER

print(ANSWER)

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

const int MAX_V = 300;

int V;
bool G[MAX_V][MAX_V];
int match[MAX_V];
bool used[MAX_V];

bool dfs(int v) {
	used[v] = true;
	for(int i = 0; i < V; i++) {
		if(!G[v][i]) continue;
		int u = i, w = match[u];
		if(w < 0 || (!used[w] && dfs(w))) {
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

int bipartite_matching() {
	int res = 0;
	memset(match, -1, sizeof(match));
	for(int v = 0; v < V; v++) {
		if(match[v] < 0) {
			memset(used, 0, sizeof(used));
			if(dfs(v)) {
				res++;
			}
		}
	}
	return res;
}

int N, M;
int xa[100], ya[100], xb[100], yb[100], v[100];

bool check(double k) {
	memset(G, 0, sizeof G);
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < M; j++) {
			double d = sqrt((xa[i] - xb[j]) * (xa[i] - xb[j]) + (ya[i] - yb[j]) * (ya[i] - yb[j]));
			G[i][j + N] = G[j + N][i] = (d / v[i]) <= k;
		}
	}

	return bipartite_matching() == M;
}

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

	while(cin >> N >> M, N) {
		V = N + M;
		for(int i = 0; i < N; i++) {
			cin >> xa[i] >> ya[i] >> v[i];
		}
		for(int i = 0; i < M; i++) {
			cin >> xb[i] >> yb[i];
		}

		double ng = 0, ok = 1e9;
		for(int loop = 0; loop < 100; loop++) {
			double mid = (ng + ok) / 2.0;
			if(check(mid)) ok = mid;
			else ng = mid;
		}
		cout << fixed << setprecision(10) << ok << endl;
	}
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll n, k;
  string str;
  cin >> n >> str >> k;
  for(i = 0; i < n; i++){
    if(str[i] != str[k - 1])
      str[i] = '*';
  }
  cout << str << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<28));
const ll linf = (1LL<<58);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b ,c, k;
    cin >> a >> b >> c >> k;
    if(k<=a) cout << k;
    else if(k<=a+b) cout << a << endl;
    else cout << a-(k-a-b) << endl;
    return 0;
}



Measured memory_bytes: 3640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(true) {
			int n=in.nextInt(),l=in.nextInt();
			if(n==0)break;
			List<Integer> A=new ArrayList<>();
			for(int i=0;i<n;i++)A.add(Integer.parseInt(in.next()));
			Collections.sort(A,Collections.reverseOrder());
			int max=0;
			for(int i=0;i<n-1;i++) {
				for(int j=i+1;j<n;j++) {
					int sum=A.get(i)+A.get(j);
					if(sum<=l)max=Math.max(max,sum);
				}
			}
			
			if(max>0)System.out.println(max);
			else System.out.println("NONE");
		}
		
	}

}



Measured memory_bytes: 42964
from collections import defaultdict
H,W,N=map(int,input().split())
ans=[0 for i in range(10)]

data=defaultdict(int)
def check(a,b):
    if a>0 and a<H-1 and b>0 and b<W-1:return True
    else:return False

def count(a,b):
    for i in range(a-2,a+1):
        for j in range(b-2,b+1):
            if check(i,j):
                x=(i,j)
                data[x]+=1
                
for k in range(N):
    a,b=map(int,input().split())
    count(a,b)

for v in data.values():
    ans[v]+=1

ans[0]=(H-2)*(W-2)-sum(ans[1:])
for i in range(10):
    print(ans[i])
    
#http://arc061.contest.atcoder.jp/data/arc/061/editorial.pdf
#https://atcoder.jp/contests/abc045/submissions/4024831
#https://atcoder.jp/contests/abc045/submissions/4017890

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

int main()
{
    int n;
    float sum=0;
    scanf("%d",&n);
    while(n--)
    {
        float x;
        string u;
        cin>>x>>u;
        if(u=="BTC")
            sum+=x*380000.0;
        else
            sum+=x;
    }
    cout<<sum;
    return 0;
}


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

int main(){
  int n,k,m;
  while(cin>>n>>k>>m){
    if(n==0)break;
    vector<int> stone;
    for(int i=0;i<n;i++){
      stone.push_back(i+1);
    }
    int eraseNum=m-1;
    stone.erase(stone.begin() + eraseNum);
    while(stone.size()!=1){
      eraseNum+=k-1;
      eraseNum = eraseNum % stone.size();
      stone.erase(stone.begin() + eraseNum);
    }
    cout << stone[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 1324
s=input()
k=int(input())
n=len(s)
count=[]
for i in range(k):
    count.append('zzzzz')
for i in range(n):
    for j in range(k):
        for l in range(k):
            if s[i:i+j+1]==count[l]:
                break
            elif s[i:i+j+1]<count[l]:
                for m in range(k-1,l,-1):
                    count[m]=count[m-1]
                count[l]=s[i:i+j+1]
                break
print(count[k-1])


Measured memory_bytes: 40048
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <complex>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
int LCM(int a,int b){
	if(a%b) return LCM(b,a%b);
    return b;
}
int main() {
	int A,B,C,N;
	while(cin >>N){
	cin >> A >>B;
	if(N==3){
	cin >> C;
	B=LCM(B,C);
	}
	deque<int> divider;
	int D=LCM(A,B);
	for(int i=1;i*i<=D;i++)
		if(D%i==0){
			cout << i << endl; 
			divider.push_front(D/i);
		}
	REP(i,divider.size())
		if(divider[i]*divider[i]!=D)
		cout << divider[i] << endl;
	}
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,a;cin>>n>>a;
  vector<pair<int,int> >we(n);
  vector<int>nage(n);
  for(int i=0;i<n;i++){
    int aa,aaa;cin>>aa>>aaa;
    we[i]=mp(aa,aaa);
    nage[i]=aaa;
  }
  sort(we.begin(),we.end());
  sort(nage.begin(),nage.end());
  int cnt=0;
  while(nage[cnt]<=we[we.size()-1].F)cnt++;
  int ans=0;
  for(int i=nage.size()-1;i>=cnt;i--){
    a-=nage[i];ans++;
    if(a<=0)break;
  }
  if(a>0){
    if(a%we[we.size()-1].F==0)
      ans+=a/we[we.size()-1].F;
    else
      ans+=a/we[we.size()-1].F+1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1408
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()

fun main(args: Array<String>) {
    var aEnd = Int.MIN_VALUE
    var aStart = Int.MAX_VALUE

    for (i in 1..N) {
        val a = sc.nextInt()
        aEnd = Math.max(aEnd, a)
        aStart = Math.min(aStart, a)
    }
    println(aEnd - aStart)
}


Measured memory_bytes: 29348
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
string S;
  cin>>S;
  for(ll i=0;i<3;i++) {
    if(S[i]=='1') {
      S[i]='9';
    }
    else if(S[i]=='9') {
      S[i]='1';
    }
  }
  
  cout<<S<<endl;
}

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

const long double PI = acos(-1);
 
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); }

bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

int main(){
    double a, b, x;
    double ans = 0, rad = 0;
    cin >> a >> b >> x;

    double s = x / a;
    if (s >= a * b / 2){
        double h = ((a * b - s) * 2) / a;
        rad = atan2(h, a);
    }else{
        double w = (2 * s) / b;
        rad = atan2(b, w);
    }
    ans = rad/(2*PI)*360;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 384
<?php
// Here your code !
$stdin = trim(fgets(STDIN));
 
$nums = explode(' ', $stdin);
 
$W = (int)$nums[0];
 
$H = (int)$nums[1];
 
$x = (int)$nums[2];
 
$y = (int)$nums[3];
 
$r = (int)$nums[4];

$is_x = (($x + $r) <= $W) && (($x - $r) >= 0);

$is_y = (($y + $r) <= $H) && (($y - $r) >= 0);
if ($is_x && $is_y){
echo 'Yes',PHP_EOL;
} else {
echo 'No',PHP_EOL;
}

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

int main(){
	int N , cnt = 0 , A; cin >> N;
	for(int i = 1 ; i <= N ; ++i){cin >> A; cnt += A & 1;}
	puts(cnt & 1 ? "NO" : "YES"); return 0;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{

    int s1, h ,m ,s2;

    scanf("%d",&s1);
    
    h = s1 / 3600;
    m = (s1 - h * 3600) / 60;
    s2 = s1 - 3600 * h - 60 * m;

    printf("%d:%d:%d\n",h, m, s2);

    return 0;
}


Measured memory_bytes: 2140
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "abc169_a.cpp"

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
}


Measured memory_bytes: 3652
def solve():
    A, B, C, D = map(int, input().split())
    ans = B-A+1
    gcd_CD = gcd(C, D)
    CD = (C//gcd_CD)*(D//gcd_CD)*gcd_CD
    ans -= (B//C-(A-1)//C)
    ans -= (B//D-(A-1)//D)
    ans += (B//CD-(A-1)//CD)
    print(ans)


def gcd(a: int, b: int) -> int:
    if b == 0:
        return a
    return gcd(b, a % b)


solve()


Measured memory_bytes: 38324
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;
using ll = long long;

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

  vector<pair<ll, ll>> v;
  rep(i,0,N-1) {
    ll price, num;
    cin >> price >> num;
    v.push_back(make_pair(price, num));
  }
  sort(v.begin(), v.end());

  ll ans = 0, cnt = 0;
  rep(i,0,N-1) {
    pair<int, int> p = v[i];
    ll price = p.first, num = p.second;
    if (cnt + num < M) {
      ans += price * num;
      cnt += num;
    } else {
      while (0 < num && cnt < M) {
        ans += price;
        num--;
        cnt++;
      }
    }
  }

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


Measured memory_bytes: 2420
/*
二部グラフになるように色を付ける。
不可能ならば空vectorを返す

0 or 1で色を付ける
-1は頂点0とつながってない部分

vector<int>();

GはGraphを想定
WeightGraphの場合は//+++++の部分を変える必要がある

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

using pii=pair<int,int>;

using Graph=vector<vector<int>>;

template<typename G>
vector<int> bipartite(const G &g){
    vector<int> color(g.size(),-1);
    stack<pii> st;
    st.push({0,0});
    while(!st.empty()){
        int idx,nc;
        tie(idx,nc)=st.top();
        st.pop();
        color[idx]=nc;
        for(auto next:g[idx]){
            if(color[next]==-1){
                st.push({next,nc^1});  //++++++++++++++++++++
            }else{
                if(color[next]!=nc^1) return vector<int>();  //+++++++++++
            }
        }
    }
    return color;
}



signed main(){
	int n;
	cin>>n;
	Graph g(n);

	for(int i=1;i<n;i++){
		int a,b;
		cin>>a>>b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	auto color=bipartite(g);

	//vout(color);
	int cnt0=0,cnt1=0;
	int num0=0,num1=1;
	for(int i=0;i<n;i++){
		if(color[i]==0) cnt0++;
		else cnt1++;
	}
	vector<int> ret(n);
	if(cnt0>cnt1) swap(cnt1,cnt0),swap(num1,num0);
	vector<int> v0,v1;
	if(cnt0<=n/3){
		for(int i=0;i<n/3;i++){
			if(i<cnt0) v0.push_back(3*(i+1));
			else v1.push_back(3*(i+1));
		}
		for(int i=1;i<=n;i++){
			if(i%3==0) continue;
			v1.push_back(i);
		}
	}else{
		int now=1;
		for(int i=1;i<=n;i++){
			if(i%3==1) v0.push_back(i);
			else if(i%3==2) v1.push_back(i);
		}
		for(int i=0;i<cnt0-(n+2)/3;i++){
			v0.push_back(now*3);
			now++;
		}
		for(int i=0;i<cnt1-(n+1)/3;i++){
			v1.push_back(now*3);
			now++;
		}
	}
	int now0=0,now1=0;
	for(int i=0;i<n;i++){
		if(num0==color[i]){
			cout<<v0[now0]<<endl;
			now0++;
		}else{
			cout<<v1[now1]<<endl;
			now1++;
		}
	}
}

Measured memory_bytes: 16756
from collections import Counter
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
dic = Counter(a)
q = int(input())
bs = []
cs = []
for _ in range(q):
    b, c = map(int, input().split())
    bs.append(b)
    cs.append(c)

ans = 0
for k, v in dic.items():
    ans += k * v

for i in range(q):
    b = bs[i]
    c = cs[i]
    b_num = dic.get(b, 0)
    ans = ans + (c - b) * b_num
    dic[c] = dic.get(c, 0) + dic.get(b, 0)
    dic[b] = 0
    print(ans)


Measured memory_bytes: 94220
// 2011/03/05 Tazoe

#include <iostream>
using namespace std;

struct point{
	int x;
	int y;
};

bool DFS(struct point phy, int n, struct point spr[10], int i_main)
{
	if(i_main==n)
		return true;

	struct point phy2[12];
	phy2[0].x  = phy.x-1;  phy2[0].y  = phy.y-2;
	phy2[1].x  = phy.x  ;  phy2[1].y  = phy.y-2;
	phy2[2].x  = phy.x+1;  phy2[2].y  = phy.y-2;
	phy2[3].x  = phy.x+2;  phy2[3].y  = phy.y-1;
	phy2[4].x  = phy.x+2;  phy2[4].y  = phy.y  ;
	phy2[5].x  = phy.x+2;  phy2[5].y  = phy.y+1;
	phy2[6].x  = phy.x+1;  phy2[6].y  = phy.y+2;
	phy2[7].x  = phy.x  ;  phy2[7].y  = phy.y+2;
	phy2[8].x  = phy.x-1;  phy2[8].y  = phy.y+2;
	phy2[9].x  = phy.x-2;  phy2[9].y  = phy.y+1;
	phy2[10].x = phy.x-2;  phy2[10].y = phy.y  ;
	phy2[11].x = phy.x-2;  phy2[11].y = phy.y-1;

	for(int i=0; i<12; i++){
		if(phy2[i].x<0||phy2[i].x>9||phy2[i].y<0||phy2[i].y>9)
			continue;

		for(int j=-1; j<=1; j++)
			for(int k=-1; k<=1; k++)
				if(phy2[i].x==spr[i_main].x+j&&phy2[i].y==spr[i_main].y+k)
					if(DFS(phy2[i], n, spr, i_main+1))
						return true;
	}

	return false;
}

int main()
{
	while(true){
		struct point phy;
		cin >> phy.x >> phy.y;
		if(phy.x==0&&phy.y==0)
			break;

		int n;
		cin >> n;

		struct point spr[10];
		for(int i=0; i<n; i++)
			cin >> spr[i].x >> spr[i].y;

		if(DFS(phy, n, spr, 0))
			cout << "OK" << endl;
		else
			cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

typedef long long LL;
typedef vector<LL> VL;
typedef vector<vector<LL>> VVL;
typedef vector<string> VS;

#define REPD(i,a,b) for (LL i=(a);i<(b);i++)
#define REP(i,n) REPD(i,0,n)

LL llRead(){
  LL a;
  cin >> a;
  return a;
};

string stringRead(){
  string a;
  cin >> a;
  return a;
};

vector<LL> vlRead(LL a){
  vector<LL> rv;
  REP(i, a){
    LL input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

vector<string> vsRead(LL a){
  vector<string> rv;
  REP(i, a){
    string input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}
vector<vector<LL>> vvlRead(LL a, LL b){
  vector<vector<LL>> rv;
  REP(i, a){
    rv.push_back(vector<LL>());
    REP(j, b) {
      LL input;
      cin >> input;
      rv.at(i).push_back(input);
    }
  }
  return rv;
}

#if 1
#define debug(d) debug1(__LINE__,#d, d)
void debug1(LL line, const char* name, VL& v) {
  cout << line << ":" << name << ":vector<LL>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, LL i) {
  cout << line << ":" << name << ":LL " << i << endl;;
}
void debug1(LL line, const char* name, VS& v) {
  cout << line << ":" << name << ":vector<string>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, VVL& v) {
  cout << line << ":" << name << ":vector<vector<LL>>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    REP(j, (LL)v.at(i).size()) {
      cout << v.at(i).at(j) << " ";
    }
    cout << ", ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, char* s) {
  cout << line << ":" << name << ":char* " << s << endl;;
}
void debug1(LL line, const char* name, vector<const char*>& v) {
  cout << line << ":" << name << ":vector<const char*>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, priority_queue<LL>& p) {
  cout << line << ":" << name << ":priority_queue<LL>(" << p.size() << ") ";
  priority_queue<LL> copy = p;
  while(!copy.empty()) {
    cout << copy.top() << " ";
    copy.pop();
  }
  cout << endl;
}
#else
#define debug(n)
#endif

int main(int argc, const char * argv[]) {
	cout.precision(16);
  // source code

  auto n = llRead();
  auto ds = vlRead(n);

  LL s = 0;
  REP(i,n-1) {
    REPD(j, i+1,n) {
      s += (ds.at(i) * ds.at(j));
    }
  }
  cout << s << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()





int main() {
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){return modpow(x,mod-2);}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    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;
}
int n,a[200010];
int cnt[200010];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<n;i++){
        cin>>a[i];
        a[i]--;
        cnt[a[i]]++;
    }
    rep(i,n)cout<<cnt[i]<<endl;
    return 0;
}


Measured memory_bytes: 6736
import math,sys

def hantei(x):
  for i in range(2, math.ceil(math.sqrt(x))):
    if x % i == 0:
      return False
    
  return True

x = int(input())

while True:
  if hantei(x):
    print(x)
    sys.exit(0)
    
  x += 1
  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s;
	cin >> s;
	stack<char> st;
	int ans = 0;
	rep(i, s.size()){
		char now = s.at(i);
		if(st.empty() || st.top() == now) st.push(now);
		else{
			st.pop();
			ans += 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        double l,ans;

        l=sc.nextDouble();
        l/=3;
        ans=l*l*l;

        System.out.println(String.format("%.7f",ans));
        sc.close();
    }
}

Measured memory_bytes: 23120
#include<bits/stdc++.h>
using namespace std;
int res=-1;
int cnt=0;
int main()
{
	int x;
	cin>>x;
	int a[100005];
	for(int i=0;i<x;i++)
	{
		cin>>a[i];
		res=max(res,a[i]);
	}
	for(int j=0;j<x;j++)
	{
		if(a[j]==res)
		{
			a[j]=0;
			break;
		}
	}
	for(int k=0;k<x;k++)
	{
		cnt+=a[k];
	}
	if(res<cnt)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 2100000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
ll get(ll a, ll b, ll c, ll d)
{
	return com(c - a + d - b, c - a);
}
ll solve(ll ax, ll ay, ll bx, ll by, ll lx, ll ly, ll ux, ll uy)
{
	ll now = get(ax, ay, lx, ly)*get(lx, ly, bx, by) % mod;
	ll ret = 0;
	for (ll i = lx + ly; i <= ux + uy; i++)
	{
		ret += now;
		if (i <= ly + ux - 1)
		{
			now += get(ax, ay, i - ly + 1, ly - 1)*get(i - ly + 1, ly, bx, by);
			now %= mod;
		}
		else
		{
			now += mod - get(ax, ay, ux, i - ux)*get(ux + 1, i - ux, bx, by) % mod;
			now %= mod;
		}
		if (i <= lx + uy - 1)
		{
			now += get(ax, ay, lx - 1, i - lx + 1)*get(lx, i - lx + 1, bx, by);
			now %= mod;
		}
		else
		{
			now += mod - get(ax, ay, i - uy, uy)*get(i - uy, uy + 1, bx, by) % mod;
			now %= mod;
		}
	}
	return ret%mod;
}
typedef pair<ll, ll>pii;
int main()
{
	invinit();
	ll xa, xb, xc, xd, xe, xf;
	ll ya, yb, yc, yd, ye, yf;
	scanf("%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld", &xa, &xb, &xc, &xd, &xe, &xf, &ya, &yb, &yc, &yd, &ye, &yf);
	xa--, ya--, xf++, yf++;
	ll ans = 0;
	ans += solve(xa, ya, xe, ye, xc, yc, xd, yd);
	ans -= solve(xa, ya, xe, yf, xc, yc, xd, yd);
	ans -= solve(xa, ya, xf, ye, xc, yc, xd, yd);
	ans += solve(xa, ya, xf, yf, xc, yc, xd, yd);
	ans -= solve(xa, yb, xe, ye, xc, yc, xd, yd);
	ans += solve(xa, yb, xe, yf, xc, yc, xd, yd);
	ans += solve(xa, yb, xf, ye, xc, yc, xd, yd);
	ans -= solve(xa, yb, xf, yf, xc, yc, xd, yd);
	ans -= solve(xb, ya, xe, ye, xc, yc, xd, yd);
	ans += solve(xb, ya, xe, yf, xc, yc, xd, yd);
	ans += solve(xb, ya, xf, ye, xc, yc, xd, yd);
	ans -= solve(xb, ya, xf, yf, xc, yc, xd, yd);
	ans += solve(xb, yb, xe, ye, xc, yc, xd, yd);
	ans -= solve(xb, yb, xe, yf, xc, yc, xd, yd);
	ans -= solve(xb, yb, xf, ye, xc, yc, xd, yd);
	ans += solve(xb, yb, xf, yf, xc, yc, xd, yd);
	printf("%lld\n", (ans + mod * 100) % mod);
}

Measured memory_bytes: 49408
<?php
$n=trim(fgets(STDIN));
$a = explode(" ",trim(fgets(STDIN)));
$ans=0;
while($n>0){
    $i=1;
    while($a[$n-1]%(pow(2,$i))==0){
        ++$i;
    }
    $ans+=$i-1;
    --$n;
}
echo $ans;

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1e9+7;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;


int main() {
	int H, W, h, w;

	cin >> H >> W >> h >> w;
	cout << H * W - (h * W + H * w - h * w) << endl;
	return 0;
}


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

int main( void )
{
    int r,g,b;
    cin >> r >> g >> b;
    
    int ans = g * 10 + b;
    if ( ans % 4 == 0 )
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fora(i,a,b) for(int i=a,Wub=b;i<Wub;++i)
#define ford(i,a,b) for(int i=a,Wub=b;i>=Wub;--i)
#define SPEEDIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 1000000
#define MOD 1073741824
using namespace std;
typedef long long ll;

int main(){
    char a,b;
    cin>>a>>b;
    if(a=='H'){
        cout<<b<<"\n";
    }else{
        if(b=='H')cout<<"D\n";
        else cout<<"H\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
int main(){
    long long int n,c;
cin>>n>>c;
long long int vals[n][2];
for (int i=0;i<n;i++)
{
    cin>>vals[i][0]>>vals[i][1];
}
long long int dp[n+1][c+1];
for (int i=0;i<=n;i++){
	for(int j=0;j<=c;j++){
		
		dp[i][j]=0;
	}
}
for (int i=1;i<n+1;i++){
	
	for(int j=1;j<c+1;j++){
		if (vals[i-1][0]>j){
			dp[i][j]=dp[i-1][j];
		}
		else{
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-vals[i-1][0]]+vals[i-1][1]);
		}
		
	}
	
}
cout<<dp[n][c];
}

Measured memory_bytes: 82344
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t


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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}
int main() {

	vector<Int> a(87);
	int n;
	a[0] = 2;
	a[1] = 1;
	for (int i = 2; i <= 86; i++) a.at(i) = a.at(i - 1) + a.at(i - 2);
	cin >> n;
	cout << a.at(n) << endl;
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}


int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    int a,b;
    cin>>a>>b;
    
    if(a>=13)cout<<b;
    else if(a<13 && a>=6)cout<<b/2;
    else cout<<0;
    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///priority_queue< int, vector< int >, greater< int > > minHeap;
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 256
D = int(input())#D=365
c = [0] + list(map(int, input().split()))#0<=c<=100
s = [0] + [[0] + list(map(int, input().split())) for _ in range(D)]#0<=s<=20000

t = [0] + [int(input()) for _ in range(D)]

M = int(input())
dq = [list(map(int, input().split())) for _ in range(M)]


held = [[0] for _ in range(27)]#選んだ日を保持
def culc_value(t):
    last = [0] * 27
    value = 0
    for d in range(1, D+1):
        type = t[d]
        held[type].append(d)
        value += s[d][type]
        last[type] = d
        for i in range(1, 27):
            value -= c[i] * (d - last[i])
    # 最終日+1 を追加、差分修正で前後見るときの後ろの最大値
    for i in range(1, 27):
        held[i].append(D+1)
    #print(held)
    return value


v_lastday = []
value = culc_value(t)

for d, q in dq:
    # 開催日の差分を修正
    value += - s[d][t[d]] + s[d][q]

    # dの前と後のq選択日のみ考えて、その間だけ修正する
    # 変換前のt[d]のマイナス計算を直す
    ind = held[t[d]].index(d)
    r = held[t[d]][ind+1]
    l = held[t[d]][ind-1]
    x = r - l
    value -= ((x + 1) * x // 2) * c[t[d]]
    y = d - l
    z = r - d
    value += (((y + 1) * y // 2) + (z + 1) * z // 2) * c[t[d]]

    del held[t[d]][ind]
    t[d] = q
    held[q].append(d)
    held[q] = sorted(held[q])
    #print(held[q])

    # 変換後のqのマイナス計算
    ind = held[q].index(d)
    r = held[q][ind+1]
    l = held[q][ind-1]
    x = r - l
    value += ((x + 1) * x // 2) * c[q]
    y = d - l
    z = r - d
    value -= (((y + 1) * y // 2) + (z + 1) * z // 2) * c[q]

    v_lastday.append(value)

for ans in v_lastday:
    print(ans)


Measured memory_bytes: 26064
#include <stdio.h>

int main(){

  int a,b,c;
  int cnt_c=0,cnt_h=0;
  while (scanf("%d,%d,%d",&a,&b,&c)!=EOF){
    if (a==b)
      cnt_h++;
    else if (c*c==a*a+b*b)
      cnt_c++;
  }
  printf("%d\n%d\n",cnt_c,cnt_h);

  return 0;
}

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

int main() {
  int N,X;
  cin >> N >> X;
  int sum = 0;
  vector<int> vec(N);
  for (int i=0;i<N;i++) {
    int m;
    cin >> m;
    vec.at(i) = m;
    sum += m;
  }
  sort(vec.begin(),vec.end());
  int mini = vec.at(0);
 
  cout << N + (X-sum)/mini << endl;
}



Measured memory_bytes: 256
words = {"resare" , "esare" , "remaerd" , "maerd",""}
s = input()
n = len(s)
now=""
f=0
s=s[::-1]
for i in range(0 ,n):
	now = now+s[i]
	if now in words:
		now = ""
if now in words:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 82016
using System;
 
class main{
  static void Main(string[] args){
    string[] s = Console.ReadLine().Split(" ");
    int first = int.Parse(s[0]);
    int second = int.Parse(s[1]);
    int third = int.Parse(s[2]);
    
    int ans = 0;
    
    for(int i = 0; i < 10; i++){
      ans = first * third - second;
      
      Console.WriteLine(ans);
      third = ans;
    }
  }
}

Measured memory_bytes: 27524
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
#define EPS 1e-8
#define equals(a,b) fabs((a) - (b)) < EPS

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

struct Point {
	double x, y;

	Point(double x=0, double y=0) : x(x), y(y) {}

	Point operator+(const Point &o) const { return Point(x+o.x, y+o.y); }

	Point operator-(const Point &o) const { return Point(x-o.x, y-o.y); }

	Point operator*(const double m) const { return Point(x*m, y*m); }

	Point operator/(const double d) const { return Point(x/d, y/d); }

	bool operator<(const Point &o) const { return x != o.x ? x < o.x : y < o.y; }

	bool operator==(const Point &o) const { return fabs(x-o.x) < EPS && fabs(y-o.y) < EPS; }

	double cross(const Point &o) const { return x * o.y - y * o.x; }

	double dot(const Point &o) const { return x * o.x + y * o.y; }

	double atan() const { return atan2(y, x); }

	double norm() const { return sqrt(dot(*this)); }

	double distance(const Point &o) const { return (o - (*this)).norm(); }

	double area(const Point &a,const Point &b) {
		Point p = a - (*this), p2 = b - (*this); 
		return p.cross(p2);
	}

	double area_abs(const Point &a,const Point &b) const {
		Point p = a - (*this), p2 = b - (*this);
		return fabs(p.cross(p2)) / 2.0;
	}	

	//??????ab?????????????????????????????????????????????????????????
	int between(const Point &a,const Point &b) {
		if(area(a,b) != 0) return 0;

		if(a.x != b.x)  return ((a.x <= x) && (x <= b.x)) || ((a.x >= x) && (x >= b.x));
		else return ((a.y <= y) && (y <= b.y)) || ((a.y >= y) && (y >= b.y));
	}      

	double distance_seg(const Point& a,const Point& b) {
		if((b-a).dot(*this-a) < EPS) {
			return (*this-a).norm();
		}
		if((a-b).dot(*this-b) < EPS) {
			return (*this-b).norm();
		}
		return abs((b-a).cross(*this-a)) / (b-a).norm();
	}
};

ostream& operator << (ostream& os, const Point& p) {
	os << "(" << p.x << ", " << p.y << ")";
	return os;
}

double polygonArea(const vector<Point>& p) {
	int n = p.size();
	double ret = 0.0;
	rep(i, n) {
		ret += p[i].cross(p[(i+1)%n]);
	}

	return abs(ret) / 2.0;
}

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

	vector<Point> p(n);
	rep(i, n) {
		cin >> p[i].x >> p[i].y;
	}

	cout << fixed;
	cout.precision(1);
	cout << polygonArea(p) << endl;

	return 0;
}

Measured memory_bytes: 1288
T=[]
for i in [None]*int(input()):
    T.append(int(input()))
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
ans=1
for t in T:
    ans=lcm(ans,t)
print(ans)

Measured memory_bytes: 38384
import Data.List

getter::IO ([Int],[Int])
getter = do
   dat<-(return.(map read).words)=<<getLine
   return (eat ([],[]) dat)
      where eat (x,y) []        = (x,y)
            eat (x,y) (z:w:rest)= eat (z:x,w:y) rest

solver::Int->[Int]->[Int]->Int
solver n xs ys = let (x_head:x_rest) = ((sortBy (\ x-> \ y ->compare (length y) (length x))).group.sort) xs in
                 let (y_head:y_rest) = ((sortBy (\ x-> \ y ->compare (length y) (length x))).group.sort) ys in
                 if head x_head /= head y_head
                   then n - ((length x_head)+(length y_head))
                   else let x_loss = (length x_head) - ((length.head) x_rest) in
                        let y_loss = (length y_head) - ((length.head) y_rest) in
                        case (x_rest,y_rest) of
                         ([],[])    -> div n 2
                         ([],_:_)   -> n - ((length x_head)+(length y_head)-y_loss)
                         (_:_,[])   -> n - ((length x_head)+(length y_head)-x_loss)
                         otherwise  -> n - ((length x_head)+(length y_head)-(min x_loss y_loss))

main::IO()
main=do
  n<-(return.read)=<<getLine
  (x,y)<-getter
  print (solver n x y)

Measured memory_bytes: 47484
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#pragma endregion

bool outof_index(int num){
    if (0 < num && num < 101) {
        return false;
    }
    else return true;
}

int main(){
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    REP(i, n) cin >> p[i];

    vector<bool> not_exit(101, true);
    REP(i, n) not_exit[p[i]]=false;

    REP(i, 52) {
        if (outof_index(x-i)) {
            cout << x-i << endl;
            return 0;
        }
        else if (not_exit[x-i]) {
            cout << x-i << endl;
            return 0;
        }
        if (outof_index(x+i)) {
            cout << x+i << endl;
            return 0;
        }
        else if (not_exit[x+i]) {
            cout << x+i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
# 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 SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }

int main()
{
    double T, X;
    cin >> T >> X;
    cout << T / X << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string s; cin >> s;
    rep(i,3){
        if(s[i] == '1') {
            s[i] = '9';
            continue;
        }
        if(s[i] == '9') s[i] = '1';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#c
n,m,x=map(int, input().split())
sp = [list(map(int, input().split())) for _ in range(n)]

import copy
result = []
def test(i,i_sum,cost):
    
    flag = 0
    if i <= n:
        for j in range(m):
            if i_sum[j] < x:
                flag = 1
                break

        if flag == 1:
                test(copy.deepcopy(i)+1, i_sum[:],cost[:])#参考書を使わない場合

                for j in range(1,m+1):#参考書を使う場合
                    i_sum[j-1] += sp[i-1][j]
                cost[0] += sp[i-1][0]
                test(copy.deepcopy(i)+1, i_sum[:],cost[:])
        else:
            result.append(cost[0])
test(0,[0]*m,[0])

if result != []:
    print(min(result))
else:
    print(-1)

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
ll mod1=1000000007ll;
ll mod2=998244353ll;

bool vis[200002];
ll ma[200002],bit[200005],rank1[200005],parent[200005];
ll c=0,x=0,n,an=0;
ll gcd(ll a, ll b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
ll power(ll x,ll y)
{   if(y==0) return 1;
    ll p=power(x,y/2);
    p=(p*p)%mod2;
    if(y%2) return  (p*x)%mod2;
    return p;
}
ll sum(ll in)
{   in++;
    ll sum1=0;
    while(in>0)
    {
        sum1+=bit[in];
        in-=in & (-in);
    }
    return sum1;
}
void update(ll in,ll val)
{   in++;
    while(in<=200002)
    {
        bit[in]+=val;
        in+=in & (-in);
    }
}
 struct vec {
    vector<ll> v;
    bool operator<( const  vec& a) const
    { return a.v[0] < v[0]; }
  };

ll find(ll x)
{
    if(x==parent[x])
    return x;
    else
    return find(parent[x]);
}
void merged(ll x, ll y)
{
    x=find(x);
    y=find(y);
    if(rank1[x]>rank1[y])
    {
        parent[y]=x;
        rank1[x]+=rank1[y];
    }
    else
    {
        parent[x]=y;
        rank1[y]+=rank1[x];
    }

}
void solve()
{
   ll n,ans=0;
   cin>>n;
   ll a[n][n],v[n],vis[n];
   for(ll i=0;i<n;i++)
   {
       for(ll j=0;j<n-1;j++)
       {
           cin>>a[i][j];
           a[i][j]--;
       }
   }
   for(ll i=0;i<n;i++)
       v[i]=0;
       ll c=0,t=n*(n-1);
       t=t/2;
   while(c!=t)
   {   ll k=c;
       for(ll i=0;i<n;i++)
       vis[i]=0;
      // cout<<c<<endl;
        for(ll i=0;i<n;i++)
       {
           if(vis[i])
          continue;
       //   cout<<i<<v[i];
          if(v[i]>=n-1)
            continue;
         ll p=a[i][v[i]];
       //    cout<<p<<v[p]<<endl;
           if(vis[p])
             continue;
         if(a[p][v[p]]==i)
         {
            vis[i]=1;
            vis[p]=1;
            v[i]++;
            v[p]++;
            c++;
         }
       }
       if(c==k)
       {
           cout<<-1<<endl;
           return;
       }
     //  cout<<c<<endl;
       ans++;
   }
   cout<<ans<<endl;
}

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


Measured memory_bytes: 8064
// Problem : D - Banned K
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

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

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int a[200000], cnt[200001] = {};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int n;
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    
    long long tot = 0;
    for (int i=1; i<=n; i++)
        tot += (long long) cnt[i] * (cnt[i] - 1) / 2;
    
    for (int i=0; i<n; i++)
        cout << tot - (long long) cnt[a[i]] * (cnt[a[i]] - 1) / 2 + (long long) (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2 << "\n";

    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  int n = s.length();
  rep(i, n) {
    if (s[i] != t[i]) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
  cin>>a>>b>>c;
  if(a+b==c){cout<<"Yes"<<endl;}
  else if(b+c==a){cout<<"Yes"<<endl;}
  else if(c+a==b){cout<<"Yes"<<endl;}
  else {cout<<"No"<<endl;}
}

Measured memory_bytes: 3636