akhauriyash/Code-Regression huggingface dataset:
// 問題の URL を書いておく
// https://atcoder.jp/contests/abc167/tasks/abc167_d

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

int main(int argc, const char* argv[])
{
    int n = Input<int>();
    int64_t k = Input<int64_t>();
    vector<int> a(n);
    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        a[i] = t - 1;
        Print(a[i]);
    }
    vector<bool> visit(n);

    int step = 0;
    int current = 0;
    int loopBegin = -1;
    map<int, int> stepMap{};

    vector<int> seq(n);
    while(true)
    {
        if(visit[current])
        {
            loopBegin = current;
            break;
        }
        visit[current] = true;
        stepMap[current] = step;
        seq[step] = current;

        current = a[current];
        step++;
    }

    int tillLoopStep = stepMap[loopBegin];
    int loopSize = step - tillLoopStep;

    Print(tillLoopStep);
    Print(loopSize);

    if(k < tillLoopStep)
    {
        cout << seq[k] + 1 << endl;
    }
    else
    {
        auto inLoop = k - tillLoopStep;
        auto mod = inLoop % loopSize;
        cout << seq[tillLoopStep + mod] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 14012
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <set>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  int n;
  cin >> n;
  set<string> s;
  for (int i=0; i<n; ++i ){
    string temp;
    cin >> temp;
    s.insert(temp);
  }
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 19224
#include<iostream>
#include<algorithm>
int main() {
	int L, A, B, C, D;
	std::cin >> L >> A >> B >> C >> D;
	int m, j;
	j = A / C;
	if (A%C != 0) {
		j = j + 1;
	}
	m = B / D;
	if (B%D != 0) {
		m = m + 1;
	}
	std::cout << L - std::max(j, m) << std::endl;
	return 0;
}

Measured memory_bytes: 3112
#include<iostream>
 
using namespace std;
 
int main(){
  
  int N;
  
  int a[200000];
  
  cin >> N;
  
  int Count = 0;
  
  int Count_ = 0;

  int j = 0;
  
  for(int i = 0; i < N; i++){
    
    cin >> a[i];
    
  }
  
  for(int i = 0; i < N; i++){
    
    for(j = Count_; j < N; j++){
      
      if(a[j] == i+1) {
        
        Count++;
        
        break;
        
      }
        
      else continue;
      
    }
    
    Count_ = j;
    
  }
  
  if(Count==0) cout << -1;
  
  else cout << N - Count;
  
}

Measured memory_bytes: 1024
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    Hs = list(map(int, input().split()))

    # Hs[0]から線形探索でOK
    ans, total = 0, 0
    for i in range(1, N):
        if Hs[i-1] >= Hs[i]:
            total += 1
            ans = max(ans, total)
        else:
            total = 0

    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 15020
def main():
    N = int(input())
    XL = [[int(i) for i in input().split()] for j in range(N)]
    rs = [[xl[0] - xl[1], xl[0] + xl[1]] for xl in XL]
    rs.sort(key=lambda p: p[1])
    ans = 1
    pre = rs[0][1]
    for r in rs[1:]:
        if pre <= r[0]:
            ans += 1
        else:
            continue
        pre = r[1]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 77656
#include <stdio.h>

int main(void){
        int x, y;

        while(1){
                scanf("%d %d", &x, &y);

                if( x==0 && y==0 )
                        break;

                else{

                        if( x<=y )
                                printf("%d %d", x, y);
                        else
                                printf("%d %d", y, x);

                        putchar('\n');
                }
        }

        return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int a,b,t;
    cin>>a>>b>>t;
    cout<<(t/a)*b<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    K = int(input())
    A, B = map(int, input().split())

    res = 'NG'
    for i in range(A//K, B+1):
        if K*i >= A and K*i<=B:
            res = 'OK'
            break
    print(res)            



if __name__ == '__main__':
    main()

Measured memory_bytes: 61932
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        double R = sc.nextInt();
        System.out.println(Math.PI*R*2);
    }

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


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

int main() {

    int n;
    cin >> n;

    vector<long> A(n);

    for (int i = 0; i < n; i++) {
        cin >> A.at(i);
    }

    long max = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            
            if (A.at(i) >= A.at(j) ) {
                if (A.at(i) - A.at(j) > max) {
                    max = A.at(i) - A.at(j);
                }
            } else {
                if (A.at(j) - A.at(i) > max) {
                    max = A.at(j) - A.at(i);
                }
            }
        }
    }

    cout << max ;    

    return 0;

    
    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n,A[MAXN];
int main()
{
	FAST
	cin>>n;
	FOR(i,0,n) {
		cin>>A[i];
	}
	ll ans = 0;
	FOR(i,0,n) {
		ll a; cin >> a;
		ans += max(0ll,A[i]-a);
	}
	cout<<ans;
}


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

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    int res=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(k==i*m+j*n-2*i*j)res=1;
        }
    }
    if(res)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
