akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; const ll MOD = MM + 7; ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a=(a+ll(b))%MOD
#define MUL(a,b) a=(a*ll(b))%MOD
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
using Graph = vector<vector<ll>>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);


// 素因数分解
map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for(int i=2; i*i<=n; i++){
        while(n%i == 0){
            ++res[i];
            n/=i;
        }
    }
    if(n!=1) res[n]=1;
    return res;
}


const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];


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


ll nCr(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll nPr(ll n, ll r) { if (r < 0 || n < r) return 0; else return (fac[n] * finv[n-r]) % MOD; }
ll nHr(ll n, ll r) { if (n == 0 && r == 0) return 1; else return nCr(n + r - 1, r); }

int main(){
    ll n, m, ans = 1;
    cin >> n >> m;
    auto pf = prime_factor(m);
    COMinit();
    for(auto p: pf){
        MUL(ans, nHr(n, p.second));
    }
    cout << ans << endl;
}


Measured memory_bytes: 15596
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    ll ans = 0;
    for(int i=1; i<=N; i++) {
        ans += 1LL * i * (N - i + 1);
    }
    for(int i=0; i+1<N; i++) {
        int u, v; scanf("%d%d", &u, &v);
        if(u > v) swap(u, v);
        ans -= 1LL * u * (N - v + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int n, m,r=0;
	cin >> n >> m;
	if (n > 1) {
		for (int i = 1; i < n; i++) {
			r += i;
		}
	}
	if (m > 1) {
		for (int i = 1; i < m;i++) {
			r += i;
		}
	}
	cout << r << endl;
	return 0;
}

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

int main(){
  int N;
  cin >>N;
  
  vector<vector<int>> data(N,vector<int>(2));
  for(int i=0;i<N;i++){cin >>data.at(i).at(0);
                       data.at(i).at(1)=i+1;
                      }
  sort(data.begin(),data.end());
 
  for(int i=0;i<N;i++){cout <<data.at(i).at(1);
                       if(i!=N-1){cout <<" ";}
                                  else{cout <<endl;}
                      }

}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n1, n2, n3;
    cin >> n1 >> n2 >> n3;
    if (n1 == 1 && n2 == 1 && n3 == 0) {
        cout << "Open" << '\n';
    } else if (n1 == 0 && n2 == 0 && n3 == 1) {
        cout << "Open" << '\n';
    } else {
        cout << "Close" << '\n';
    }
    return 0;
}


Measured memory_bytes: 3220
// -*- coding:utf-8; tab-width:4 -*-
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

// ティツァツ」テァツュツ?
namespace solution {
    using namespace std;
   
    typedef istringstream ISS;
    typedef ostringstream OSS;
    typedef vector<string> VS;
    typedef long long LL;
    typedef int INT;
    typedef vector<INT> VI;
    typedef vector<VI> VVI;
    typedef pair<INT, INT> II;
    typedef set<LL> SET;

    const int SIZE = 100001;
    int n;
    SET S;

    struct Solution {
        void init() {
            S.clear();
        }
   
        bool input() {
            if ( ! ( cin >> n ) )
                return false;
            for ( int i = 0; i < n; ++ i ) {
                LL a;
                cin >> a;
                S.insert(a);
            }
            return true;
        }

        int solve() {
            int key = 0;
            for ( SET::iterator it_i = S.upper_bound(key);
                    it_i != S.end(); ) {
                key = *it_i;
                for ( int i = 1; 2 * i * i + i + i <= key; ++ i )
                    if ( ( key - i ) % ( 2 * i + 1 ) == 0 ) {
                        S.erase(key);
                        break;
                    }
                it_i = S.upper_bound(key);
            }
            return S.size();
        }

        void output( int result ) {
            cout << result << endl;
        }
      
        int run() {
            while ( init(), input() ) {
                output(solve());
            }
            return 0;
        }
    };
}

int main() {
    return solution::Solution().run();
}

Measured memory_bytes: 3544
def resolve():
    S = str(input().split())
    ans = 0

    for pos in range(len(S)):
        for ln in range(pos, len(S)):
            if all('ACGT'.count(c) == 1 for c in S[pos:ln+1]):
                ans = max(ans, ln - pos + 1)

    print(ans)
    return

resolve()

Measured memory_bytes: 9048
W,H=map(int,input().split())
P=[int(input()) for i in range(W)]
Q=[int(input()) for j in range(H)]
P.append(float('inf'))
Q.append(float('inf'))
P.sort(reverse=True)
Q.sort(reverse=True)
now_W=W+1
now_H=H+1
cost=0
while now_W>1 or now_H>1:
    if P[-1]<Q[-1]:
        cost+=P.pop()*now_H
        now_W-=1
    elif Q[-1]<P[-1]:
        cost+=Q.pop()*now_W
        now_H-=1
    elif P[-1]==Q[-1]:
        if now_W<=now_H:
            cost+=Q.pop()*now_W
            now_H-=1
        elif now_W>now_H:
            cost+=P.pop()*now_H
            now_W-=1
print(cost)

Measured memory_bytes: 11500
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        var s = Console.ReadLine();
        if (s[0] == 'A' && s[1] != 'C' && s.Last() != 'C' && s.Count(c => c == 'C') == 1 && s.Count(c => c > 'Z') == s.Length - 2) Console.WriteLine("AC");
        else Console.WriteLine("WA");
    }
}


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

