akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define mk(arr,n,type)      type *arr=new type[n];
#define dbg(x) cerr << #x << " is " << x << endl;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
clock_t beg = clock();
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
const double pi = 3.1415926535897932384626433;
void FILE_IO(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void JH(){
    int n;cin>>n;
    int a[n];
    int flag=0;
    fo0(i,n){
        cin>>a[i];
        if(a[i]==0){
            flag=1;
        }
    }
    if(flag){
        cout<<0;
        return;
    }
    sort(a,a+n);
    int p=1e18;
    int temp=0;
    int prod=1;
    fo0(i,n){
        p/=a[i];
        if(p<=0){
            temp=1;
            break;
        }
        else{
            prod*=a[i];
        }
    }
    if(temp){
        cout<<-1;
    }
    else{
        cout<<prod;
    }
}

int32_t main()
{
    FILE_IO();FAST_IO;int t=1;
    // cin>>t;
    while(t--){JH();}cerr<<"Execution time: "<<(double)(clock()-beg)/1000<<"s ";
}


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

const double pi = acos(-1);
const int mod = 1e9 + 7;

int main() {
	long long n, k;
	cin >> n >> k;
	long long ans = 0;
	for (long long i = k; i <= n + 1; i++) {
	 	ans = (ans + (i * (n + 1 - i) + 1)) % mod;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3652
import java.io.*;
 
class Main{ 
public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[ ] str_div = br.readLine().split(" ");

        int w = Integer.parseInt(str_div[0]);
        int h = Integer.parseInt(str_div[1]);
        int x = Integer.parseInt(str_div[2]);
        int y = Integer.parseInt(str_div[3]);
        int r = Integer.parseInt(str_div[4]);



        if((x - r >= 0) && (x + r <= w) && (y - r >= 0) && (y + r <= h))
        System.out.println("Yes");
        else
        System.out.println("No");
 }
}
   

Measured memory_bytes: 17088
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;
 
class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
    long N;
    void solve()
    {
        var Q = cin.nextlong;
        var H = cin.nextlong;
        var S = cin.nextlong;
        var D = cin.nextlong;
        N = cin.nextlong;
 
        long x = (N / 2) * (Math.Min(Math.Min(Q * 8, H * 4), Math.Min(S * 2, D)));
        long y = (N % 2) * (Math.Min(Math.Min(Q * 4, H * 2), S));
        WriteLine(x + y);
    }
 
}
 
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13264
a, b, c = (int(x) for x in input().split())

if a <= b <= c:
    print(str(a), str(b), str(c))
elif a <= c <= b:
    print(str(a), str(c), str(b))
elif b <= a <= c:
    print(str(b), str(a), str(c))
elif b <= c <= a:
    print(str(b), str(c), str(a))
elif c <= b <= a:
    print(str(c), str(b), str(a))
else:
    print(str(c), str(a), str(b))


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

int main(){
    string o, e;
    cin >> o >> e;
    for(int i = 0; i < o.size(); i++){
        cout << o[i];
        if(i < e.size())
            cout << e[i];
    }
    cout << '\n';
}


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

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

	int best = 1;
	for(int i = 1; i * i <= m; i++){
		if(m % i == 0){
			if(i <= m / n) best = max(i, best);
			if(m / i <= m / n) best = max(m / i, best);
		}
	}
	cout << best << endl;
	return 0;
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	auto d = vector<int>(m);
	for(auto& e : d) cin >> e;
	sort(d.begin(), d.end());
	for(auto i = 0; i < m - 1; ++i){
		d[i] = d[i + 1] - d[i];
	}
	sort(d.begin(), --d.end());
	long long int ans = 0;
	for(auto i = 0; i < m - n; ++i){
		ans += d[i];
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    while(1){
        int b;
        cin >> b;
        if(b == 0) break;

        int n;
        for(long long int i=1; ; i++){
            if(i*(i+1)/2 > b){
                n = i-1;
                break;
            }
        }
        int ansl, ansn;
        for(int i=n; i>0; i--){
            if(i%2 == 0){
                if(b%(i/2) == 0 && 2*b/i %2 == 1){
                    ansl = b/i -i/2 +1;
                    ansn = i;
                    break;
                }
            }else{
                if(b%i == 0){
                    ansl = b/i -i/2;
                    ansn = i;
                    break;
                }
            }
        }
        cout << ansl << " " << ansn << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n,W;
    cin>>n>>W;
    vi w(n+1),v(n+1);
    rep(i,n)cin>>w[i+1]>>v[i+1];
    vvll dp(n+1, vll (W+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=W;j++){
            if(j-w[i]>=0){
                chmax(dp[i][j],dp[i-1][j-w[i]]+v[i]);
            }
            chmax(dp[i][j],dp[i-1][j]);
        }
    }
    cout<<dp[n][W]<<endl;
    

//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 80256
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [0] + [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(A,(len(cumsum) - 2)):
    if ((cumsum[i+2] - cumsum[i]) == 2) and A <= i <= (max(C,D)-1):
        flag = False
        break
for j in range(A,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3] and (B <= j + 2 <= D):
        flag_oinuki = True
 
if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 12524
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
CSS
CSR
---+/

void main(string[] args) {
  const S = readln.chomp;
  const T = readln.chomp;
  zip(S, T).count!(x => x[0] == x[1]).writeln;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

int main() {
    double r, s, p;
    cin >> r;
    s = r * r * M_PI;
    p = 2 * r * M_PI;
    cout << fixed << s << " " << fixed << p << endl;


    return 0;
}

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

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

  ll X; cin >> X;
  ll ans = X  + X * X + X * X * X;
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3608
ans = []

while true
	args = gets.split(" ").map{|e|e.to_i}
	break if args[0]==-1 && args[1]==-1 && args[2]==-1
	if args[0]==-1 || args[1]==-1
		ans.push "F"
	elsif args[0] + args[1] >= 80
		ans.push "A"
	elsif args[0] + args[1] >= 65
		ans.push "B"
	elsif args[0] + args[1] >= 50
		ans.push "C"
	elsif args[0] + args[1] >= 30
		if args[2] >= 50
			ans.push "C"
		else
			ans.push "D"
		end
	elsif args[0] + args[1] < 30
		ans.push "F"
	end
end

ans.each{|e|
	puts e
}

Measured memory_bytes: 6108
'use strict';

function main(input) {
  const args = input.split('\n');
  const nums = args[1].split(' ');
  nums.sort();
  for (let i = 0; i < nums.length-1; ++i) {
    if (nums[i] === nums[i+1]) {
      console.log('NO');
      return;
    }
  }
  console.log('YES');
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 34088
#pragma region

#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin); i < (end); i++)
#define IFOR(i, begin, end) for (int i = (end)-1; i >= (begin); i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define MOD 1000000007
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  REP(i, vec.size())
  i == 0
      ? os << vec[i]
      : os << ", " << vec[i];
  os << " ]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &deq) {
  os << "deq[ ";
  REP(i, deq.size())
  i == 0
      ? os << deq[i]
      : os << ", " << deq[i];
  os << " ]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &m) {
  os << "{ ";
  for (auto &&k : m) &k == &(*m.begin()) ? os << k.first << " => " << k.second : os << ", " << k.first << " => " << k.second;
  os << " }";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &m) {
  os << "{ ";
  for (auto &&k : m) &k == &(*m.begin()) ? os << k.first << " => " << k.second : os << ", " << k.first << " => " << k.second;
  os << " }";
  return os;
}

#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);

  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  cout << (A1 + A2 + A3 >= 22 ? "bust" : "win") << endl;
}


Measured memory_bytes: 256
import math
s = input()
s_li = list(s)

import collections
c = collections.Counter(s_li)
common_li = c.most_common()
# [('a', 4), ('c', 2), ('b', 1)]
sp_li = s.split(common_li[0][0])

#print(sp_li)
def check(sp_li):
    count = []
    if len(sp_li)==0:
        return 0
    else:
        count = []
        for i,s in enumerate(sp_li):
            count.append(len(s))
        return max(count)


all_li = []
kaisuu = 0
for i,c in enumerate(common_li):
    #print(common_li,c[0],c[1])
    sp_li = s.split(c[0])
    all_li.append(check(sp_li))

#print(all_li)
print(min(all_li))
            

Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int main()
{
    int h,w;
    cin>>h>>w;
    while(h!=0)
    {
        int i,j;
        for(i=0; i<h; i++)
        {
            for(j=0; j<w; j++)
                if(i==0||i==h-1||j==0||j==w-1)
                    cout<<"#";
                else
                    cout<<".";
            cout<<endl;
        }
        cout<<endl;
        cin>>h>>w;
    }
    return 0;
}



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

int main(){
    int k,x;
    cin >>  k >>  x ;
    for(int i = -k+1;i <k ; i++){
        if ((x+i >= -1000000) && (x+i <= 1000000)){
                cout <<x+i << ' ';
        }
    }
    cout << endl;
}   

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;


int main() {
    int n, m;
    cin >> n >> m;
    int ml=1, mr=n;
    for (int i=0;i<m;i++) {
        int l, r;
        cin >> l >> r;

        if (ml < l) {
            ml = l;
        }
        if (r < mr) {
            mr = r;
        }
    }
    if (ml <= mr) {
        cout << (mr-ml+1) << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


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

using namespace std;

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while(getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

int main(){
	string str;
    vector<string> date;
	cin >> str;
	date = split(str, '/');
	if(stoi(date[1]) > 4) cout << "TBD";
	else if (stoi(date[2]) <= 30) cout << "Heisei";
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int N;
    ll M;
    cin >> N >> M;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    vector<ll> s(N + 1);
    rep(i, N) s[i + 1] = s[i] + a[i];

    map<ll, ll> count;
    ll ans = 0;
    rep(i, N + 1) {
        ll r = s[i] % M;
        ans += count[r];
        count[r]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5760
import sys
from collections import Counter

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


def resolve():
    n = int(input())
    D = list(map(int, input().split()))
    m = int(input())
    T = list(map(int, input().split()))

    P = Counter(D)

    for i in range(m):
        P[T[i]] -= 1

    for v in P.values():
        if v < 0:
            print("NO")
            break
    else:
        print("YES")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 41692
{-# OPTIONS_GHC -O2 -optc-O2 #-}
module Main where

import Control.Applicative
import Control.Monad
import Data.Int
import Data.List

solve :: Int64 -> [Int64] -> Int64
solve t ds = t + (snd $ foldl' update (0, 0) ds)
    where update (p, total) c | p + t <= c = (c, total + t)
                              | otherwise = (c, total + c - p)

main :: IO ()
main = do
  [_, t] <- map read . words <$> getLine
  ds <- map read . words <$> getLine
  print $ solve t ds


Measured memory_bytes: 70012
def main():
    n, k = map(int, input().split())
    stones = tuple(map(int, input().split()))
    inf = 10**9
    dp = [inf]*n
    dp[0] = 0
    for i in range(n):
        for t in range(1, k+1):
            step = i+t
            if step < n:
                v = dp[i]+abs(stones[i]-stones[step])
                if v < dp[step]:
                    dp[step] = v
    print(dp[-1])


if __name__ == '__main__':    
    main()


Measured memory_bytes: 20680
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
	int a[4];
	int b,flg,c,d,e,cunt,m,f;
	
	scanf("%d",&d);
	while(d!=0000){
		
		m=1000;
		cunt=0;
		flg=0;
		
		f=d;
		
		for(int i=0;i<3;i++){
			a[3-i]=d/m;
			d=d%m;
			m/=10;
		}
		a[0]=d;
		
		for(int i=0;i<3;i++){
			if(a[i]!=a[i+1]) flg=1;
		}
		
		
		
		if(flg==1){
			while(f!=6174){
				c=0;
				e=0;
				sort(a,a+4);
				m=1;
				for(int i=0;i<4;i++){
					c+=a[i]*m;
					m*=10;
				}
				sort(a,a+4,greater<int>());
				m=1;
				for(int i=0;i<4;i++){
					e+=a[i]*m;
					m*=10;
				}
				
				d=c-e;
				
				
				f=d;
				
				m=1000;
				
				for(int i=0;i<3;i++){
					a[3-i]=d/m;
					d=d%m;
					m/=10;
				}
				a[0]=d;
				cunt++;
			}
		}
		
		if(flg==0){
			printf("NA\n");
		}else{
			printf("%d\n",cunt);
		}
		scanf("%d",&d);
	}

} 

Measured memory_bytes: 1052
#include <bits/stdc++.h>
using namespace std;
long long n;
set<int> ans;
void dfs(long long x) {
	if(x > n) return;
	long long y = x;
	set<int> s;
	while(y > 0) {
		s.insert(y % 10);
		y /= 10;
	}
	if(s.size() == 3) ans.insert(x);
	for(int i = 3; i <= 7; i += 2) {
		dfs(x * 10 + i);
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	
	cin >> n;
	dfs(0);
	cout << ans.size() << endl;
	return 0;
}


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


class BIT1():
    """
    Binary Indexed Tree (1-indexed)
    """
    def __init__(self, n, data=None):
        self.n = n
        self.bit = [0] * (self.n + 1)
        self.data = [0] * (self.n + 1)
        if data:
            self.build(data)

    def build(self, data):
        for i in range(self.n):
            self.bit[i + 1] = self.data[i + 1] = data[i]
        for i in range(1, self.n):
            j = i + (i & (-i))
            if j <= self.n:
                self.bit[j] += self.bit[i]

    def add(self, idx, x):
        # add x to idx-th element
        # idx: 1-indexed
        self.data[idx] += x
        while idx <= self.n:
            self.bit[idx] += x
            idx += (idx & (-idx))

    def sum(self, idx):
        # get sum of [1, idx]
        # idx: 1-indexed
        s = 0
        while idx:
            s += self.bit[idx]
            idx -= (idx & (-idx))
        return s


n, q = map(int, input().split())
a = list(map(int, input().split()))
bit = BIT1(n, a)
for _ in range(q):
    t, p, q = map(int, input().split())
    if t == 0:
        bit.add(p + 1, q)
    else:
        print(bit.sum(q) - bit.sum(p))


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

int t[10][10];

int getdigit(int number){
	int a=number/1000;
	int b=(number%1000)/100;
	int c=(number%100)/10;
	int d=number%10;
	return (t[t[t[t[0][a]][b]][c]][d]);
}

int getdigit(int a,int b,int c,int d){
	return (t[t[t[t[0][a]][b]][c]][d]);
}

int check(int a,int b,int c,int d,int e){
	return t[t[t[t[t[0][a]][b]][c]][d]][e];
}


int main(void){
	int count=0;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			cin>>t[i][j];
		}
	}
	for(int cd=0;cd<10000;cd++){
		int code=cd;
		bool flag=true;
		int digit=getdigit(code);
		code=code*10+digit;
		int a=code/10000;
		int b=(code%10000)/1000;
		int c=(code%1000)/100;
		int d=(code%100)/10;
		int e=digit;
		// replacement
		for(int i=1;i<10;i++){
			// if(digit==getdigit((a+i)%10,b,c,d))goto FAIL;
			if(check((a+i)%10,b,c,d,e)==0)goto FAIL;
		}
		for(int i=1;i<10;i++){
			// if(digit==getdigit(a,(b+i)%10,c,d))goto FAIL;
			if(0==check(a,(b+i)%10,c,d,e))goto FAIL;
		}
		for(int i=1;i<10;i++){
			// if(digit==getdigit(a,b,(c+i)%10,d))goto FAIL;
			if(0==check(a,b,(c+i)%10,d,e))goto FAIL;
		}
		for(int i=1;i<10;i++){
			// if(digit==getdigit(a,b,c,(d+i)%10))goto FAIL;
			if(0==check(a,b,c,(d+i)%10,e))goto FAIL;
		}
		for(int i=1;i<10;i++){
			// if(((digit+i)%10)==getdigit(a,b,c,d))goto FAIL;
			if(0==check(a,b,c,d,(e+i)%10))goto FAIL;
		}

		if(a!=b&&0==check(b,a,c,d,e))goto FAIL;
		if(c!=b&&0==check(a,c,b,d,e))goto FAIL;
		if(d!=c&&0==check(a,b,d,c,e))goto FAIL;
		if(e!=d&&0==check(a,b,c,e,d))goto FAIL;
		goto SUCCESS;
FAIL:
		count++;
		continue;
SUCCESS:;
	}
	cout<<count<<endl;
	return 0;
}

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

int64_t times2(int64_t n) {
	int64_t output = 1;
	for (int64_t i = 0; i < n; ++i) {
		output *= 2;
	}
	return output;
}

int main() {
	//input
	int64_t H;
	cin >> H;

	//calculation
	if (H == 1) {
		cout << 1 << endl;
		return 0;
	}

	int64_t count = 1;
	while (1) {
		H /= 2;
		count++;
		if (H == 1) {
			break;
		}
	}
	int64_t output = times2(count) - 1;

	//output
	cout << output << endl;


	return 0;
}


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

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

using ll = long long;

using namespace std;

ll pow_mod(ll a, ll b, ll p) {
	if (b == 0)return 1;
	else if (b % 2 == 0)return (pow_mod(a*a, b / 2, p) % p);
	else return (pow_mod(a, b - 1, p)*a%p);
}

ll factorial_mod(ll a, ll p) {
	if (!a)return 1;
	else return a * factorial_mod(a - 1, p) % p;
}

ll sum_digit(ll N) {
	int ans = 0;
	for (; N != 0;) {
		ans += N % 10;
		N /= 10;
	}
	return ans;
}

ll gcd(ll a,ll b) {
	if (!b)return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

int L;
int s[65] = { 0 }, g[65] = { 0 }, len[65] = { 0 };

int main(){
	scanf("%d", &L);
	int cnt = 0;
	for (int i = L; i != 1; i /= 2)cnt++;
	for (int i = 1; i < cnt + 1; i++) {
		s[2*i-2] = i;
		g[2*i-2] = i + 1;
		len[2 * i - 2] = 0;
		s[2 * i - 1] = i;
		g[2 * i - 1] = i + 1;
		len[2 * i - 1] = pow(2, i - 1);
	}
	for (int i = cnt - 1; i != -1; i--) {
		if (pow(2, i) <= L - pow(2, cnt)) {
			s[2 * cnt + i] = i + 1;
			g[2 * cnt + i] = cnt + 1;
			len[2 * cnt + i] = L - pow(2, i);
			L -= pow(2, i);
		}
	}
	int cnt2 = 0;
	rep(i, 65)if (s[i] != 0)cnt2++;
	printf("%d %d\n", cnt + 1, cnt2);
	rep (i, 65) {
		if (s[i] != 0)printf("%d %d %d\n", s[i], g[i], len[i]);
	}
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  string s;
  cin >> s;
  int S = 0, W = 0, N = 0, E = 0;
  rep(i,s.size()){
    if(s[i] == 'S') S++;
    if(s[i] == 'W') W++;
    if(s[i] == 'N') N++;
    if(s[i] == 'E') E++;
  }
  bool ans = true;
  if((S != 0 && N == 0) || (S == 0 && N != 0)) ans = false;
  if((W != 0 && E == 0) || (W == 0 && E != 0)) ans = false;
  YesorNo(ans);
}

Measured memory_bytes: 256
using System;

namespace UnityChan
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int S;

			string str = Console.ReadLine ();
			S = int.Parse (str);

			Console.WriteLine ("{0}:{1}:{2}", S / 3600 , S % 3600 / 60, S % 60);


		}
	}
}

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main() {
	ll n, d, a, ans = 0;
	cin >> n >> d >> a;
	d *= 2;
	vector<pair<ll, ll>> xh(n);
	rep(i,n) cin >> xh[i].first >> xh[i].second;
	sort(xh.begin(), xh.end());
	queue<pair<ll, ll>> q;
	ll totdm = 0;
	rep(i,n) {
		ll x = xh[i].first;
		ll h = xh[i].second;
		while (!q.empty() && q.front().first < x) {
			totdm -= q.front().second;
			q.pop();
		}
		h -= totdm;
		if (h > 0) {
			ll count = (h + a - 1) / a;
			ans += count;
			totdm += count * a;
			q.emplace(x + d, count * a);
		}

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


Measured memory_bytes: 7896
#define _CRT_SECURE_NO_WARNINGS
#include <array>
#include <algorithm>
#include <cstdio>

using namespace std;

int H, W;
int mx, mn;

int calc(int first, int second)
{
    if (first % 3 == 0 || second % 3 == 0) return 0;

    // 第1辺 切り上げ
    int fu = (first + 3 - 1) / 3;

    // 第1辺 切り上げ 残り
    int rfu = first - fu;

    // 第1辺 切り下げ
    int fd = first / 3;

    // 第1辺 切り下げ 残り
    int rfd = first - fd;

    int p1u = fu * second;
    int p1d = fd * second;

    // 第2辺 切り上げ
    int su = (second + 2 - 1) / 2;

    // 第2辺 切り上げ 残り
    int rsu = second - su;

    // 第2辺 切り下げ
    int sd = second / 2;

    // 第2辺 切り下げ 残り
    int rsd = second - sd;

    // 第1辺 切り上げ
    // 第2辺 切り上げ
    int p2 = rfu * su;
    int p3 = rfu * rsu;

    mx = max(p1u, p2);
    mn = min(p1u, p3);
    int div1 = mx - mn;

    // 第1辺 切り上げ
    // 第2辺 切り下げ
    p2 = rfu * sd;
    p3 = rfu * rsd;

    mx = max(p1u, p3);
    mn = min(p1u, p2);
    int div2 = mx - mn;

    // 第1辺 切り下げ
    // 第2辺 切り上げ
    p2 = rfd * su;
    p3 = rfd * rsu;

    mx = max(p1d, p2);
    mn = min(p1d, p3);
    int div3 = mx - mn;

    // 第1辺 切り下げ
    // 第2辺 切り下げ
    p2 = rfd * sd;
    p3 = rfd * rsd;

    mx = max(p1d, p3);
    mn = min(p1d, p2);
    int div4 = mx - mn;

    // 第1辺 だけで 3分割
    // 第1辺 (切り上げ 残り) 切り上げ
    int fuu = (rfu + 2 - 1) / 2;

    // 第1辺 (切り上げ 残り) 切り上げ 残り
    int rfuu = rfu - fuu;

    // 第1辺 (切り上げ 残り) 切り下げ
    int fud = rfu / 2;

    // 第1辺 (切り上げ 残り) 切り下げ 残り
    int rfud = rfu - fud;

    // 第1辺 (切り下げ 残り) 切り上げ
    int fdu = (rfd + 2 - 1) / 2;

    // 第1辺 (切り下げ 残り) 切り上げ 残り
    int rfdu = rfd - fdu;

    // 第1辺 (切り下げ 残り) 切り下げ
    int fdd = rfd / 2;

    // 第1辺 (切り下げ 残り) 切り下げ 残り
    int rfdd = rfd - fdd;

    // 第1辺 (切り上げ 残り) 切り上げ
    // 第1辺 (切り上げ 残り) 切り上げ 残り
    p2 = fuu * second;
    p3 = rfuu * second;

    mx = max(p1u, p2);
    mn = min(p1u, p3);
    int div5 = mx - mn;

    // 第1辺 (切り上げ 残り) 切り下げ
    // 第1辺 (切り上げ 残り) 切り下げ 残り
    p2 = fud * second;
    p3 = rfud * second;

    mx = max(p1u, p3);
    mn = min(p1u, p2);
    int div6 = mx - mn;

    // 第1辺 (切り下げ 残り) 切り上げ
    // 第1辺 (切り下げ 残り) 切り上げ 残り
    p2 = fdu * second;
    p3 = rfdu * second;

    mx = max(p1d, p2);
    mn = min(p1d, p3);
    int div7 = mx - mn;

    // 第1辺 (切り下げ 残り) 切り下げ
    // 第1辺 (切り下げ 残り) 切り下げ 残り
    p2 = fdd * second;
    p3 = rfdd * second;

    mx = max(p1d, p3);
    mn = min(p1d, p2);
    int div8 = mx - mn;

    mn = min({div1, div2, div3, div4, div5, div6, div7, div8});
    return mn;
}

int main()
{

    if (scanf("%d%d", &H, &W) < 2) return 0;
    int HW = calc(H, W);
    int WH = calc(W, H);
    printf("%d\n", min(HW, WH));

    return 0;
}


Measured memory_bytes: 128
import heapq  # heapqライブラリのimport
X,Y,Z,K=map(int,input().split())
A= list(map(int,input().split()))
B= list(map(int,input().split()))
C= list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
check=[[0,0,0]]
lst =[(-(A[0]+B[0]+C[0]),0,0,0)]
heapq.heapify(lst)
for r in range(K):
 a=lst[0][1]
 b=lst[0][2]
 c=lst[0][3] 
 print(lst[0][0]*(-1))
 heapq.heappop(lst)
 if a<X-1 :
  if [a+1,b,c] not in check:
   heapq.heappush(lst, (-(A[a+1]+B[b]+C[c]),a+1,b,c))
   check.append([a+1,b,c])
 if b<Y-1 :
  if [a,b+1,c] not in check:
   heapq.heappush(lst, (-(A[a]+B[b+1]+C[c]),a,b+1,c))
   check.append([a,b+1,c])
 if c<Z-1 :
  if [a,b,c+1] not in check:
   heapq.heappush(lst, (-(A[a]+B[b]+C[c+1]),a,b,c+1))
   check.append([a,b,c+1])

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,ll> pil;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;

namespace io{
    const int L = (1 << 20) + 1;

    char buf[L], *S , *T, c;

    char getchar() {
        if(__builtin_expect(S == T, 0)) {
            T = (S = buf) + fread(buf, 1, L, stdin);
            return (S == T ? EOF : *S++);
        }
        return *S++;
    }

    int inp() {
        int x = 0, f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }

    unsigned inpu()
    {
        unsigned x = 0; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar());
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x;
    }

    ll inp_ll() {
        ll x = 0; int f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }

    char B[25], *outs=B+20, *outr=B+20;
    template<class T>
    inline void print(register T a,register char x=0){
        if(x) *--outs = x, x = 0;

        if(!a)*--outs = '0';
        else
            while(a)
                *--outs = (a % 10) + 48, a /= 10;

        if(x)
            *--outs = x;

        fwrite(outs, outr - outs , 1, stdout);
        outs = outr;
    }
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;
const int maxN = 1e5;
struct node
{
	ll cnt,mon;	
}F[maxN];
int a[maxN];
int main()
{
	int K = inp();
	ll A = inp_ll();
	ll B = inp_ll();
	ll ans = 0;
	if(B-A<=2 || K<=A)
	{
		ans = 1+K;
		cout<<ans<<endl;
		return 0;
	}
	else
	{
		ans = A+(K-A+1)/2*(B-A)+(K-A+1)%2; 
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)
#define test cout << "test" << endl;
#define NNN_MAX 100010
typedef pair<int,int> P;

int max(int a,int b){
	if (a>b) return a;
	return b;
}

int min(int a,int b){
	if (a>b) return b;
	return a;
}

int main (){
	int AAA,BBB,CCC;
	int max1,max2,max3;
	int onaji1,onaji2,chiga;
	int count =0;
	cin >>AAA >>BBB >>CCC;
	if(AAA==BBB && AAA==CCC){
		cout << count << endl;
		return 0;
	}
	//3つとも偶数奇数が等しいとき
	if(AAA%2 == BBB%2 && AAA%2 == CCC%2){
		max1 = max(AAA,max(BBB,CCC));
		max3 = min(AAA,min(BBB,CCC));
		max2 = AAA+BBB+CCC-max1-max3;
		count += (max1-max3)/2+(max1-max2)/2;
	}
	//少なくとも2つは偶奇が一致する
	else{
		if(AAA%2 == BBB%2){
			onaji1 = max(AAA,BBB);
			onaji2 = AAA+BBB-onaji1;
			chiga  = CCC; 
		}
		else if(AAA%2 == CCC%2){
			onaji1 = max(AAA,CCC);
			onaji2 = AAA+CCC-onaji1;
			chiga  = BBB;			
		}
		else {
			onaji1= max(BBB,CCC);
			onaji2= BBB+CCC-onaji1;
			chiga  = AAA;
		}

		count += (onaji1-onaji2)/2; // 偶奇数が一致する2つについて、数字を揃える=onaji1になってる
		if(chiga>onaji1){
			count += chiga-onaji1; //chigaのほうがデカイならchigaにそろえる、これは1刻みなので差を加える
		}
		else{
			count += (onaji1+1 - chiga)/2 +1; //chigaが小さいなら、chigaをonaji+1にするそのあとonajiを+1
		}
	}

	cout << count <<endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            if(n==0) break; 

            ArrayList<Integer> list = new ArrayList<Integer>();
            while(n>0){
                list.add(n%8);
                n /= 8;
            }

            for(int i=list.size()-1; i>=0; i--){
                int num = list.get(i);
                if(num>=4) num++;
                if(num>=6) num++;
                System.out.print(num);
            }
            System.out.println();
        }
    }

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

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

int main() {
  int n;
  cin >> n;
  vector<int> data(n);
  for (int i = 0; i < n; i++) {
    cin >> data[i];
  }
  int minv = data[0];
  int maxv;
  for (int i = 1; i < n; i++) {
    if (i == 1) {
      maxv = data[i] - minv;
    } else {
      maxv = max(maxv, data[i] - minv);
    }
    minv = min(minv, data[i]);
  }
  cout << maxv << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;

	if (M == 1) {
		printf("1 2\n");
		return;
	}

	int i1 = 1;
	int i2 = M + 2;

	rrep(diff, M, 1) {
		printf("%d %d\n", i1, i1 + diff);
		i1++;
		swap(i1, i2);
	}
}







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


Measured memory_bytes: 2104
// #include C {
#include<cstring>
#include<cassert>
#include<cstdio>
#include<cctype>
#include<cmath>
// }

// #include C++ {
#include<functional>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<map>
#include<set>
// }

using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 100005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
int p[MAX_N];
/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
//  WF("output.txt");
	DF("err.txt");

	int N;
	scanf("%d", &N);
	int a = N / 10;
	int b = N % 10;
	if (a == 9 || b == 9)
		printf("Yes\n");
	else
		printf("No\n");
}

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

using namespace std;

int main()
{
	int n;
	int d[101];
	int num[101] = {0};
	int res = 0;

	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> d[i];
	}
	for(int j = 0; j < n; j++)
	{
		num[d[j]]++;
	}
	
	for(int m = 0; m <= 100; m++)
	{
		if(num[m] != 0)
		{
			res++;
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
  lli a, b;
  cin >> a >> b;
  lli midpoint;
  if( (a+b) % 2 == 0)
  {
    cout <<  (a+b) / 2 << endl; 
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
import scala.collection.mutable
import scala.io.StdIn.{readInt, readLine}

object Main {
  def main(args: Array[String]): Unit = {
    val n = readInt()
    val set = mutable.HashSet[String]()
    for (_ <- 1 to n) {
      set.add(readLine())
    }

    Array("S", "H", "C", "D").foreach(suit => {
      (1 to 13).foreach(rank => {
        val card = s"${suit} ${rank}"
        if (!set.contains(card)) {
          println(card)
        }
      })
    })
   }
}



Measured memory_bytes: 43836
N = int(input())
s = []

for i in range(N) :
    s.append(int(input()))

ans = sum(s)
s.sort()

for i in range(N) :
    if ans%10 != 0 :
        print(ans)
        break
    elif s[i]%10 != 0:
        ans -= s[i]
else :
    print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int dp[100005];
vector <vector <int> > V(100005);
int N,M,blank=-1;
int call(int i){
	if (V[i].empty())	return 0;
	if(dp[i]!=-1)		return dp[i];
	int ans = 0;
	for(auto x:V[i]){
		ans = max(ans,1+call(x));
	}
	return dp[i] = ans;
}

int main()
{
	cin>>N>>M;
	memset(dp,blank,sizeof(dp));
	int i,j,k,p,q,l;
	for(i=0;i<M;i++){
		cin>>p>>q;
		V[p].push_back(q);
	}
	for(i=1;i<=N;i++)
		V[0].push_back(i);
	cout<<call(0)-1;
	return 0;
}

Measured memory_bytes: 8696
/*
#include<iostream>
using namespace std;

int main()
{
	char a[10];
	int b;
	cin >> a;
	b = a[0]-48;
	cout << b << endl;
	return 0;
}
*/



#include<iostream>
#include<queue>

using namespace std;

#define ny first
#define nx second

typedef pair < int, int > PR;

PR tp;


queue< PR > qu1,qu2;

int gy[] = { 1,0,-1,0,1,1,-1,-1};
int gx[] = { 0,1,0,-1,1,-1,1,-1};

int ly, lx;
char map[1000 + 10][1000 + 10];
int mmap[1000 + 10][1000 + 10] = { 0 };


int nami1(void);
int nami2(void);

int ans = 0;


int main()
{
	int i, j, k;
	int a;


	cin >> ly >> lx;

	for (i = 0; i < ly; i++)
	{
		cin >> map[i];
	}

	for (i = 1; i < ly-1; i++)
	{
		for (j = 1; j < lx-1; j++)
		{
			for (k = 0; k < 8; k++)
			{
				if (map[i + gy[k]][j + gx[k]] == '.')
				{
					mmap[i][j]++;
				}
			}
			
			if (map[i][j] != '.' && map[i][j] != '9')
			{
				a = map[i][j] - 48;
				if (a <= mmap[i][j])
				{
					tp.ny = i;
					tp.nx = j;

					qu1.push(tp);
				}
			}
		}
		
	}

	nami1();

	cout << ans << endl;

	return 0;
}


int nami1(void)
{
	int i, j;
	int b;
	PR tmp;
	ans++;

	while (!qu1.empty())
	{
		tp = qu1.front();
		qu1.pop();

		for (i = 0; i < 8; i++)
		{
			mmap[tp.ny + gy[i]][tp.nx + gx[i]]++;

			b = map[tp.ny + gy[i]][tp.nx + gx[i]] - 48;

			if (mmap[tp.ny + gy[i]][tp.nx + gx[i]] - b == 0)
			{
				tmp.ny = tp.ny + gy[i];
				tmp.nx = tp.nx + gx[i];

				qu2.push(tmp);
			}
		}
	}
	if (!qu2.empty())
	{
		return nami2();
	}
	else
	{
		return 0;
	}
	return 0;
}

int nami2(void)
{
	int i, j;
	int b;
	PR tmp;
	ans++;

	while (!qu2.empty())
	{
		tp = qu2.front();
		qu2.pop();

		for (i = 0; i < 8; i++)
		{
			mmap[tp.ny + gy[i]][tp.nx + gx[i]]++;

			b = map[tp.ny + gy[i]][tp.nx + gx[i]] - 48;

			if (mmap[tp.ny + gy[i]][tp.nx + gx[i]] - b == 0)
			{
				tmp.ny = tp.ny + gy[i];
				tmp.nx = tp.nx + gx[i];

				qu1.push(tmp);
			}
		}
	}
	if (!qu1.empty())
	{
		return nami1();
	}
	else
	{
		return 0;
	}
	return 0;
}

Measured memory_bytes: 39124
#include <bits/stdc++.h>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define maxn 300005
int t[4 * maxn];
int n, k;
int sum(int v, int l, int r, int tl, int tr) {
    if (l > r) return 0;
    if (l == tl && r == tr) return t[v];
    int tm = (tl + tr) / 2;
    return max(sum(v * 2, l, min(r, tm), tl, tm), sum(v * 2 + 1, max(l, tm + 1), r, tm + 1, tr));
}
void update(int v, int cl, int cr, int pos) {
    if (cl == cr) {
        int l = pos - k;
        if (l < 0) l = 0;
        int r = pos + k;
        if (r > 300000) r = 300000;
        t[v] = 1 + sum(1, l, r, 0, 300000);
    } else {
        int cm = (cl + cr) / 2;
        if (pos <= cm) {
            update(v * 2, cl, cm, pos);
        } else {
            update(v * 2 + 1, cm + 1, cr, pos);
        }
        t[v] = max(t[v * 2], t[v * 2 + 1]);
    }
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    memset(t, 0, sizeof(t));
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        update(1, 0, 300000, a);
    }
    cout << t[1] << endl;
}

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

using str = string;
using ss = stringstream;

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

    int n;
    cin>>n;

    str s;
    cin>>s;

    int ans=0;
    int x=0;

    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='I')x++;
        else if(s[i]=='D')x--;
        ans=max(ans,x);
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3616
n = int(input())
a = list(map(int, input().split()))
pbox = []
nbox = []
if 0 in a:
    count = 0
    for i in a:
        count += abs(i)
    print(count)
else:
    for i in a:
        if i > 0:
            pbox.append(i)
        else:
            nbox.append(i)
    if len(nbox) % 2 == 0:
        count = 0
        for i in a:
            count += abs(i)
        print(count)
    else:
        box = []
        for i in a:
            box.append(abs(i))
        mi = min(box)
        count = 0
        for i in a:
            count += abs(i)
        print(count - 2*mi)

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

using i64 = int64_t;

using Graph = vector<vector<int>>;

bool dfs(int u, int c, pair<int, int> &color, vector<int> &visited, const Graph &graph){
    bool res = true;
    visited[u] = c;
    if(c == 1)color.first++;
    else color.second++;
    for(auto v: graph[u]){
        if(visited[v] == c)return false;
        if(visited[v] == (c^3))continue;
        //cout << u << " " << c << endl;
        res &= dfs(v, c^3, color, visited, graph);
    }
    return res;
}

int main(){
    int n, m;
    while(cin >> n >> m, n > 0){
        Graph graph(n+1, vector<int>());
        for(int i=0;i<m;++i){
            int u, v;
            cin >> u >> v;
            graph[u].push_back(v);
            graph[v].push_back(u);
        }
        pair<int, int> color({0, 0});
        vector<int> visited(n+1, 0);
        bool ok = true;
        for(int i=1;i<=n;++i){
            if(visited[i] == 0){
                ok &= dfs(i, 1, color, visited, graph);
            }
        }
        if(!ok){
            cout << 0 << endl;
            continue;
        }
        set<int> ans;
        if(color.first % 2 == 0)ans.insert(color.first/2);
        if(color.second % 2 == 0)ans.insert(color.second/2);
        cout << ans.size() << endl;
        for(auto e: ans){
            cout << e << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3208
N, K = map(int, input().split())

count = 0
for i in range(K, N+2):
    # print(i, (i-1)*i/2, (N+1-i+N)*i/2)
    count += (N+1-i+N)*i/2 - (i-1)*i/2 +1
    # if i == 10:
    #     break
print(int(count)%(10**9+7))

Measured memory_bytes: 67372
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
int N;
char C[2][55];
vector<bool> A;

int main() {
  INCANT;
  cin >> N;
  rep(i, 2) rep(j, N) cin >> C[i][j];
  
  int idx=0;
  while(idx<N) {
    if (C[0][idx]==C[1][idx]) {
      A.push_back(true);
      idx++;
    }
    else if (idx<N-1 && C[0][idx]==C[0][idx]) {
      A.push_back(false);
      idx+=2;
    }
  }
  ll ret=A[0]?3ll:6ll;
  rep(i, A.size()-1) {
    if (A[i]) ret*=2ll;
    else if (!A[i] && A[i+1]) ret*=1ll;
    else ret*=3ll;
    ret%=MOD;
  }

  cout << ret << "\n";
  return 0;
}

Measured memory_bytes: 256