akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    if n == 1:
        return 1
    e = collections.defaultdict(list)
    for _ in range(n-1):
        a,b = LI_()
        e[a].append(b)
        e[b].append(a)

    w = [None] * n

    d = [None] * n
    def f(i,p):
        r = 1
        s = [1]
        t = []
        for c in e[i]:
            if c == p:
                s.append(r)
                t.append(1)
                continue
            u = f(c,i) + 1
            r *= u
            r %= m
            s.append(r)
            t.append(u)
        for j in range(len(t)-2, -1, -1):
            t[j] *= t[j+1]
            t[j] %= m
        t.append(1)
        d[i] = [s, t]
        w[i] = r
        return r

    def g(i,p,k):
        w[i] *= k
        w[i] %= m
        s,t = d[i]
        for j,c in enumerate(e[i]):
            if c == p:
                continue
            g(c,i,(s[j] * t[j+1] * k) % m + 1)

    f(0, -1)
    g(0, -1, 1)
    return '\n'.join(map(str, w))


print(main())


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

int main() {
	int n;
	cin >> n;
	int i=1;
	ll sum = 1;
	while(i != n)
	{
	    i=i+1;
	    if(i%3 !=0 && i%5 != 0)
	    {
	     sum += i;   
	    }
	    
	}
	cout << sum;
	return 0;
}


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

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

    priority_queue<int> pq;
    int n, m; cin >> n >> m;
    while (n--) {
        int a; cin >> a;
        pq.push(a);
    }

    while (m--) {
        int x = pq.top();
        pq.pop();
        pq.push(x / 2);
    }

    ll cost = 0;
    while (!pq.empty()) {
        cost += pq.top();
        pq.pop();
    }

    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 892
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