ll solve() {
    string S;
    cin >> S;
    ll n = S.size();
    const ll MOD = 1e9 + 7;
    auto Add = [&](ll& x, ll y) { x = ( x % MOD + y % MOD ) % MOD; };
    auto Mul = [&](ll& x, ll y) { x = ( x % MOD * y % MOD ) % MOD; };
    vector<vector<ll>> dp(n+2, vector<ll>(4, 0));
    dp[0][0] = 1;
    for ( int i = 1; i < n+2; i++ ) {
        char c = S[i-1];
        if ( c == '?' ) {
            for ( int j = 0; j <= 3; j++ ) {
                ll x = dp[i-1][j];
                Mul(x, 3);
                if ( j > 0 ) {
                    Add(x, dp[i-1][j-1]);
                }
                dp[i][j] = x;
            }
        } else {
            for ( int j = 0; j <= 3; j++ ) {
                dp[i][j] = dp[i-1][j];
            }
            int j = c - 'A' + 1;
            Add(dp[i][j], dp[i-1][j-1]);
        }
    }
    ll ans = dp[n+1][3];
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 7424
#pragma GCC optimize("O3")
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include<bits/stdc++.h>
    #define int long long
    # define mo 1000000007
    using namespace std;
    #define goku ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    signed main(){
        goku
       int n;
       cin>>n;
       string s;
       cin>>s;
       int c=0;
       for(int i=2;i<n;i++)
       {
           if(s[i]=='C'&&s[i-1]=='B'&&s[i-2]=='A')
            c++;
       }
       cout<<c;
       return 0;
    }


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    if (n % 1000 == 0) System.out.println(0);
    else System.out.println(1000 * (n / 1000 + 1) - n);
  }
}

Measured memory_bytes: 32880
from itertools import product


def main():
    N, M, X = map(int, input().split())
    CA = [list(map(int, input().split())) for _ in range(N)]

    it = (0, 1)
    pat = list(product(it, repeat=N))

    ans = 10**10
    for p in pat:
        tmp = [0] * M
        flag = [0] * M
        tmp_cost = 0
        for i, b in enumerate(p):
            if b == 1:
                tmp_cost += CA[i][0]
                for j in range(M):
                    tmp[j] += CA[i][j+1]
                    if tmp[j] >= X:
                        flag[j] = 1
                if sum(flag) == M:
                    if ans > tmp_cost:
                        ans = tmp_cost

    if ans == 10**10:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9644
#include<iostream>
#include<string>

int main(){
  	std::string str;
  	std::cin >> str;
  	int stackS=0, dub=0;
  	bool prevT=false;
  	for(auto&&c : str){
      	if(c=='S'){
          	if(prevT){
              	prevT=false;
            }
          	stackS++;
        }
      	else if(c=='T'){
          	if(stackS>0){
              	stackS--;
              	dub++;
            }
          	prevT=true;
        }
    }
  	std::cout << str.size() - dub*2 << std::endl;
  	return 0;
}

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

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ans=a+b+c-max({a,b,c});
  cout<<ans+max({a,b,c})*(1<<k)<<endl;
  return 0;
}


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

int main(){
  int a ,b ; 
  cin >> a >> b ; 
  
  if((a*b)%2 == 0){
    cout << "Even" << endl ; 
  }
  else{
    cout << "Odd" << endl ; 
  }
  
}

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

#define N 300005
#define M 2000005

#define ls (t<<1)
#define rs ((t<<1)|1)
#define mid ((l+r)>>1)

#define mk make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;

int i,j,m,n,p,k;

