akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

const int maxx = 100000 + 10;
struct Node {
	int key;
	Node *prev, *next;
};

Node *nil;

// 链表初始化
void init() {
	nil = (Node *)malloc(sizeof(Node));
	//C++ nil = new Node();
	nil->next = nil;
	nil->prev = nil;
}

// 从链表搜索出值为key的结点 O(n)
Node* listSearch(int key) {
	// 从链表头结点开始访问
	Node *cur = nil->next;
	while (cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

// 打印链表
void printList() {
	Node *cur = nil->next;
	int flag = 0;
	while (cur != nil) {
		if (flag++ > 0)
			printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

// 删除结点t
void deleteNode(Node *t) {
	// t为头结点不做处理
	if (t == nil)
		return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
	//C++ delete(t);
}

// 删除头结点
void deleteFirst() {
	deleteNode(nil->next);
}

// 删除尾结点
void deleteLast() {
	deleteNode(nil->prev);
}

// 删除指定的key O(n)
void deleteKey(int key) {
	deleteNode(listSearch(key));
}

// 在链表头部添加元素key
void insert(int key) {
	Node *x = (Node *)malloc(sizeof(Node));
	//C++ Node *x = new Node();
	x->key = key;

	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}
int main() {
	int n, key, size = 0;
	char op[20];
	scanf("%d", &n);
	getchar();
	// 初始化链表
	init();
	for (int i = 0; i < n; i++) {
		scanf("%s %d", op, &key);
		if (op[0] == 'i') {
			insert(key);
			size++;
		}
		else {
			if (strlen(op) > 6) {
				if (op[6] == 'F') {//删除头结点
					deleteFirst();
				}
				else {//删除尾结点
					deleteLast();
				}
			}
			else { //删除结点
				deleteKey(key);
			}
			size--;
		}
	}
	printList();
	return 0;
}


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

int main()
{
  ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
  int n, m, x, y;
  cin >> n >> m;
  
  vector<int> a(n+1, 0);
  for(int i = 0; i < m; i++)
  {
    cin >> x >> y;
    a[x]++;
    a[y]++;
  }
  
  for(int i = 1; i <= n; i++)
  {
    cout << a[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
  long long A,B,C,D;
  cin>>A>>B>>C>>D;
  long long E=C*D/gcd(C,D);
  long long P=B/C+B/D-B/E;
  long long Q=(A-1)/C+(A-1)/D-(A-1)/E;
  cout<<B-A+1-P+Q<<endl;
}

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

 int main(){
   long long int n,a,b;
   cin>>n>>a>>b;
   long long int c;
   c=a+b;
   long long int ans;
   ans=(n/c)*a;
   if(n%c>a){
      ans=ans+a;
   }else{
      ans=ans+n%c;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int a, b, c;

void input() {
  cin >> a >> b >> c;
}

void solve() {
  int num = 0;
  for (int t=1; t<=c; t++) {
    if (t%a==0) num += b;
  }
  cout << num << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
mod utils {
    use std::error::Error;
    use std::io::stdin;
    use std::str::FromStr;

    #[allow(dead_code)]
    pub fn read_line<T>() -> Result<Vec<T>, Box<Error>>
    where
        T: FromStr,
        T::Err: 'static + Error,
    {
        let mut line = String::new();
        let _ = stdin().read_line(&mut line)?;
        let parsed_line = line.split_whitespace()
            .map(|x| x.parse::<T>())
            .collect::<Result<Vec<T>, T::Err>>()?;

        Ok(parsed_line)
    }

    #[allow(dead_code)]
    pub fn read_lines<T>(n: usize) -> Result<Vec<Vec<T>>, Box<Error>>
    where
        T: FromStr,
        T::Err: 'static + Error,
    {
        (0..n).map(|_| read_line()).collect()
    }
}

fn solve() -> Result<(), Box<std::error::Error>> {
    let header = utils::read_line::<usize>()?;
    let amount = header[0];
    let n_coins = header[1];
    let coins = utils::read_line::<usize>()?;

    let mut dp = vec![vec![0; amount + 1]; n_coins];

    let mut cumsum = coins[0];
    let mut n_coins_cumsum = 1;
    while cumsum <= amount {
        dp[0][cumsum] = n_coins_cumsum;
        cumsum += coins[0];
        n_coins_cumsum += 1;
    }

    for i in 1..n_coins {
        dp[i] = dp[i - 1].to_vec();

        for j in 1..(amount + 1) {
            if j >= coins[i] {
                dp[i][j] = std::cmp::min(dp[i][j], dp[i][j - coins[i]] + 1);
            }
        }
    }

    println!("{}", dp[n_coins - 1][amount]);

    Ok(())
}

fn main() {
    match solve() {
        Err(err) => panic!("{}", err),
        _ => (),
    };
}



Measured memory_bytes: 11076
# -*- coding: utf-8 -*-
"""
Created on Sun May 19 22:22:33 2019

@author: Yamazaki Kenichi
"""

N,M = map(int,input().split())
xyz = [list(map(int,input().split())) for i in range(M)]

import sys
sys.setrecursionlimit(10**6)

class UnionFind(object):

    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        else:
            return False

uf = UnionFind(N+1)
for c in xyz:
    uf.union(c[0],c[1])
ans = -1
for u in uf.table:
    if u<0:
        ans += 1
print(ans)

Measured memory_bytes: 30340
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    string l;
    cin >> l;

    s64 dp[l.size() + 1][2];
    rep (i, l.size() + 1)
    {
        rep (j, 2)
        {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;

    rep (i, l.size())
    {
        if (l[i] == '0')
        {
            dp[i + 1][0] += dp[i][0];
            dp[i + 1][1] += dp[i][1] * 3 % MOD;
        }
        else
        {
            dp[i + 1][0] += dp[i][0] * 2 % MOD;
            dp[i + 1][1] += (dp[i][1] * 3 % MOD + dp[i][0] % MOD) % MOD;
        }
    }

    cout << (dp[l.size()][0] + dp[l.size()][1]) % MOD << "\n";
    return 0;
}



Measured memory_bytes: 2000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repl(i,n) for(int64_t i=0;i<(int64_t)(n);i++)
#define MAX_N 10000000
#define ll int64_t
#define all(v) (v).begin(),(v).end()
#define P pair<int,int>
using namespace std;


int main() {
  string s; cin>>s;
  int red=0,blue=0;
  rep(i,s.size()) {
    if(s[i]=='0') red++;
    else if(s[i]=='1') blue++;
  }
  cout<<min(red,blue)*2<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#define T true
#define F false

using namespace std;

int num, m, tag;
queue<int> nx;

bool Search(int n, vector<vector<bool>> &map, vector<bool> &d) {
	if (n == tag) {
		while (!nx.empty())
			nx.pop();
		return F;
	}
	for (int i = 0; i < num; i++) {
		if (map[n][i] && d[i]) {
			nx.push(i);
			d[i] = F;
		}
	}
	if (nx.empty())
		return T;
	n = nx.front();
	nx.pop();
	return Search(n, map, d);
}

int main(void) {
	int i = 0, ans = 0;
	cin >> num >> m;
	vector<int> a(m), b(m);
	vector<vector<bool>> map(num, vector<bool>(num, F));
	for (; i < m; i++) {
		scanf("%d%d", &a[i], &b[i]);
		map[--a[i]][--b[i]] = T;
		map[b[i]][a[i]] = T;
	}
	for (i = 0; i < m; i++) {
		tag = b[i];
		map[a[i]][tag] = F;
		map[tag][a[i]] = F;
		vector<bool> d(m, T);
		if (Search(a[i], map, d))
			ans++;
		map[a[i]][tag] = T;
		map[tag][a[i]] = T;
	}
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

int main(){
  string s;
  int N;
  cin >> s;
  cin >> N;
  set<string> arr;
  int len = s.size();
  for(int i=0;i<len;i++){
    for(int j=1; j<=N; j++){
      string sub = s.substr(i,min(j,len-i));
      arr.insert(sub);
    }
  }
  auto itr = arr.begin();
  for(int n=0;n<N-1;n++){
    itr++;
  }
  cout << *itr << endl;
  // cout << arr[N-1] << endl;
  // for(int i=0;i<N;i++){
  //   cout<<arr[i]<<endl;
  // }
  // bool x=s.substr(0,2)<s.substr(1,2);
  // cout << arr[0] << endl;
  // cout << len << endl;
}

Measured memory_bytes: 1664
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): return k.join(list(map(str, lst)))
INF = float('inf')

from fractions import gcd
def lcm(x, y):
    return x // gcd(x, y) * y

def f(x, c, d):
    r = x
    r -= x // c
    r -= x // d
    r += x // lcm(c, d)
    return r

def f2(n, C, D):
    return n - n//C - n//D + n//lcm(C, D)

def solve():
    a, b, c, d = MI()

    # g = lcm(c, d)
    # bb = b - (b // c) - (b // d) + (b // g)
    # a = a - 1
    # aa = a - (a // c) - (a // d) + (a // g)
    # print(bb - aa)
    print(f(b, c, d) - f(a-1, c, d))
    # print(f2(b, c, d) - f2(a-1, c, d))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 5048
#include <stdio.h>

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

typedef struct{
    int y;
    int x;
} pos_t;

typedef struct{
    short fy;
    short fx;
    short ty;
    short tx;
} move_t;

char a[512][512];
move_t out[512*512];

int main(void){
    int h=gl(), w=gl();
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int t = getchar_unlocked() - 48;
            getchar_unlocked();
            a[i][j] = t;
        }
    }
    char haveCoin = 0;
    int pos = 0;
    pos_t now, old;
    for(int i=0; i<h; i++){
        now.y = i;
        for(int j=0; j<w; j++){
            now.x = i%2==0 ? j : w-1-j;
            if(haveCoin){
                out[pos].fy=old.y+1;
                out[pos].fx=old.x+1;
                out[pos].ty=now.y+1;
                out[pos].tx=now.x+1;
                pos++;
            }
            haveCoin ^= a[now.y][now.x]&1;
            old = now;
        }
    }
    printf("%d\n", pos);
    for(int i=0; i<pos; i++){
        printf("%d %d %d %d\n", out[i].fy, out[i].fx, out[i].ty, out[i].tx);
    }
    return 0;
}


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

namespace abc089_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split();
            Console.WriteLine(s.Contains("Y") ? "Four" : "Three");
        }
    }
}

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

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    
    if((a * b) > (c * d))
    {
        cout << a * b << endl;
    }
    else
    {
        cout << c * d << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 1 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    int r , d , xi;

    cin>>r >>d >>xi;
    
    vl v(11 , 0);

    for(int i=0; i<10; ++i){
        
        xi = r * xi - d;

        cout<<xi<<endl;

    }



    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("cin","r",stdin);
    freopen("cout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


Measured memory_bytes: 256
def insertion_sort(A, N):
    for i in range(1, N, 1):
        A_str = [str(x) for x in A]
        print(" ".join(A_str))
        v = int(A[i])
        j = i - 1
        while j >= 0 and int(A[j]) > v:
            A[j + 1] = int(A[j])
            j = j - 1
        A[j + 1] = v
    A_str = [str(x) for x in A]
    print(" ".join(A_str))


_N = int(input())
_A = list(input().split())
_A = [int(x) for x in _A]
insertion_sort(_A, _N)



Measured memory_bytes: 5604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int t = 1;
		int y = 1;
		int[][] ty = new int[10000][2];
		int count = 0;

		// tとyが0になるまで回して、二次元配列tyを埋める　一回作業するごとにcountが1増える
		for (int i = 0; t != 0 || y != 0; i++) {

			String line = sc.nextLine();
			String[] HW = line.split(" ");
			t = Integer.parseInt(HW[0]);
			y = Integer.parseInt(HW[1]);
			ty[i][0] = t;
			ty[i][1] = y;

			count++;

		}

		// tyとint変数countを使って＃で作った四角形を出力する
		for (int i = 0; i < count-1; i++) {

			StringBuilder x = new StringBuilder();
			for (int j = 0; j < ty[i][1]; j++) {

				x.append("#");

			}

			String z = x.toString();

			for (int j = 0; j < ty[i][0]; j++) {

				System.out.println(z);

			}
			System.out.println("");

		}

	}

}



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

using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge
{
	int v,next;
}vs[300010];
int st[300010],ee,n,size[300010],fg;
inline void addedge(int u,int v)
{
	vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee;
}
inline int dfs(int rt,int pr)
{
	int ret=1,cnt=0;
	for(int i=st[rt];i;i=vs[i].next)
	{
		if(vs[i].v==pr) continue;
		cnt+=dfs(vs[i].v,rt);
	}
	if(cnt>1) fg=1; 
	if(cnt==1) ret=0; 
	return ret;
}
int main()
{
	n=read(); 
	for(int i=1;i<n;i++)
	{
		int u=read(), v=read();
		addedge(u,v); addedge(v,u);
	}
	int x=dfs(1,0); if(x) fg=1;
	if(fg) cout << "First" << endl;
	else cout << "Second" << endl;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
ll mod_pow(ll x, ll p){
	ll res=1;
	ll n=x;
	while(p>0){
		if(p&1==1)res=(res*n)%MOD;
		n=(n*n)%MOD;
		p=(p>>1);
	}
	return res;
}

int main() {
    ll N; cin>>N;
    vector<bitset<60>> A(N);
    for (int i = 0; i < N; i++){
        ll a; cin>>a;
        A[i]=a;
    }
    vector<ll> num(60,0);
    for (int i = 0; i < N; i++){
        for (int j = 0; j < 60; j++){
            if(A[i][j])num[j]++;
        }
    }
    ll ans=0;
    for (int i = 0; i < 60; i++){
        ll tmp=num[i]*(N-num[i])%MOD;
        tmp*=mod_pow(2,i);
        tmp%=MOD;
        ans+=tmp;
        ans%=MOD;
    }
    cout<<ans<<endl;
}

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

int N;
string S[110];
int main (){
    cin >> N;
    for(int i=0; i<N; i++) cin >> S[i];
    char tail;
    for(int i=0; i<N; i++){
        string say = S[i];
        if( tail != say[0] && i > 0){
            cout << "No" << endl;
            return 0;
        }
        for(int j=0; j<i; j++){
            if( S[j] == say ) {
                cout << "No" << endl;
                return 0;
            }
        }
        int l = say.length();
        tail = say[l-1];
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  unordered_map<int,int> a;
  for (int i = 0; i < n; ++i)
  {
    int tmp;
    cin>>tmp;
    a[tmp]++;
  }

  bool table[(int)1e6+30]={};
  for(const auto& f: a) 
  {
    int e=f.first;
    if(f.second!=1) table[e]=true;
    for (int i = e*2; i <= 1e6+20; i+=e)
    {
      table[i]=true;
    }
  }
  int ans=0;
  for(const auto& e: a) 
  {
    if(!table[e.first]) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12384
/******************************************
* AUTHOR : SOMU KUMAR *
* INSTITUTION : IIT BHUBANESWAR *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//code here...............//
int x;
cin>>x;
cout<<(x==1? 0 : 1)<<endl;
return 0;
}

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

int main(){
    long long int mod = 998244353;
    int n;
    scanf("%d", &n);
    int d[n];
    long long int t[n], p[n];
    for(int i=0; i<n; i++){
        t[i] = 0;
        p[i] = 1;
    }
    for(int i=0; i<n; i++){
        scanf("%d", &d[i]);
    }
    for(int i=0; i<n; i++){
        t[d[i]]++;
    }
    for(int i=1; i<n; i++){
        long long int z = t[i-1];
        for(long long int j=1; j<t[i]; j++){
            z = ((z%mod) * (t[i-1]%mod))%mod;
        }
        if(t[i] == 0){
            p[i] = 0;
        }else{
        p[i] = z;
        }
    }
    if(d[0] != 0 || t[0] != 1){
        printf("0\n");
    }else{
        int f = 1;
        int x = 0;
        for(int i=1; i<n; i++){
            if(t[i] > 0){
                if(x != i-1){
                    f = 0;
                }
                x = i;
                p[i] = ((p[i-1]%mod) * (p[i]%mod))%mod;
            }
        }
        if(f){
        printf("%lld\n", p[x]);
        }else{
            printf("0\n");
        }
    }

    return 0;
}

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

int main() {
    int64_t x, y;
    cin >> x >> y;
    int ans = 0;
    while (x <= y) {
        x *= 2;
        ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
struct node{
    int v, d;
};
typedef long long LL;
vector<node> G[100010];
LL f[100010];
void dfs(int u, int fa, int d)
{
    f[u]=f[fa]+d;
    int len=G[u].size();
    for (int i=0; i<len; i++)
    {
        int v=G[u][i].v;
        if (v!=fa) dfs(v, u, G[u][i].d);
    }
}
int main()
{
    int n;
    scanf("%d", &n);
    for (int i=1; i<n; i++)
    {
        int u, v, d;
        scanf("%d%d%d", &u, &v, &d);
        G[u].push_back((node){v, d});
        G[v].push_back((node){u, d});
    }
    int Q, K;
    scanf("%d%d", &Q, &K);
    f[0]=0;
    dfs(K, 0, 0);
    while (Q--)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        cout<<f[x]+f[y]<<endl;
    }
}

Measured memory_bytes: 12800
def main():
    N,K = map(int, input().split())

    if N <= K:
        if abs(N-K) < N:
            print(abs(N-K))
        else:
            print(N)
    else:
        n = N%K
        if abs(n-K) < n:
            print(abs(n-K))
        else:
            print(n)

main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int n;
    cin >> n;
    if (n == 0){
      break;
    }
    vector<string> f(n);
    for (int i = 0; i < n; i++){
      cin >> f[i];
    }
    int ans = 0;
    for (int i = 0; i < n - 1; i++){
      if (f[i][0] != f[i + 1][0] && f[i][1] == f[i + 1][1]){
        ans++;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;
using ll = long long;

int main(){
  ll N; //NC3 < N^3 = 8*10^9 > INT_MAX
  cin >> N;

  vector<int> L(N);

  for(auto& l : L){
    cin >> l;
  }

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

  ll ans = 0;

  for(ll i = N-1; i > 1; --i){
    for(ll j = i-1; j > 0; --j){
      auto itr = lower_bound(L.begin(), L.end(), L[i] - L[j] + 1);
      ll index = distance(L.begin(), itr);
      if(j - index > 0){
        ans += j - index;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long int n,i,ans;
	cin>>n;
	long int t[n+1],x[n+1],y[n+1];
	t[0]=0;x[0]=0;y[0]=0;
	for(i=1;i<=n;i++)
	   cin>>t[i]>>x[i]>>y[i];
	for(i=1;i<=n;i++)
	  {
	      ans=x[i]+y[i]-x[0]-y[0];
	      if(t[i]<ans)
	        {
	        	  cout<<"No";
	        	  return 0;
	        }
	     else 
	       {
	       	 long int a=t[i]-ans;
	       	 if(a%2!=0)
	       	   {
	       	   	cout<<"No";
	       	   	return 0;
	       	   }
	       }
	  }
	cout<<"Yes";  
	return 0;
}


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

int main(){
  int N, M; cin >> N >> M; int dp[N][N], to[N][N] = {};
  rep(i, N){
    rep(j, N){
      dp[i][j] = inf;
    }
  }
  rep(i, M){
    int a, b, c; cin >> a >> b >> c;
    a--; b--; 
    dp[a][b] = c; dp[b][a] = c;
    to[a][b] = c; to[b][a] = c;
  }
  rep(k, N){
    rep(i, N){
      rep(j, N){
        dp[i][j] = min(dp[i][k] + dp[k][j], dp[i][j]);
      }
    }
  }
  int ans = 0;
  rep(i, N){
    rep(j, N){
      if(dp[i][j]<to[i][j] && i!=j) ans++;
    }
  }
  cout << ans/2 << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int gcd(int a,int b)
{
  int temp;

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

int main()
{
  int a,b;
  scanf("%d%d",&a,&b);
  printf("%d\n",gcd(a,b));

  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	while(1){
		int a,b,c,d,e,na,nb,nc,ans=0;
		cin>>a>>b>>c>>d>>e;
		if(a==0) break;
		cin>>na>>nb>>nc;
		int n=na+nb+nc,sum=a*na+b*nb+c*nc;
		if(n<d){
			if(sum>d*e) ans=d*e;
			else ans=sum;
		}else{
			if(nc>=d) ans=nc*e+nb*b+na*a;
			else if(nb+nc>=d){
				ans=min(sum,d*e+(nc+nb-d)*b+na*a);
			}else{
				ans=min(sum,d*e+(n-d)*a);
			}
		}
		o(ans);
	}

}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,h,w;
    cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;
}


Measured memory_bytes: 256
h,w,k = map(int,input().split())


c = [list(map( list,input().split())) for l in range(h)]
t=0


for i in range (2**h):
   a = [0] * w
   for p in range(h):
      for q in range(w):
         if c[p][0][q] == "#":
            if i//(2**p)%2==0:
               a[q]+=1
   for m in range(2**w):
      kk=0
      for j in range(w):
         if m//(2**j)%2==0:
            kk+=a[j]
      if k==kk:
         t+=1

print(t)


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

int solve() {
  int A, B, C;
  cin >> A >> B >> C;

  using Memo=tuple<int,int,int>;
  set<Memo> used;

  int i;
  for(i = 0; !((A&1)||(B&1)||(C&1)); ++i) {
    if(used.count(Memo(A, B, C))) return -1;
    used.emplace(A, B, C);
    auto a = A/2;
    auto b = B/2;
    auto c = C/2;
    A = b+c;
    B = a+c;
    C = a+b;
  }
  return i;
}

int main() {
  cout << solve() << endl;
}


Measured memory_bytes: 256
using System;

namespace AtCorderBeginner137
{
    public class Answer
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a;
            int.TryParse(input[0], out a);
            int b;
            int.TryParse(input[1], out b);

            int sum = a + b;
            int sub = a - b;
            int multi = a * b;
            if(sum >= multi && sum >= sub)
            {
                Console.WriteLine(sum);
            }
            else if(sub >= multi && sub >= sum)
            {
                Console.WriteLine(sub);
            }
            else
            {
                Console.WriteLine(multi);
            }
        }
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

typedef pair<int, ll> E;
vector<E> G[2500];
ll dist[2500];
int main() {
	int N, M, P;
	cin >> N >> M >> P;
	for (int i = 0; i < M; i++) {
		int A, B, C;
		cin >> A >> B >> C;
		A--; B--;
		G[A].emplace_back(B, P - C);
	}
	fill(dist, dist + N, INF);
	dist[0] = 0;
	for (int k = 1; k <= 2 * N; k++) {
		for (int i = 0; i < N; i++) {
			for (E e : G[i]) {
				if (dist[i] == -INF) {
					dist[e.first] = -INF;
					continue;
				}
				if (dist[i] !=INF && dist[e.first] > dist[i] + e.second) {
					if (k == N) dist[e.first] = -INF;
					else dist[e.first] = dist[i] + e.second;	
				}
			}
		}
	}
	if (dist[N - 1] == -INF) cout << -1 << endl;
	else cout << max(-dist[N - 1], 0LL) << endl;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

Vll a(55),p(55);
LL f(LL n, LL x){
    if(n == 0){
        return (x<=0)?0:1;
    }else if(x == 1){
        return 0;
    }else if(x <= 1 + a[n-1]){
        return f(n-1,x-1);
    }else if(x == 2+a[n-1]){
        return p[n-1]+1;
    }else if(x <= 2 + 2*a[n-1]){
        return p[n-1]+1+f(n-1,x-2-a[n-1]);
    }else if(x == 3 + 2*a[n-1]){
        return 2*p[n-1]+1;
    }
}

int main(){
    LL n,x;
    cin>>n>>x;
    a[0] = 1;
    p[0] = 1;

    REP2(i,1,n+1){
        a[i] = 2*a[i-1] + 3;
        p[i] = 2*p[i-1] + 1;
    }

    cout<<f(n,x)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int main(void){
  int n,ans=0;
  scanf("%d",&n);
  int a[n],b,c[n-1];
  FOR(n)scanf("%d",&a[i]);
  FOR(n){
    scanf("%d",&b);
    ans+=b;
  }
  FOR(n-1)scanf("%d",&c[i]);
  FOR(n-1)if(a[i+1]-a[i]==1)ans+=c[a[i]-1];
  PRN(ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	long long int x,k,d,n,ans;	cin>>x>>k>>d;
	x=abs(x);
	n=x/d;
	if(n>=k)	ans = x-k*d;
	else{
		x-=n*d;
		k-=n;
		if(k%2==0) ans = abs(x);
		else ans = min(abs(x-d),abs(x+d));
 
	}
 
	cout<<ans;
return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int top(int n){
    while(n >= 10){
        n /= 10;
    }
    return n;
}

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

    map<pii, int> mp;
    for (int i = 1; i <= n; ++i) {
        mp[pii(top(i), i%10)]++;
    }

    ll res = 0;
    for (auto &x : mp){
        int a = x.first.first;
        int b = x.first.second;
        if (a == b){
            res += x.second * x.second;
        }
        else{
            if (mp.count(pii(b, a)) > 0){
                res += x.second * mp[pii(b, a)];
            }
        }
    }
    cout << res << endl;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INTXT std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());
#define INF 1e9

using namespace std;
typedef long long ll;
static const ll MOD = 1000000007LL;

signed main() {
  IOS
  // INTXT
  int n;
  cin >> n;
  
  vector<int> rains(n);

  ll a = 0;
  REP(i, n){
    cin >> rains.at(i);
    if (i % 2 == 0){
      a += rains.at(i);
    }
    else{
      a -= rains.at(i);
    }
  }
  cout << a;

  REP(i, n - 1){
    a = rains.at(i) * 2 - a;
    cout << " " << a;
  }
  cout << endl;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	  	int a,b,c;
     	cin>>a>>b>>c;
		if(c-a+b > 0) 
     		cout<< (c-a+b) << endl;
     	else
     		cout<<"0\n";
     	return 0;
}

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

using namespace std;

int main(){
 
 int n;
 cin >> n;
 
 int js = 0;
 map<string , char> mp;
 while(n--){
  string s1;
  cin >> s1;
  
  
  if(!mp.count(s1)) js++, mp[s1]++;
 }
 cout << js << endl;
 return 0;
} 

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

int main() {
	long long int a, b, c;
	int x;
	bool flg = true;

	while (1) {
		cin>>a;
		if (cin.eof()) break;
		cin>>b;

		c=a+b;

		x = 1;
		flg = true;
		while (flg) {
			if ((c=c/10)>0)
				x++;
			else
				flg = false;
		}
		cout<<x<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
const long long INF=9e15;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long id=0;id<N;id++) cin>>v.at(id)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(N);
  vlin(a,N);
  ll res = 1;
  bool NG = false;
  rep(i ,N){
    if(a[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i, N){
    if(((ll)1e18 + a[i] - 1) / a[i] < res){
      NG = true;
      //cout << res << " " << a[i] << endl;
    }
    res *= a[i];
  }

  if(NG){
    cout <<  -1 << endl;
    return 0;
  }

  if(res > (ll)1e18){
    cout << -1 << endl;
    return 0;
  }

  cout << res << endl;
}

  


Measured memory_bytes: 4028
/* Headers */
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdio>
#include <cctype>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#define FOR(i,a,b,c) for(int i=(a);i<=(b);i+=(c))
#define ROF(i,a,b,c) for(int i=(a);i>=(b);i-=(c))
#define FORL(i,a,b,c) for(long long i=(a);i<=(b);i+=(c))
#define ROFL(i,a,b,c) for(long long i=(a);i>=(b);i-=(c))
#define FORR(i,a,b,c) for(register int i=(a);i<=(b);i+=(c))
#define ROFR(i,a,b,c) for(register int i=(a);i>=(b);i-=(c))
#define RevEdge(x) x^1
#define lowbit(x) x&(-x)
#define LeftChild(x) x<<1
#define RightChild(x) (x<<1)+1
#define CLOSE_IN() fclose(stdin);
#define CLOSE_OUT() fclose(stdout);
#define FILE_IN(x) freopen(x,"r",stdin);
#define FILE_OUT(x) freopen(x,"w",stdout);
#define IOS(x) std::ios::sync_with_stdio(x)
#define Dividing() printf("-----------------------------------\n");
namespace FastIO {
#define gc() (iS == iT ? (iT = (iS = ibuff) + fread(ibuff, 1, SIZ, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
    const int SIZ = 1 << 21 | 1;
    char* iS, * iT, ibuff[SIZ], obuff[SIZ], * oS = obuff, * oT = oS + SIZ - 1, fu[110], cc;
    int fr;
    inline void out() {
        fwrite(obuff, 1, oS - obuff, stdout);
        oS = obuff;
    }
    template<class Type>
    inline void read(Type& x) {
        x = 0;
        Type y = 1;
        for (cc = gc(); (cc > '9' || cc < '0') && cc != '-'; cc = gc());
        cc == '-' ? y = -1 : x = (cc & 15);
        for (cc = gc(); cc >= '0' && cc <= '9'; cc = gc())
            x = x * 10 + (cc & 15);
        x *= y;
    }
    template<class Type>
    inline void print(Type x, char text = '\n') {
        if (x < 0)
            * oS++ = '-', x *= -1;
        if (x == 0)
            * oS++ = '0';
        while (x)
            fu[++fr] = x % 10 + '0', x /= 10;
        while (fr);
            * oS++ = fu[fr--];
        * oS++ = text;
        out();
    }
    inline void prints(char x[], char text = '\n') {
        for (register int i = 0; x[i]; ++i)
            * oS++ = x[i];
        * oS++ = text;
        out();
    }
}
using namespace FastIO;
template<typename T>
inline T max(T a, T b) {return (a > b) ? a : b;}
template<typename T>
inline T min(T a, T b) {return (a > b) ? b : a;}
/* definitions */
const int MAXN = 1e5 + 10, MAXM = 4e2 + 10;
int n, m, a[MAXN], b[MAXN], ans;
bool alive[MAXM][MAXM], death[MAXN];
/* functions */
int main(int argc, char *argv[]) {
    /*FILE_IN("data.in");*/ read(n); read(m);
    FOR(i, 1, m, 1) read(a[i]), read(b[i]);
    FOR(i, 1, n, 1) {
        alive[i][i] = true;
        ROF(j, m, 1, 1) {
            int u = a[j], v = b[j];
            if(alive[i][u] && alive[i][v]) {death[i] = true; break;}
            if(alive[i][u] || alive[i][v]) {alive[i][u] = alive[i][v] = true;}

        }
    }
    FOR(i, 1, n, 1)
        FOR(j, i + 1, n, 1) {
            if(death[i] || death[j]) continue;
            bool flag = false;
            FOR(k, 1, n, 1) if(alive[i][k] && alive[j][k]) {flag = true; break;}
            if(!flag) ans++;
        }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 5444
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    int a = min({4 * Q, H + 2 * Q, 2 * H, S});
    if (2 * a > D) cout << (N / 2) * D + (N % 2) * a << endl;
    else cout << N * a << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

alice_score = 0
bob_score = 0

for i in range(len(a)):
    if i % 2 == 0:
        alice_score += a[i]
    else:
        bob_score += a[i]

print(alice_score - bob_score)


Measured memory_bytes: 3060
eval'H,W='+gets.split*?,
B=$<.map(&:chop)*?#+?#*W+=1
*Q=i=0
d=B.count ?.
p loop{(d-=1
i+=Q.size)if 0>i-=1
break d if H*W<3+k=Q.shift
[-W,-1,W,1].map{|l|B[l+=k][B[l]=?#]||Q<<l}}rescue p~0

Measured memory_bytes: 1788
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=1e6+5,M=2e6+5,MOD=1e9+7,OO=1e9;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();
	
	int n,m;

	cin>>n>>m;

	std::vector<string> a(n);
	for(int i=0;i<n;i++)cin>>a[i];

	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(a[i][j]=='#'){
				bool yes = false;
				for(int k=0;k<4;k++){
					int newx = i+dx[k];
					int newy = j+dy[k];
					if(newx>=0 && newx<n && newy>=0 && newy<m){
						if(a[newx][newy]=='#')yes = true;
					}
				}
				if(!yes)return cout<<"No\n",0;
			}

		}
	}

	cout<<"Yes\n";

}



Measured memory_bytes: 256
N ,M = map(int,input().split( ))
l = []
for i in range(M):
	p, y = map(int,input().split( ))
	l.append((y, p, i))
l.sort()


p_count  = [0 for i in range(N)]

l_2 = []
for i in range(M):
	p_count[l[i][1]-1] += 1
	l_2.append((l[i][2], l[i][1], p_count[l[i][1]-1]))
l_2.sort()
for i in range(M):
	print(str(l_2[i][1]).zfill(6)+str(l_2[i][2]).zfill(6))


Measured memory_bytes: 34044
import java.util.Scanner;

public class Main {
	void main() {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[]a=new int[n];
		for(int i=0;i<a.length;i++) {
			a[i]=sc.nextInt();
		}
		for(int i=n-1;i>=0;i--) {
			System.out.print(+a[i]);
			if(i>0) {
				System.out.print(" ");
			}
		}
		System.out.println();
	
	}

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

}



Measured memory_bytes: 26396
N = int(input())
F = [list(map(int,input().split())) for i in range(N)]
P = [list(map(int,input().split())) for i in range(N)]
 
ans = -10**9
for i in range(2**10-1):
  Bit = [1]*10
  for j in range(10):
    if (i>>j)&1:
      Bit[j]=0
  count = 0
  for k in range(N):
    op = sum(b&f for b,f in zip(Bit,F[k]))
    count+=P[k][op]
  ans = max(ans,count)
print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,i;
cin>>n;
int flag=1;
string str;
cin>>str;
if(n%2==0)
{for(i=0; i<n/2 ; i++)
if(str[i]!=str[n/2 +i])
{flag=0;
break;
}
if(flag==1)
cout<<"Yes";
else
cout<<"No";
}
else
cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << "2018";
    for (int i = 4; i < s.size(); ++i)
        cout << s[i];
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <bitset>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
using ppp = pair<pair<int, int>, pair<int, int>>;
#define MOD 1000000007
#define INF 1LL << 59
const int MAX = 510000;
const long long mod = 917120411LL;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int sieve[1000010];
void make_sieve()
{
    for (int i = 0; i < 1000010; ++i)
        sieve[i] = true;
    sieve[0] = sieve[1] = false;
    for (int i = 0; i * i < 1000010; ++i)
    {
        if (sieve[i])
        {
            for (int j = 2; j * i < 1000010; ++j)
            {
                sieve[i * j] = false;
            }
        }
    }
}

ll GCD(ll a, ll b)
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
ll pow_mod(ll x, ll n)
{
    ll res = 1;
    while (n)
    {
        if (n & 1)
        {
            res = res * x;
        }
        x = x * x;
        n >>= 1;
    }
    return res;
}

ll ans[200010];
ll a[200010];
int main()
{
    int N;
    cin >> N;
    vector<int> v;
    for (int i = 1; i <= N; ++i)
        cin >> a[i];
    for (int i = N; i >= 1; --i)
    {
        ll sum = 0;
        for (int j = i; j <= N; j += i)
        {
            sum += ans[j];
        }

        if (a[i] != sum % 2)
        {
            ans[i]++;
            v.push_back(i);
        }
    }

    cout << v.size() << endl;

    for (int i = 0; i < v.size(); ++i)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }

    return 0;
}


Measured memory_bytes: 5496
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAx = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAx, min_index = -1;

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

vector<pair<char, int>> strcompress(string S, int N){
    int count = 1;
    char c = S[0];
    vector<pair<char, int>> vec; 
	rep(i, N-1){
		if(c == S[i+1]){
			count++;
		}else{
			vec.push_back(make_pair(c, count));
			count = 1;
			c = S[i+1];
		}
	}
	vec.push_back(make_pair(c, count));
    return vec;
}

int main() {
    cin >> N >> K;
    cin >> R >> S >> P;
    string s;
    cin >> s;
    string t = "";
    ll score = 0;
    for(int i=0;i<N;i++){
        if(s[i] == 'r') {
            t += 'p';
            score += P;
        }
        else if(s[i] == 'p') {
            t += 's';
            score += S;
        }
        else {
            t += 'r';
            score += R;
        }
    }
    rep(i, K){
        string check = "";
        rep(j, N/K){
            check += t[j*K+i];
        }
        if(N%K > i) check += t[(N/K)*K+i];
        vector<pair<char, int>> vec = strcompress(check, check.size());
        rep(j, vec.size()) {
            if(vec[j].first == 'p') score -= P*(vec[j].second/2);
            if(vec[j].first == 'r') score -= R*(vec[j].second/2);
            if(vec[j].first == 's') score -= S*(vec[j].second/2);
        }
    }
    cout << score;
}


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

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

   int n, k;
   cin >> n >> k;
   vector <ll> a(n);
   for (auto &i : a)
      cin >> i;
   for (int i = k; i < n; i++) {
      if (a[i - k] < a[i])
         cout << "Yes\n";
      else
         cout << "No\n";
   }

   return 0;
}

Measured memory_bytes: 4784