/* Made by Takauov Yerzhan - 31/01/2020 */
#include <bits/stdc++.h>
#define enter endl
#define LL long long
#define LD long double
#define UL unsigned long long
#define Okoshka ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define F first
#define S second

using namespace std;

const LL MXN = 3e5 + 7;
const LL MOD = 1e9 + 7;
const LL INF = 1e18 + 7;

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

int h, n, a[MXN], b[MXN];

LL dp[MXN];

int main()
{
    ///Okoshka;
    cin >> h >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i];
    }
    for(int i = 1; i <= h; i++){
        dp[i] = MOD;
    }
    dp[0] = 0;
    for(int i = 0; i <= h; i++){
        for(int j = 1; j <= n; j++){
            dp[i] = min(dp[i], dp[max(0, i - a[j])] + b[j]);
        }
    }
    cout << dp[h];
}


Measured memory_bytes: 2432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		
		System.out.println(reverse(str));
	}

	public static String reverse(String source) {
		StringBuffer dest = new StringBuffer();
		for (int i = source.length() - 1; i >= 0; i--) {
			dest.append(source.charAt(i));
		}
		return dest.toString();
	}
}

Measured memory_bytes: 24084
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <memory.h>
#include <algorithm>
#include <cassert>

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(c) (c).begin(), (c).end()
#define sz(c) int((c).size())
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fst first
#define snd second

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using pii = pair<int, int>;

#define FNAME "a"

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr);
#else
#define eprintf(args...) ;
#endif

const int MOD = 1e9 + 7;

void add(int& x, int y) {
    ((x += y) >= MOD) && (x -= MOD);
}

void sub(int& x, int y) {
    add(x, -y + MOD);
}

int mul(int x, int y) {
    return x * 1ll * y % MOD;
}

int mpow(int a, int p) {
    int res = 1;
    for (; p > 0; p >>= 1, a = mul(a, a)) {
        if  (p & 1) {
            res = mul(res, a);
        }
    }
    return res;
}

int inv(int x) {
    int y = mpow(x, MOD - 2);
    assert(mul(x, y) == 1);
    return y;
}

int N;

bool read() {
    if  (!(cin >> N)) {
        return 0;
    }
    return 1;
}

const int MAXN = 2e6 + 10;

int fact[MAXN];
int inv_fact[MAXN];

void precalc() {
    fact[0] = 1;
    for (int i = 1; i < MAXN; ++i) {
        fact[i] = mul(fact[i - 1], i);
    }
    forn(i, MAXN) {
        inv_fact[i] = inv(fact[i]);
    }
}

int binom(int n, int k) {
    if  (n < k || n < 0 || k < 0) {
        return 0;
    }
    return mul(fact[n], mul(inv_fact[n - k], inv_fact[k]));
}

int partition(int n, int k) {
    // n = a1 + ... + a_{k}, a_i > 0
    return binom(n - 1, k - 1);
}

int get(int k) {
    // cnt sets # = k, all covered
    if  (k < 2) {
        return 0;
    }
    k = N - 1 - k;
    assert(k >= 0);
    assert(k <= N - 3);

    return partition(N - 1 - k, k + 1);
}

int solve() {
    if  (N == 2) {
        return 1;
    } 

    int all = mul(fact[N - 1], N);
    forn(k, N) {
        int cur = get(k);
        cur = mul(cur, fact[k]);
        cur = mul(cur, fact[N - 1 - k]);
        sub(all, cur);
    }

    return all;
}

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

#ifdef LOCAL
    freopen(FNAME ".in", "r", stdin);
    freopen(FNAME ".out", "w", stdout);
#endif

    precalc();

    while (read()) {
        int ans = solve();
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 15872
def resolve():
    def addans(i, ans):
        return ans * i % mod
    import sys
    import bisect
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    inf = float("inf")
    n, k = map(int, input().split())
    a = sorted(list(map(int, input().split())))
    l = bisect.bisect_left(a, 0)
    r = bisect.bisect_right(a, 0)
    ans = 1
    minus = a[::-1]
    plus = a[:]
    if r == n and k % 2 == 1:
        ans = 1
        for i in range(k):
            ans = addans(a[-i - 1], ans)
        print(ans)
        return
    if k % 2 == 1:
        ans = plus.pop()
        k -= 1
    try:
        m = minus.pop() * minus.pop()
    except:
        m = -inf
    try:
        p = plus.pop() * plus.pop()
    except:
        p = -inf
    for _ in range(k // 2):
        if p >= m:
            ans = addans(p, ans)
            try:
                p = plus.pop() * plus.pop()
            except:
                p = -inf
        else:
            ans = addans(m, ans)
            try:
                m = minus.pop() * minus.pop()
            except:
                m = -inf
    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 31648
#include <stdio.h>
#include <algorithm>
int  l, m, r, s;
long long x, y, n;
int a[100000];
int e[100000];
int b[300001];
int main() {
	scanf("%lld", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", a + i);
		e[i] = a[i];
	}
	std::sort(e, e + n);
	l = 0;
	r = n;
	while (r - l - 1) {
		m = (l + r) / 2;
		b[s = n]++;
		x = 0;
		y = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] < e[m]) {
				x += b[s];
				s++;
			}
			else {
				s--;
				x -= b[s];
			}
			b[s]++;
			y += x;
		}
		for (int i = 0; i <= 3 * n; i++) b[i] = 0;
		if (4 * y > (n * (n + 1))) r = m;
		else l = m;
	}
	printf("%d\n", e[l]);
}

