akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<ll M = 1000000007>
struct modint{
    ll val;
    modint(): val(0){}
    template<typename T>
    explicit modint(T t){val = t%M; if(val < 0) val += M;}

    modint pow(ll k){
        modint res(1), x(val);
        while(k){
            if(k&1) res *= x;
            x *= x;
            k >>= 1;
        }
        return res;
    }
    template<typename T>
    modint& operator=(T a){ val = a%M; if(val < 0) val += M; return *this; }
    modint inv() {return pow(M-2);}
    modint& operator+=(modint a){ val += a.val; if(val >= M) val -= M; return *this;}
    modint& operator-=(modint a){ val += M-a.val; if(val >= M) val -= M; return *this;}
    modint& operator*=(modint a){ val = 1LL*val*a.val%M; return *this;}
    modint& operator/=(modint a){ return (*this) *= a.inv();}
    modint operator+(modint a) const {return modint(val) +=a;}
    modint operator-(modint a) const {return modint(val) -=a;}
    modint operator*(modint a) const {return modint(val) *=a;}
    modint operator/(modint a) const {return modint(val) /=a;}
    modint operator-(){ return modint(-val);}
    bool operator==(const modint a) const {return val == a.val;}
    bool operator!=(const modint a) const {return val != a.val;}
    bool operator<(const modint a) const {return val < a.val;}
};

using mint = modint<MOD>;

int main() {
    ll h, w, t;
    cin >> h >> w >> t;
    ll x = __gcd(h, t)*__gcd(w, t);
    h /= __gcd(h, t); w /= __gcd(w, t);
    cout << (mint(2).pow(h) + mint(2).pow(w) - mint(1) + mint(2).pow(__gcd(h, w)) - mint(2)).pow(x).val << "\n";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * (n + 1)
for h in range(n):
    k = min(b[h], a[h])
    c[h] = c[h] + k
    a[h] = a[h] - k
    #print("h:{} a:{} b:{} k:{} c:{}".format(h, a, b, k, c))
    k = min(b[h] - k, a[h + 1])
    c[h + 1] = c[h + 1] + k
    a[h + 1] = a[h + 1] - k
    #print("h:{} a:{} b:{} k:{} c:{}".format(h, a, b, k, c))
print(sum(c))


Measured memory_bytes: 18752
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val K = sc.nextInt()

    val lunluns = mutableListOf(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L)
    var newLunluns = lunluns

    while (lunluns.size < K) {
        var nextLunLuns = mutableListOf<Long>()
        for (lunlun in newLunluns) {
            val last = lunlun % 10
            if (last == 0L) {
                nextLunLuns.add(lunlun * 10 + 0)
                nextLunLuns.add(lunlun * 10 + 1)
            } else if (last == 9L) {
                nextLunLuns.add(lunlun * 10 + 8)
                nextLunLuns.add(lunlun * 10 + 9)
            } else {
                nextLunLuns.add(lunlun * 10 + last - 1)
                nextLunLuns.add(lunlun * 10 + last)
                nextLunLuns.add(lunlun * 10 + last + 1)
            }
        }
        newLunluns = nextLunLuns
        lunluns.addAll(nextLunLuns)
    }
    println(lunluns[K - 1])
}


Measured memory_bytes: 40580
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
void Main()
{
  ll x;
  cin >> x;
  
  
  int count = 0;
  ll mint = 100;
  
  while(mint < x){
    mint = mint *1.01;
    
    count++;
  }
  
  printf("%d", count);
}
 
int main()
{
  std::cout << std::fixed << std::setprecision(15);
  Main();
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
typedef long long ll;
typedef long double ld;
long long dx[] = {1,0,-1,0};
long long dy[] = {0,1,0,-1};
long long dx8[] = {1,1,0,-1,-1,-1,0,1};
long long dy8[] = {0,1,1,1,0,-1,-1,-1};
long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};

struct SparseTable{
    long long merge(long long x,long long y){
        return min(x,y);
    }
    vector<vector<long long>> table;
    vector<int> log_table;
    SparseTable(vector<long long> A) : table(){
        log_table.resize(A.size()+1);
        log_table[1] = 0;
        for(int i = 2;i <= A.size();i++){
            log_table[i] = log_table[i/2] + 1;
        }
        table.resize(A.size());
        fill(table.begin(),table.end(),vector<long long>(log_table[A.size()]+1));
        for(int i = 0;i < A.size();i++)table[i][0] = A[i];
        for(int i = 1;(1 << i) <= A.size();i++){
            for(int j = 0;j+(1<<i) <= A.size();j++){
                table[j][i] = merge(table[j][i-1],table[j+(1<<(i-1))][i-1]);
            }
        }
    }
    long long query(long long i,long long j){
        return merge(table[i][log_table[j-i+1]],table[j-(1 << log_table[j-i+1])+1][log_table[j-i+1]]);
    }
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,L;
    cin >> N >> L;
    vector<long long> a(N);
    FOR(i,0,N)cin >> a[i];
    SparseTable st(a);
    FOR(i,0,N-L)cout << st.query(i,i+L-1) << ' ';
    cout << st.query(N-L,N-L+L-1) << endl;
}