int main() {

    int n, r;
    while(cin >> n >> r, n) {
        vector< int > card(n);
        for(int i = 0; i < n; i++)
            card[i] = n - i;
        while(r--) {
            int p, c; cin >> p >> c;
            vector< int > temp(c);
            p--;
            for(int cnt = 0, i = p; i < p + c; i++, cnt++)
                temp[cnt] = card[i];
            for(int i = p - 1; i >= 0; i--)
                card[i + c] = card[i];

            for(int i = 0; i < c; i++) {
                //cout << card[i] << " " << temp[i] << endl;
                card[i] = temp[i];
            }

        }

        cout << card[0] << endl;
    }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

char s[5];
int num[3];

int main() {
    scanf("%s", s + 1);
    rep(i, 1, 3) num[s[i] - 'A']++;
    if (!num[0] || !num[1]) puts("No");
    else puts("Yes");
    return 0;
}


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

def Find(x, par):
  if par[x] < 0:
    return x
  else:
    par[x] = Find(par[x], par)
    return par[x]

def Unite(x, y, par, rank):
  x = Find(x, par)
  y = Find(y, par)
  
  if x != y:
    if rank[x] < rank[y]:
      par[x] = y
    else:
      par[y] = x
      if rank[x] == rank[y]:
        rank[x] += 1
    
def Same(x, y, par):
  return Find(x, par) == Find(y, par)
 
n, k, l = map(int, input().split())
rpar = [-1]*n
tpar = [-1]*n
rrank = [0]*n
trank = [0]*n
 
for i in range(k):
  p, q = map(int, input().split())
  p, q =p-1, q-1
  Unite(p,q, rpar, rrank) 

for i_ in range(l):
  p, q = map(int, input().split())
  p, q =p-1, q-1
  Unite(p,q, tpar, trank)

d = {}
IDs = [0]*n
for j in range(n):
  ID = Find(j, rpar)+(Find(j, tpar)+1)*10**8
  IDs[j] = ID
  if ID in d:
    d[ID] += 1
  else:
    d[ID] = 1

ans = []
for j in range(n):
    ans.append(d[IDs[j]])
print(*ans)

Measured memory_bytes: 36204
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define lson root<<1
#define rson root<<1|1
#define Mid int mid=(l+r)>>1;
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
#define Mem(a,b) memset(a,b,sizeof(a))
#define MAXN 400
#define mod 1000000007
#define ll long long
#define eps 1e-6
using namespace std;
ll lcm(ll a,ll b){
    ll d=__gcd(a,b);
    return a/d*b;
}
int main()
{
    int n;
    scanf("%d",&n);
    ll ans=1;
    while(n--){
        ll x;
        scanf("%lld",&x);
        ans=lcm(ans,x);
    }
    printf("%lld\n",ans);
}


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

int main(){
  ll n;
  cin >> n;
  vector<ll> l(n);
  rep(i,n) cin >> l.at(i);
  sort(l.begin(),l.end());
  ll ans = 0;
  for(ll i=0;i<n-2;++i){
    ll a = l.at(i);
    for(ll j=i+1;j<n-1;++j){
      ll b = l.at(j);
      //itr1 - l.begin() = a+b未満の数字の数
      auto itr1 = lower_bound(l.begin(),l.end(),a+b);
      //itr2-l.begin() = b未満の数字の数
      auto itr2 = lower_bound(l.begin(),l.end(),b);
      //a+b未満かつb以上の数を求めたい
      ll right = itr1 - l.begin();
      ll left = j+1;
      ans += right - left;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]
for i in range(2, n + 1):
    if h[n-i] > h[n-i+1]:
        if h[n-i] - 1 == h[n-i+1]:
            h[n-i] -= 1
        else:
            print("No")
            exit()

for i in range(2, n + 1):
    if h[n-i] > h[n-i+1]:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 14396
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	s := scanString()
	if s[2] == s[3] && s[4] == s[5] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int a,b,c,d,e; cin>>a>>b>>c>>d>>e;
    int de=60*c+d-60*a-b;
    cout<<de-e<<endl;
    
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] data = new int[N];
		ArrayList<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < N; i++) {
			data[i] = sc.nextInt();
		}
		Arrays.sort(data);
		int cnt = 1;
		for (int i = 0; i < (N - 1); i++) {
			if (data[i] != data[i + 1]) {
				cnt++;
			}
		}
		if (cnt <= K) {
			System.out.println(0);
		} else {
			int x = 1;
			for (int i = 0; i < data.length; i++) {
				if (i == (data.length - 1)) {
					list.add(x);
				} else if (data[i] == data[i + 1]) {
					x++;
				} else {
					list.add(x);
					x = 1;
				}
			}
			int[] Fdata = new int[list.size()];
			for (int i = 0; i < Fdata.length; i++) {
				Fdata[i] = list.get(i);
			}
			Arrays.sort(Fdata);
			int ans = 0;
			for (int i = 0; i < (Fdata.length - K); i++) {
				ans += Fdata[i];
			}
			System.out.println(ans);
		}

		sc.close();
	}

}

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

int main() {
    int n,m,x;
    cin>>n>>m>>x;
    int a=0;
    int b=0;
    int input;
    for (size_t i = 0; i < m; i++)
    {
        cin>>input;
        if(input<x)a++;
        else{b++;}
        /* code */
    }
    cout << std::min(a,b)<<endl;
    
        
    return 0;
}

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