char c[N],s[N];

int gcd(int x,int y)
{
		return !y?x:gcd(y,x%y);
}

int main()
{
		scanf("%d%d",&n,&m);
		scanf("%s%s",c+1,s+1);
		long long w=1ll*n*m/gcd(n,m),a=1,b=1,i=1,j=1;
		while (i<=n&&j<=m)
		{
				if (a<b)
				a+=m,++i; 
				else if (a>b) b+=n,++j;
				else if (a==b) 
				{
						if (c[i]!=s[j]) 
						{
								puts("-1");
								return 0;
						}
						a+=m; b+=n; ++i; ++j;
				}
		}
		printf("%lld\n",w); 
}

Measured memory_bytes: 384
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;

int main()
{
  int n;cin>>n;
  int p[n + 10];
  rep(i, n) cin >> p[i];
  int count = 0;
  rep(i,n){
    if(p[i]==i+1)count++;
  }
  if (n - count <= 2)
    cout << "YES" << endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    
    class BIT:
        '''
        0-indexed
        '''
        def __init__(self, N):
            self.size = N
            self.tree = [0] * (N + 1)
            self.depth = N.bit_length()

        def _bitsum(self, i):
            ret = 0
            while i:
                ret += self.tree[i]
                i ^= i & -i
            return ret

        # [l,r)の和
        def bitsum(self, l, r=None):
            if r is None:
                return self._bitsum(l)
            else:
                return self._bitsum(r) - self._bitsum(l)

        # i番目にxを追加
        def add(self, i, x):
            i += 1
            while i <= self.size:
                self.tree[i] += x
                i += i & -i
            return

        def lower_bound(self, x):
            sum_ = 0
            pos = 0
            v = 1 << self.depth
            for i in range(self.depth, -1, -1):
                k = pos + v
                if k <= self.size and sum_ + self.tree[k] < x:
                    sum_ += self.tree[k]
                    pos += v
                v >>= 1
            return pos + 1, sum_

    
    N,Q=MI()
    C=LI()
    
    Query =[]
    
    M=10**6
    M2=10**12
    for i in range(Q):
        l, r = MI()
        l-=1
        r-=1
        Query.append(r*M2 + l*M + i)
    Query.sort()
    
    """
    事前処理 + クエリの高速処理
    or 
    クエリ先読み
    
    とりあえずrの昇順にクエリをソートしておく．
    結局，各色ごとに1つ前のやつがどこにあるかが問題=>各色ごとに最新の物だけを保持すれば良い．
    最終的にクエリに答えたいので，i番目が使えるかどうかBITで管理
    """
    bit=BIT(N+3)
    dd=[N+3]*(N+1)#多くとっておく
    
    ans=[0]*Q
    pre=-1
    for q in Query:
        r = q // 10 ** 12
        l = (q % 10 ** 12) // 10 ** 6
        i = q % 10 ** 6
        for j in range(pre+1,r+1):
            c=C[j]
            old=dd[c]#その色の古いやつ
            bit.add(old,-1)#もしまだ出てきていないなら，範囲外の使わないところを-1する
            #最新を追加
            dd[c]=j
            bit.add(j,1)
        pre=r
        ans[i]=bit.bitsum(l,r+1)
        
    for a in ans:
        print(a)
main()


Measured memory_bytes: 152484
n,m = map(int, input().split())

data = [[0,0] for _ in range(n)]
for i in range(n):
  data[i][0],data[i][1] = map(int, input().split())

data = sorted(data, key=lambda x: x[0])

rest = m
money = 0
for a,b in data:
  #print(a,b)
  if b <rest:
    rest-=b
    money+=a*b
  else:
    money += a*rest
    break

print(money)

Measured memory_bytes: 22052
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

d = defaultdict(lambda : -1)
def solve():
    global d
    def dfs(x,pre,k,m):
        global d
        p = 1
        if pre != -1:
            if x < pre:
                d[(x,pre)] = k
            else:
                d[(pre,x)] = k
        for y in v[x]:
            if p == k:
                p += 1
            if m[y]:continue
            m[y] = 1
            dfs(y,x,p,m)
            p += 1
    n = I()
    v = [[] for i in range(n)]
    e = []
    f = [0]*n
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
        e.append((a,b))
        f[a] += 1
        f[b] += 1
    if n == 2:
        print(1)
        print(1)
        return
    m = [0]*n
    m[0] = 1
    dfs(0,-1,0,m)
    print(max(f))
    for x,y in e:
        print(d[(x,y)])
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 106396
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

int main(){
  int a,b;
  cin>>a>>b;
  if(a<=b)cout<<a<<endl;
  else cout<<a-1<<endl;
  return 0;
}




Measured memory_bytes: 256
/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( char *X, char *Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
char lcs[index+1]; 
lcs[index] = '\0'; // Set the terminating character 

// Start from the right-most-bottom-most corner and 
// one by one store characters in lcs[] 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
cout<<lcs<<endl; 
} 

/* Driver program to test above function */
int main() 
{ 
string s1,s2;
cin>>s1>>s2;
int m = s1.length(); 
int n = s2.length();
char x[s1.length()];
char y[s2.length()]; 
for (int i = 0; i < sizeof(x); i++) 
{ 
        x[i] = s1[i];
}
for (int i = 0; i < sizeof(y); i++) 
{ 
        y[i] = s2[i];
}

lcs(x, y, m, n); 
return 0; 
} 


Measured memory_bytes: 38720
#include <stdio.h>

int main() {
	char x;
	int data[26];
	int k = 0;
	int i = 0;

        for (int i = 0; i < 27; i++) {
		data[i] = 0;
	}

	while (scanf("%c", &x) != EOF) {
			if ('a' <= x &&  x <= 'z') {
				k = x - 'a';
				data[k] += 1;
			}
			else if ('A' <= x && x <= 'Z') {
				k = x - 'A';
				data[k] += 1;
			}
			i = i + 1;
	}

	for (int i = 0; i < 26; i++) {
		printf("%c : %d\n",i+'a', data[i]);
	}
	return 0;
}


Measured memory_bytes: 2708
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    int _max = -1;
    for (int i=0; i<n; i++) {
        int p;
        cin >> p;
        ans += p;
        _max = max(_max, p);
    }

    ans -= _max/2;
    cout << ans << endl;
}