Measured memory_bytes: 217780
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <cmath>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll BIGP = 1000000007L;
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N, L;
    cin >> N >> L;
    ll ans = 0;
    ll moreZero = BIGP;
    ll id = 0;
    rep(i, N)
    {
        ll t = i + L;;
        ans += t;
        if (abs(t) < moreZero)
        {
            moreZero = abs(t);
            id = t;
        }
    }
    ans -= id;
    cout << ans;
    //
    return 0;
}

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

using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli; 

int main(){
    ulli i,j,k;
    vector<lli> lnln(0);
    cin >> k;
    for(i=1;i<10;i++)lnln.push_back(i);
    for(i=0;i<100000;i++){
        j = lnln[i]%10;
        if(j != 0)lnln.push_back(10*lnln[i] + j - 1);
        lnln.push_back(10*lnln[i] + j);
        if(j != 9)lnln.push_back(10*lnln[i] + j + 1);
    }
    cout << lnln[k-1] << endl;
    return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}
int MOD = pow(10, 9) + 7;

//出力形式を返す関数
string out(vector<int> v){
    string ans="[";
    for(int i=0;i<v.size();i++){
        if(i!=0) ans+=", ";
        ans+=to_string(v[i]);
    }
    ans+="]";
    return ans;
}

signed main() {
	int h,n; cin>>h>>n;
    vector<int> dp(h+1,pow(10,9)); dp[0]=0;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i]>>b[i];

    //各HPについての処理
    for(int hi=0;hi<h;hi++){
        //各魔法についての処理
        for(int ni=0;ni<n;ni++){
            int index=hi+a[ni];
            if(index>h) index=h;
            dp[index]=min(dp[index],dp[hi]+b[ni]); 
        }
    }

    cout<<dp[h]<<endl;
    //output_yoko(dp);

}

Measured memory_bytes: 3712
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();
        int cpb = 0;
        int cpe = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '(') {
                cpb++;
            } else if (s.charAt(i) == ')') {
                cpe++;
            }
        }
        if (cpb > cpe) {
            for (int i = 0; i < cpb - cpe; i++) {
                s = s + ")";
            }
        } else if (cpb < cpe) {
            for (int i = 0; i < cpe - cpb; i++) {
                s = "(" + s;
            }
        }

        int depth = 0;
        int minDepth = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '(') {
                depth++;
            } else if (s.charAt(i) == ')') {
                depth--;
                if (depth < minDepth) {
                    minDepth = depth;
                }
            }
        }
        for (int i = 0; i < -minDepth; i++) {
            s = "(" + s + ")";
        }

        System.out.println(s);
    }
}


Measured memory_bytes: 22612
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for (i = 0; i <= VMAX; i++) {C[i] = 0;
  }

  for (i = 0; i < n; i++){

    scanf("%d", &A[i+1]);

    C[A[i+1]]++;
  }

  for (i = 1; i <= VMAX; i++) {
    C[i] = C[i] + C[i-1];
  }
  
  for (j = 1; j <= n; j++){

    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for (i = 1; i < n; i++){
    printf("%d ", B[i]);
  }

  printf("%d\n", B[i]);
  return 0;
}




Measured memory_bytes: 9564
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int X, A;
    cin >> X >> A;

    if(X < A){
        cout << 0 << endl;
    }
    else{
        cout << 10 << endl;
    }

    return 0;
}

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

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<string> hoge(n);
    vector<string> sample(m);
    
    for(int i=0;i<n;i++) cin>>hoge.at(i);
    for(int i=0;i<m;i++) cin>>sample.at(i);
    
    string ans="No";
    
    for(int i=0;i<n-m+1;i++){
        for(int j=0;j<n-m+1;j++){
            bool ok=true;
            for(int k=i;k<i+m;k++){
                for(int l=j;l<j+m;l++){
                    if(hoge.at(k).at(l)!=sample.at(k-i).at(l-j)){
                        ok=false;
                        break;
                    }
                    if(!ok) break;
                }
            }
            if(ok){
                ans="Yes";
                break;
            }
        }
        if(ans=="Yes") break;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
a,b,k = map(int,input().split())
a_after = 0
b_after = 0
if a >= k:
    a_after = a - k
    b_after = b
else:
    b_after = b - (k-a) if b - (k-a) >=0 else 0
print(a_after, b_after)

Measured memory_bytes: 2940
import com.sun.org.apache.bcel.internal.generic.BIPUSH;

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static final void NO() { out.println("NO"); }
    public static final void YES() { out.println("YES"); }

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

    // ========================================================================= //

    public void solve() {
        long N = sc.nextInt();
        long sqrt = (long)Math.ceil(Math.sqrt(N));
        while (sqrt * sqrt > N) {
            sqrt--;
        }
        System.out.println(sqrt * sqrt);
    }

}