int main(int argc,char* argv[]){
    lli n,temp;
    lli cnt=0;

    cin>>n;

    temp=100;
    while(1){
        temp*=1.01;
        cnt++;
        if(temp>=n){
            cout<<cnt<<endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
	string str;
	char n,m;
	int a=1,b=0,c=0,d;
	while(cin>>str){
		n=str[0];m=str[2];
		if(n=='A'&&m=='B'){
			d=a;a=b;b=d;
		}else if(n=='A'&&m=='C'){
			d=a;a=c;c=d;
		}else if(n=='B'&&m=='A'){
			d=b;b=a;a=d;
		}else if(n=='B'&&m=='C'){
			d=b;b=c;c=d;
		}else if(n=='C'&&m=='A'){
			d=c;c=a;a=d;
		}else{
			d=c;c=b;b=d;
		}
	}
	if(a)cout<<'A'<<endl;
	if(b)cout<<'B'<<endl;
	if(c)cout<<'C'<<endl;
	return 0;
}

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

int main(){
  char buf[2][256];
  scanf("%s %s",buf[0],buf[1]);
  
  char a[256];
  
  sprintf(a,"%s%s\0",buf[0],buf[1]);
  
  double aa;
  aa = (double)(sqrt(atoi(a)))-(int)(sqrt(atoi(a)));
  if(aa == 0)
    puts("Yes");
  else
    puts("No");
  return 0;
}

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

int main(int argc, char** argv) {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (((A-1) / D) < ((C-1) / B))
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3620
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline int ri() {int x; scanf("%d", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/


int f(int a, int b) {
  if (a <= 0 && b >= 0) return 0;
  else if (a > 0) return 1;
  else {
    b = min(b, -1) - a + 1;
    if (b & 1) return -1;
    else return 1;
  }
}
int g(int a, int b) {
  LL res = 1;
  rep(i, a, b + 1) 
    res *= i;
  if (res == 0) return 0;
  else if (res > 0) return 1;
  else return -1;
}

int main() {
  #ifdef _TEST_
  freopen("input.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  #endif
  map<int, string> res;
  res[-1] = "Negative";
  res[1] = "Positive";
  res[0] = "Zero";
  int a, b;
  cin >> a >> b;
  cout << res[f(a, b)] << endl;
  //rep(i, -5, 5)
  //rep(j, i, 5)
  //assert(f(i, j) == g(i, j));

  return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()
ans = 0
# if b == 1:
#     print(ans)
#     exit()
if b == 1:
    print(ans)
    exit()


while(1):

    if ans == 0:
        b -= a
        ans += 1
    else:
        if b <= 0:
            print(ans)
            exit()
        else:
            b -= (a-1)
            ans += 1

    

# n = INT()
# a, b, c = MAP()
# ans = 1
# # count = 0
# count = a
# flag = False
# # for i in range(30):
# while flag == False:
#     if count >= b:
#         flag = True    
#     else:
#         count += a-1
#         ans += 1
# print(ans)





# k = 1
# count = 0
# ans = 0
# A = []


# count += a
# ans += 1


# while(1):
#     if count >= b:
#         print(ans)
#         exit()
#     else:
#         count += a-1
#         ans += 1
#         # print()




# count += a
# ans += 1

# for i in range(100):
#     if b <= count:
#         print(ans)
#         exit()

#     else:
#         count += a-1
#         ans += 1 
#         # print(ans)

# for i in range(30):
# while(1):
#     count += a
#     ans += 1
#     print(count)

#     if b <= count:
#         print(ans)
#         exit()
#     else:   
#         count = count-1
#     # print(ans)
    
    # # A.append(a)
    # # if sum(A)
    # if count == 0:
    #     count += a
    #     ans += 1
    # else:
    #     count += a-1
    #     ans += 1
    # print(count)
    # print(ans)
    # if b<=count:
    #     # print(count)
    #     print(ans)
    #     exit()



Measured memory_bytes: 5180
#include <iostream>
#include <algorithm>
#include <functional>
#include <climits>
#include <string>
#include <cstring>
#include <cmath>
#include <cassert>

#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
const int LN = 18, MOD = 1e9 + 7;
const int MN = 2e5 + 5;

int N;
ll C, h[MN], dp[MN];

struct line {
    ll m, b;

    ll value(ll x) {
        return m * x + b;
    }

    ld intersect(line a) {
        ll dy = a.b - b;
        ll dm = m - a.m;
        if (dm < 0) dy = -dy, dm = -dm;
        return (ld) dy / dm;
    }
};

deque<line> q;

void insert(line a) {
    while (q.size() >= 2 && a.intersect(q.back()) <= q.back().intersect(q[q.size() - 2])) q.pop_back();
    q.push_back(a);
}

ll query(ll x) {
    while (q.size() >= 2 && q.front().value(x) >= q[1].value(x)) q.pop_front();
    return q.front().value(x);
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    cin >> N >> C;
    for (int i = 1; i <= N; i++) cin >> h[i];
    dp[1] = 0;
    q.push_back({-2 * h[1], h[1] * h[1]});
    for (int i = 2; i <= N; i++) {
        dp[i] = query(h[i]) + h[i] * h[i] + C;
        insert({-2 * h[i], dp[i] + h[i] * h[i]});
    }
    cout << dp[N] << '\n';
    return 0;
}

Measured memory_bytes: 5632
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	int N,M,X;
	cin>>N>>M>>X;
	int A[SIZE]={};
	for(int i=0;i<M;i++){
		int a;
		cin>>a;
		A[a]++;
	}
	for(int i=1;i<N;i++)
		A[i]+=A[i-1];
	cout<<min(A[X-1],A[N-1]-A[X])<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
typedef long long int ll;
ll gcd(ll a,ll b) {
  if(b==0) return a;
  return gcd(b,a%b);
 }
int main(){
  ll n;
  cin >>n;
  ll a[n],ans;
  for(ll i=0;i<n;i++) cin >>a[i];
  ans=a[0];
  for(ll i=1;i<n;i++){
      ans=gcd(ans,a[i]);
  }
  cout <<ans<<endl;
}


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

#define rep(i,n) for(int i = 0;i < (int)(n);i++)
int main(){
    int a,max,min,n;
    long long sum;
    sum = 0;
    max = -1000010;
    min = 1000010;
    cin >> n;
    
    rep(i,n){
        cin >> a;
        sum += a;
        if(max < a) max = a;
        if(min > a) min = a;
    }
    cout << min << " " << max << " " << sum << endl;
}



Measured memory_bytes: 3096
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

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

	int n;
	double d;
	cin >> n >> d;

	int ans = 0;
	REP(i, n) {
		ll x, y;
		cin >> x >> y;

		if (d >= sqrt(x*x + y*y)) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
 
#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define VT(T) vector<T>
 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;
 
ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();
 
ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}
 
ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}
 
ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

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

	int a, b;
	cin>>a>>b;
	if(a<b){
		while(b--){
			cout<<a;
		}
	} else {
		while(a--){
			cout<<b;
		}
	}

	cout<<endl;
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    string s;cin >> s;
    int sum = 0;
    for (auto &&c : s)
    {
        int temp  = c-'0';
        sum += temp;
    }
    if(sum%9==0)
    {
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
 int A,B;
  cin>>A>>B;
  int ans;
 for(int i=1;i<4;i++){
 
   if(A!=i && B!=i)
     ans=i;
 
 
 } cout<<ans<<endl;

     
     
     
     }

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,len,count=0;
    scanf("%d",&n);
    char a[n];
    scanf("%s",a);
    for(int i=0;i<n;i++)
    {
        if(a[i]=='A')
        {
            if(a[i+1]=='B')
            {
                if(a[i+2]=='C')
                {
                    count++;
                }
            }
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	int D; cin >> D;

	vector<int> c(26,0);
	vector<vector<int>> s(D,vector<int>(26,0));
	vector<int> t(D,0);
	vector<int> last(26,0);

	for (int i = 0; i < 26; i++) {
		cin >> c[i];
	}

	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			cin >> s[i][j];	
		}
	}

	for (int i = 0; i < D; i++) {
		cin >> t[i];
	}

	
	int ans = 0;
	for (int i = 0; i < D; i++) {
		ans += s[i][t[i]-1];	
		last[t[i]-1] = i+1;
		for (int j = 0; j < 26; j++) {
			ans -=	c[j] * ((i+1) - last[j]) ;
		}
		cout << ans << endl;
	}




	return 0;
}


Measured memory_bytes: 3672
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		sc.close();
		int x = 0;
		int num = 0;
		for(int i = 0;i < N;i++) {
			num = S.charAt(i)=='I' ? ++num : --num;
			x = Math.max(x, num);
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

int x,y;

int main()
{
    cin >> x >> y;
    if (x<10&&y<10)cout << x*y << endl;
    else cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

input = sys.stdin.readline


def Y():
    print("Yes")


def N():
    print("No")


def ST():
    return input().rstrip()


def I():
    return int(input())


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


def LI():
    return list(MI())


n = I()

c = 0
for _ in range(n):
    d1, d2 = MI()
    if d1 == d2:
        c += 1
        if c >= 3:
            Y()
            exit()
    else:
        c = 0

N()


Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long long N,X,P,Q;
vector<long long> A,B;

long long sub1(long long i){
  long long q=N*X;
  for (long long j=1;j<=N;j++){
    long long t=(j-1)/i;
    if (t>0){
      q+=(2*t+3)*A[j];
    }else{
      q+=5*A[j]+X;
    }
  }
  return q;
}
long long sub2(long long i){
  if (i>=0)
    return sub1(i+1)-sub1(i);
  else return 0;
}

bool comp(long long x,long long y){
  return sub2(x)<sub2(y);
}

int main(){
  cin >> N >> X;
  A.assign(N+10,0);
  B.assign(N+10,0);
  for (long long i=1;i<=N;i++){
    B[i]=i;
    cin >> A[N+1-i];
  }
  cout << sub1(upper_bound(&B[1],&B[N],-1,comp)-&B[0]) << endl;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <iostream>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(void) {
  int n;
  cin >> n;
  ll cnt[10][10];
  rep(i, 10) rep(j, 10) cnt[i][j] = 0;
  rep(i, n + 1) {
    if(i == 0)
      continue;
    int k = 1;
    while(i / k >= 10)
      k *= 10;
    int rd = i % 10;
    int ld = i / k;
    ++cnt[rd][ld];
  }
  ll ans = 0;
  rep(i, 10) rep(j, 10) ans += cnt[i][j] * cnt[j][i];
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

template <typename T>
T modpow(T x, T n, const T mod) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

template <typename T>
T inverse(T x, const T mod) {
    return modpow(x, mod - 2, mod);
}

template <typename T>
T lagrange_interpolation(T xs, T ys, const ll m) {
    // mod m
    const ll n = xs.size();
    for(ll i = 0; i < n; i++) {
        xs[i] %= m;
        ys[i] %= m;
    }
    T all_c(n + 1);
    all_c[0] = 1;
    for(ll i = 0; i < n; i++) {
        T tmp(n + 1, 0);
        for(ll j = 0; j < n; j++) {
            tmp[j + 1] = all_c[j];
        }
        for(ll j = 0; j < n; j++) {
            tmp[j] = (m + tmp[j] - xs[i] * all_c[j] % m) % m;
        }
        all_c = move(tmp);
    }

    T c(n, 0);
    for(ll i = 0; i < n; i++) {
        ll qi = 1;
        for(ll j = 0; j < n; j++) {
            if(i == j) continue;
            qi = qi * (m + xs[i] - xs[j]) % m;
        }
        // qiの分母の部分の逆元とx_iのときの値y_iをかける．
        qi = inverse(qi, m) * ys[i] % m;

        auto tmp_c = all_c;
        for(ll j = n - 1; j >= 0; j--) {
            c[j] = (c[j] + qi * tmp_c[j + 1]) % m;
            tmp_c[j] = (tmp_c[j] + tmp_c[j + 1] * xs[i]) % m;
        }
    }
    return c;
}

int main() {
    ll p;
    cin >> p;
    vector<ll> xs(p), ys(p);
    for(ll i = 0; i < p; i++) {
        xs[i] = i;
        cin >> ys[i];
    }
    auto res = lagrange_interpolation(xs, ys, p);
    for(ll i = 0; i < p; i++) {
        cout << res[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
x=int(input())

if 400<=x <=599:
  print(8)
elif 600<=x <=799:
  print(7)
elif 800<=x <=999:
  print(6)
elif 1000<=x <=1199:
  print(5)
elif 1200<=x <=1399:
  print(4)
elif 1400<=x <=1599:
  print(3)
elif 1600<=x <=1799:
  print(2)
elif 1800<=x <=1999:
  print(1)

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

int main() {
	vector<int> arr;
	int t;
	int oper, num;
	cin >> t;
	for(int i = 0; i < t; i++) {
		cin >> oper;
		if(oper == 0) {
			cin >> num;
			arr.push_back(num);
		}
		else if(oper == 1) {
			cin >> num;
			cout << arr[num] << endl;
		}
		else {
			arr.pop_back();
		}
	} 
	return 0;
}


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

int main()
{
   long a,b,c,d,i;
   cin>>a>>b>>c>>d;
   for(i=1;i<=100;i++)
   {
       c=c-b;
       if(c<=0)
       {
           cout<<"Yes"<<endl;
           return 0;
       }
       a=a-d;
       if(a<=0)
       {
           cout<<"No"<<endl;
           return 0;

       }
   }

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
 
int main(){
    ll n,ans = 0;
    cin >> n;
  if (n == 1) {
    cout << 1;
    return 0;
  }
    long a[n];
    REP(i,n) {
        cin >> a[i];
    }
    sort(a, a+n);
    ll counter = 0;
    for(ll i = 0 ;i < n-1 ;i++) {
        counter++;
        if(a[i] != a[i+1]) {
            if (counter % 2 == 1) {
                ans++;
            }
            counter = 0;
        }
    }
    counter++;
  if (counter % 2 == 1) {
    ans++;
  }
  cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b;
	cin>>a>>b;
	if (a<b){
	for (int i = 0; i < b; ++i)
		cout<<a;
	}
	else{ 
		for (int i = 0; i < a; ++i)
			cout<<b;
	
}
}

Measured memory_bytes: 256
#include<stdio.h>

long double gyaku(long double x){
	return 1.0/x;
}

int main(){
  int n;
  long double a[101],sum=0.0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
  	scanf("%Lf",&a[i]);
    sum += gyaku(a[i]);
  }
  printf("%Lf",gyaku(sum));
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
    int i;
    cin >> i;
    int num[i];
    long int sum = 0;
    for(int j = 0;j < i; j++){
    cin >> num[j];
    }
    int max= num[0];
    int min= num[0];
    for(int k = 0;k < i; k++){
    if(max<num[k]) max=num[k];
    if(num[k]<min) min=num[k];
    sum = sum + num[k];
    }
    cout << min << " " << max << " " << sum << "\n"; 
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int n,k,x,y; cin >>n>>k>>x>>y;

    if (n <= k) {
        cout << n*x << endl;
    } else {
        cout << k*x + (n-k)*y << endl;
    } 

    return 0;
}





Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn eat(l: usize, x: u64, height: &Vec<u64>, patty: &Vec<u64>) -> u64 {
    if x == 0 {
        0
    } else if l == 0 {
        1
    } else if x == 1 {
        0
    } else if x < 1 + height[l - 1] {
        eat(l - 1, x - 1, height, patty)
    } else if x == 1 + height[l - 1] {
        patty[l - 1]
    } else if x == 2 + height[l - 1] {
        1 + patty[l - 1]
    } else if x < 2 + 2 * height[l - 1] {
        1 + patty[l - 1] + eat(l - 1, x - 2 - height[l - 1], height, patty)
    } else {
        patty[l]
    }
}

fn main() {
    let nx: Vec<u64> = read_vec();

    let mut height: Vec<u64> = vec![1; 51];
    let mut patty: Vec<u64> = vec![1; 51];
    for i in 1..51 {
        height[i] = 2 * height[i - 1] + 3;
        patty[i] = 2 * patty[i - 1] + 1;
    }

    println!("{}", eat(nx[0] as usize, nx[1], &height, &patty));
}


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

int main()
{
  char s[11],t[11];
  int a,b;
  char u[11];

  scanf("%s %s",s,t);
  scanf("%d %d",&a,&b);
  scanf("%s",u);

  if(strcmp(s,u)==0){
    printf("%d %d",a-1,b);
  }else{
    printf("%d %d",a,b-1);
  }



  return 0;
  }

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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int32_t main()
{
    double res=0.0;
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        double x;
        cin>>x;
        string s;
        cin>>s;
        if(s=="JPY")
         res+=x;
         else
          res+=(x*380000.0);
    }
    cout.precision(17);
    cout<<res<<"\n";
      return 0;
}

Measured memory_bytes: 256
from itertools import combinations
import math


def solve():
    n, d = map(int, input().split())
    x = list(list(map(int, input().split())) for _ in range(n))
    c = 0
    for p1, p2 in combinations(x, 2):
        d = 0
        for i in range(len(p1)):
            d += abs(p1[i] - p2[i]) ** 2
        d = math.sqrt(d)
        if d.is_integer():
            c += 1
    return c


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;
 
const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
 
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;
 
 
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}
 
template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}
 
template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}
 
template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}
 
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
 
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
 
template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}
 
template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}
 
template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}
 
template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}
 
template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}
 
  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};
 
template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}
 