Measured memory_bytes: 3672
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Thu Dec  6 02:18:23 2018
//
package main

import (
	"fmt"
	"sort"
)

var N, K int

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

func timeMin(first []int, second []int) int {
	timeMin := 1000000000
	for i := 1; i <= K; i++ {
		if i <= len(first) && K-i <= len(second) {
			var time int
			if K-i-1 < 0 {
				time = first[i-1]
			} else {
				time = 2*first[i-1] + second[K-i-1]
			}

			timeMin = min(time, timeMin)
		}
	}

	return timeMin
}

func main() {
	fmt.Scan(&N, &K)

	var left, right []int
	for i := 0; i < N; i++ {
		var x int
		fmt.Scan(&x)
		if x < 0 {
			left = append(left, -x)
		} else {
			right = append(right, x)
		}
	}
	sort.Ints(left)

	fmt.Println(min(timeMin(left, right), timeMin(right, left)))
}


Measured memory_bytes: 5504
from collections import Counter

N, M = map(int, input().split())
A = [0] + [int(s) for s in input().split()]

S = [0] * (N + 1)
for i in range(1, N + 1):
    S[i] = (S[i - 1] + A[i]) % M

c = Counter()
ans = 0
for i in range(N + 1):
    ans += c[S[i]]
    c[S[i]] += 1

print(ans)


Measured memory_bytes: 15948
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
 cin >> N;
  vector<int> a(N);
  for(int i = 0;i<N;i++){
    cin >> a[i];
  }
  int S = a[0];
  int c = 0;
  for(int j = 0;j<N;j++){
    c++;
    if(S == 2){
      cout << c << endl;
      return 0;
    }
    S = a[S-1];
  }
  cout << -1 << endl;
  
}

Measured memory_bytes: 640
N = int(input())
T = []

for _ in range(N):
    T.append(int(input()))

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

ans = T[0]
for i in range(N-1):
    ans = lcm(ans,T[i+1])

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int h[1005];