Measured memory_bytes: 23636
from bisect import bisect_left as bl

N, Q = map(int, input().split())
ans = 0
q1 = []
q2 = []
query = []
for _ in range(Q):
    n, p = map(int, input().split())
    query.append((n, p))
    if n == 1:
        q1.append(p)
    else:
        q2.append(p)
q1.sort()
q2.sort()
board = [N - 2, N - 2]
count1 = len(q1)
count2 = len(q2)
for n, p in query:
    if n == 1:
        if p > board[1] + 1:
            continue
        index = bl(q1, p)
        ans += board[0] * (count1 - index)
        board[1] = p - 2
        count1 = index
    else:
        if p > board[0] + 1:
            continue
        index = bl(q2, p)
        ans += board[1] * (count2 - index)
        board[0] = p - 2
        count2 = index
print((N - 2) ** 2 - ans)

Measured memory_bytes: 102408
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int N;
std::vector<int> p;

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }

    int min_val = p[0];
    int ans = 1;
    for(int i=1;i<N;i++){
        if(p[i] <= min_val){
            ans++;
            min_val = p[i];
        }
    }

    cout << ans << endl;


    return 0;
}


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

int main () {
  int x,a,b;
  cin>>x>>a>>b;
  int da = abs(x - a), db = abs(x - b);
  if(da<=db){
    cout<<'A'<<endl;
  }
  else{
    cout<<'B'<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

void vecprint(vector<int> v) {
    for(auto x : v) {
        cout << x << " ";
    }
    cout << endl;
}

void qprint(priority_queue<long> q) {
    while(!q.empty()) {
        cout << q.top() << " ";
        q.pop();
    }
    cout << endl;
}

int main(void) {
    int n, m;
    cin >> n >> m;
    
    priority_queue<long> q;
    for(int i = 0; i < n; i++) {
        long tmp;
        cin >> tmp;
        q.push(tmp);
    }
    
    //qprint(q);
    
    for(int i = 0; i < m; i++){
        long tmp;
        tmp = q.top();
        tmp /= 2;
        q.pop();
        q.push(tmp);
        //qprint(q);
    }

    long ans = 0;
    for(int i = 0; i < n; i++) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
}

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

int main(){
  unsigned long n;
  cin >> n;
  unsigned long mod = 1000000007, answer = 1;
  for(int i = 1;i <= n;i++){
    answer = (answer % mod) * (i % mod);
    answer %= mod;
  }
  cout << answer;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define pi 3.14159265
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <ll, ll> pll;
const ll M=1e9+7;
ll inf=1e18;
int prime[1000001];
int main()
{
    ll n;
    cin>>n;
    for(int i=2;i*i<=1000000;i++)
        if(prime[i]==0)
            for(int j=i+i;j<=1000000;j+=i)
                prime[j]=i;
    vector <ll> v;
    for(int i=2;i<=1000000;i++)
        if(prime[i]==0 && n%i==0){
            v.pb(i);
        }
    ll ans1=0;
    for(int i=0;i<v.size();i++){
        ll x=0;
        while(n%v[i]==0 && n>1){
            x++;
            n/=v[i];
        }
        ll l=1,r=80,mid,ans=1;
        while(l<=r){
            mid=(l+r)/2;
            if((mid*(mid+1))/2<=x){
                ans=mid;
                l=mid+1;
            }
            else
                r=mid-1;
        }
        ans1+=ans;
    }
    if(n!=1)
        cout<<ans1+1<<endl;
    else
        cout<<ans1<<endl;
}


Measured memory_bytes: 7532
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
 
typedef long long ll;

int main2() {

  int N; cin >> N;
  vector<int> A(N), B(N);
  REP(i, N) {
    cin >> A[i];
    cin >> B[i];
  }
  ll ans = 0;
  for (int i = N - 1; i >= 0; i--) {
    int x = (A[i] + ans) % B[i];
    if (x > 0) ans += B[i] - x;
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Measured memory_bytes: 1024
class UnionFind:

    def __init__(self, n):
        self.par = [-1] * n


    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.par[x] > self.par[y]:
            x, y = y, x
        self.par[x] += self.par[y]
        self.par[y] = x
        return True


    def root(self, x):
        path = []
        while self.par[x] >= 0:
            path.append(x)
            x = self.par[x]
        for y in path:
            self.par[y] = x
        return x


    def same(self, x, y):
        return self.root(x) == self.root(y)


    def size(self, x):
        return -self.par[self.root(x)]


n, m = map(int, input().split())
uni = UnionFind(n)
for _ in range(m):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    uni.unite(x, y)

a = [0] * n
for i in range(n):
    a[uni.root(i)] = 1

print(sum(a))

Measured memory_bytes: 11644
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;
const int MOD = 1000000007;
#define MAX_N (1000010)

int main()
{
	int X;
	scanf("%d", &X);

	vector<bool> is_prime(MAX_N, true);
	is_prime[0] = is_prime[1] = false;

	for (int i = 2; i * i <= MAX_N; i++) {
		if (!is_prime[i])
			continue;
		for (int j = i; i * j <= MAX_N; j++)
			is_prime[i * j] = false;
	}

	for (int i = X; i <= MAX_N; i++)
		if (is_prime[i]) {
			printf("%d\n", i);
			break;
		}

	return 0;
}


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

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	string a;
	cin >> a;
	bool fail = 0;
	map <string, int> m;
	m[a]++;
	for (int i = 1; i < n; i++) {
		string str;
		cin >> str;
		m[str]++;
		if (m[str] > 1) fail = 1;
		if (str[0] != a[a.size() - 1]) fail = 1;
		a = str;
	}
	if (fail) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#include<string>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define ALL(c) (c).begin(), (c).end()
// #define dump(a) cerr << #a << "=" << (a) << endl

using namespace std;

int main() {
	string line;
	char left_paren;
	bool is_yes;
	vector<char> left_parens;

	while(getline(cin,line)) {
		if (line[0] == '.') break;

		left_parens.clear();
		is_yes = true;

		rep(i,line.size()) {
			if (line[i] == '(') {
				left_parens.push_back(line[i]);
			}
			else if (line[i] == '[') {
				left_parens.push_back(line[i]);
			}
			else if (line[i] == ')') {
				if (left_parens.empty()) {
					is_yes = false;
				}
				else {	
					left_paren = left_parens.back();
					if (left_paren != '(') {
						is_yes = false;
					}
					left_parens.pop_back();
				}
			}
			else if (line[i] == ']') {
				if (left_parens.empty()) {
					is_yes = false;
				}
				else {	
					left_paren = left_parens.back();
					if (left_paren != '[') {
						is_yes = false;
					}
					left_parens.pop_back();
				}
			}
		}
		if (left_parens.size() > 0)
			is_yes = false;

		if (is_yes) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	

	return 0;
}

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

using ll = long long;
using namespace std;

ll n, k, a, b;
vector< pair<int, int> > v;

int main(){
	cin >> n >> k;
	for(int i = 0; i < n; ++i){
		cin >> a >> b;
		v.push_back(make_pair(a, b));
	}
	
	sort(v.begin(), v.end());
	
	ll cnt = 0;
	for(int i = 0; i < n; ++i){
		cnt += v[i].second;
		if(cnt >= k){
			cout << v[i].first << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1400
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <utility>

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)

#define INF 		2000000007
#define MOD			998244353
#define MAX 		100005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

template<typename T>
void print(vector<T>);

struct S{
	int b;
	int c;
	S(){
		b=0,c=0;
	}
	S(int x1,int x2){
		b=x1;
		c=x2;
	}
	bool operator<(const S &another) const
	{
		return c < another.c;
	};
	bool operator>(const S &another) const
	{
		return c > another.c;
	};
};


int main(){
	int N,M;cin>>N>>M;
	vector<int> A(N);
	vector<S>	BC(M); 
	REP(i,N)cin>>A[i];
	sort(A.begin(),A.end() );

	REP(i,M){
		int B,C;cin>>B>>C;
		BC[i].b = B;
		BC[i].c = C;
	}
	sort(BC.begin(),BC.end(),greater<S>());

	int itr = 0;
	REP(i,M){
		REP(j,BC[i].b){
			if(itr > N) break;
			if(BC[i].c > A[itr])
				A[itr] = BC[i].c;
			itr++;
		}
	}

	//print(A);

	ull cnt = 0;
	REP(i,N)cnt+=A[i];
	cout << cnt << endl;

	return 0;
}

template<typename T>
void print(vector<T> vec){
	cout << "[";
	for(auto itr : vec)cout << itr << ":";
	cout << "]" << endl;
}






Measured memory_bytes: 1408
import copy
import heapq
import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

n = ip()
a = iprow()
b = iprow()
c = iprow()
s = sum(b)
for i in range(n-1):
    if a[i+1]-1 == a[i]:
        s+=c[a[i]-1]
print(s)

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

int main( void )
{
    string line;
    long long a, b, n;
    while ( getline( cin, line ) ) {
        istringstream is( line );
        is >> a >> b >> n;
        a %= b;
        
        long long sum = 0;
        for ( long long i = 0; i < n; i++ ) {
            a *= 10;
            sum += a / b;
            a %= b;
        }
        cout << sum << endl;
    }
    return 0;
}

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

typedef int integer;

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
#define bs binary_search
#define up upper_bound
#define lw lower_bound
#define fs first 
#define sd second 
#define mp make_pair    

#define fore(i,a,b) for(ll i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = a - 1; i >= b; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define mm(a,b) memset(a , b , sizeof a) 
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())

#define infi  2e9
#define int long long
#define endl '\n'
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+7;
const ll INF = 1e10;
const ld EPS = 1e-8;

typedef pair<ll,ll> pll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

const int MAXN = 3000;
const int K=20;

string s,t;
int dp[MAXN][MAXN];
string rec[MAXN][MAXN];

int lcs(int m, int n) { 
   if(m<0||n<0)return 0;
   int &r=dp[m][n];
   if(r!=-1)return r; 
   if(s[m]==t[n])r=1+lcs(m-1,n-1);
   else r = max(lcs(m,n-1), lcs(m-1,n)); 
   return r;
} 	

integer main(){
	cin>>s>>t;
	mm(dp,-1);
	int r = lcs(SZ(s)-1,SZ(t)-1);
	string res="";int i,j; i=SZ(s)-1; j=SZ(t)-1;
	while(j>=0&&i>=0){
		if(s[i]==t[j]){
			res+=s[i]; i--; j--;
		}else if(i==0){
			j--;
		}else if(j==0){
			i--;
		}else if((dp[i][j-1]>dp[i-1][j])){
			j--;
		}else{
			i--;
		}
	}
	reverse(ALL(res));
	cout<<res;
    return 0;
}



Measured memory_bytes: 141056
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,n) for(i=0;i<n;i++)in(v[i]);
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define cf(n) printf("%I64d\n",n)
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
typedef long long int ll;
#define N 100005
int sp[N][20],po[20],ar[2*N];
void up(int j,int x,int n)
{
    sp[j][0]=x;
    for(int k=1;k<20;k++)
        if(j+po[k]<=n)sp[j][k]=__gcd(sp[j][k-1],sp[j+po[k-1]][k-1]);
    return ;
}
int query(int a,int b)
{
    if(a>b)
        return 0;
    int y,x=b-a+1;
    y=ar[x],x-=po[y];
    return __gcd(sp[a][y],sp[a+x][y]);
}
int main()
{
    int n,i,k,q,a,b;
    in(n);
    vector<int> v(n);
    ar[1]=0,k=1,po[0]=1;
    while(k<N)
    {
        for(i=k+1;i<2*k;i++)
            ar[i]=ar[k];
        ar[2*k]=1+ar[k],k*=2;
    }
    for(i=1;i<20;i++)
        po[i]=2*po[i-1];
    for(i=0;i<n;i++)
        in(v[i]);
    for(i=n-1;i>=0;i--)
        up(i,v[i],n);
    int ans=0;
    for(i=0;i<n;i++)
    {
        ans=max(ans,__gcd(query(0,i-1),query(i+1,n-1)));
    }
    out(ans);
    return 0;
}


Measured memory_bytes: 8960
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-ffloat-store")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define endl "\n"
#define f(i,a,b) for(int i=a;i<b;i++)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
#define inf  1e18
#define ps(x,y)   fixed<<setprecision(y)<<x
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define inp(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N = 2e3 + 10;
int main() 
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
    int n;
    cin >> n;
    const int m = 1000000007;
 
    long long n10 = 1, n9 = 1, n8 = 1;
    for (int i = 0; i < n; i++) {
        n10 = n10 * 10 % m;
        n9 = n9 * 9 % m;
        n8 = n8 * 8 % m;
    }
 
    long long ans = n10 - (n9 * 2 - n8);
    while (ans < 0) ans += m;
    cout << ans << endl;
return 0;   
}

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

int main(){
  int n, a, b;
  cin >> n;
  bool ok = false;
  int k = 0;
  int res = n;
  while(res){
    k += res%10;
    res/=10;
  }
  if(n%k==0) ok = true;
  if(ok)  puts("Yes");
  else  puts("No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

class UnionFind {
private:
	int n;
	int* par;
	int* hight;

	int root(int a) {
		while (par[a] != a) a = par[a];
		return a;
	}
public:
	UnionFind(int num) {
		n = num;
		par = new int[n];
		hight = new int[n];
		for (int i = 0; i < n; ++i) {
			par[i] = i;
			hight[i] = 1;
		}
	}
	~UnionFind() {
		delete[] par;
	}

	void unite(int a, int b) {
		int ra = root(a);
		int rb = root(b);
		if (ra == rb) return;

		if (hight[ra] > hight[rb]) {
			par[rb] = ra;
		}
		else if (hight[ra] < hight[rb]) {
			par[ra] = rb;
		}
		else {
			par[ra] = rb;
			++hight[rb];
		}
	}
	bool same(int a, int b) {
		return root(a) == root(b);
	}

	int numofRoot() {
		int counter = 0;
		for (int i = 0; i < n; ++i) if (par[i] == i) ++counter;
		return counter;
	}

	void init() {
		for (int i = 0; i < n; ++i) {
			par[i] = i;
			hight[i] = 1;
		}
	}
};

using UF = UnionFind;

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

	int n, m;
	cin >> n >> m;
	pii* edge = new pii[m];
	rep(i, m) cin >> edge[i].first >> edge[i].second;

	int ans = 0;
	UF uf(n);
	rep(i, m) {
		rep(j, m) {
			if (i != j) uf.unite(edge[j].first - 1, edge[j].second - 1);
		}

		if (uf.numofRoot() != 1) {
			++ans;
		}

		uf.init();
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 256
import math
from collections import deque
n,k=map(int,input().split())
v=list(map(int,input().split()))
#k回までだったー誤読
ans=0
for i in range(1,min(k,n)+1):
    #取るところ(大きい方とは限らないのか)
    for m in range(i+1):
        s=v[:m]+v[n-(i-m):]
        s.sort()
        #取った個数より多く詰めようとしないように！
        #残りk-i回ある
        for j in range(i,min(k,2*i)):#それ以上詰められない場合
            #0より小さい場合は書き換える
            if s[j-i]<0:s[j-i]=0
        #取り出したやつの最大(戻す場合は0)
        ans=max(ans,sum(s))
        #残りk-j回ある(breakの時のjはやってないので)
        #ここからはいい感じに出すのと入れるのを繰り返す(偶数の場合はこのままか)
        #必要すらない、k回を使い切らなくていいので
        #print(sum(s))
print(ans)

Measured memory_bytes: 9504
import sys

s = sys.stdin.read()
line = s.splitlines()[0]
a, b = [int(x) for x in s.split(" ")]
product = a * b


def is_even(x):
    return x % 2 == 0


x = is_even(product)


def f(x):
    if x:
        return "Even"
    else:
        return "Odd"


x = f(x)
print(x)


Measured memory_bytes: 2940
//ループを発見する
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int town = scan.nextInt();
		long K = scan.nextLong();

		//  読み取り部分
		int[] warp = new int[town];
		int[] ahead = new int[town];
		for(int ct = 0; ct < town; ct++){
			warp[ct] = scan.nextInt();	
		}


		//　ループ部分導出準備
		int des = 0;
		int nums = 0;
		// ahead == 町を訪れた回数
		ahead[0] = 1;
		// times == 移動順記録　鳥の巣理論より町の数＋1回の移動時には少なくともループが発生している
		int[] times = new int[town + 1];
		times[0] = 0;
		// 移動を記録していく
		for(int ct = 0; ct < town; ct++){
			// ct度めの移動でどの町(配列順で考える→町番号－1)に向かうかを記録
			times[ct + 1] = warp[des] - 1;
			// 向かう町に行ったものとし訪れた回数に計上
			ahead[warp[des]-1]++;
			if(ahead[warp[des]-1] >= 2){
				// 移動回数を記録
				nums = ct + 1;
				break;
			}
			// 次の移動先を参照
			des = warp[des] - 1;
		}

		if(K > nums && nums != 0){
			for(int ct = 0; ct < town; ct++){
				if(times[ct] == warp[des]-1){
					K -= ct;
					nums -= ct;
					K %= nums;
					nums = ct;
					break;
				}
			}
			System.out.println(times[nums + (int)K] + 1);
		}else{
			System.out.println(times[(int)K] + 1);
		}

	}
}

Measured memory_bytes: 61328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    if(abs(a-c) <= d || (abs(a-b) <= d && abs(c-b) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

const int MAXN = 100010;
const int INF = 0x3f3f3f3f;
int A[MAXN], B[MAXN], C[MAXN];
int n, li[MAXN], bak, pre[MAXN], suc[MAXN], s2[MAXN];
void lb(int & x) { x = std::lower_bound(li + 1, li + 1 + bak, x) - li; }
std::vector<int> ls[MAXN], rs[MAXN];
int ansl[MAXN];
typedef std::pair<int, int> pi;
std::map<pi, int> dec;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n; int m = n + 1;
	for (int i = 1; i <= n; ++i) std::cin >> A[i] >> B[i];
	for (int i = 1; i <= m; ++i) std::cin >> C[i];
	std::copy(C + 1, C + 1 + m, li + 1);
	std::sort(li + 1, li + 1 + m);
	bak = std::unique(li + 1, li + 1 + m) - li - 1;
	for (int i = 1; i <= n; ++i) lb(A[i]), lb(B[i]);
	for (int i = 1; i <= m; ++i) lb(C[i]);
	for (int i = 1; i <= n; ++i) {
		++pre[A[i]];
		if (B[i] < A[i]) {
			rs[B[i]].push_back(A[i] - 1);
			ls[A[i] - 1].push_back(B[i]);
		}
	}
	for (int i = 1; i <= m; ++i) --pre[C[i]];
	for (int i = 1; i <= bak; ++i) pre[i] += pre[i - 1];
	std::priority_queue<pi, std::vector<pi>, std::greater<pi> > q1;
	int ans = n;
	for (int i = bak; i; --i) {
		pre[i] += suc[i] += suc[i + 1];
		for (auto t : ls[i]) q1.emplace(t, i);
		while (pre[i] < -1) {
			if (!q1.empty() && q1.top().first <= i) {
				pi t = q1.top(); q1.pop();
				int l = t.first;
				--suc[l - 1]; ++pre[i]; ++suc[i];
				--ans; ++dec[t];
				++s2[i + 1]; --s2[t.second + 1];
			} else { ans = -INF; break; }
		}
	}
	memset(suc, 0, bak + 1 << 2);
	std::priority_queue<int> q2;
	*ansl = ans;
	for (int i = 1; i <= bak; ++i) {
		pre[i] += suc[i] += suc[i - 1];
		pre[i] += s2[i] += s2[i - 1];
		for (auto t : rs[i])
			if (dec[pi(i, t)]) --dec[pi(i, t)];
			else q2.push(t);
		if (pre[i] == -1) {
			if (!q2.empty() && q2.top() >= i) {
				int t = q2.top(); q2.pop();
				++suc[i]; ++pre[i]; --suc[t + 1];
				--ans;
			} else ans = -INF;
		}
		ansl[i] = ans;
	}
	int Q; std::cin >> Q;
	while (Q --> 0) {
		int x, y; std::cin >> x >> y; lb(x), lb(y);
		int ans = std::max(ansl[x - 1] + 1, ansl[y - 1]);
		std::cout << (ans < 0 ? -1 : ans) << '\n';
	}
	return 0;
}


Measured memory_bytes: 22008
#include <iostream>
#include <sstream>
#include <regex>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include  <cassert>
#include <fstream>
#include <codecvt>

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define int ll
const int INF = (1LL << 32);
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };


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


ullong power(ullong x, ullong n) {
	ullong res = 1;
	if (n > 0) {
		res = power(x, n / 2);
		if (n % 2 == 0) res = (res * res) % MOD;
		else res = (((res * res) % MOD) * x) % MOD;
	}
	return res;
}

signed main() {
	ios::sync_with_stdio(true);
	int m, n;
	cin >> m >> n;
	cout << power(m, n) << endl;
	return 0;
}


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

ll solve(const vector<int> &h, const vector<int> &w) {
    ll ret = 0;
    map<int,int> h_edge, w_edge;

    for (int i = 0; i < n; ++i) {
        int edge_length = 0;
        for (int j = i; j < n; ++j) {
            edge_length += h[j];
            h_edge[edge_length]++;
        }
    }

    for (int i = 0;i < m; ++i) {
        int edge_length = 0;
        for (int j = i;j < m; ++j) {
            edge_length += w[j];
            w_edge[edge_length]++;
        }
    }

    for (auto &&e: h_edge) {
        ret += (e.second*w_edge[e.first]);
    }
    return ret;
}


int main() {
    while (true) {
        cin >> n >> m;
        if (n == 0 && m == 0) break;
        vector<int> h(n),w(m);
        rep(i,n) cin >> h[i];
        rep(i,m) cin >> w[i];
        cout << solve(h,w) << endl;
    }
}


Measured memory_bytes: 34320
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 rr;
	cin >> rr;
	cout << rr * rr << endl;
	return 0;
}

Measured memory_bytes: 3540
#include"bits/stdc++.h"
using ll=long long; 
using ld=long double; 
using namespace std;
void __print(int x) {cerr << x;} 
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;} 
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x){cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;} 
void __print(double x) {cerr << x;}
void __print(ld x){cerr << x;} 
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x){cerr<<'\"'<<x<<'\"';}
void __print(const string &x) {cerr<<'\"'<<x<<'\"';}
void __print(bool x){cerr<<(x?"true":"false");}
template<typename T, typename V>
void __print(const pair<T, V> &x){cerr<<'{'; __print(x.first);cerr<<','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) 
{ return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) 
{ return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")"; } 
void debug_out() { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) 
{
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE 
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#ifndef ONLINE_JUDGE 
#define debugt(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debugt(...) 42
#endif
int row[3*100000+3],col[3*100000+3]; 
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif
  int h,w,m; cin>>h>>w>>m; int x,y; map<pair<int,int>,int>g; map<int,vector<int>>f; 
  for(int i=1;i<=m;i++)
  {
    cin>>x>>y; x--; y--; row[x]++; col[y]++;   
    g[{x,y}]=1; f[y].emplace_back(x); 
  }
  for(int i=0;i<=w-1;i++)
  { 
    sort(f[i].begin(),f[i].end()); 
  }
  int t=-1; 
  for(int i=0;i<=w-1;i++)
  { 
    t=max(col[i],t); 
  } 
  int ans=0; 
  vector<int>v; for(int i=0;i<=w-1;i++){ if(col[i]==t) v.emplace_back(i); }
  for(int i=0;i<=h-1;i++)
  {
    int res=row[i]; int j=v[0]; 
    if(g[{i,j}]==0){ res+=t; }
    else 
    {
      if((int)v.size()==1)
      {
        res+=(t-1); 
      }
      else
      {
        int flag=0; 
        for(auto idx:v)
        {
          auto it=lower_bound(f[idx].begin(),f[idx].end(),i); 
          if(it==f[idx].end()||*it!=i){ flag=1; break; }
        }
        if(flag){ res+=t; } else res+=(t-1); 
      }
    }
    ans=max(res,ans); 
  }
  cout<<ans<<"\n"; 
  return 0; 
}

Measured memory_bytes: 77196
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int check(int x) {
    if (x == 1) return 300000;
    else if (x == 2) return 200000;
    else if (x == 3) return 100000;
    else return 0;
}

int main() {
    int x, y; cin >> x >> y;

    int ans = check(x) + check(y);

    if (x == 1 && y == 1) ans += 400000;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << "-->" << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
    #define mod 998244353
 
#define fi first
#define se second

int32_t main() 
{
  int n,r;
  cin>>n>>r;
  int ans = 0;
  while(n>0){
      ans++;
      n /= r;
  }
  cout << ans;
} 

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-22 07:16:24
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  int a, b; cin >> a >> b;
  if (a + b >= 10) {
    cout << "error" << endl;
  } else {
    cout << a + b << endl;
  }

  return 0;
}

Measured memory_bytes: 256
k = int(input())
x = 7 % k
i = 1
set = set()
is_there = False

while not is_there:
    set.add(x)
    if x == 0:
        print(i)
        break
    x = (x*10+7) % k
    if x in set:
        is_there = True
    set.add(x)
    i += 1
    if x == 0:
        print(i)
        break
else:
    print('-1')

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

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

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	vector<vector<int>> S(m);
	rep(i,n){
		S[a[i]%m].emplace_back(a[i]);
	}
	rep(i,m) sort(S[i].begin(),S[i].end());

	int ans=S[0].size()/2;
	if(m%2==0) ans+=S[m/2].size()/2;
	for(int i=1;i<=(m-1)/2;i++){
		int sz1=S[i].size(),sz2=S[m-i].size();
		if(sz1>=sz2){
			int dup=0;
			rep(j,sz1) if(j+1<sz1 && S[i][j]==S[i][j+1]) dup++, j++;
			ans+=sz2;
			ans+=min(dup,(sz1-sz2)/2);
		}
		else{
			int dup=0;
			rep(j,sz2) if(j+1<sz2 && S[m-i][j]==S[m-i][j+1]) dup++, j++;
			ans+=sz1;
			ans+=min(dup,(sz2-sz1)/2);
		}
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int ans=0;
  string s;
  cin>>s;

  for(int i=0;i<4;i++){
    if(s[i]=='+') ans++;
    else ans--;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256