int main() {
  int N;
  cin >> N;
  vector< int > dp(N + 1);
  for(int i = 1; i <= N; i++) {
    for(int j = i; j <= N; j += i) dp[j]++;
  }
  int64 ret = 0;
  for(int i = 1; i <= N; i++) ret += 1LL * dp[i] * i;
  cout << ret << "\n";
}
 

Measured memory_bytes: 42264
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


int sz[200005], par[200005], c[200005], w[200005];
map<int, int> cnt[200005];
vector<ii> arr[200005], yolo;
ll fac[200005], invFac[200005];


int root(int v){
    if(v == par[v]) return v;
    return par[v] = root(par[v]);
}


void unite(int a, int b){
    a = root(a), b = root(b);
    if(a == b)  return;
    if(sz[a] < sz[b])   swap(a, b);
    sz[a] += sz[b];
    par[b] = a;
}


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

    fac[0] = invFac[0] = 1;
    for(int i=1;i<=200000;i++){
        fac[i] = (i * fac[i-1]) % MOD;
        invFac[i] = pwr(fac[i], MOD-2);
    }

    int n, x, y;
    cin>>n>>x>>y;

    for(int i=1;i<=n;i++){
        sz[i] = 1;  par[i] = i;
    }

    for(int i=1;i<=n;i++){
        cin>>c[i]>>w[i];
        arr[c[i]].pb(ii(w[i], i));
    }

    for(int i=1;i<=n;i++){
        if(arr[i].empty())  continue;
        sort(arr[i].begin(), arr[i].end());
        for(auto it : arr[i])
            if(it.ff + arr[i][0].ff <= x)
                unite(it.ss, arr[i][0].ss);
        yolo.pb(arr[i][0]);
    }

    sort(yolo.begin(), yolo.end());
    for(auto it : yolo)
        if(it.ff + yolo[0].ff <= y)
            unite(it.ss, yolo[0].ss);

    for(int i=1;i<=n;i++){
        if(c[i] != c[yolo[0].ss] && w[i]+w[yolo[0].ss] <= y)
            unite(i, yolo[0].ss);
        if((int)yolo.size() == 1)   continue;
        if(c[i] != c[yolo[1].ss] && w[i]+w[yolo[1].ss] <= y)
            unite(i, yolo[1].ss);
    }

    for(int i=1;i<=n;i++)
        cnt[root(i)][c[i]]++;

    ll ans = 1;
    for(int i=1;i<=n;i++)
        if(root(i) == i){
            ans *= fac[sz[i]];
            ans %= MOD;
            for(auto it : cnt[i])
                ans = (ans * invFac[it.ss]) % MOD;
        }

    cout<<ans;
    return 0;
}