Measured memory_bytes: 256
/*   CREATED BY
       STREAM_CIPHER
       28-03-2020
  */
  #include <bits/stdc++.h>
  #include <cstdio>
  using namespace std;
  typedef long long  int ll;
   int main()  
   {
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL); 
       
        string a;
        cin>>a;
        if(a[2]==a[3]&&a[4]==a[5])
          cout<<"Yes\n";
         else
          cout<<"No\n";
   }      

Measured memory_bytes: 256
P,L="+<"
p=print
r=range
p(6484,P,0,1,3,L,2,3,3)
for x in 0,1:
	p(P,x,3,x)
	for t in r(30):p(P,v:=x+4,v,v,P,v,3,6),exec('p(P,6,6,6);'*(29-t));p(L,6,x,T:=x*60+9+t,P,v,T,v)
for t in r(60):p(P,2,2,2);[p(P,8+t-s,69+s,5,L,3,5,6,P,2,6,2)for s in r(t)]

Measured memory_bytes: 9340
#include<iostream>
using namespace std;
long int gcd(long int a, long int b){
	if(b==0) return a;
  	else return gcd(b,a%b);
}

int main(){
int n;
  cin >> n;
  long int arr[n];
  for ( int i = 0; i < n; i++)
    cin >> arr[i];
  long int res=0;
  for (int i = 0; i < n; i++)
    res = gcd(arr[i], res);
  // print the result
  cout << res <<'\n';

return 0;
}

Measured memory_bytes: 1024
def is_prime(num):
    if num == 1:
        raise ValueError("error!")
    d = 2
    while d * d <= num:
        if num % d == 0:
            return False
        d += 1
    return True
    
n, k = list(map(int, input().split()))
mod = 10 ** 9 + 7

n_power_table = [-1] * (k+1)
for i in range(k+1):
    n_power_table[i] = pow(i, n, mod)

# 素数リストを作っておく
prime_list = []
for i in range(2, k+1):
    if is_prime(i):
        prime_list.append(i)

prime_2_list = []
prime_3_list = []
prime_4_list = []
prime_5_list = []
prime_6_list = []