int main() {
    FIO
    int n; cin >> n;
    int t, a; cin >> t >> a;
    double _max = 1000000.0, temp = 0.0;
    int ans = 0;
    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 1; i <= n; i++) {
    	temp = t - (h[i]*0.006);
    	if (abs(temp-a) < _max) {
    		_max = abs(temp-a);
    		ans = i;
    	}
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
void f(int a, int b, int u) {
	if (u) {
		int d = (a ^ b) & u;
		d &= -d;
		u ^= d;
		int c = a ^ u & -u;
		f(a, c, u);
		f(c ^ d, b, u);
	} else {
		printf("%d ", a);
	}
}
int main() {
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	if (__builtin_parity(a ^ b)) {
		puts("YES");
		f(a, b, (1 << n) - 1);
	} else {
		puts("NO");
	}
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>

int main(){
	int n,data[3];
	std::cin>>n;
	for(int i=0;i<n;i++){
		std::cin>>data[0]>>data[1]>>data[2];
		std::sort(data,data+3);
		std::cout<< (data[0]*data[0]+data[1]*data[1]==data[2]*data[2]?"YES":"NO")<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1172
#include<stdio.h>
#define A 50
#define B 50
#define N 20

int main(void)
{
    int a = 0;
    int b = 0;
    int n = 0;
    int sum_tx = 0;

    scanf("%d %d %d", &n, &a, &b);
    if(a >= 1 && b >= 1 && n >= 1){
        if(a <= A && b <= B && n <= N){
            sum_tx = a*n;
            if(sum_tx >= b) printf("%d", b);
            else printf("%d", sum_tx);
        }
    }
    return 0;
}


Measured memory_bytes: 128
import datetime

while True:
  y1, m1, d1, y2, m2, d2 = map(int, input().split())
  if y1 < 0 or m1 < 0 or d1 < 0 or y2 < 0 or m2 < 0 or d2 < 0:
    break

  D1 = datetime.datetime(y1, m1, d1)
  D2 = datetime.datetime(y2, m2, d2)
  dD = D2 - D1
  print(dD.days)


Measured memory_bytes: 6040
a, b, c, x, y = map(int, input().split())
cost = float('inf')

for i in range(x+1):
    n = x - i
    if y >= n:
        pay = a*i + 2*n*c + (y-n)*b
    else:
        pay = a*i + 2*n*c
    if cost > pay:
        cost = pay

for i in range(y+1):
    n = y -i
    if x >= n:
        pay = b*i + 2*n*c + (x-n)*a
    else:
        pay = b*i + 2*n*c
    if cost > pay:
        cost = pay
print(cost)

Measured memory_bytes: 3064
x,y=list(map(int,input().split()))
if x>=0 and y>0:
    if x>y:
        print(2+x-y)
    else:
        print(y-x)
elif x<0 and y>0:
    print(abs(x+y)+1)
elif x>=0 and y<0:
    print(abs(x+y)+1)
elif x<0 and y<0:
    if x>y:
        print(2+x-y)
    else:
        print(y-x)
elif y==0:
    if x<=0:
        print(abs(x))
    else:
        print(x+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    string s;
    cin>>s;

    string t;
    cin>>t;
    int found = 0;
    rep(i,0,s.length())
    {
        if ( s[i] != t[i] )
        {
            found = 1;
            break;
        }
    }

    if ( found == 1 )
    {
        cout<<"No"<<endl;
    }
    else
    {
        {
            cout<<"Yes"<<endl;
        }
    }
    
    
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <utility>
using namespace std;

#define INF 100

int main(void){
  int n;
  cin >> n;
  for(int dataset = 0; dataset < n; dataset++){
    int h, w;
    cin >> h >> w;

    vector<string> input(h);
    vector<vector<int> > screening(h, vector<int>(w));
    map<char, int> material;
    vector<pair<pair<int, int>, pair<int, int> > > range;
    for(int i = 0; i < h; i++){ cin >> input[i]; }
    for(int i = 0; i < h; i++)
      for(int j = 0; j < w; j++)
        if(input[i][j] != '.' && material.count(input[i][j]) == 0)
          material[input[i][j]] = material.size();
    material['.'] = material.size();
    for(int i = 0; i < h; i++)
      for(int j = 0; j < w; j++)
        screening[i][j] = material[input[i][j]];
    
    for(int k = 0; k < (int)material.size(); k++){
      int minh = INF, minw = INF, maxh = 0, maxw = 0;
      for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
          if(screening[i][j] == k){
            minh = min(minh, i);
            maxh = max(maxh, i);
            minw = min(minw, j);
            maxw = max(maxw, j);
          }
        }
      }
      range.push_back(make_pair(make_pair(minh, minw), make_pair(maxh, maxw)));
    }

    
    vector<bool> dp(1 << material.size(), false);
    dp[0] = true;
    for(int i = 0; i < (1 << material.size()); i++){      
      if(dp[i]){
        for(int j = 0; j < (int)material.size(); j++){
          if((i & (1 << j)) == 0){
            int next = i | (1 << j);
            if(!dp[next]){
              bool flag = true;
              int minh = range[j].first.first;
              int minw = range[j].first.second;
              int maxh = range[j].second.first;
              int maxw = range[j].second.second;
              for(int k = minh; flag && k <= maxh; k++)
                for(int m = minw; flag && m <= maxw; m++)
                  flag = ((next & (1 << screening[k][m])) != 0);
              dp[next] = flag;
            }
          }
        }
      }
    }

    if(dp[dp.size() - 1]){ cout << "SAFE" << endl; }
    else{ cout << "SUSPICIOUS" << endl; }
  }

  return 0;
}

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

int main() {
    int x;
    int i = 1;
    while(true) {
        cin >> x;
        if (x == 0) {
            break;
        }
        cout << "Case " << i << ": " << x << endl;
        i++;
    }
    return 0;
}


Measured memory_bytes: 2996
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <stdio.h>
const long long INF=1e18;

using namespace std;

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

    int ans=0;
    vector<int>a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }

    for(int i=0;i<N;i++){
        if((a[i]%2!=0&&(i+1)%2!=0)||(a[i]==1&&(i+1)%2!=0)){
            ans++;
        }
    }

    cout<<ans<<endl;

}


Measured memory_bytes: 3636
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int tmp;
    if (a > b) {
      tmp = a;
      a = b;
      b = tmp;
    }
    if (a > c) {
      tmp = a;
      a = c;
      c = tmp;
    }
    if (b > c) {
      tmp = b;
      b = c;
      c = tmp;
    }

    System.out.printf("%d %d %d\n", a, b, c);
  }
}



