akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef complex<double> CD;

int main() {
	int n; cin >> n;
	VI x(n), y(n);
	rep(i, n)cin >> x[i] >> y[i];
	
	int sum = 0;
	rep(i, n) {
		sum += x[i] * y[(i == n - 1) ? 0 : i + 1] - x[(i == n - 1) ? 0 : i + 1] * y[i];
	}
	printf("%.1f\n", (double)sum / 2);
}
/*
20 90 418 -407 61 12 -258 -457
0
*/


Measured memory_bytes: 3236
#include <iostream>
#include <vector>

using namespace std;

class UnionFind {
  public:
    UnionFind(int n): par(n, -1) { }
    int root(int x) {
      if (par[x] < 0) return x;
      else return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
      x = root(x), y = root(y);
      if (x == y) return;
      if (par[y] < par[x]) swap(x, y);
      par[x] += par[y];
      par[y] = x;
    }
    bool same(int x, int y) {
      return root(x) == root(y);
    }
    int size(int x) {
      return -par[root(x)];
    }

  private:
    vector<int> par;
};

int main()
{
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> e;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    e.push_back(make_pair(a, b));
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    UnionFind uf(N);
    for (int j = 0; j < M; j++) {
      if (i != j) {
        uf.unite(e[j].first, e[j].second);
      }
    }
    if (!uf.same(e[i].first, e[i].second)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Mat = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5+10;

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    
    int lim = min(a,b);
    vi t;
    for(int x=1; x<=lim; ++x){
        if(a%x==0 && b%x==0){
            t.push_back(x);
        }
    }
    cout(t[t.size()-k]);
    return 0;
}

Measured memory_bytes: 384
N, H, W = [int(a) for a in input().strip().split()]
A = []
B = []
for i in range(0, N):
    ak, bk = [int(a) for a in input().strip().split()]
    A.append(ak)
    B.append(bk)

count = 0
for a, b in zip(A, B):
    if a >= H and b >= W:
        count = count + 1

print(count)

Measured memory_bytes: 3060
main:: IO ()
main = do
    [x,a,b] <- (map read . words) <$> getLine
    putStrLn $ solve (x,a,b)

-- |
--
-- >>> solve (4,3,6)
-- "safe"
--
-- >>> solve (6,5,1)
-- "delicious"
--
-- >>> solve (3,7,22)
-- "dangerous"
solve :: (Int, Int, Int) -> String
solve (x,a,b)
  | b - a >= x + 1  = "dangerous"
  | b - a <= 0  = "delicious"
  | otherwise  = "safe"


Measured memory_bytes: 508
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def f(n)
    if n.odd?
        return 3*n+1
    else
        return n/2
    end
end
s=gets.to_i
a=[]
a.push(s)
exist={}
ans=0
exist[s]=1
loop do
  a_=f(a[-1])
  unless exist[a_].nil?
      ans=a.size+1
      break
  else
      exist[a_]=1
      a.push(a_)
  end
end
puts ans

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

int main()
{
    int n, k; cin >> n >> k;
    string s; cin >> s;

    int happy = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i+1]) happy++;
    }
    cout << min(happy + 2*k, n - 1) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

#define WHITE 0
#define BLACK 1

ll n;
vvll graph;
V<bool> visited;
vvll dp;

void dfs(ll i) {
  if (visited[i]) return;
  visited[i] = true;
  dp[i][WHITE] = dp[i][BLACK] = 1;
  REP(j, graph[i].size()) {
    if (!visited[graph[i][j]]) {
      dfs(graph[i][j]);
      dp[i][WHITE] = dp[i][WHITE] * ((dp[graph[i][j]][WHITE] + dp[graph[i][j]][BLACK]) % MOD) % MOD;
      dp[i][BLACK] = dp[i][BLACK] * dp[graph[i][j]][WHITE] % MOD;
    }
  }
  // cout << i << ' ' << dp[i][WHITE] << ' ' << dp[i][BLACK] << endl;
}

int main() {
  cin >> n;
  graph.resize(n);
  dp.resize(n, vll(2, 0));
  REP(i, n-1) {
    ll x, y; cin >> x >> y;
    graph[x-1].push_back(y-1);
    graph[y-1].push_back(x-1);
  }
  visited.resize(n, false);
  dfs(0);
  cout << (dp[0][WHITE] + dp[0][BLACK]) % MOD << endl;
  return 0;
}