ll = len(prime_list)
for i, p1 in enumerate(prime_list):
    for j in range(i+1, ll):
        p2 = prime_list[j]
        if p1*p2 > k:
            break
        prime_2_list.append(p1*p2)
        for v in range(j+1, ll):
            p3 = prime_list[v]
            if p1*p2*p3 > k:
                break
            prime_3_list.append(p1*p2*p3)
            # print(p1, p2, p3)
            for w in range(v+1, ll):#enumerate(prime_list[v+1:]):
                p4 = prime_list[w]
                if p1*p2*p3*p4 > k:
                    break
                prime_4_list.append(p1*p2*p3*p4)
                for x in range(w+1, ll):#, p5 in enumerate(prime_list[w+1:]):
                    p5 = prime_list[x]
                    if p1*p2*p3*p4*p5 > k:
                        break
                    prime_5_list.append(p1*p2*p3*p4*p5)
                    for y in range(x+1, ll):#, p5 in enumerate(prime_list[w+1:]):
                        p6 = prime_list[y]
                        if p1*p2*p3*p4*p5*p6 > k:
                            break
                        prime_6_list.append(p1*p2*p3*p4*p5*p6)

prime_2_list.sort()
prime_3_list.sort()
prime_4_list.sort()
prime_5_list.sort()
prime_6_list.sort()

# prime_3_list = []
# for i, p1 in enumerate(prime_list):
#     for j, p1_ in enumerate(prime_2_list):
#         if p1*p1_ > k:
#             break
#         prime_3_list.append(p1*p1_)

# list(set(prime_3_list)).sort()

# print(prime_3_list)

ans = 0
temp = 0