Measured memory_bytes: 39152
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int n, cnt = 0;
	vector<int> d;

	cin >> n;
    
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		d.push_back(x);
	}

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

	cout << d.at(n / 2) - d.at(n / 2 - 1) << endl;

	return 0;
	
}

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

using namespace std;

int n;

int sum_digit(int num) {
	int sum = 0;
    while (num != 0) {
        sum = sum + num % 10;
        num = num / 10;
    }
	return sum;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
	if (n % sum_digit(n) == 0)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
// #define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[500010], factinv[500010] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,500010)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

void solve() 
{
    int n;
    cin >> n;
    int a[n] , sum = 0 , ans = 0;
    rep(i,n)
    {
        cin >> a[i], sum += a[i];
        if(a[i]==0)
            ans += sum/2 , sum = 0;
    }
    ans += sum/2;
    cout << ans << endl;
}  

Measured memory_bytes: 4428
#include<stdio.h>
int main()
{
    int i, j;
    scanf("%d %d", &i, &j);
    if(i<=8)
    {
        if(j<=8)
            printf("Yay!\n");

        else
            printf(":(");
    }
    else
        printf(":(");
    return 0;
}


Measured memory_bytes: 128
data_list = list(map(int, input().split()))

n = data_list[0]
x = data_list[1]
y = data_list[2]

if n == x == y:
    print(n, n)
    exit(0)

if n - (x + y) >= 0:
    print(min(x, y), 0)
else:
    print(min(x, y), x + y - n)


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

#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    int N, M;
    cin >> N >> M;
    if (N == M){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long N, long long M, std::vector<long long> s,
           std::vector<long long> c)
{
  vi digits(N,0);
  vec<bool> fixed(N,false);
  if(N>1){
    digits[0]=1;
  }
  rep(i,M){
    if(!fixed[s[i]-1]){
      digits[s[i]-1] = c[i];
      fixed[s[i]-1] = true;
    }
    else{
      if(fixed[s[i]-1] && digits[s[i]-1]!=c[i]) { cout << -1 << endl; return; }
    }
    dump(fixed, digits);
  }
  if(N>1 && digits[0]==0) {cout << -1 << endl; return; }
  ll ret = 0;
  rep(i,N){
    ret *= 10;
    ret += digits[i];
  }
  cout << ret << endl;
  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long N;
  std::cin >> N;
  long long M;
  std::cin >> M;
  std::vector<long long> s(M);
  std::vector<long long> c(M);
  for (int i = 0; i < M; i++) {
    std::cin >> s[i];
    std::cin >> c[i];
  }
  solve(N, M, std::move(s), std::move(c));
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
  ll N,M;
  cin >> N >> M;
  vector<vector<int> > G(N);
  vector< pair<ll,ll> > Load(M);
  vector<int> arrow(N);
  rep(i,M){
    int A,B;
    cin >> A >> B;
    A--;B--;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  vector<int> dist(N,-1);
  queue<int> Q;
  int cnt = 1;
  dist[0] = 0;
  Q.push(0);
  while(!Q.empty()){
    int v = Q.front();
    Q.pop();
    for(int nv: G[v]){
      if(dist[nv] != -1)continue;
      dist[nv] = 0;
      cnt++;
      arrow[nv] = v;
      Q.push(nv);
    } 
  }
    if(cnt == N){
      cout << "Yes" <<endl;
      rep2(i,1,N)
        cout << arrow[i] + 1 << endl;
    }else {
      cout << "No" << endl;
    }
    return 0;
  }


Measured memory_bytes: 13612
n,m=map(int,input().split())
g=[[10**9]*n for i in range(n)]
edges=[]
for i in range(m):
  u,v,c=map(int,input().split())
  g[u-1][v-1]=g[v-1][u-1]=c
  edges.append((u-1,v-1,c))
for k in range(n):
  for i in range(n):
    for j in range(n):
      g[i][j]=min(g[i][j],g[i][k]+g[k][j])
cnt=0
flag=False
for u,v,c in edges:
  if g[u][v]==c:
    cnt+=1
print(m-cnt)


Measured memory_bytes: 42220
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int money = 0;
	while(x > 0 || y > 0) {
		if (x > 0 && y > 0) {
			if (a + b <= c * 2) {
				money += a + b;
				x--, y--;
			}
			else {
				money += c * 2;
				x--, y--;
			}
		}
		else if (x == 0) {
			if (b <= c * 2) {
				money += b;
				y--;
			}
			else {
				money += c * 2;
				y--;
			}
		}
		else if (y == 0) {
			if (a <= c * 2) {
				money += a;
				x--;
			}
			else {
				money += c * 2;
				y--;
			}
		}
	}
	cout << money;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

int main()
{

    set<int> a;
    int b;
    rep(i,3){
        cin>>b;
        a.insert(b);
    }
    cout<<a.size()<<endl;
    return 0;
}


Measured memory_bytes: 380