Measured memory_bytes: 15360
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int h, w;
vector<string>fi;

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

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> h >> w;
	fi.resize(h);
	rep(i, h)cin >> fi[i];
	vector<vector<int>>dist(h, vector<int>(w, -1));
	queue<P>que;
	rep(i, h) {
		rep(j, w) {
			if (fi[i][j] == '#') {
				dist[i][j] = 0;
				que.push(P(i, j));
			}
		}
	}
	while (!que.empty()) {
		auto cur = que.front();
		que.pop();
		rep(dir, 4) {
			int nx = cur.first + dx[dir];
			int ny = cur.second + dy[dir];
			if (nx < 0 || nx >= h || ny < 0 || ny >= w) {
				continue;
			}
			if (dist[nx][ny] == -1) {
				dist[nx][ny] = dist[cur.first][cur.second] + 1;
				que.push(P(nx, ny));
			}
		}
	}
	int ans = 0;
	rep(i, h) {
		rep(j, w) {
			ans = max(ans, dist[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 25524
ALPHABETS = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
size = len(ALPHABETS)
N = input()
S = input()
converted = map(lambda x: ALPHABETS[(ALPHABETS.index(x) + int(N)) % size], list(S))
print(''.join(converted))

Measured memory_bytes: 3188
#include<stdio.h>

int main(){
   int x;
   scanf("%d", &x);
   int x500yen = x/500;
   int x500fra = x%500;
   int x5yen = x500fra/5;
   int result = x500yen*1000 + x5yen*5;
   printf("%d\n", result);

   return 0;
}

Measured memory_bytes: 1708
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,temp,curr,m;
    string s;
    cin >> s;
    cin >> n;
    int normal = 1;
    vector<char> dpn, blkg;
    while(n--)
    {
        int tipe, tipe2;
        cin >> tipe;
        if(tipe == 1)
        {
             normal ^= 1;
        }
        else
        {
            char c;
            cin >> tipe2 >> c;
            if(tipe2 == 1)
            {
                if(normal) dpn.push_back(c);
                else blkg.push_back(c);
            }
            else
            {
                if(normal) blkg.push_back(c);
                else dpn.push_back(c);
            }
        }
    }
    string jadi = "";
    if(normal)
    {
        for(auto x : dpn) jadi += x;
        reverse(jadi.begin(), jadi.end());
        jadi += s;
        for(auto x : blkg) jadi += x;
    }
    else
    {
        for(auto x : blkg) jadi += x;
        reverse(jadi.begin(), jadi.end());
        reverse(s.begin(), s.end());
        jadi += s;
        for(auto x : dpn) jadi += x;
    }
    cout << jadi << endl;
    return 0;
}


Measured memory_bytes: 1368
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nm = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var graph = new List<int>[nm[0]].Select(x => new List<int>()).ToArray();
            for (var i = 0; i < nm[1]; i++)
            {
                var ab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                var a = ab[0] - 1;
                var b = ab[1] - 1;
                graph[a].Add(b);
                graph[b].Add(a);
            }
            var queue = new Queue<int>();
            queue.Enqueue(0);
            var depths = Enumerable.Repeat(-1, nm[0]).ToArray();
            depths[0] = 0;
            var parents = new int[nm[0]];
            while (queue.Any())
            {
                var current = queue.Dequeue();
                foreach (var next in graph[current])
                {
                    if (depths[next] != -1) continue;
                    parents[next] = current + 1;
                    depths[next] = depths[current] + 1;
                    queue.Enqueue(next);
                }
            }

            Console.WriteLine("Yes");
            for (var i = 1; i < parents.Length; i++)
            {
                Console.WriteLine(parents[i]);
            }
        }
    }
}


Measured memory_bytes: 52576
n = int(input())
t, a = map(int, input().split())
heights = enumerate(map(int, input().split()))
ans = min(
    map(
        lambda x: [x[0], abs(a - (t - int(x[1]) * 0.006))]
        , heights
    )
    , key = (lambda y: y[1])
)
print(ans[0] + 1)


Measured memory_bytes: 9160
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	A := ScanText(scanner)
	B := ScanText(scanner)
	
	if len(A) > len(B) {
	    fmt.Println("GREATER")
	} else if len(A) < len(B) {
	    fmt.Println("LESS")
	} else {
	    eq := true
	    for i := 0; i < len(A); i++ {
	        if A[i] > B[i] {
	            fmt.Println("GREATER")
	            eq = false
	            break
	        } else if A[i] < B[i] {
	            fmt.Println("LESS")
	            eq = false
	            break
	        }
	    }
	    if eq {
	        fmt.Println("EQUAL")
	    }
	}
	
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

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

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 

Measured memory_bytes: 640
#include <stdio.h>
int main(void)
{
	int h,w,c[101][101],i;
	scanf("%d%d",&h,&w);
	for(i=0; i<h; i++){
		scanf("%s",c[i]);
	}
	for(i=0; i<h; i++){
		printf("%s\n%s\n",c[i],c[i]);
	}
	return 0;
}

Measured memory_bytes: 256
/*
* 重新用指针实现一遍双头链表
*/

# include <cstdio>
# include <cstring>
# include <cstdlib>