Measured memory_bytes: 26248
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define sc second
typedef pair<int,int> P;
typedef pair<int,P> PP;
int stringintoint(string S){
	int res=S[0]-'0';
	for(int i=1;i<(int)S.length();i++){
		res*=10;
		res+=(S[i]-'0');
	}
	return res;
}
int main()
{
	while(true){
		int M,N,K,D;
		scanf("%d%d%d%d",&M,&N,&K,&D);
		if(M==0&&N==0&&K==0&&D==0)break;
		int calo[6];
		for(int i=0;i<M;i++)scanf("%d",&calo[i]);
		vector<PP>G;
		int S[150][1<<6];
		for(int i=0;i<=M+N+1;i++){
			for(int j=0;j<(1<<6);j++){
				S[i][j]=1<<30;
			}
		}
		for(int i=0;i<D;i++){
			string S1,S2;
			int X;
			cin >> S1 >> S2 >> X;
			X*=K;
			int v1,v2;
			if(S1=="H")v1=0;
			else if(S1[0]=='C'){
				v1=stringintoint(S1.substr(1));
			}
			else if(S1[0]=='L'){
				v1=M+stringintoint(S1.substr(1));
			}
			else{
				v1=M+N+1;
			}
			if(S2=="H")v2=0;
			else if(S2[0]=='C'){
				v2=stringintoint(S2.substr(1));
			}
			else if(S2[0]=='L'){
				v2=M+stringintoint(S2.substr(1));
			}
			else{
				v2=M+N+1;
			}
			G.pb(PP(X,P(v1,v2)));
			G.pb(PP(X,P(v2,v1)));
		}
		/*
		for(int i=0;i<12;i++){
			printf("%d %d %d\n",G[i].fi,G[i].sc.fi,G[i].sc.sc);
		}*/
		S[0][0]=0;
		while(true){
			bool update=false;
			for(int i=0;i<(2*D);i++){
				for(int j=0;j<(1<<M);j++){
					if(G[i].sc.sc>=1&&G[i].sc.sc<=M&&((j>>(G[i].sc.sc-1))&1))continue;
					if(S[G[i].sc.fi][j]==(1<<30))continue;
					if(G[i].sc.sc>=1&&G[i].sc.sc<=M){
						//if(G[i].sc.sc==1&&j==2&&i==3)printf("114514\n");
						if(S[G[i].sc.sc][j+(1<<(G[i].sc.sc-1))]>S[G[i].sc.fi][j]+G[i].fi-calo[G[i].sc.sc-1]){
							update=true;
							S[G[i].sc.sc][j+(1<<(G[i].sc.sc-1))]=S[G[i].sc.fi][j]+G[i].fi-calo[G[i].sc.sc-1];
							//printf("%d,%d::%d %d:%d\n",i,j,G[i].sc.sc,j+(1<<(G[i].sc.sc-1)),S[G[i].sc.sc][j+(1<<(G[i].sc.sc-1))]);
						}
					}
					else{
						if(S[G[i].sc.sc][j]>S[G[i].sc.fi][j]+G[i].fi){
							update=true;
							S[G[i].sc.sc][j]=S[G[i].sc.fi][j]+G[i].fi;
							//printf("%d,%d::%d %d:%d\n",i,j,G[i].sc.sc,j,S[G[i].sc.sc][j]);
						}
					}
				}
			}
			if(!update)break;
			//printf("\n");
		}
		//printf("%d %d\n",S[3][2],S[1][3]);
		int ans=1<<30;
		for(int i=0;i<(1<<M);i++){
			ans=min(ans,S[M+N+1][i]);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1316
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>

#define For(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  For(i,0,n)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
void printhoge(set<int> v) {
	ALL(it, v) {
		cout << *it << " ";
	}
	cout << endl;

}



int main() {
	string s;
	ll k;
	cin >> s >> k;
	if (s[0] != '1') {
		cout << s[0] << endl;
		return 0;
	}

	int piv = 0;
	while (piv < s.length() && k > 0) {
		if (s[piv] == '1' && k != 0) {
			k--;
			piv++;
			continue;
		}
		cout << s[piv] << endl;
		return 0;
	}
	cout << 1 << endl;
	return 0;

}



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

public class Solution
{
    // max: 対象を含む
    static long Count(long min, long max, int d)
    {
        if (max < d)
        {
            return 0;
        }

        long count = 0;
        for (long cur = min; cur <= max; cur *= d)
        {
            var left = Math.Max(cur, min / cur * cur);
            var right = max / cur * cur;
            count += (right - left) / cur + 1;
        }
        return count;
    }

    public static void Main()
    {
        var n = long.Parse(Console.ReadLine());
        if (n <= 2 || n % 2 != 0)
        {
            Console.WriteLine(0);
            return;
        }
        var twos = Count(2, n, 2);
        var fives = Count(10, n, 5);
        var tens = Math.Min(twos, fives);
        Console.WriteLine(tens);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
	const int path[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1 };
//	cut here before submit 
//	freopen ("testcase.busline2", "r", stdin );
	string str = "";
	int n;

	while (getline (cin, str ) ){
		stringstream ssn(str);
		ssn >> n;
		if (n == 0 ){
			break;
		} // end if
		int i, j, k;
		for (i = 0; i < n; ++i){
			getline (cin, str );
			if (str.empty() ){
				break;
			} // end if
			vector <int> res;
			int from, to;
			stringstream ss(str);
			ss >> from >> to;
			int len = sizeof(path)/sizeof(path[0]);
			if (from < to ){
				for (j = from; j != to; j = (j + 1) % len ){
					res.push_back(path[j]);
				} // end for
			}else if (from > to ){
				bool found = (from < 6 ? false : true);
				for (k = 0; k < len; ++k){
					if (path[k] == from){
						if (!found ){
							found = true;
							continue;
						}else{
							break;
						} // end if
					} // end if
				} // end for
				for (j = k; j != to && path[j] != to; j = (j + 1) % len ){
					res.push_back(path[j]);
				} // end for
			} // end if
						
			res.push_back(path[to] );

			int size = res.size();
			for (j = 0; j < size; ++j){
				cout << res[j];
				if (j != size - 1){
					cout << ' ';
				} // end if
			} // end for
			cout << endl;
		} // end for
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    long long luca[n+1];
    luca[0]=2;
    luca[1]=1;
    for (int i=2; i<=n; i++)
    {
        luca[i]=luca[i-1]+luca[i-2];
    }
    cout<<luca[n];
    return 0;
}


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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<int> v(N);
    for(auto& e : v)
        cin >> e;

    sort(v.begin(), v.end());
    int sum = 0;
    for(int i = 0; i < N - 1; ++i)
        sum += v[i];

    cout << (v[N - 1]< sum  ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <stack>
#include <string>
#include <map>

using namespace std;

int s(vector<int> a, vector<int> b) {
	int s = 0;
	for (int i = 0; i < a.size(); i++)
		s += (a[i] * b[i]);
	return s;
}

int main()
{
	int N, M, C, ctr = 0;
	cin >> N >> M >> C;
	vector<int>B(M);
	for (int i = 0; i < M; i++)
		cin >> B[i];

	vector<vector<int>>A(N, vector<int>(M,0));
	for (int i = 0; i < N; i++){
		for (int j = 0; j < M; j++)
			cin >> A[i][j];
		if (s(A[i], B) + C > 0)
			ctr++;
	}
	cout << ctr << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
#include<algorithm>
int main(void)
{
	char S[100000];
	scanf("%s", S);
	int count[2] = { 0 };
	int i = 0;
	while (S[i]!='\0') {
		if (S[i] == '1')
			count[0]++;
		else
			count[1]++;
		i++;
	}

	if (count[0] > count[1]) {
		printf("%d", count[1] * 2);
	}
	else
		printf("%d", count[0] * 2);

	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main() {
  long int a, b, ans;
  scanf("%ld %ld", &a, &b);
  long int x = a*b;

  if (a<b) {  //swap
    long int tmp = a;
    a = b;
    b = tmp;
  }

  //ユークリッドの互除法
  long int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  ans = x/b;
  printf("%ld\n", ans);
  return 0;
}


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

int main()
{
ll n ;
cin >> n ;
string s[n];
rep(i, n){
  cin >> s[i];
}
rep(i,n){
  sort(s[i].begin(),s[i].end());
}
map<string,ll> m;
rep(i,n){
  m[s[i]]++;
}
for (auto i = m.begin(); i != m.end(); ++i) {
  if((i->second)>1)ans+=i->second*(i->second-1);
}
cout << ans/2 << endl;
return 0;
}


Measured memory_bytes: 18176
#include<stdio.h>

void initialize(int a[],int num){
	for(num--;num>=0;num--){
		a[num]=0;
	}
	
}

int findResult(int numbers[],int max[]){
	int outputCnt=0,maxCnt=0;
	int i;
	
	for(i=1;i<=100;i++){
		if(maxCnt<numbers[i]){
			outputCnt=0;
			maxCnt=numbers[i];
		}
		if(maxCnt==numbers[i]){
			max[outputCnt]=i;
			outputCnt++;
		}
		
	}
	
	
	return outputCnt;
}

void outputResult(int numbers[],int cnt){
	int i;
	for(i=0;i<cnt;i++){
		printf("%d\n",numbers[i]);
	}
	
}

int main(){
	int numbers[101];
	int result[100];
	int inputedNum;
	int resultCnt;
	
	initialize(numbers,101);
	
	while(scanf("%d",&inputedNum)!=EOF){
		numbers[inputedNum]++;
	}
	
	resultCnt=findResult(numbers,result);
	
	outputResult(result,resultCnt);
	
	return 0;
}

Measured memory_bytes: 0
import           Control.Applicative
import           Control.Monad
import           Data.Char
import           Data.List

main :: IO ()
main = do
  (word:text) <- takeWhile (/= "END_OF_TEXT") . lines <$> getContents
  print (length $ filter (== (map toLower word)) (concatMap (map (map toLower) . words) text))



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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll m, k;
	cin >> m >> k;
	
	if (k >= (1 << m)) {
		cout << -1 << endl;
	} else if (k == 0) {
		FOR(i,0,1 << m) cout << i << " " << i << " ";
		cout << endl;
	} else if (m == 1) {
		cout << -1 << endl;
	} else {
		FOR(i,0,1 << m) if (i != k) cout << i << " ";
		cout << k << " ";
		FORD(i,0,1 << m) if (i != k) cout << i << " ";
		cout << k << endl;
	}
}



Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,i,j,k,l,r,l1,r1,pos,pos1,len;
	string s,s1;
	cin>>n>>m>>len>>pos>>pos1>>s>>s1;
	l=1;
	l1=1;
	r=m;
	r1=n;
	for(i=len-1;i>=0;i--){
		if(s1[i]=='L'||s1[i]=='R'){
			if(s1[i]=='L'){
				r++;
				if(r>m){
					r=m;
				}
			}
			else{
				l--;
				if(l<1){
					l=1;
				}
			}
		}
		else{
			if(s1[i]=='U'){
				r1++;
				if(r1>n){
					r1=n;
				}
			}
			else{
				l1--;
				if(l1<1){
					l1=1;
				}
			}
		}
		if(s[i]=='L'||s[i]=='R'){
			if(s[i]=='L'){
				l++;	
			}
			else{
				r--;
			}
		}
		else{
			if(s[i]=='U'){
				l1++;
			}
			else{
				r1--;
			}
		}
		//cout<<l<<" "<<r<<" "<<l1<<" "<<r1<<endl;
		if(l1>r1||l>r){
			cout<<"NO";
			return 0;
		}
	}
	if(pos>=l1&&pos<=r1&&pos1>=l&&pos1<=r){
		cout<<"YES";
	}
	else{
		cout<<"NO";
	}
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

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

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

template<class T>
T Sq(const T& t){
	return t*t;
}

int main(){
	string s=readString();
	int ans=0;
	char last='$';
	for(auto c:s){
		if(c!=last)
			ans++;
		last=c;
	}
	cout<<ans-1<<endl;
}


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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it = (c).begin(); it != (c).end(); it++)
#define X first
#define Y second

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 21;
vector< vector<bool> > m(N);

const string DI = "NESW";
const int DX[4] = {0, 1, 0, -1};
const int DY[4] = {1, 0, -1, 0};

int main(void){
    map<char, pii> d;
    rep(i, 4) d[DI.at(i)] = mp(DX[i], DY[i]);
    rep(i, N) m[i].resize(N);

    string res;
    for(int n; res = "Yes", cin >> n, n; cout << res << endl){
        rep(i, N) fill(ALL(m[i]), false);

        while(n -- ){
            int x, y; cin >> x >> y;
            m[y][x] = true; }
        
        pii cur = mp(10, 10);
        m[cur.Y][cur.X] = false;
        cin >> n;
        while(n --){
            char dir; cin >> dir;
            int len; cin >> len;

            while(len --){
                cur.X += d[dir].X, cur.Y += d[dir].Y;
                m[cur.Y][cur.X] = false;
            }
        }

        rep(i, N) if(find(ALL(m[i]), true) != m[i].end()) res = "No";
    }

    return 0;
}

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

int main() {
    const string ACGT = "ACGT";
    string S;
    cin >> S;

    size_t longest = 0;
    size_t startPos = 0;
    auto npos = static_cast<size_t>(-1);
    while(startPos < S.length()) {
        if((startPos = S.find_first_of(ACGT, startPos)) == npos)
            break;
        auto endPos = S.find_first_not_of(ACGT, startPos);
        size_t L = endPos == npos ? S.length() - startPos : endPos - startPos;
        if(L > longest)
            longest = L;
        startPos = endPos;
    }
    cout << longest << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    REP(i, 0, N) {
        cin >> a[i];
    }
    ll pa = 0;

    REP(i, 0, N) {
        ll tmp = a[i] / 2;
        pa += tmp;
        a[i] -= (2 * tmp);
        if(i < N - 1){
            if(a[i] == 1 && a[i+1] > 0){
                a[i]--;
                a[i+1]--;
                pa++;
            }
        }
    }

    cout << pa << endl;
    return 0;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	double t, x;
	cin >> t >> x;
	cout << t/x << endl;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};

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

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int main(){
	int c[3][3];
	REP(i,3)REP(j,3)cin>>c[i][j];
	REP(a1,101){
		REP(a2,101){
			REP(a3,101){
				bool judge=false;
				if(c[0][0]-a1==c[1][0]-a2 && c[1][0]-a2==c[2][0]-a3){
					if(c[0][1]-a1==c[1][1]-a2 && c[1][1]-a2==c[2][1]-a3){
						if(c[0][2]-a1==c[1][2]-a2 && c[1][2]-a2==c[2][2]-a3){
							judge=true;
						}
					}
				}
				if(judge){
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

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

    vector<int> s(N);
    int res = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> s.at(i);
        res += s.at(i);
    }

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

    if (res % 10 != 0)
    {
        cout << res << endl;
        return 0;
    }

    for (int i = 0; i < N; i++)
    {
        if (s.at(i) % 10 != 0)
        {
            cout << res - s.at(i) << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w,m; cin >> h >> w >> m;
  int br[300001];
  int bc[300001];
  int cntr[300001] = {};
  int cntc[300001] = {};
  int maxr=0,maxc=0;
  for(int i = 0; i < m; ++i){
    cin >> br[i] >> bc[i];
    ChangeMax(maxr,++cntr[br[i]]);
    ChangeMax(maxc,++cntc[bc[i]]);    
  }
  bitset<300001>r,c;
  int cr=0,cc=0;
  if(w < h)for(int i = w+1; i <= h; ++i)if(maxr == cntr[i])cr+=r[i] = 1;
  if(h < w)for(int i = h+1; i <= w; ++i)if(maxc == cntc[i])cc+=c[i] = 1;
  for(int i = min(w,h); i >= 1; --i){
    if(maxr == cntr[i])cr+=r[i] = 1;
    if(maxc == cntc[i])cc+=c[i] = 1;
  }
  int cntd = 0;
  for(int i = 0; i < m; ++i)
    cntd += c[bc[i]]&r[br[i]];
  cout << maxr + maxc - (cntd == cr*cc) << endl;
}


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

int main(){
	int C1, C2, C3;

	while(cin >> C1 >> C2 >> C3){
		int sum = C1 + C2;
		int num[11] = {0};
		num[C1] = num[C2] = num[C3] = 1;

		int cnt = 0;
		for(int i=1;i<=10;i++){
			if(num[i] == 0){
				if(sum+i <= 20) cnt++;
			}
		}

		if((double)cnt/7 >= 0.5) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>

#define rep(i, n) for(int i = 0;i < (int)(n); i++)
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);

    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        b[i] = a[i];
    }

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

    vector<ll> front;
    vector<ll> back;


    for (int i = 0; i < n / 2 + n % 2; ++i) {
        front.push_back(a[i]);
    }

    for (int i = 0; i < n / 2; ++i) {
        back.push_back(a[n - 1 - i]);
    }

    vector<ll> front2;
    vector<ll> back2;

    for (int i = 0; i < front.size(); ++i) {
        if (i % 2 == 0) {
            front2.insert(front2.begin(), front[i]);
        } else {
            front2.push_back(front[i]);
        }
    }

    for (int i = 0; i < back.size(); ++i) {
        if (i % 2 == 0) {
            back2.push_back(back[i]);
        } else {
            back2.insert(back2.begin(), back[i]);
        }
    }

    vector<ll> rev;
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            rev.push_back(front2[i / 2]);
        } else {
            rev.push_back(back2[i / 2]);
        }
    }


    ll ans = 0;
    ll ans2 = 0;
    for (int i = 0; i < n; ++i) {
        if (i > 0) {
            ans += abs(rev[i - 1] - rev[i]);
        }
    }



    vector<ll> ff;
    vector<ll> bb;

    for (int i = 0; i < n / 2; ++i) {
        ff.push_back(a[i]);
    }

    for (int i = 0; i < n / 2 + n % 2; ++i) {
        bb.push_back(a[n - 1 - i]);
    }

    vector<ll> ff2;
    vector<ll> bb2;

    for (int i = 0; i < ff.size(); ++i) {
        if (i % 2 == 0) {
            ff2.insert(ff2.begin(), ff[i]);
        } else {
            ff2.push_back(ff[i]);
        }
    }

    for (int i = 0; i < bb.size(); ++i) {
        if (i % 2 == 0) {
            bb2.push_back(bb[i]);
        } else {
            bb2.insert(bb2.begin(), bb[i]);
        }
    }

    vector<ll> res;
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            res.push_back(bb2[i / 2]);
        } else {
            res.push_back(ff2[i / 2]);
        }
    }

    for (int i = 0; i < n; ++i) {
        if (i > 0) {
            ans2 += abs(res[i - 1] - res[i]);
        }
    }
    cout << max(ans, ans2);
    return 0;
}


Measured memory_bytes: 8020
#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() {
    ll l, r;
    cin >> l >> r;
    ll ans = 2020;
    r = min(l+2019, r);
    for (ll i = l; i <= r; i++) {
        for (ll j = i+1; j <= r; j++) {
            ans = min(ans, (i*j)%2019);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608