for g in range(1, k+1):
    # kosuu は、gcd = gとなる組み合わせの個数
    p = k // g
    
    kosuu = n_power_table[p]

    for prime in prime_list:
        if prime > p:
            break
        kosuu -= n_power_table[p//prime]
    
    for prime in prime_2_list:
        if prime > p:
            break
        kosuu += n_power_table[p//prime]
    
    for prime in prime_3_list:
        if prime > p:
            break
        kosuu -= n_power_table[p//prime]

    for prime in prime_4_list:
        if prime > p:
            break
        kosuu += n_power_table[p//prime]

    for prime in prime_5_list:
        if prime > p:
            break
        kosuu -= n_power_table[p//prime]

    for prime in prime_6_list:
        if prime > p:
            break
        kosuu += n_power_table[p//prime]

    kosuu %= mod
    ans += g * kosuu
    # print(g, kosuu)
    temp += kosuu

print(ans% mod)
# print(temp)


Measured memory_bytes: 15668
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;

int n;
vector<int> w;

int main() {
    cin >> n;
    w.resize(n+1);

    for(int i = 1; i <= n; i++)
        cin >> w[i];
    
    int w_min = INF;
    for(int t = 1; t < n; t++) {
        int s1 = accumulate(w.begin()+1, w.begin()+t+1, 0);
        int s2 = accumulate(w.begin()+t+1, w.end(), 0);
        w_min = min(w_min, abs(s1-s2));
    }

    cout << w_min << endl;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, k = map(int, input().split())
    h = sorted([int(input()) for _ in range(n)])
    ans = float('inf')
    for i in range(n-k+1):
        ans = min(ans, h[i+(k-1)]-h[i])
    print(ans)
            
if __name__ == '__main__':
    main()

Measured memory_bytes: 14128
#include<stdio.h>
#define MAX 100

int main()
{
  int n;
  int i,j,k,l;
  int p[MAX+1];
  int m[MAX+1][MAX+1];

  scanf("%d",&n);
  for( i = 1 ; i <= n ; i++ ){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  for( i = 1 ; i <= n ; i++ )m[i][i] = 0;
  for( l = 2 ; l <= n ; l++ ){
    for( i = 1 ; i <= n - l + 1; i++ ){
      j = i + l - 1;
      m[i][j] = 1000000;
      for( k = i; k <= j - 1; k++ ){
	if( m[i][j] > m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j])
	  m[i][j] =  m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	else m[i][j] = m[i][j];
      }
    }
  }
  printf("%d\n",m[1][n]);
  
  return 0;
}



Measured memory_bytes: 2112
#include <stdio.h>

int main(void){
  int a,b,c,d,e;
  scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);

  if(a == 0){
    printf("%d\n",1);
  }else if(b == 0){
    printf("%d\n",2);
  }else if(c == 0){
    printf("%d\n",3);
  }else if(d == 0){
    printf("%d\n",4);
  }else if(e == 0){
    printf("%d\n",5);
  }

}


Measured memory_bytes: 1708
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

const double PI = acos(-1);
const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    std::cout << max(a*b, c*d) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    
    int n;
    cin>>n;
    map<string,ll> m;
    rep(i,0,n){
        string s;
        cin>>s;
        sort(all(s));
        m[s]++;
    }
    
    ll ans=0;
    for(auto p:m){
        ll x=p.second;
        if(x>1) ans+=(x*(x-1)/2);
    }
    cout<<ans<<endl;
}



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

int main(){
    int r, c;                    // row x column
    cin >> r >> c;
    int table[r+1][c+1]; 

    // processing inputs
    
    for(int j=0; j<c+1; j++) table[r][j] = 0; // init last row
    for(int i=0; i<r; i++){
        table[i][c] = 0;                      // init last column 
        for(int j=0; j<c; j++){
            cin >> table[i][j];
            table[i][c] += table[i][j];       // store sum into last column
            table[r][j] += table[i][j];       // store sum into last row
        }
    }
    for(int j=0; j<c; j++){
        table[r][c] += table[r][j];     // sum last row 
    } 

    // render table
    for(int i=0; i<r+1; i++){
        for(int j=0; j<c+1; j++){
            cout << table[i][j] << flush;
            if(j!=c) cout << " " << flush;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
import java.util.Scanner;
class Main
 {
   public static void main(String[] args)
      {
      Scanner S = new Scanner(System.in);
      int a = S.nextInt();
      int b = S.nextInt();
      int c = S.nextInt();
      if(a<b && b<c){
      System.out.printf("%d %d %d\n", a, b, c);
              }
      else if(a<b && c<b){
      System.out.printf("%d %d %d\n", a, c, b);
            }
       else if(b < a && a < c){
      System.out.printf("%d %d %d\n", b, a, c);
      }
       else if(b < c && c < a){
      System.out.printf("%d %d %d\n", b, c, a);
      }
       else if(c < a && a < b){
      System.out.printf("%d %d %d\n", c, a, b);
      }
      else{
      System.out.printf("%d %d %d\n", c, b, a);
 }
}
}


Measured memory_bytes: 26280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
	
int a[25];
int dp[22][(1<<21)+5];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		int b=0;
		for(int j=0;j<n;j++)
		{
			int x; cin>>x;
			if(x) b^=(1<<j);
		}
		a[i]=b;
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<(1<<n);j++)
		{
			if(__builtin_popcount(j)!=i) continue;
			for(int k=0;k<n;k++)
			{
				if((j&(1<<k))>0&&(a[i-1]&(1<<k))>0) dp[i][j]=add(dp[i][j],dp[i-1][j^(1<<k)]);
			}
		}
	}
	cout<<dp[n][(1<<n)-1]<<'\n';
}


Measured memory_bytes: 162048
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vii;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << max({ a * b, c * d }) << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()
print(-(-(a+b)//2))

Measured memory_bytes: 5192
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 0;
    int a, b, t; cin >> a >> b >> t;
    for(int i=a;i<=t;i+=a){
        ans += b;
    }
    cout << ans;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
from functools import lru_cache
import sys
from collections import deque
sys.setrecursionlimit(1000000)
	
sorted_a = ""
m = dict({})

N = int(input())
A = ''.join(list(map(lambda x: str(int(x)-1), input().split())))
sorted_a = ''.join(list(sorted(A)))

q = deque()
q.append((A, 0))
m[A] = 0
while True:
	a, x = q.popleft()
	if a in m and m[a] < x:
		continue
	if x == (len(a)-1) // 2:
		break;

	for i in range(len(a)):
		for j in range(i+2, len(a)+1):
			next_a = a[:i:] + a[::-1][len(a)-j:len(a)-i:] + a[j::]
			if next_a in m:
				continue

			q.append((next_a, x+1))
			m[next_a] = x+1
			
m2 = dict({})
q = deque()
q.append((sorted_a, 0))
m2[sorted_a] = 0
while True:
	a, x = q.popleft()
	if a in m2 and m2[a] < x:
		continue
	if x == (len(a)-1) // 2:
		break;

	for i in range(len(a)):
		for j in range(i+2, len(a)+1):
			next_a = a[:i:] + a[::-1][len(a)-j:len(a)-i:] + a[j::]
			if next_a in m2:
				continue
			q.append((next_a, x+1))
			m2[next_a] = x+1

ret = sys.maxsize
for a, x in m.items():
	if a in m2:
		ret = min(ret, x + m2[a])
	
if ret == sys.maxsize:
	print(len(A) - 1)
else:
	print(ret)



Measured memory_bytes: 84216
from collections import Counter


def solve(n, aaa):
    if n == 2:
        return aaa == [1, 1]

    count = Counter(aaa)
    min_a = min(count)
    max_a = max(count)
    # 最大値（直径）が所定の範囲内か
    if not 2 <= max_a <= n - 1:
        return False
    # 最小値は半径以下にはならない & 直径パス上の中点として半径である点が必要
    if min_a != (max_a + 1) // 2:
        return False
    # 中点は直径が偶数なら1個、奇数なら2個しかあり得ない
    if count[min_a] != max_a % 2 + 1:
        return False
    # 直径パス上の点として半径+1～直径の各距離が2点ずつ必要
    if any(count[a] < 2 for a in range(min_a + 1, max_a + 1)):
        return False
    # 後の頂点は直径パスの適当な箇所に接続すれば任意の距離に出来る
    return True


n = int(input())
aaa = list(map(int, input().split()))
print('Possible' if solve(n, aaa) else 'Impossible')


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

As = list(map(int, input().split()))
As.sort()

BCs = []
for _ in range(M):
  b, c = tuple(map(int, input().split()))
  BCs.append((b, c))
BCs.sort(key=lambda x: x[1], reverse=True)
  
num = 0
i = 0
for b, c in BCs:
  for j in range(b):
    a = As[i]
    
    if a >= c:
      break
    else:
      num += c
      i += 1
      
    if i == len(As):
      break
      
  if a >= c or i == len(As):
    break
num += sum(As[i: ])
    
print(num)

Measured memory_bytes: 22492
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define mp1(a,b,c) P1(a,P(b,c))
#define pque(a) priority_queue<a>
#define rpque(a) priority_queue<a,vector<a>,greater<a>>

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
const int kaijou[10]={1,1,2,6,24,120,720,5040,40320,362880};

int main(){
	static ll n,t;
	static ll x[52][2],y[52][2],z[52][2];
	
	scanf("%lld%lld",&n,&t);
	rep(i,n){
		scanf("%lld",&x[i][0]);
		scanf("%lld",&y[i][0]);
		scanf("%lld",&z[i][0]);
		scanf("%lld",&x[i][1]);
		scanf("%lld",&y[i][1]);
		scanf("%lld",&z[i][1]);
	}
	
	static vector<ll> Zx,Zy,Zz;
	rep(i,n){
		Zx.pb( x[i][0] );
		Zx.pb( x[i][1] );
		Zy.pb( y[i][0] );
		Zy.pb( y[i][1] );
		Zz.pb( z[i][0] );
		Zz.pb( z[i][1] );
	}
	sor(Zx); uniq(Zx);
	sor(Zy); uniq(Zy);
	sor(Zz); uniq(Zz);
	
	static ll imos[102][102][102] = {};
	
	rep(i,n){
		ll x1 = lb(Zx,x[i][0]) - Zx.begin();
		ll x2 = lb(Zx,x[i][1]) - Zx.begin();
		ll y1 = lb(Zy,y[i][0]) - Zy.begin();
		ll y2 = lb(Zy,y[i][1]) - Zy.begin();
		ll z1 = lb(Zz,z[i][0]) - Zz.begin();
		ll z2 = lb(Zz,z[i][1]) - Zz.begin();
		imos[x1][y1][z1] ++;
		imos[x1][y1][z2] --;
		imos[x1][y2][z1] --;
		imos[x2][y1][z1] --;
		imos[x1][y2][z2] ++;
		imos[x2][y1][z2] ++;
		imos[x2][y2][z1] ++;
		imos[x2][y2][z2] --;
	}
	
	rep1(i,101)rep(j,102)rep(k,102)imos[i][j][k] += imos[i-1][j][k];
	rep(i,102)rep1(j,101)rep(k,102)imos[i][j][k] += imos[i][j-1][k];
	rep(i,102)rep(j,102)rep1(k,101)imos[i][j][k] += imos[i][j][k-1];
	
	static ll ret = 0;
	
	rep(i,Zx.size()){
		rep(j,Zy.size()){
			rep(k,Zz.size()){
				if(imos[i][j][k] >= t){
					ret += (Zx[i+1]-Zx[i]) * (Zy[j+1]-Zy[j]) * (Zz[k+1]-Zz[k]);
				}
			}
		}
	}
	
	printf("%lld\n",ret);
}

Measured memory_bytes: 9492
N = int(input())
pos = []
for _ in range(N):
    x, l = map(int,input().split())
    pos.append((x+l, x-l))

pos.sort()

ans = 0
cur = float('-inf')
for i in range(N):
    if cur <= pos[i][1]:
        ans += 1
        cur = pos[i][0]

print(ans)

Measured memory_bytes: 22772
#include <iostream>
using namespace std;
int main(void){
    string we;
    cin>>we;
    if(we=="RRR") cout<<3<<endl;
    if(we=="RRS"||we=="SRR") cout<<2<<endl;
    if(we=="RSS"||we=="SRS"||we=="SSR"||we=="RSR") cout<<1<<endl;
    if(we=="SSS") cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  long long x;
  cin >> x;
  cout << (x / 500) * 1000 + ((x % 500) / 5) * 5 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  int n; cin >> n;
  V a(n);
  rep(i, n) cin >> a[i];
  
  int m = *max_element(all(a));
  int mi = *min_element(all(a));
  if (m - mi > 1) {
    cout << "No" << endl;
    return 0;
  }
  if (m == mi) if (m == n-1 || (1 <= m && m <= n/2)) {
    cout << "Yes" << endl;
    return 0;
  }

  int k = 0;
  rep(i, n) if (a[i] == m) k++;

  int l = n-k+1;
  int r = n-k+k/2;

  if (l <= m && m <= r) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int n,a[50],q,m;
int dfs(int i,int m){
	if(m==0) return 1;
	if(i>=n) return 0;
	if(m<0) return 0;
	int x=(dfs(i+1,m)||dfs(i+1,m-a[i]));
	return x;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++) 
	cin>>a[i];
	cin>>q;
	for(int i=1;i<=q;i++){
		cin>>m;
		if(dfs(0,m)){
			cout<<"yes"<<endl;
		}else{
			cout<<"no"<<endl;
		}
	}
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

ll dp[105][8];

int main()
{
    int h,w,k; cin >> h >> w >> k;
    dp[0][0] = 1;
    //int m[8] = {1,2,3,5,8,13,21,34};
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            for(int bit = 0; bit < (1<<(w-1)); bit++){
                bool c = false;
                rep(mask,w-2){
                    if((bit & (1<<mask)) && (bit & (1<<(mask+1)))) c = true;
                }
                if(c) continue;
                if(j == 0){
                    if(bit & (1<<j)) dp[i+1][j] += dp[i][j+1];
                    else dp[i+1][j] += dp[i][j];
                }else if(j == w-1){
                    if(bit & (1<<(w-2))) dp[i+1][j] += dp[i][j-1];
                    else dp[i+1][j] += dp[i][j];
                }else{
                    if(bit & (1<<(j))) dp[i+1][j] += dp[i][j+1];
                    else if(bit & (1<<(j-1))) dp[i+1][j] += dp[i][j-1];
                    else dp[i+1][j] += dp[i][j];
                }
                dp[i+1][j] %= mod;
            }
        }
    }
    cout << dp[h][k-1];
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int h, w;
  while (cin >> h >> w) {
    char g[h][w];
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> g[i][j];
      }
    }

    const int H = 500;
    const int W = 500;
    char a[H][W];
    char b[H][W];
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        a[i][j] = b[i][j] = '.';
      }
    }

    auto show = [&] () {
      for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
          cout << a[i][j];
        }
        cout << endl;
      }
      cout << endl;
      for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
          cout << b[i][j];
        }
        cout << endl;
      }
    };
    
    for (int i = 0; i < h; i += 2) {
      for (int j = 0; j < w - 1; ++j) {
        a[i][j] = '#';
      }
      for (int j = 1; j < w; ++j) {
        b[i + 1][j] = '#';
      }
    }

    
    for (int i = 0; i < h; ++i) {
      a[i][0] = b[i][w - 1] = '#';
    }

    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (g[i][j] == '#') {
          a[i][j] = '#';
          b[i][j] = '#';
        }
      }
    }

    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (a[i][j] == '#' && b[i][j] == '#') {
          assert(g[i][j] == '#');
        }
        if (g[i][j] == '#') {
          assert(a[i][j] == '#' && b[i][j] == '#');
        }
      }
    }
    
    show();
  }
  
  return 0;
}


Measured memory_bytes: 1536
package main

import (
	"fmt"
)

func main() {
    var num int;
    
    fmt.Scan(&num);
    
    ans := 1
    
    for i := 0; i < num; i++ {
        var a int;
        fmt.Scan(&a);
        if a == 0 {
            fmt.Println(0);
            return;
        }
        if ans == -1 { continue }
        if a <= 1000000000000000000/ans {
            ans *= a;
        } else {
            ans = -1
            continue
        }
        
    }
    fmt.Println(ans)
}

Measured memory_bytes: 6328