struct Node { // 结点结构体
	int key;
	Node *prev, *next;
};

Node *nil; // 声明头结点

void init() { // 初始化头结点函数
	nil = (Node *)malloc(sizeof(Node)); // 给头结点分配内存空间
	nil->next = nil;
	nil->prev = nil;
}

// 插入函数
void insert(int key) {
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	// 在头结点后面插入元素
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

Node* listSearch(int key) {
	Node *cur = nil->next;
	while (cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

void deleteNode(Node *t) {
	if (t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

int main() {
	// freopen("data.in", "r", stdin);
	// freopen("data.out", "w", stdout);

	init(); // 初始化头结点
	
	int n, x; char buff[20]; // buff[]用来临时存储每一条命令。 
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", buff);
		if (buff[6] == '\0') {
			scanf("%d", &x);
			if (buff[0] == 'i')
				insert(x);
			else
				deleteKey(x);
		}
		else if (buff[6] == 'F') {
			deleteFirst();
		}
		else if (buff[6] == 'L') {
			deleteLast();
		} 
	}
	
	int flag = 0;
	Node *cur = nil->next;
	while(cur != nil) {
		if (flag != 0)
			printf(" ");
		flag = 1;
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
	
	return 0;
}


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

int main()
{
  string s;
  cin >> s;
  string a;
  for (int i = 0; i < s.length(); i++)
  {
    if (s[i] == 'B')
    {
      if (!a.empty())
        a = a.erase(a.length() - 1, 1);
    }
    else
    {
      a += s[i];
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define maxn	500005
#define inf		int(21e8)
#define mod		int(1e9+7)
#define db		double
#define ll		long long
#define si 		stack<int>
#define qi 		queue<int>
#define vi 		vector<int>
#define pi 		pair<int, int>
#define pq  	priority_queue< int, vector<int>, greater<int> >
using namespace std;
ll powmod(ll a, ll b) {
	ll res = 1; a %= mod;
	for (; b; b >>= 1)
		res = (res * ((b & 1) ? a : 1)) % mod,
		a = a * a % mod;
	return res;
}
ll gcd(ll a, ll b) {
	return b ? gcd(a, b) : a;
}
int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	int ans = 0;
	for(int i = 0; i < n; i ++) if(s[i] != t[i]) ans ++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3864
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),a,i,min=1000000000,max=0;
		for(i=0;i<n;i++) {
			a=stdIn.nextInt();
			if(min>a) min=a;
			if(a>max) max=a;
		}
		System.out.print(max-min);
	}
}

Measured memory_bytes: 21844
from collections import deque
def main():
    H,W = map(int, input().split())
    S = [[0]*W for _ in range(H)]
    for i in range(H):
        # 1は道,0は壁
        tmp = list(map(lambda x:1 if x=='.' else 0, input()))
        S[i] = tmp
    # BFS
    ans = 0
    for i in range(H):
        for j in range(W):
            # (i,j)がスタート地点
            # (i,j)が壁
            if S[i][j] == 0:
                continue
            dist = [[-1]*W for _ in range(H)]
            dist[i][j] = 0
            que = deque([(i,j)])
            while que:
                si,sj = que.pop()
                for r,b in [(1,0),(0,1),(-1,0),(0,-1)]: # 右,下,左,上(移動方向)
                    gi = si+r
                    gj = sj+b
                    # 枠外
                    if gi<0 or (H-1)<gi or gj<0 or (W-1)<gj:
                        continue
                    # 壁
                    if S[gi][gj] == 0:
                        continue
                    # 探索済み
                    if dist[gi][gj]!=-1:
                        continue
                    dist[gi][gj] = dist[si][sj]+1
                    que.appendleft((gi,gj))
            ans = max(ans,max([max(d) for d in dist]))
    print(ans)

main()


Measured memory_bytes: 3316
int main(int argc, const char * argv[]) {
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(0<=a&&a<=100&&0<=b&&b<=100&&0<=c&&c<=100){
        if(a<b&&b<c){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 580
from math import factorial
n,m=[int(i) for i in input().split()]
if abs(n-m)>=2:
    print(0)
else:
    num=factorial(n)*factorial(m)
    if abs(n-m)==1:
        print(num%(10**9+7))
    else:
        print(2*num%(10**9+7))

Measured memory_bytes: 5196
#include <bits/stdc++.h>
#include <ext/numeric>
/**
       return NO_PAIN ? NO_GAIN : GAIN;
*/
using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) x.size()
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power(n, m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE
#define MOD 1000000007


typedef long long ll;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    //freopen("test cases\\out.txt", "w", stdout) ;
    int n; cin>>n;
    ld lo = 0;
    ll m = 1;
    bool flag = 0, zero = 0;
    for(int i = 0; i<n; i++){
        ll a; cin>>a;
        if(!a) zero = 1;
        if(log(a) + lo > log(1e18)) flag = 1;
        m *= a;
        lo += log(a);
    }
    if(zero) return cout<<0, 0;
    if(flag) return cout<<-1, 0;
    cout<<m;
	return 0;
}


Measured memory_bytes: 3860
def main():
    x1, y1, x2, y2 = map(int, input().split())
    v1 = x2-x1
    v2 = y2-y1
    x3, y3 = x2-v2, y2+v1
    x4, y4 = x3-v1, y3-v2
    return x3, y3, x4, y4

if __name__ == '__main__':
    output = main()
    print(" ".join(map(str, output)))

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

int main(){
  int n, k;
  cin >> n >> k;
  if(n<=k){
    cout << 0;
    return 0;
  }
  vector<int>h(n);
  for(int i=0; i<n; i++)cin >> h[i];
  sort(h.rbegin(), h.rend());
  cout << accumulate(h.begin()+k, h.end(), 0L);
  return 0;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int k = sc.nextInt();

    int[] nums = new int[n];

    for(int i = 0; i < n; i++){
      nums[i] = sc.nextInt();
    }
    
    Arrays.sort(nums);

    int sa = 1000000000;
    for(int i = 0; i + k - 1 < n; i++){
      int m = nums[i + k - 1] - nums[i];
      if(sa > m){
        sa = m;
      }
    }

    System.out.println(sa);
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 26816
N , M = map(int,input().split())

food = [0] * M

for i in range(N) :
    A = list(map(int,input().split()))
    for index in A[1:] :
        food[index-1] += 1

ans = 0
for count in food :
    if count >= N :
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype (i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype (i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
int n,m,ans;priority_queue<pii > q;pii a[100005];
bool cmp(pii x,pii y){
    return x.se>y.se;
}
int main()
{
    scanf("%d%d",&n,&m);
    rep(i,1,n) {int t1,t2;scanf("%d%d",&t1,&t2);a[i].se=m-t1+1,a[i].fi=t2;}
    sort(a+1,a+n+1,cmp);int p=1;
    per(i,m,1){
        while(a[p].se>=i&&p<=n) {q.push(a[p]);p++;}
        if(!q.empty()) {ans+=q.top().fi;q.pop();}
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 2168
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int x,a,b;
    cin>>x>>a>>b;
    if(a>=b)cout<<"delicious"<<endl;
    else if(a+x>=b)cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
B = gets.chomp.split.map(&:to_i)

total = A.inject(&:+)
# p A
# p B
# p total

0.upto(B.size - 1).each do |i|
  if B[i] > A[i]
    B[i] = B[i] - A[i]
    A[i] = 0
  else
    A[i] = A[i] - B[i]
    B[i] = 0
  end
  
  # Try A[i+1]
  if B[i] > A[i+1]
    B[i] = B[i] - A[i+1]
    A[i+1] = 0
  else
    A[i+1] = A[i+1] - B[i]
    B[i] = 0
  end
end

# For Debug
# p A
# p B

p total - A.inject(&:+)


Measured memory_bytes: 17556
h,w=map(int,input().rstrip().split(' '))
A = list()
a = "#"*(w+2)
A.append(a)
for i in range(h):
  a = str(input().rstrip())
  a = "#"+a+"#"
  A.append(a)

a = "#"*(w+2)
A.append(a)
for a in A:
  print(a)


Measured memory_bytes: 3316
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int Q=444444;
int inc=1;
int las[Q],nn[Q],e[Q];
int LAS[Q],NN[Q];
void iNS(int x,int y)
{
	e[++inc]=y;
	nn[inc]=las[x];
	las[x]=inc;
}
void ins(int x,int y)
{
	iNS(x,y),iNS(y,x);
}
void tins(int x,int y)
{
	NN[y]=LAS[x];
	LAS[x]=y;
}
int vis[Q],col[Q],c[Q];
int dfs(int x)
{
	int res=0;
	for(int y=LAS[x];y;y=NN[y]){
		int now=dfs(y);
		if(res)ins(res,now),res=0;
		else res=now;
	}
	if(res)vis[x]=1;
	return res?res:x;
}
void Color(int x)
{
	vis[x]=1;
	for(int t=las[x];t;t=nn[t]){
		int y=e[t];
		if(!vis[y])col[y]=-col[x],Color(y);
	}
}
void Deal(int n)
{
	int rt,x;
	for(int i=1;i<=n;i++)LAS[i]=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		++c[x+1];
		if(x>0)tins(x,i);
		else rt=i;
	}
	dfs(rt);
}
int main()
{
	int n;
	scanf("%d",&n);
	Deal(n),Deal(n);
	for(int i=1;i<=n+1;i++)
		if(c[i]&1)return puts("IMPOSSIBLE")&0;
	puts("POSSIBLE");
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])col[i]=1,Color(i);
		printf("%d ",col[i]);
	}
	return 0;
}
/*
8
2 7 1 2 2 1 -1 4
4 -1 4 7 4 4 2 4
*/

Measured memory_bytes: 14976
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  int tadd = 0;
  bool ok = true;
  REP(i,n){
    REP(j,n - i){
      ok = true;
      if(s[i+j] != t[j]) {
        ok = false;
        break;
      }
    }
    if(ok) {
      tadd = i;
      break;
    }
  }

  int ans = 0;
  if(!ok) ans = 2*n;
  else ans = n + tadd;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
def dfs(x, y, W, H):
    if x >= H or y >= W or x < 0 or y < 0:
        return
    if visited[x][y] == 1:
        return
    if gridgraph[x][y] == '.' or gridgraph[x][y] == '@':
        visited[x][y] = 1
        dfs(x+1, y, W, H)
        dfs(x, y+1, W, H)
        dfs(x-1, y, W, H)
        dfs(x, y-1, W, H)
    if gridgraph[x][y] == '#':
        return

    return


while True:
    W, H = map(int, input().split())
    if W == 0 and W == 0:
        break
    gridgraph = [list(input()) for _ in range(H)]

    visited = [[0]*W for _ in range(H)]

    sx = -1
    sy = -1
    for i, row in enumerate(gridgraph):
        for j in range(len(row)):
            if row[j] == '@':
                sx = i
                sy = j
    dfs(sx, sy, W, H)

    ans = 0
    for row in visited:
        ans += sum(row)
    print(ans)



Measured memory_bytes: 5760
N,K=map(int,input().split())
D=list(map(int,input().split()))

n=[str(N)[i] for i in range(len(str(N)))]
#print(n)
for i in range(N,10*N+1):
  flag=True
  for j in range(len(str(i))):
    if(int(str(i)[j]) in D):
      flag=False
  if(flag==True):
    ans=i
    break
print(ans)

Measured memory_bytes: 3064
#include <math.h>
#include <stdio.h>

#define EPS 1e-10

int rel_s_s( double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, double *x, double *y ) {
	double numer = ( x3 - x1 ) * ( y4 - y3 ) - ( x4 - x3 ) * ( y3 - y1 );
	double denom = ( x2 - x1 ) * ( y4 - y3 ) - ( x4 - x3 ) * ( y2 - y1 );

	if ( fabs( denom ) < EPS )
		if ( fabs( numer ) < EPS ) {
			double h1 = x1 == x2 ? ( y3 - y1 ) / ( y2 - y1 ) : ( x3 - x1 ) / ( x2 - x1 );
			double h2 = x1 == x2 ? ( y4 - y1 ) / ( y2 - y1 ) : ( x4 - x1 ) / ( x2 - x1 );

			if ( ( h1 < h2 ? h1 : h2 ) < 0.0 && fabs( h1 < h2 ? h2 : h1 ) < EPS ) {
				*x = x1;
				*y = y1;
				return 4;
			} else if ( fabs( ( h1 < h2 ? h1 : h2 ) - 1.0 ) < EPS && 1.0 < ( h1 < h2 ? h2 : h1 ) ) {
				*x = x2;
				*y = y2;
				return 4;
			} else if ( h1 < 0.0 && h2 < 0.0 || 1.0 < h1 && 1.0 < h2 )
				return 3;
			else
				return 5;
		} else
			return 2;
	else {
		double t = numer / denom;
		double s = ( ( x3 - x1 ) * ( y2 - y1 ) - ( x2 - x1 ) * ( y3 - y1 ) ) / denom;

		if ( fabs( t - 0.5 ) < 0.5 + EPS && fabs( s - 0.5 ) < 0.5 + EPS ) {
			*x = x1 + t * ( x2 - x1 );
			*y = y1 + t * ( y2 - y1 );

			if ( fabs( ( x2 - x1 ) * ( x4 - x3 ) + ( y2 - y1 ) * ( y4 - y3 ) ) < EPS )
				return 1;
			else
				return 0;
		} else
			return 6;
	}
}

int main( void ) {
	int q;

	scanf( "%d", &q );
	while ( q-- ) {
		int rel;
		double x0, y0, x1, y1, x2, y2, x3, y3, x, y;

		scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3 );

		rel = rel_s_s( x0, y0, x1, y1, x2, y2, x3, y3, &x, &y );
		printf( "%d\n", rel == 2 || rel == 3 || rel == 6 ? 0 : 1 );
	}

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
using namespace std;
typedef long long ll;
typedef vector<int>VI;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100//5
#define MAX_N 200100
#define MAX_B 1001001//6
#define MAX_S 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
bool is_prime(int n){
    if(n==1)return 0;
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return 0;
    }
    return 1;
}
int main(){
    int q;cin>>q;
    bool like[MAX];
    memset(like,0,sizeof(like));
    for(int i=1;i<100000;i+=2){
        if(is_prime(i) &&is_prime((i+1)/2)){
            like[i]=1;
        }
    }
    int sum[MAX];
    sum[0]=0;
    rep(i,100000){
        sum[i+1]=sum[i]+like[i];
    }
    rep(i,q){
        int l,r;cin>>l>>r;
        cout<<sum[r+1]-sum[l]<<endl;
    }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



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

  int ans=N/3;
  cout<<ans<<"\n";
  return 0;
}


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

int main() {
  int a;
  int d,e,f;
  cin >> a;
  
  d = a / 100; //100の位
  f = a % 10; // 1の位
  e = (a - (100*d) - f)/10; //10の位
  
  cout << d+e+f << endl;
}

Measured memory_bytes: 3596
void main() {
	(N => N.iota.map!(i => ri).any!"a & 1" ? "first" : "second")(ri).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

using namespace std;

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

    int ans = 0;

    for (int i = 0; i < S.length(); ++i) {
        if (S[i] != 'J') continue;
        int lenj = 1, leno = 0, leni = 0;
        
        while (S[i] == 'J') { lenj++; i++; }
        while (lenj && S[i] == 'O') { leno++; i++; }
        while (leno && S[i] == 'I') { leni++; i++; }

        if (leno <= lenj && leno <= leni) ans = max(ans, leno);
    }

    cout << ans << endl;
}

Measured memory_bytes: 2052
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
const ll mod = 1e9 + 7;

const int N = 200000;

int n;

ll a[N], d[N]; // b[i] = a[i] + d[i]
ll asum;

set<PL> neg, pos;
ll possum;

void add_d(int x, ll y) {
  d[x] = y;
  if (x == 0 || x == 2 * n - 1) return;
  if (y >= 0) {
    possum += y;
    pos.insert(PL(y, x));
  } else {
    neg.insert(PL(y, x));
  }
}

void rm_d(int x) {
  ll y = d[x];
  if (x == 0 || x == 2 * n - 1) return;
  if (y >= 0) {
    possum -= y;
    pos.erase(PL(y, x));
  } else {
    neg.erase(PL(y, x));
  }
}

ll solve() {
  if (0) {
    cerr << "possum = " << possum << endl;
    for (auto n: neg) {
      cerr << " " << n.first;
    }
    cerr << endl;
    for (auto p: pos) {
      cerr << " " << p.first;
    }
    cerr << endl;
  }
  ll tot = possum;
  if (pos.size() % 2 == 1) {
    tot += max(-pos.begin()->first, neg.rbegin()->first);
  }
  return tot + asum;
}


int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> n >> q;
  VL a(2 * n), b(2 * n);
  REP(i, 0, 2 * n) {
    cin >> a[i];
    asum += a[i];
  }
  REP(i, 0, 2 * n) {
    ll b;
    cin >> b;
    add_d(i, b - a[i]);
  }
  REP(i, 0, q) {
    int p, x, y;
    cin >> p >> x >> y;
    p--;
    asum += x - a[p];
    a[p] = x;
    rm_d(p);
    add_d(p, y - x);
    cout << solve() << "\n";
  }
}


Measured memory_bytes: 18944
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>=b)
        for(int i=0;i<a;i++) printf("%d",b);
    if(a<b)
        for(int i=0;i<b;i++) printf("%d",a);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

int main(void){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    for(ll i = 0;i < n;i++){
        if(a-b >= (n-1-i)*c - i*d && a-b <= (n-1-i)*d-i*c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
 	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i,n;
  int card[10001][2];

  for(;;){
    scanf("%d", &n);
    if(n==0) break;

    int ansa=0,ansb=0;
    int suma[10001]={0};
    int sumb[10001]={0};

    for(i=0;i<n;i++){
      scanf("%d %d", &card[i][0], &card[i][1]);
      if(card[i][0]>card[i][1]){
	suma[i]=card[i][0]+card[i][1];
      } else if(card[i][0]<card[i][1]){
	sumb[i]=card[i][0]+card[i][1];
      } else {
	suma[i]=sumb[i]=card[i][0];
      }
      ansa=ansa+suma[i];
      ansb=ansb+sumb[i];
    }
    printf("%d %d\n", ansa, ansb);
  }

  return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    string s;
    cin >> s ;
    if(s.length()==2) cout << s ;
    else {
        for(int i=s.length()-1;i>=0;i--)
            cout << s[i];
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	string s; cin >> s;
	int len = s.length();
	int x = 1 << (len - 1);
	ll sum = 0;
	rep(i, x) {
		queue<int> q;
		rep(j, len-1) {
			if (i&(1 << j)) {
				q.push(j);
			}
		}
		q.push(len - 1);
		int now = 0;
		while (!q.empty()) {
			int nex = q.front(); q.pop();
			string u = s.substr(now, nex - now + 1);
			sum += stoll(u);
			now = nex + 1;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
from pip._vendor.distlib.compat import raw_input
while True:
    n = int(raw_input())
    if n == 0: break
    data = {}
    order = []
    for i in range(n):
        id,price,quant = map(int, raw_input().split())
        if id in data:
            data[id] += price * quant
        else:
            data[id] = price * quant
            order.append(id)

    if max(data.values()) < 1000000: print("NA")
    else:
        for i in order:
            if data[i] >= 1000000:
                print(i)

Measured memory_bytes: 24892
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 1001001001;
const int MAX_N = 100100;
const double PI = 3.14159265358979323846;



int main(int argc, char *args[]) {
	int r;
	cin >> r;
	cout << r*r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  double n, m, sum_val = 0;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, 0, n) {
    cin >> a[i];
    sum_val += a[i];
  }
  int ans = 0;
  rep(i, 0, n) {
    if (a[i] >= sum_val / (4.0 * m)) ans++;
  }

  if (ans >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(){
  int n,ans=1;
  scanf("%d",&n);
  char a[n+1][11];
  for(int i=0;i<n;i++){
    scanf("%s",a[i]);
  }
  
 qsort(a,n,11,strcmp);
  
    for(int i=1;i<n;i++){
    if(strcmp(a[i],a[i-1])!=0) ans++;
    
  }

  
 
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 5740
from heapq import heapify,heappush,heappop

N, M, S = map(int, input().split())

# !!グラフの作成!! #
tmp = [list(map(int, input().split())) for _ in range(M)]

U = [0 for _ in range(M)]
V = [0 for _ in range(M)]
A = [0 for _ in range(M)]
B = [0 for _ in range(M)]

for i in range(M):
  U[i] = tmp[i][0] -1
  V[i] = tmp[i][1] -1
  A[i] = tmp[i][2]
  B[i] = tmp[i][3]
A_m = max(A)
S = min(N*A_m, S)
#print(A_m)

I = [[] for _ in range(N * (N*A_m+1))] 
# 隣接リスト(頂点iで銀貨j枚持ちのとき、i*N*(A_m+1)+jとおく)
for i in range(M):
  for j in range(A[i], N*A_m+1):
    I[U[i]*(N*A_m+1)+j].append((V[i]*(N*A_m+1)+j-A[i],B[i]))
    I[V[i]*(N*A_m+1)+j].append((U[i]*(N*A_m+1)+j-A[i],B[i]))

for i in range(N):
  C, D = map(int, input().split())
  for j in range(N*A_m+1):
    I[i*(N*A_m+1)+j].append((i*(N*A_m+1)+min(C+j,N*A_m),D))
#print(I)

def dijkstra(I):# I:隣接リスト(頂点、コスト、そのほか制約) 
  N = len(I)
  task = [] 
  visited = [0 for _ in range(N)]
  min_cost = [0 for _ in range(N)]
  cost = [10**20 for _ in range(N)]
  prev_points = [0 for _ in range(N)]
  heappush(task, (0, S, -1))
  # !!比較値がスカラーでないときは、一番左の0を適宜変更する!! #
  # !!最初の点番号が0でないときは、真ん中の0を変更する!! #
  
  flag = 0
  while task:
    while task:
      c, p, prev = heappop(task)    
      if visited[p] == 0:
        break  
      if len(task) == 0:
        flag = 1
    if flag == 1:
      break
    #print(task)
    visited[p] = 1
    min_cost[p] = c
    prev_points[p] = prev
  
    for j, c_ad in I[p]: #制約が入るときはここに追加
      if visited[j] == 1: continue
      #print(p//(N*A_m+1),p%(N*A_m+1),j//(N*A_m+1),j%(N*A_m+1),c_ad)
      cost_next = next_cost(I, p, j, c, c_ad)
      if cost[j] > cost_next:
        cost[j] = cost_next
        heappush(task, (cost_next, j, p))

  return (min_cost, prev_points)

def next_cost(I, p, j, c, c_ad): # !!現在の点pから次の点jへのコストを計算する方法を記入!! #  
#c:点pにつくまでに払ったコスト、c_ad:次回追加されるコスト#
  return c + c_ad

min_cost, prev_points = dijkstra(I)

for i in range(1, N):
  print(min(min_cost[i*(N*A_m+1):(i+1)*(N*A_m+1)]))

Measured memory_bytes: 98312
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

  std::reverse(s.begin(),s.end());
  int i = 0;
  while(i<s.size()){
    int flag = 1;
    string subs5 = s.substr(i,5);
    string subs6 = s.substr(i,6);
    string subs7 = s.substr(i,7);
    if(subs5=="maerd"){
      i += 5;
      flag = 0;
    }
    
    if(subs5=="esare"){
      i += 5;
      flag = 0;
    }
    
    if(subs7=="remaerd"){
      i += 7;
      flag = 0;
    }

    if(subs6=="resare"){
      i += 6;
      flag = 0;
    }

    if(flag == 1){
      cout << "NO" << endl;
      return 0;
    }
    
  }

  cout << "YES" << endl;
  return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std; typedef long long ll; const int INF=1e9; typedef pair<ll,ll> P;

int main() {
  ll k; cin>>k;
  ll n=50;
  ll a[n]; fill(a,a+n,k/n);
  for(int i=n-1,j=1;i>=0;i--,j++) {
    if (j<=k%n) a[i]+=n;
    else a[i]+=n-(k%n+1);
  }
  cout<<n<<endl;
  for(int i=0;i<n;i++) {
    cout<<a[i]<<" ";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N,A,B,C,D;
  string S;
  bool sanashi=false;
  cin >> N >> A >> B >> C >> D >> S;

  for(int ciwa=0,casi=0,i=A; i<max(C,D); i++){
    if(S.at(i)=='#'){
      ciwa++;
      casi=0;
      if(ciwa>=2 && ((A<i && i<C)||(B<i && i<D))){cout << "No" << endl; return 0;}
    } else {
      casi++;
      ciwa=0;
      if(casi>=3 && B<=i && i<=D){sanashi=true;}
    }  
  }
  
  if(C>D){
    if(sanashi){
      cout << "Yes" << endl; return 0;
    }else{
      cout << "No" << endl; return 0;
    }
  } else {       
    cout << "Yes" << endl; return 0;
  }
}

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

int dp[1025][100001],v[323456],w[323456];
int f(int a,int l){
  if(l<0)return -1000000000;
  if(!a)return 0;
  if(a>1024)return max(f(a/2,l),f(a/2,l-w[a])+v[a]);
  if(~dp[a][l])return dp[a][l];
  return dp[a][l]=max({f(a/2,l),f(a,l-1),f(a/2,l-w[a])+v[a]});
}

int main(){
  memset(dp,-1,sizeof(dp));
  int n;cin>>n;
  for(int i=0;i<n;i++)cin>>v[i+1]>>w[i+1];
  int q;cin>>q;
  while(q--){
    int a,l;cin>>a>>l;
    cout<<f(a,l)<<endl;
  }
}


Measured memory_bytes: 413704
def degrade(ai, bi, ci)
  res = []
  if ai > 0
    res.push [ai - 1, bi, ci]
  end
  if bi > 0
    res.push [ai, bi - 1, ci]
  end
  if ci > 0
    res.push [ai, bi, ci - 1]
  end
  return res
end

def score(path, a, b, c)
  ai, bi, ci = path
  a[ai] + b[bi] + c[ci]
end

def queue_push(queue, path, a, b, c)
  this_score = score(path, a, b, c)
  i = queue.index { |path2|
    score(path2, a, b, c) <= this_score
  }
  if i
    queue.insert(i, path)
  else
    queue.push(path)
  end
end

x, y, z, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
b = gets.split.map(&:to_i).sort
c = gets.split.map(&:to_i).sort

output = []
queue = [[a.size-1, b.size-1, c.size-1]]
seen = {}

until k == 0
  ai, bi, ci = queue.shift

  puts a[ai] + b[bi] + c[ci]
  k -= 1

  paths = degrade(ai,bi,ci).reject { |path| seen[path] }
  paths.each do |path|
    seen[path] = true
  end
  paths.each do |path|
    queue_push(queue, path, a, b, c)
  end
end


Measured memory_bytes: 2680
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a =  sc.nextInt();
		int b = sc.nextInt();
		if(a+b<24) {
			System.out.println(a+b);
			
		} else {
			System.out.println(a+b-24);
			
		}

  	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef long long ll;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,k,a[N];
ll s1[N],s2[N];
int main() {
    cin>>n>>k;
    for(int i=1;i<=n;i++) a[i]=gi(),s1[i]=s1[i-1]+a[i],s2[i]=s2[i-1]+max(a[i],0);
    ll ans=0;
    for(int i=1;i<=n-k+1;i++) ans=max(ans,s2[i-1]+s2[n]-s2[i+k-1]+max(0ll,s1[i+k-1]-s1[i-1]));
    printf("%lld\n",ans);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 2176
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
int x,a;
scanf("%d %d",&x,&a);
if(x<a){printf("0");}
else{printf("10");}
return 0;
}

int min(a,b,c){
    return 0;
}

Measured memory_bytes: 128