akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int MAX { 200010 };

vector<int> adj[MAX];
bitset<MAX> visited;

struct Point { int x, y; };

void dfs(int u, vector<int>& xs, vector<int>& ys)
{
    if (visited[u])
        return;

    visited[u] = true;

    u > 100000 ? ys.push_back(u) : xs.push_back(u);

    for (auto v : adj[u])
        dfs(v, xs, ys);
}

ll solve(vector<Point>& ps)
{
    for (auto p : ps)
    {
        auto u = p.x, v = p.y + 100000;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    ll ans = 0;

    for (int i = 1; i < MAX; ++i)
    {
        if (not visited[i])
        {    
            vector<int> xs, ys;

            dfs(i, xs, ys);

            for (auto x : xs)
                ans += (ys.size() - adj[x].size());
        }
    }

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<Point> ps(N);

    for (int i = 0; i < N; ++i)
        cin >> ps[i].x >> ps[i].y;

    auto ans = solve(ps);

    cout << ans << '\n';

    return 0;
}


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

int main() {
    string S, T;
    cin >> S >> T;
    int N = S.size();
    bool can = true;
    
    map<char, char> ma, ima;
    for (int i = 0; i < N; i++) {
        char s = S[i], t = T[i];
        if (ma.count(s)) {
            if (ma[s] != t) can = false;
        }
        if (ima.count(t)) {
            if (ima[t] != s) can = false;
        }
        ma[s] = t;
        ima[t] = s;
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define mp make_pair
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 1LL << 30;
const ll LINF = 1LL << 60;
const double eps = 1e-9;
const ll MOD = 1000000007LL;
ll dp[110][4][4][4];
int main() {
    int n;cin>>n;
    dp[0][3][3][3]=1;
    for(ll i=1;i<=n;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                for(int l=0;l<4;l++){
                    for(int m=0;m<4;m++){
                        if(m==1){
                            if(j==0&&l==2)continue;
                            if(j==0&&k==2)continue;
                            if(k==2&&l==0)continue;
                            if(k==0&&l==2)continue;
                        }else if(m==2){
                            if(k==0&&l==1)continue;
                        }
                        dp[i][k][l][m]+=dp[i-1][j][k][l];
                        dp[i][k][l][m]%=MOD;
                    }
                }
            }
        }
    }
    ll ans=0;
    for(int i=0;i<4;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                ans+=dp[n][i][j][k];
                ans%=MOD;
            }
        }
    }
    cout<<ans<<endl;
}
//「AG」の2つ以下後にCを入れるとダメ
//「GA」の直後にCを入れるとダメ
//「AxG」の直後にCを入れるとダメ

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int k;
    cin >> k;
    int ans = 0;
    rep(i,k)rep(j,k)rep(l,k){
        ans += gcd(gcd(i+1,j+1),l+1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
# ARC059C - いっしょ / Be Together (ABC043C)
n = int(input())
lst = list(map(int, input().rstrip().split()))
ans = float("inf")
for i in range(-100, 101):
    cnt = 0
    for j in lst:
        cnt += (i - j) ** 2
    ans = min(ans, cnt)
print(ans)

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const ll INF = 1e18;

int main(void){

	ll N; cin >> N;

	ll ans = INF;
	for(ll i=1;i*i<=N;++i){
		if(N % i == 0){
			ll j = N / i;
			ans = min(ans, i+j-2);
		}
	}

	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

diff = float('inf')
ans = 0

for i in range(n):
    if abs(t - h[i] * 0.006 - a) < diff:
        diff = abs(t - h[i] * 0.006 - a)
        ans = i + 1

print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
  string a,b;
  int count=0;
  cin >> a;
  cin >> b;
  for(int i=0;i<(a.size());++i)
  {
    if(a[i]==b[i])
    {
      count++;
    }
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> a;

    rep(i,n){
        int tmp;
        cin >> tmp;
        a.pback(tmp);
    }

    int ans = INT_MAX;

    for(int i = -100; i <= 100; i++){
        int tmpcost = 0;

        rep(j,n){
            int tmp = i - a[j]; 
            tmpcost = tmpcost + tmp * tmp;
        }

        ans = min(ans,tmpcost);
        
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
a = gets.chomp.split('').map(&:to_i)

['+', '-'].repeated_permutation(3) do |arr|
  ans = 0
  4.times do |i|
    if i == 0
      ans = a[i]
    else
      if arr[i-1] == '+'
        ans += a[i]
      else
        ans -= a[i]
      end
    end
    if i == 3 && ans == 7
      puts "#{a[0]}#{arr[0]}#{a[1]}#{arr[1]}#{a[2]}#{arr[2]}#{a[3]}=7"
      exit
    end
  end
end


Measured memory_bytes: 1788
#pragma comment(linker, "/STACK:10240000")
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 100010;

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

int main ()
{
    scanf ("%s", &s);
    int len = strlen (s);
    for (int i = 0; i < len; i ++)
    {
        num[s[i] - 'a'] ++;
    }
    int mins = min (min (num[0], num[1]), num[2]);
    num[0] -= mins;
    num[1] -= mins;
    num[2] -= mins;
    int all = num[0] + num[1] + num[2];
    int maxs = max (max (num[0], num[1]), num[2]);
    if ((maxs <= 1) && (all <= 2))
    {
        printf ("YES\n");
    }
    else
    {
        printf ("NO\n");
    }

    return 0;
}

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

#define X first
#define Y second

struct NODE{
	int x,y,time,bit;
};
int done[25][25][100][1<<5];
int bomb[25][25];
vector< pair<int,int> > path[5];
int main(){
	int W,H;
	int N;
	cin >> W >> H >> N;
	int sx,sy;
	cin >> sx >> sy;
	for(int i = 0 ; i < 25 ; i++)
		for(int j = 0 ; j < 25 ; j++)
			bomb[i][j] = 1;
	for(int i = 1 ; i <= H ; i++)
		for(int j = 1 ; j <= W ; j++)
			bomb[i][j] = 0;

	
	for(int i = 0 ; i < N ; i++){
		int L;
		cin >> L;
		int x,y;
		while(L--){
			cin >> x >> y;
			path[i].push_back(make_pair(x,y));
		}
		
		bomb[y][x] = 1;
	}
	queue<NODE> Q;
	Q.push({sx,sy,0,0});
	while( Q.size() ){
		NODE q = Q.front(); Q.pop();
		if( done[q.x][q.y][q.time][q.bit]++ ) continue;
		int badflag = 0;
		
		for(int i = 0 ; i < N ; i++){
			if( (q.bit >> i & 1) == 0 && q.time + 1 == path[i].size() ) badflag = 1;
		}
		if(badflag) continue;
		int nextbit = q.bit;
		for(int i = 0 ; i < N ; i++){
			if( (q.bit >> i & 1) == 0 ){
				if( path[i][q.time].X == q.x && path[i][q.time].Y == q.y ) nextbit |= (1<<i);
			}
		}
		if( nextbit == (1<<N)-1 ){
			cout << q.time << endl;
			return 0;
		}
		
		for(int dx = -1 ; dx <= 1 ; dx++){
			for(int dy = -1 ; dy <= 1 ; dy++){
				int tx = q.x + dx;
				int ty = q.y + dy;
				if( bomb[ty][tx] ) continue;
				Q.push({tx,ty,q.time+1,nextbit});
			}
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 7752
#include <algorithm>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
    string s; cin >> s;
    int K; cin >> K;

    int n = s.size();
    map<string, int> num;
    for (int i = 0; i < n; i++) {
        for (int j = i; j < i + K; j++) {
            string ss = s.substr(i, j - i + 1);
            num[ss]++;
        }
    }

    map<string, int>::iterator it = num.begin();
    for (int i = 0; i < K - 1; i++) it++;
    cout << it->first << endl;
    return 0;
}

Measured memory_bytes: 1920
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,b = LI()
    if a == b:
        print(2*a)
    else:
        print(2*max(a,b)-1)
    return

#B
def B():
    n = I()
    h = LI()
    m = h[0]
    ans = 1
    for i in range(1,n):
        if m <= h[i]:
            ans += 1
            m = h[i]
    print(ans)
    return

#C
def C():
    s = S()
    ans = 0
    n = len(s)
    t = ["1" if i%2 else "0" for i in range(n)]
    for i in range(n):
        if t[i] != s[i]:
            ans += 1
    ans2 = 0
    t = ["0" if i%2 else "1" for i in range(n)]
    for i in range(n):
        if t[i] != s[i]:
            ans2 += 1
    print(min(ans,ans2))
    return

#D
def D():
    n = I()

    return

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


Measured memory_bytes: 51484
#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;
    
    if (a < b) {
        std::cout << "a < b" << std::endl;
    } else if (a > b) {
        std::cout << "a > b" << std::endl;
    } else {
        std::cout << "a == b" << std::endl;
    }
}



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

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n){
    cin>>a.at(i);
  }
  long c=0;
  long ans=0;
  bool ch=true;
  long co=0;
  if(a.at(0)!=0){
  rep(i,n){
    if(ch){
      if(co+a.at(i)>=0){
        c+=co+a.at(i)+1;
        co=-1;
      }
      else{
        co+=a.at(i);
      }
      ch=false;
    }
    else{
      if(co+a.at(i)<=0){
        c+=1-co-a.at(i);
        co=1;
      }
      else{
        co+=a.at(i);
      }
      ch=true;
    }
   }
    ch=false;
    co=0;
  rep(i,n){
    if(ch){
      if(co+a.at(i)>=0){
        ans+=co+a.at(i)+1;
        co=-1;
      }
      else{
        co+=a.at(i);
      }
      ch=false;
    }
    else{
      if(co+a.at(i)<=0){
        ans+=1-co-a.at(i);
        co=1;
      }
      else{
        co+=a.at(i);
      }
      ch=true;
    }
  }
    ans=min(ans,c);
    cout<<ans<<endl;
  }
  else{
    
   rep(i,n){
    if(ch){
      if(co+a.at(i)>=0){
        c+=co+a.at(i)+1;
        co=-1;
      }
      else{
        co+=a.at(i);
      }
      ch=false;
    }
    else{
      if(co+a.at(i)<=0){
        c+=1-co-a.at(i);
        co=1;
      }
      else{
        co+=a.at(i);
      }
      ch=true;
    }
   }
    ch=false;
    co=0;
    rep(i,n){
    if(ch){
      if(co+a.at(i)>=0){
        ans+=co+a.at(i)+1;
        co=-1;
      }
      else{
        co+=a.at(i);
      }
      ch=false;
    }
    else{
      if(co+a.at(i)<=0){
        ans+=1-co-a.at(i);
        co=1;
      }
      else{
        co+=a.at(i);
      }
      ch=true;
    }
  }
    ans=min(ans,c);
    cout<<ans<<endl;
  }  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    int x,y,a,b,c; cin>>x>>y>>a>>b>>c;
    vi v1,v2,v3;
    int p[a]; rep(i,0,a-1) cin>>p[i];
    int q[b]; rep(i,0,b-1) cin>>q[i];
    int r[c]; rep(i,0,c-1) cin>>r[i];
    sort(p,p+a,greater<int>());
    sort(q,q+b,greater<int>());
    sort(r,r+c,greater<int>());
    rep(i,0,x-1){
        int t=p[i];
        v1.pb(t);
    }
    rep(i,0,y-1){
        int t=q[i];
        v2.pb(t);
    }
    rep(i,0,c-1){
        int t=r[i];
        v3.pb(t);
    }
    sort(all(v1)); sort(all(v2));
    int j=0,k=0,i=0;
    while(i<c){
        if(j<x&&k<y){
            if(v1[j]>v2[k]){
                if(v2[k]<v3[i]){
                    v2[k]=v3[i]; k++; i++;
                }
                else if(v1[j]<v3[i]){
                    v1[j]=v3[i]; j++; i++;
                }
                else {j++; k++;}
            }
            else{
                
                if(v1[j]<v3[i]){
                    v1[j]=v3[i]; j++; i++;
                }
                else if(v2[k]<v3[i]){
                    v2[k]=v3[i]; k++; i++;
                }
                else{j++; k++;}
            }
        }
        else if(j<x){
            if(v1[j]<v3[i]){
                v1[j]=v3[i]; j++; i++;
            }
            else{j++; k++;}
        }
        else if(k<y){
            if(v2[k]<v3[i]){
                v2[k]=v3[i]; k++; i++;
            }
            else {j++; k++;}
        }
        else break;
    }
    rep(i,0,x-1) ans+=v1[i];
    rep(i,0,y-1) ans+=v2[i];
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 5492
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String a = in.next();
            String b = in.next();
            int n = Integer.parseInt(a + b);
            if (n == Math.pow((int) Math.sqrt(n), 2)) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

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

    }
}



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

int main() {
    int n,a,ans=0;
    cin >> n;
    ll l[105];
    memset(l,0,sizeof(l));
    rep(i,n){
        cin >> l[i];
    }
    rep(i,n-2){
        for(int j=i+1; j<n-1;j++){
            if(l[i] ==l[j]){
                continue;
            }
            for(int k=j+1;k<n;k++){
                if(l[i] == l[k] || l[j] == l[k]){
                    continue;
                }
                a = min(l[i]+l[j]-l[k],min(l[j]-l[i]+l[k],l[k]+l[i]-l[j]));
              if(a > 0){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
p = inl()
sm = sum(p[:k])
mx = sm
#ddprint(sm)
for i in range(1,n-k+1):
    sm += p[i+k-1]-p[i-1]
    #ddprint(sm)
    mx = max(mx,sm)
print((mx+k)/2)


Measured memory_bytes: 71792
#include <iostream>
#include <string>
#include <map>
 
constexpr int MAX_N=200000*2;
 
using ll=long long int;
 
std::string str;
 
std::map<char,ll> map;
 
int n;
 
int main() {
 
    std::cin>>str;
 
    n=str.size();
 
    ll ans=(ll)n*(ll)(n-1)/2;
 
    for(auto ch : str)
        map[ch]++;
 
    for(auto&& p : map)
        ans-=p.second*(p.second-1)/2;
 
    std::cout<<ans+1<<std::endl;
 
    return 0;
}

Measured memory_bytes: 640
N,A,B,C,D = list(map(int,input().split()))

S = input()

def AA(mojiretu):
    if '##' in mojiretu:
     print("No")
    else:
     print("Yes")

Scp = S
if C < D:
      AA(Scp[A:D])
      
else:
    if "..." in Scp[B-2:D]:
      AA(Scp[A:C])
    else:
      Scp = Scp[:D-1]+"#" + Scp[D:]
      AA(Scp[A:C])

    

Measured memory_bytes: 3764
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////
    string predict_weathers, real_weathers;
    int count = 0;
    cin >> predict_weathers >> real_weathers;
    
    for (int i = 0; i < predict_weathers.size(); i++) {
        if (predict_weathers.at(i) == real_weathers.at(i)) {
            count++;
        }
    }
 
    cout << count << endl;
    
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

         ll a,b;
         cin >> a >> b;
         cout << a*b << endl;
        
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;

int main(void) {

  int y, x, d;
  cin >> y >> x >> d;
  vector<string> s(y);
  for(int i=0; i<y; i++) cin >> s[i];

  int cnt = 0;
  for(int i=0; i<y; i++){
    for(int j=0; j<x; j++){
      bool f = true;
      for(int k=0; k<d; k++){
        if( j + k >= x ) f = false;
        if( j + k >= x ) break;
        if( s[i][j+k] == '#' ) f = false;
      }
      cnt += f;
      f = true;
      for(int k=0; k<d; k++){
        if( i + k >= y ) f = false;
        if( i + k >= y ) break;
        if( s[i+k][j] == '#' ) f = false;
      }
      cnt += f;
    }
  }
  cout << cnt << endl;

  return 0;
}


// EOF

Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
int n;
int a[N], b[N], c[N];

int main(){
	int n, k; scanf("%d%d", &n, &k);
	if(!(k * 2 <= n+1)){
		printf("-1\n");
		return 0;
	}
	if(n == 1){
		a[0] = 1, b[0] = 2, c[0] = 3;
	} else {
		a[0] = k, a[1] = k + (n+1)/2;
		FOR(i, 2, n) a[i] = a[i-2] + 1;
		b[1] = k + n, b[0] = b[1] + n/2;
		FOR(i, 2, n) b[i] = b[i-2] + 1;
		REP(i, n) c[i] = k + 2*n + i;
	}
	REP(i, n) assert(a[i] + b[i] <= c[i]);
	REP(i, n) printf("%d %d %d\n", a[i], b[i], c[i]);
}


Measured memory_bytes: 3456
n = gets.to_s.to_i
a = gets.to_s.split.map(&:to_i)

c = Array.new(2*10**5+1,0)
a.each do |k|
  c[k] += 1
end

s = c.map{|k| k * (k-1)/2}.inject(:+) + 1

a.each do |k|
  puts s - c[k]
end

Measured memory_bytes: 24836
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());

            long ans = (N - 1) * N / 2;

            Console.WriteLine(ans);
        }
    }
}




Measured memory_bytes: 13140
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(list(map(int, input().split())))

# print(B)
# print(A)

def main():
    cnt = 0
    for i in range(N):
        val = C
        for j in range(M):
            val += A[i][j] * B[j]
        # print(val)
        if val > 0:
            cnt += 1
    return cnt

print(main())


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

int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<int> pq;
    rep(i,n){
        int a;
        cin>>a;
        pq.push(a);
    }
    rep(i,m){
        pq.push(pq.top()/2);
        pq.pop();
    }
    ll ans=0;
    while(!pq.empty()){
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()

int main() 
{ 
    ll n, k;
    cin>>n>>k;
    ll c=0,w=0;
    map<ll,pair<ll,bool>>m;
    for( ll i=0;i<n;i++)
    {
        m[i].fi =0;
        m[i].se=false;
    }
    for(ll i=0;i<k;i++)
    {    ll temp;
        cin>>temp;
        string s;
        cin>>s;
        
         if(s=="WA")
            { if(m[temp].se)
                {    
                  continue;
                }   
                else (m[temp].fi)++;

            }
            else 
                {
                    if(m[temp].se)
                    {
                        continue;
                    }
                    else {
                    m[temp].se=true;
                    w+=m[temp].fi;
                    c++;

                    }
                    
                }
        


    }
    cout<<c<<" "<<w<<endl;
   
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    int x, n;
    cin >> x >> n;
    set<int> s;
    rep(i, n) {
        int x;
        cin >> x;
        s.insert(x);
    }

    int dif = 114514;
    int ans = 0;
    rep(i, 102) {
        if(s.find(i) != s.end()) continue;
        if(dif > abs(x - i)) {
            dif = abs(x - i);
            ans = i;
        }
    }

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


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <deque>
#include <functional>
#include <initializer_list>
#include <math.h>
#include <map>
#include <random>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

// グリッド上の縦横移動
constexpr std::array<std::pair<int, int>, 4> dxdy = {
    std::pair<int, int>( 1,  0),
    std::pair<int, int>(-1,  0),
    std::pair<int, int>( 0,  1),
    std::pair<int, int>( 0, -1)
};

void VintOut(std::vector<int>& A){
    const int n = A.size();
    if(n == 0){putchar('\n'); return;}
    printf("%d", A[0]);
    for(int i = 1; i < n; ++i) printf(" %d", A[i]);
    putchar('\n');
}
void VintOut(std::vector<long long int>& A){
    const int n = A.size();
    if(n == 0){ putchar('\n'); return;}
    printf("%lld", A[0]);
    for(int i = 1; i < n; ++i) printf(" %lld", A[i]);
    putchar('\n');
}

template <typename T>
inline bool chmin(T& a, T b){
    if(b < a){ 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;
}

inline bool isIn(int x, int y, int H, int W){
    return 0 <= x and x < H and 0 <= y and y < W;
}
inline bool bitUP(int state, int k){ return (state >> k) & 1; }
inline bool bitUP(long long int state, int k){ return (state >> k) & 1;}

// z-algorithm
template <class T> std::vector<int> z_algorithm(const T &str) {
    const int n = str.size();
    std::vector<int> resOfCP(n); resOfCP[0] = n;
    int i = 1, j = 0;
    while (i < n) {
        while (i + j < n and str[j] == str[i + j]) ++j;
        resOfCP[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i + k < n and k + resOfCP[k] < j) resOfCP[i + k] = resOfCP[k], ++k;
        i += k; j -= k;
    }
    return resOfCP;
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



int main(void){
    int n, m; std::cin >> n >> m;
    if(n == m) std::cout << "Yes\n";
    else std::cout << "No\n";
    
    return 0;
}

Measured memory_bytes: 888
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline
    N = int(input())
    d = defaultdict(int)
    for n in range(N):
        d[input().strip()] += 1
    for s in ['AC', 'WA', 'TLE', 'RE']:
        print(s+' x', d[s])

if __name__ == '__main__':
    main()

Measured memory_bytes: 9476
from collections import Counter
mods = Counter([(0, 0)])
ten_i_mod3 = 1
temp3 = 0
ten_i_mod673 = 1
temp673 = 0
for digit in reversed(input()):
    digit = int(digit)
    temp3 += digit * ten_i_mod3
    temp673 += digit * ten_i_mod673
    temp3 %= 3
    temp673 %= 673
    mods[(temp3, temp673)] += 1
    ten_i_mod3 *= 10
    ten_i_mod673 *= 10
    ten_i_mod3 %= 3
    ten_i_mod673 %= 673
ans = 0
for key in mods:
    n = mods[key]
    ans += n * (n - 1) // 2
print(ans)

Measured memory_bytes: 82572
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define P push
#define R return
#define C continue
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define SI size()
#define F first
#define S second
#define B begin()
#define E end()
#define W while
using namespace std;
long long MOD=1e9+7;
long long INF=1e16+7;
ll n,m,dp[11][(1<<10)];
vector<ll> adj[10];
ll DP(ll x,ll mask){
    if(mask==((1<<n)-1))R 1;
    ll &ret=dp[x][mask];
    if(ret!=-1)R ret;
    ret=0;
    for(int i=0;i<adj[x].SI;i++){
        ll node=adj[x][i];
        if(mask&(1<<node))C;
        ret+=DP(node,mask+(1<<node));
    }
    R ret;
}
int main()
{
    MEM(dp,-1);
    cin>>n>>m;
    for(int i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        a--;
        b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    cout<<DP(0,1);
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdint>

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

  std::vector<int> A(N);
  for (int &a: A)
    scanf("%d", &a);

  for (int i=0; i<N; ++i)
    fprintf(stderr, "%d%c", A[i], i+1<N? ' ':'\n');

  intmax_t res=0, val=1;
  for (int i=0; i<N; ++i) {
    if (A[i] < val) continue;
    if (A[i] == val) {
      ++val;
      continue;
    }

    intmax_t num=(A[i]-1)/val;
    res += num;
    A[i] -= val*num;
    if (A[i] % val == 0) {
      A[i] = 1;
      if (val == 1) ++val;
    }
  }

  for (int i=0; i<N; ++i)
    fprintf(stderr, "%d%c", A[i], i+1<N? ' ':'\n');

  printf("%jd\n", res);
  return 0;
}


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

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100000;
ll A[MAX_N];
int B[MAX_N];

int main()
{
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> A[i] >> B[i];
	}
	ll sum = 0;
	int j = N-1;
	while(j>=0){
		ll mod = (A[j]+sum) % B[j];
		if(mod != 0){
			sum += B[j] - mod;
		}
		j--;
	}
	cout << sum;
}


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

int N, M, X, ans=2e9;
vector<int> C(100);
int A[100][100];


void calc(vector<int> v) {
    vector<int> tmp(M, 0);
    int cost=0;
    for(int i=0; i<N; i++){
    	if(v[i] == 1){
	    cost += C[i];
	    for(int j=0; j<M; j++){
		tmp[j] += A[i][j];
	    }
	}
    }
    bool flag = true;

    for(int i=0; i<M; i++){
	if(tmp[i]<X)
	    flag=false;
    }

    if(flag)
	ans = min(ans, cost);

    
}
void DFS(int depth, vector<int> v) {    
    if(depth == N){
	calc(v);
	return;
    }    
    for(int i=0; i<2; i++){
	v[depth] = i;
	DFS(depth+1, v);	
    }
}


int main() {
    cin >> N >> M >> X;
    vector<int> v(N+1);    
    for(int i=0; i<N; i++){
	cin >> C[i];
	for(int j=0; j<M; j++){
	    cin >> A[i][j];
	}
    }
    DFS(0, v);			    
    cout << (ans==2e9? -1: ans) << endl;
} 




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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 1009;
int h, n;
pair<int, int> s[N];
int dp[N][10009];

bool comp(pair<int, int> a, pair<int, int> b) {
    return a.first*b.second < b.first*a.second;
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> h >> n;
    for(int i = 0; i < n; ++i) {
        cin >> s[i].first >> s[i].second;
    }

    sort(s, s+n);
    for(int j = 1; j <= h; ++j) {
        dp[0][j] = 10000000000;
    }

    for(int i = 0; i < n; ++i) {
        int a, b;
        tie(a, b) = s[i];
        for(int j = 0; j <= h; ++j) {
            dp[i+1][j] = dp[i][j];
            int prev = max(0LL, j-a);
            int cand = dp[i+1][prev] + b;
            dp[i+1][j] = min(dp[i+1][j], cand);
        }
    }

    cout << dp[n][h] << '\n';
    
    return 0;
}


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

int main() {
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(a >= k){
		cout << k << endl;
	}
	else if(a + b >= k){
		cout << a << endl;
	}
	else{
		int d;
		d = k - a - b;
		cout << a - d << endl;
	}
}



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

int debug = 0;

int main()
{
    int n, m;
    cin >> n >> m;
    if(n-m == 0)
        printf("Yes\n");
    else
        printf("No\n");
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: int, B: int, C: int, s: "List[int]"):
    v = [A, B, C]
    ans = []
    if sum(v) == 0:
        return None
    if sum(v) == 1:
        for l, r in s:
            if v[l] + v[r] == 0:
                return None
            if v[l] == 0:
                ans.append(l)
            else:
                ans.append(r)
            v[l], v[r] = v[r], v[l]
        return ans
    if sum(v) > 1:
        for i in range(N):
            l, r = s[i]
            if v[l] + v[r] == 0:
                return None
            if v[r] == 0 or v[l] > v[r] or (v[r] == 1 and v[l] == 1 and i != N - 1 and r in s[i + 1]):
                ans.append(r)
                v[l] -= 1
                v[r] += 1
            else:
                ans.append(l)
                v[l] += 1
                v[r] -= 1
        return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    def s2i(s: str):
        return ord(s[0])-ord('A'), ord(s[1])-ord('A')

    def i2s(i: int):
        return chr(i + ord('A'))

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [s2i(next(tokens)) for _ in range(N)]  # type: "List[int]"
    ans = solve(N, A, B, C, s)
    if ans == None:
        print(NO)
    else:
        print(YES)
        print("\n".join(list(map(i2s, ans))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 89736
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
// scanf("%d %d %d %d",&w,&b,&d,&s); %lld
// printf("%d\n" ,points);
// const double PI=acos(-1);

int main(){
    int a,b;
    cin >> a >> b;
    if(a<6) cout << 0 << endl;
    else if(a<13) cout << b/2 << endl;
    else cout << b << endl;
    return 0;
}


Measured memory_bytes: 3588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BIceRinkGame solver = new BIceRinkGame();
        solver.solve(1, in, out);
        out.close();
    }

    static class BIceRinkGame {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.nextInt();
            long[] a = new long[k];

            // read input in reverse
            for (int i = k - 1; i >= 0; i--) {
                a[i] = in.nextInt();
            }

            long lower = 2, upper = 2;

            for (long x : a) {
                long l2 = (lower / x) * x;
                if (l2 < lower) l2 += x;

                long u2 = (upper / x) * x;

                lower = l2;
                upper = u2 + (x - 1);
                if (lower > upper) {
                    break;
                }
            }

            if (lower > upper) {
                out.println(-1);
            } else {
                out.format("%d %d%n", lower, upper);
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 41004
#include <iostream>
#include <map>
#include <string>

int main(){
  int N;
  std::map<std::string, bool> m;
  std::cin >> N;
  for(int i = 0; i < N; ++i){
    std::string s;
    std::cin >> s;
    if(m.find(s) == m.end()){
      m.insert(std::make_pair(s,true));
    }
  }
  std::cout << m.size() << std::endl;
  return 0;
}

Measured memory_bytes: 19180
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e10,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
   // cin>>t;
    while(t--)
    { 
       char c;
       int a,b;
       cin>>a;
       cin>>c;
       cin>>b;
       if(c=='-')
       cout<<a-b;
       else
       cout<<a+b;
       
    }
}
// 🍪 🍪 🍪


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
#define mod 1000009
int main(){

	long long n;
	cin >> n;

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

	vector<long long> bb(mod,1000000000000);

	long long ans = 0;
	for(long long i=n-1;i>=0;i--){
		long long ind = upper_bound(bb.begin(),bb.end(),a[i])-bb.begin();
		if(bb[ind]==1000000000000)
			ans++;
		bb[ind]=a[i];
	}

	 // for(long long i=0;i<n;i++){
	 // 	cout << bb[i] << " ";
	 // }
	 // cout << "\n";

	cout << ans << "\n";


	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(a*10+b+c, max(a+b*10+c, a+b+10*c)) << '\n';
    return 0;
}

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

public class Main{

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";
        while (!(line = br.readLine()).equals("-")) {
            int n = Integer.parseInt(br.readLine());
            for (int i = 0; i < n; i++) {
                int m = Integer.parseInt(br.readLine());
                line = line.substring(m) + line.substring(0, m);
            }
            System.out.println(line);
        }
    }
}




Measured memory_bytes: 24544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
const ll INFLL=LLONG_MAX;
const int INF=INT_MAX;
#define eb emplace_back
#define emp emplace
#define mp(a,b) make_pair(a,b)
template<class T> using min_heap=priority_queue<T,vector<T>,greater<T> >;
template<class T>
void sort(vector<T>& v){
	sort(v.begin(),v.end());
}
template <class T, class U>
void sort(vector<T>& v,U func){
	sort(v.begin(),v.end(),func);
}
template <class T>
int lb_index(vector<T>& v,T k){
	return lower_bound(v.begin(),v.end(),k)-v.begin();
}
template <class T>
int ub_index(vector<T>& v,T k){
	return upper_bound(v.begin(),v.end(),k)-v.begin();
}
int n,m;
vector<int>v[100000];
vector<int>st(100000,-1),et(100000,-1);
vector<int>low(100000);
vector<pair<int,int> >bridge;
int tim;
void dfs(int u,int p){
	st[u]=tim++;
	low[u]=st[u];
	for(auto i:v[u]){
		if(p==i)continue;
		if(st[i]==-1){
			dfs(i,u);
			low[u]=min(low[u],low[i]);
			if(st[u]<low[i]){
				bridge.emplace_back(u,i);
			}
		}
		else if(et[i]==-1){
			low[u]=min(low[u],st[i]);
		}
	}
	et[u]=tim;
}
int main(){
	cin>>n>>m;
	while(m--){
		int l,r;
		cin>>l>>r;
		v[l].emplace_back(r);
		v[r].emplace_back(l);
	}
	for(int i=0;i<n;i++){
		if(st[i]==-1)dfs(i,-1);
	}
	map<pii,bool>p;
	for(int i=0;i<bridge.size();i++){
		bridge[i]={min(bridge[i].fi,bridge[i].se),max(bridge[i].fi,bridge[i].se)};
	}
	sort(bridge);
	for(auto i:bridge){
		if(!p[i])cout<<min(i.fi,i.se)<<" "<<max(i.fi,i.se)<<"\n";
		p[i]=1;
	}
}


Measured memory_bytes: 7632
n, a, b = list(map(int, input().split()))
s = list(input())

b_cnt = 0
a_cnt = 0
for si in s:
    if si == "c":
        print("No")
        
    elif si == "a":
        if a_cnt+b_cnt < a + b:
            print("Yes")
            a_cnt+=1
        else:
            print("No")
        
    else:
        if a_cnt + b_cnt < a + b and b_cnt < b:
            print("Yes")
            b_cnt += 1
        else:
            print("No")
        


Measured memory_bytes: 4712
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	int len = 0;
	for(int i = 1; i <= a; i++){
		for(int j = 1; j <= b; j++){		
			int fir,sec;
			fir = j / 10;
			sec = j % 10;
			if(fir > 1 && sec > 1 && fir*sec == i){
//				cout << i <<" " << j <<endl;
				len++;
			}
		}
	}
	cout << len;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
    long long n, ans = 1;
    scanf("%lld", &n);
    long long a[100000], b = 1000000000000000000;
    for (int i = 1; i <= n; i++) { scanf("%lld", &a[i]); }

    for (int i = 1; i <= n; i++) {
        if (a[i] == 0) { printf("0"); return 0; }
    }

    for (int i = 1; i <= n; i++) {
        if (b / ans < a[i]) { printf("-1"); return 0; }

        ans *= a[i];
    }

    printf("%lld", ans);
}

Measured memory_bytes: 2444
"use strict"
function Main(input) {
  input = input.split('\n');
  let i1 = input[0].trim().split(' ').map(Number);
  let n = i1[0];
  let k = i1[1];
  let mons = input[1].trim().split(' ').map(Number);
  mons.sort((a,b) => b-a);

  let t = mons.slice(k);
 
  if(t.length === 0) {
    console.log(0)
    return;
  }
 
  let atk = t.reduce((acc, val) => {
    return acc+=val;
  })
 
  console.log(atk)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main()
{
    int a,b;
    cin>>a>>b;
    int sum=0,tem=b;
    while(1)
    {
        if(tem==0)break;
        sum++;
        tem/=10;
    }
    while(sum)
    {
        a*=10;
        sum--;
    }
    a+=b;
    int z=sqrt(a);
    if(a==z*z)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
package main

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

func main() {
	A := nextInt()
	B := nextInt()
	M := nextInt()

	a := make([]int, A)
	b := make([]int, B)
	am := math.MaxInt32
	bm := math.MaxInt32

	for i := 0; i < A; i++ {
		a[i] = nextInt()
		am = min(am, a[i])
	}
	for i := 0; i < B; i++ {
		b[i] = nextInt()
		bm = min(bm, b[i])
	}

	cost := am + bm
	for i := 0; i < M; i++ {
		x := nextInt() - 1
		y := nextInt() - 1
		c := nextInt()

		cost = min(cost, a[x]+b[y]-c)
	}

	fmt.Println(cost)
}

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

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

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


int main(){
  ll sum = 0;
  int N;
  cin >> N;
  for(int i = 1; i <= N; i++){
    if(i % 3 == 0 && i % 5 == 0) sum += 0;
    else if(i % 3 == 0) sum += 0;
    else if(i % 5 == 0) sum += 0;
    else sum += i;
  }
cout << sum << "\n";
return 0;

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D,E;
  cin >> A >>B>>C>>D>>E;
  if(A==0){
    cout << 1 <<endl;
  }
  if(B==0){
    cout << 2 <<endl;
  }
  if(C==0){
    cout << 3 <<endl;
  }
  if(D==0){
    cout << 4 <<endl;
  }
  if(E==0){
    cout << 5 <<endl;
  }
}

Measured memory_bytes: 3596