akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace _8_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                var n = Console.ReadLine();
                if (n == "0") break;
                var sum = 0;
                for(var i=0;i<n.Length;i++)
                {
                    sum += n[i].ToInt();
                }
                Console.WriteLine(sum);
            }
        }
    }
    public static class CharExt
    {
        public static int ToInt(this char self)
        {
            return self - '0';
        }
    }
}



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

int main() {
  int N, M;
  cin >> N >> M;

  vector<vector<char>> A(N, vector<char>(N));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A.at(i).at(j);
    }
  }

  vector<vector<char>> B(M, vector<char>(M));
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < M; j++) {
      cin >> B.at(i).at(j);
    }
  }

  for (int i = 0; i <= N - M; i++) {
    for (int j = 0; j <= N - M; j++) {
      int ans = 1;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          if (A.at(i + k).at(j + l) != B.at(k).at(l)) ans = 0;
        }
      }
      if (ans) {
        cout << "Yes" << endl;
        return 0;
      }
      ans = 1;
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define OKawaiiKoto ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
int main()
{
    OKawaiiKoto
    ll n;
    cin>>n;
    cout<<(1000-n%1000)%1000;
}


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

using namespace std;

int main(void)
{
    int min = 100000;
    int sum = 0;
    bool flag = true;
    int n;
    vector<int> s;

    cin>>n;
    for(int i = 0;i < n;i++)
    {
	int temp;
	cin>>temp;
	s.push_back(temp);
	sum += temp;
	
	if(temp % 10 != 0) {
	    flag = false;
	    min = min < temp ? min :temp;
	}

    }

    if(flag) {
	cout<<0<<endl;

	return 0;
    }

    if(sum % 10 != 0)
	cout<<sum<<endl;
    else
    {
	cout<<sum - min<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    private static final Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int t;
        if(a>b) {
            t = a;
            a = b;
            b = t;
        }
        if(b>c) {
            t = b;
            b = c;
            c = t;
        }
        if(a>b) {
            t = a;
            a = b;
            b = t;
        }
        System.out.println(a+" "+b+" "+c);
    }
}

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

int main() {
  
  int N; cin >> N;
  vector<int> A(N);
  for (int i = 0; i < A.size(); i++) {
    cin >> A[i];
  }
  
  int counter = 0;
  bool is_all_even = true;
  while(is_all_even) {
    
    for (int i = 0; i < A.size(); i++) {
      if (A[i] % 2 == 1) {
        is_all_even = false;
        break;
      }
      A[i] /= 2;
    }
    
    if (is_all_even) counter++;
  }
  
  cout << counter << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
using namespace std;


struct R{
	int h,w;
	R(int a,int b):h(a),w(b){}
	bool operator<(R a){
		if(h*h+w*w!=a.h*a.h+a.w*a.w)return h*h+w*w < a.h*a.h+a.w*a.w;
		return h<a.h;
	}
};
int main(){
	int h,w;
	while(cin>>h>>w,h|w){
		R ans(150,150),in(h,w);
		for(int i=1;i<=150;i++){
			for(int j=i+1;j<=150;j++){
				R t(i,j);
				if(in<t && t<ans)ans=t;
			}
		}
		cout<<ans.h<<' '<<ans.w<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
ll v[1 << 17];
bool used[5000][5000];
int main() {
	int n; cin >> n;
	rep(i, n) {
		cin >> v[i];
	}
	sort(v, v + n);
	int out = 1;
	rep(i, n) {
		Rep(j, i + 1, n) {
			if (used[i][j])continue;
			vector<int> s;
			int dif = v[j] - v[i];
			s.push_back(i); s.push_back(j);
			int now = v[j] + dif;
			while (true) {
				int id = lower_bound(v, v + n, now) - v;
				if (id < n&&v[id] == now) {
					s.push_back(id); now += dif;
				}
				else break;
			}
			out = max(out, (int)s.size());
			rep(k, s.size()-1) {
				used[s[k]][s[k + 1]] = true;
			}
		}
	}
	cout << out << endl;
	return 0;
}


Measured memory_bytes: 27256
#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>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9+7;

int main() {
  int k, n;
  cin >> k >> n;
  if (k%2==0) {
    rep(i,n) printf("%d%c", (i==0)?(k/2):k, (i == n-1)?'\n':' ');
  } else {
    vector<int> v;
    rep(i,n) v.push_back(k/2+1);
    rep(i,n/2) {
      if (v.back()==1) v.pop_back();
      else {
        v.back()--;
        while (v.size()<n)
        {
          v.push_back(k);
        }
      }
    }
    for(int c : v) cout << c << " ";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 5224
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;
using P = pair<ll,ll>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, m;
  cin >> n >> m;
  Graph G(n);
  rep(i,m) {
    ll a, b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  V d(n,-1);
  queue<ll> q;
  d[0] = 0;
  q.push(0);

  while (!q.empty()) {
    ll v = q.front();
    q.pop();
    for (ll nv : G[v]) {
      if (d[nv] != -1) continue;
      d[nv] = v+1;
      q.push(nv);
    }
  }

  bool bo = true;
  rep(i,n) {
    if (d[i] == -1) bo = false;
  }

  if (bo) {
    cout << "Yes\n";
    rep(i,n-1) cout << d[i+1] << '\n';
  }
  else cout << "No\n";

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

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

int main()
{
  int C[3][3];
  rep(i,3){
    rep(j,3) cin >> C[i][j];
  }
  //9マス計算の横軸のチェック
  bool check1 = false;
  rep(i,2)
  {
    rep(j,2)
    {
      int layer1 = C[i][j] - C[i][j+1];
      int layer2 = C[i+1][j] - C[i+1][j+1];
      if(layer1 != layer2) check1 = true; 
    }
  }
  bool check2 = false;
  rep(i,2)
  {
    rep(j,2)
    {
      int layer1 = C[i][j] - C[i+1][j];
      int layer2 = C[i][j+1] - C[i+1][j+1];
      if(layer1 != layer2) check2 = true; 
    }
  }
  if(check1 || check2) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<functional>
typedef long long ll;

using namespace std;


int main(){
    ll N, X, D;
    cin >> N >> X >> D;
    if(D == 0){
        if(X == 0){
            cout << 1 << endl;
            return 0;
        }
        ll ans = N+1;
        cout << ans << endl;
        return 0;
    }
    if(D<0){ X = X+(N-1)*D;D = -D;}
    map<ll, vector<pair<ll, ll>>> mp;
    ll cnt = 0;
    bool odd=false;
    for(ll k=0;k<=N;k++){
        ll key = (k*X) % D;
        ll s = (k*X-key)/D + k*(k-1LL)/2LL;
        ll e = (k*X-key)/D + (2LL*N-k-1LL)*k/2LL;
        
        if(mp.count(key) == 0){
            mp[key] = vector<pair<ll, ll>>();
        }
        mp[key].push_back(make_pair(s,e));
    }
    for(auto pa:mp){
        auto v = pa.second;
        sort(v.begin(), v.end());
        pair<ll,ll> now;
        now = v[0];
        for(int i=1;i<v.size();i++){
            if(v[i].first <= now.second){
                now.second = max(v[i].second, now.second);
            }else{
                cnt += now.second-now.first + 1;
                now = v[i];
            }
        }
        cnt += now.second-now.first+1;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 22144
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
    int32_t a, b, C;
    static const double pi = atan(1) * 4;

    cin >> a >> b >> C;

    cout << fixed << setprecision(5) << a * b * sin(C * pi / 180) / 2 << endl;
    cout << fixed << setprecision(5) << a + b + sqrt(a * a + b * b - 2 * a * b * cos(C * pi / 180)) << endl;
    cout << fixed << setprecision(5) << b * sin(C * pi / 180) << endl;

    return 0;
}

Measured memory_bytes: 3428
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    ll n, m; cin >> n >> m;

    ll ans = 0;

    ll temp = min(n, m/2);

    n -= temp;
    m -= temp*2;
    ans += temp;

    // cout << n << " " << m << endl;

    if(m < 4){
        cout << ans;
    }
    else{
        cout << ans + m/4;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long ans=1;
    for(int i=1;i<=n;i++){
        ans = ans*i;
        if(ans>1000000007){
            ans=ans%1000000007;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve())
}

func resolve() int {
	n := scanInt(sc)
	as := nextIntSlice(sc, n)
	sort.Sort(sort.IntSlice(as))
	sum := 0
	cand := -1
	for i := 0; i < len(as); i++ {
		sum += as[i]
		if cand == -1 && as[i]%10 != 0 {
			cand = as[i]
		}
	}
	if sum%10 != 0 {
		return sum
	}
	if cand == -1 {
		return 0
	}
	return sum - cand
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys
import math
INF = float("inf")


def divisors_pair(n):
    ret_A = []
    ret_B = []
    for i in range(1, int(n ** 0.5) + 1):
        d, m = divmod(n, i)
        if m == 0:
            ret_A.append(i)
            ret_B.append(d)
    return ret_A, ret_B


def solve(N: int):
    A, B = divisors_pair(N)
    m = INF
    for a, b in zip(A, B):
        curr = max(len(str(a)), len(str(b)))
        m = min(m, curr)
    print(m)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <iostream>
#include <vector>

using namespace std;

bool check(const vector<vector<int>>& A, int maxNum){
	const int N = A.size();
	const int M = A[0].size();
	vector<int> hold(M, 1);
	vector<int> idx(N, 0);
	vector<int> part(M, 0);
	for(int i=0;i<N;i++) part[A[i][0]]++;
	while(true){
		bool update = false;
		for(int i=0;i<M;i++){
			if(part[i] > maxNum){
				hold[i] = 0;
				for(int j=0;j<N;j++){
					if(A[j][idx[j]] != i) continue;
					--part[i];
					while(idx[j] < A[j].size() && !hold[A[j][idx[j]]]) ++idx[j];
					if(idx[j] == A[j].size()) return false;
					part[A[j][idx[j]]]++;
				}
				update = true;
			}
		}
		if(!update) break;
	}
	return true;
}

int main(){
	int N, M;
	while(cin >> N >> M){
		vector<vector<int>> A(N, vector<int>(M));
		for(auto& v : A){
			for(auto& t : v){ cin >> t; --t; }
		}
		int L = 0, R = N;
		while(R-L > 1){
			int mid = (L+R)/2;
			if(check(A, mid)) R = mid;
			else L = mid;
		}
		cout << R << endl;
	}
}


Measured memory_bytes: 640
n = int(input())
a = [int(i) for i in input().split(" ")]

max_a = max(a)
dp = [0] * (max_a + 1)

for i in a:
    for j in range(i, max_a + 1, i):
        dp[j] += 1

out = 0
for i in a:
    if dp[i] == 1:
        out += 1

print(out)

Measured memory_bytes: 32060
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m,res=inf;
vvi g;
vi dp,a;

P dfs(int v,int t){
	a[v]=t;
	P p={1,0};
	for(int u=0;u<n;u++) if(g[v][u]){
		if(!a[u]){
			P q=dfs(u,-t);
			if(q==make_pair(0,0)) return {0,0};
			p.first+=q.second;
			p.second+=q.first;
		}
		if(a[u]==t) return {0,0};
	}
	return p;
}

int main(){
	cin>>n>>m;
	g=vvi(n,vi(n,1));
	dp=a=vi(n+1);
	dp[0]++;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u][v]=g[v][u]=0;
	}
	for(int i=0;i<n;i++) g[i][i]=0;
	for(int i=0;i<n;i++) if(!a[i]){
		P p=dfs(i,1);
		if(p==make_pair(0,0)){
			cout<<-1<<endl;
			return 0;
		}
		vi DP(n+1);
		int A=p.first,B=p.second;
		for(int j=0;j<=n;j++) if(j>=A&&dp[j-A]||j>=B&&dp[j-B]) DP[j]=1;
		dp=DP;
	}
	for(int i=1;i<=n;i++) if(dp[i]) res=min(res,i*(i-1)/2+(n-i)*(n-i-1)/2);
	cout<<res<<endl;
}

Measured memory_bytes: 2176
#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;
  cin >> n;
  
  vector<bool> eq;
  rep(i,n){
    int a, b;
    cin >> a >> b;
    if(a == b) eq.emplace_back(1);
    else eq.emplace_back(0);
  }
  
  int cnt = 0;
  rep(i,n){
    if(eq[i]) cnt++;
    else cnt = 0;
    
    if(cnt >=3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl; 
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)


#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vec{
    double x, y;
};

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

template<class T>
T min(T a, T b)
{
    if (a < b) return a;
    return b;
}

template<class T>
T max(T a, T b)
{
    if (a > b) return a;
    return b;
}

using namespace std;

int main()
{
    // cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    int N,miX = 1000000;
    cin >> N;
    vector<int> X(N);
    rep(i, N) {
        cin >> X[i]; 
    }
    
    ll res;
    rep(i, 101){
        res = 0;
        rep(k, N) {
            res += (X[k] - i) * (X[k] - i);
        }
        if (res < miX) {
            miX = res;
        }
    }
    cout << miX << endl;
    return 0;
}



Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	ll a,b;
	cin >> a >> b;
	if (a==1&&b==2) {
		cout << 3 << endl;
	}
	else if (a == 1 && b == 3) {
		cout << 2 << endl;
	}
	else if (a == 2 && b == 1) {
		cout << 3 << endl;
	}
	else if (a == 2 && b == 3) {
		cout << 1 << endl;
	}
	else if (a == 3 && b == 2) {
		cout << 1 << endl;
	}
	else if (a == 3 && b == 1) {
		cout << 2 << endl;
	}

}



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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong K, N;
  vector<llong> A;

  cin >> K >> N;
  A.resize(N);
  for (auto &in: A) {
    cin >> in;
  }

  llong sum = 0, maxi = -inf<llong>;
  for (int i = 1; i <= N; ++i) {
    sum += (A[i%N] - A[i-1] + K) % K;
    maxi = max(maxi, (A[i%N] - A[i-1] + K) % K);
  }

  cerr << sum << " " << maxi << endl;

  cout << sum - maxi << endl;

  return 0;
}

Measured memory_bytes: 1792
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int a,b;
    cin >> a >> b;
    
    if(a>=1 and a<=9 and b>=1 and b<=9)
    cout << a*b ;
    else
    cout << -1;

	return 0;
    
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    pair<int,int>a[100005];
    for(int i=0;i<n;i++)
    {
        cin>>a[i].first;
        a[i].second=i+1;
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        cout<<a[i].second<<" ";
    }
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <functional>
#include <string.h>

using namespace std;
static const int INF = 2e9;
static const int SIZE = 10001;
typedef pair<int, int> P;
struct edge
{
	int to;
	int cost;
};

int d[SIZE];
vector<edge> G[SIZE];

void solve()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; ++j)
		{
			int to, cost;
			scanf("%d %d", &to, &cost);
//			cin >> to >> cost;
			edge e1;
			e1.to = to;
			e1.cost = cost;
			G[u].push_back(e1);
		}
	}
	for (int i = 0; i < SIZE; ++i)
	{
		d[i] = INF;
	}
	d[0] = 0;
	priority_queue<P, vector<P>, greater<P> > pque;
	pque.push(P(0, 0));
	while (!pque.empty())
	{
		P p = pque.top();
		pque.pop();
		int v = p.second;
		for (int i = 0; i < G[v].size(); ++i)
		{
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				pque.push(P(d[e.to], e.to));
			}
		}
	}
	for (int i = 0; i < n; ++i)
	{
		printf("%d %d\n", i, d[i]);
//		cout << i << " " << d[i] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 6380
/*
AizuOnline A0057
The Number of Area
*/
#include <stdio.h>


main()
{
  long int lines,areas;

  while(EOF!=scanf("%ld",&lines) && lines)
    {
      areas = lines*(lines+1)/2 + 1;
      printf("%ld\n",areas);
    }
return(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)


int main() {
#ifdef _WIN32
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0); // cin??¨cout?????£????????????
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll n, w; cin >> n >> w;
	vl friends(n + 1); FOR(i, 1, n + 1) cin >> friends[i];
	friends[0] = w + 1;
	sort(friends.begin() + 1, friends.end()); reverse(friends.begin() + 1, friends.end());

	ll mod = TEN(9) + 7;
	vector<vvl> dp(2, vvl(n + 1, vl(w + 1, 0)));
	dp[0][0][0] = 1;
	FOR(i, 1, n + 1) {
		REP(j, n + 1) REP(k, w + 1) dp[i % 2][j][k] = 0;
		REP(j, n + 1) REP(k, w + 1) {
			if (k + friends[i] <= w) (dp[i % 2][j][k + friends[i]] += dp[(i - 1) % 2][j][k]) %= mod;
			(dp[i % 2][i][k] += dp[(i - 1) % 2][j][k]) %= mod;
		}
	}

	ll sum = 0;
	REP(j, n + 1) FOR(k, max(0ll, w - friends[j] + 1), w + 1) (sum += dp[n % 2][j][k]) %= mod;
	cout << sum << endl;

	return 0;
}

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

# 累積和で実装

now = 1
cnt = 0
nums = []
for i in range(N):
    if int(S[i]) == now:
        cnt += 1
    else:
        nums.append(cnt)
        cnt = 1
        now = 1 - now
nums.append(cnt)
if int(S[-1]) == 0:
    nums.append(0)

# print(nums)

cumulative_sum = []
M = len(nums)
sum = 0
for i in range(M):
    sum += nums[i]
    cumulative_sum.append(sum)

# print(cumulative_sum)

ans = 0
start = 0
final = 2 * K
answers = []

# M = len(nums) = len(cumulative_sum)
# if M < 2 * K + 1:
#     print(len(S))
# else:
if final <= M-1:
    while(final <= M-1):
        if start == 0:
            answers.append(cumulative_sum[final])
        else:
            ans = cumulative_sum[final] - cumulative_sum[start-1]
            answers.append(ans)

        # print(start, final, ans)
        start += 2
        final += 2
    print(max(answers))
else:
    print(cumulative_sum[-1])

# print(answers)


Measured memory_bytes: 9468
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public static void Main(string[] args)
	{
		string s = Console.ReadLine();
		Dictionary<char, int > cs = new Dictionary<char, int>(2);
		for(int i = 0; i < s.Length; i++)
		{
			char c = s[i];
			if(!cs.ContainsKey(c))
			{
				cs.Add(c, 0);
			}
			cs[c]++;
			if(cs[c]>=3)
			{
				Console.WriteLine("No");
				return;
			}
		}
		if(cs.Count == 2)
		{
			foreach (char c in cs.Keys)
			{
			
				if(cs[c]!=2)
				{
					Console.WriteLine("No");
					return;
				}
			}
					Console.WriteLine("Yes");
			
			return;
		}
		
		Console.WriteLine("No");
	}

	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

	
}



Measured memory_bytes: 13152
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 0, ans = 0;
		for (int i = 1; i <= N; i++) {
			int cnt = 0;
			int ii = i;
			while (ii % 2 == 0) {
				ii /= 2;
				cnt++;
				if (cnt > count) {
					count = cnt;
					ans = i;
				}
			}
		}
		if (N == 1)
			System.out.println(1);
		else
			System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 22736
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main{

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
		Scanner  sc=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
	int n=sc.nextInt();
	int m=sc.nextInt();
	long x[]=new long[n];
	long y[]=new long[m];
	for(int i=0;i<n;i++) {
		x[i]=sc.nextLong();
	}
	for(int i=0;i<m;i++) {
		y[i]=sc.nextLong();
	}
	Arrays.parallelSort(x);
	Arrays.parallelSort(y);
	
	long sum=0;
	for(int i=0;i<n;i++) {
		sum=(sum+i*x[i]-(n-1-i)*x[i])%mod;
			
		
	}
	long sum1=0;
	for(int i=0;i<m;i++) {
		sum1=(sum1+i*y[i]-(m-1-i)*y[i])%mod;
			
		
	}
	out.println((sum*sum1)%mod);
	out.flush();
	
}
	static long combi(int p,int q) {
		int dp[][]=new int[100001][3];
		for(int i=0;i<100001;i++) {
			dp[i][0]=1;
		}
	for(int i=0;i<3;i++) {
			dp[0][i]=0;
		}
	for(int i=1;i<10001;i++) {
		for(int j=0;j<=2;j++) {
			if(j==0||j==i) {
				dp[i][j]= 1;
			}else
			dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
		}
	}
	return dp[p][q];
	}
}

Measured memory_bytes: 61236
#include<cstdio>
using namespace std;
int main()
{
	int n,m,a,i,x;
	x=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d",&a);
		x+=a;
	}
	n-=x;
	if(n<0) printf("-1\n");
	else printf("%d\n",n);
	return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


int cmp(const void *p, const void *q) {
    // printf("(%s) (%s)\n", *(const char **)p, *(const char **)q);
    return strcmp(*(const char **)p, *(const char **)q);
}

string solve(string& A) {
    int L = A.size();
    vvi az(26);
    rep(i,L) {
        int ch = A[i] - 'a';
        az[ch].pb(i);
    }
#ifdef DEBUG
    rep(ch,26){
        cerr << (char)('a'+ch) << " " << az[ch] << endl;
    }
#endif

    vector<int> rev(L);
    set<int> abc;
    int k = 0;
    for (int i=L-1; i>=0; --i) {
        abc.insert(A[i] - 'a');
        rev[i] = k;
        if (abc.size() == 26) {
            ++k;
            abc.clear();
        }
    }
#ifdef DEBUG
    cerr << rev << endl;
#endif
    int len = k+1;

    vector<char> ans(len);
    rep(ch,26) {
        if (!found(abc, ch)) {
            ans[0] = ch;
            if (az[ch].empty()) {
                ans[0] += 'a';
                return string(ALL(ans));
            }
            break;
        }
    }

    int last = az[ans[0]][0];
    // cerr << last << endl;
    rep1(i,k) {
        rep(ch,26) {
            auto it = lower_bound(ALL(az[ch]), last+1);
            if (it != az[ch].end()) {
                int at = *it;
                if (rev[last]-1 != rev[at]) continue;
                last = at;
            }
            ans[i] = ch; break;
        }
    }

    rep(i, len) ans[i] += 'a';
    return string(ALL(ans));
}

int main() {
    string A; cin >> A;
    cout << solve(A) << endl;
    return 0;
}


Measured memory_bytes: 2180
s= list(input())
n=len(s)

mod=10**9+7

ans=0
dp=[[0,0,0] for i in range(n+1)]
cnt=1

for i in range(n):
    if s[i]=='A':
        dp[i+1][0]=dp[i][0]+cnt
        dp[i+1][1]=dp[i][1]
        dp[i+1][2]=dp[i][2]
        dp[i+1][0]%=mod
    elif s[i]=='B':
        dp[i+1][0]=dp[i][0]
        dp[i+1][1]=dp[i][1]+dp[i][0]
        dp[i+1][2]=dp[i][2]
        dp[i+1][1]%=mod
    elif s[i]=='C':
        dp[i+1][0]=dp[i][0]
        dp[i+1][1]=dp[i][1]
        dp[i+1][2]=dp[i][2]+dp[i][1]
        dp[i+1][2]%=mod
    else:
        dp[i+1][0]=3*dp[i][0]+cnt
        dp[i+1][1]=3*dp[i][1]+dp[i][0]
        dp[i+1][2]=3*dp[i][2]+dp[i][1]
        cnt*=3
        cnt%=mod
        dp[i+1][0]%=mod
        dp[i+1][1]%=mod
        dp[i+1][2]%=mod

print(dp[-1][-1])

Measured memory_bytes: 59404
N = int(input())
S = [[0]*10]*N
P = [0]*N
n = [0]*N
for i in range(N):
    S[i],P[i]= input().split()
    n[i] = i+1

P_list = list(map(int,P))

for j in range (N-1):
    for i in range(N-1):
        if S[i] > S[i+1]:
            tmp = S[i]
            S[i] = S[i+1]
            S[i+1] = tmp
            tmp = P_list[i]
            P_list[i] = P_list[i+1]
            P_list[i+1] = tmp
            tmp = n[i]
            n[i] = n[i+1]
            n[i+1] = tmp
        elif S[i] == S[i+1]:
            if P_list[i] < P_list[i+1]:
                tmp = P_list[i]
                P_list[i] = P_list[i+1]
                P_list[i+1] = tmp
                tmp = n[i]
                n[i] = n[i+1]
                n[i+1] = tmp

for i in range(N):
    print(n[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int n;
    cin >> n;
    rep(i, n){
        int a; cin >> a;
        if(a%2==0){
            if(a%3!=0 && a%5!=0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    ll a = 1;
    REP(i, N) {
        a = std::min(a * 2, a + K);
    }
    cout << a << endl;
    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    for (auto &&i : s)
    {
        i = 'x';
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] v = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        int c = Math.min(n, k);
        int max = -1000000000;
        for (int i = 0; i <= c; i++) {
            for (int j = 0; j <= c; j++) {
                if (i + j <= c) {
                    List<Integer> list = new ArrayList<>();
                    int sum = 0;
                    for (int l = 0; l < i; l++) {
                        list.add(v[l]);
                        sum += v[l];
                    }
                    for (int r = 0; r < j; r++) {
                        list.add(v[n - 1 - r]);
                        sum += v[n - 1 - r];
                    }
                    Collections.sort(list);
                    for (int m = 0; m < Math.min(i + j, k - i - j); m++) {

                        if (list.get(m) < 0) {
                            sum -= list.get(m);
                        }
                    }
                    max = Math.max(max, sum);
                }

            }
        }
        System.out.println(max);

    }

}

Measured memory_bytes: 22612
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    [n, k] = li()
    if k > (n - 1) * (n - 2) // 2:
        print(-1)
    else:
        mesh_edge_list = []
        for i in range(n):
            for j in range(i + 1, n):
                mesh_edge_list.append((i, j))
        for _ in range(k):
            del_index = -1
            for index, edge in enumerate(mesh_edge_list):
                if edge[1] != n - 1:
                    del_index = index
                    break
            mesh_edge_list.pop(del_index)

        print(n * (n - 1) // 2 - k)
        for edge in mesh_edge_list:
            print(edge[0] + 1, edge[1] + 1)

# 頂点対を最大にするのは１つの中心点をつくる場合　(n-1)(n-2)//2
# 　それより大きいKの場合は無理
# メッシュにすればK=0でも構成できる
# 0 <= k <= (n-1)(n-2)//2 では？
# メッシュからui,viの辺を除くとk=1の場合が作れる
# 　n番目の頂点は距離２の頂点対として使わないことにすれば
# 　適当に頂点対をk個作って、その間の辺を取り除けばいい


Measured memory_bytes: 43120
#include <cstdio>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
  ll n;
  scanf("%lld",&n);
  ll a,count4=0,count2=0,odd=0;
  rep(i,n){
    scanf("%lld",&a);
    if(a%2){
      odd++;
    }else if(a%4==0){
      count4++;
    }else{
      count2++;
    }
  }

  if(odd==0){
    printf("Yes\n");
    return 0;
  }

  if(odd+(count2?1:0)<=count4+1){
    printf("Yes\n");
    return 0;
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a = 0;
		int b4 = 0;
		int b2 = 0;
		int b0 = 0;

		for (int i = 0; i < n; i++) {
			a = Integer.parseInt(sc.next());
			if (a % 2 == 0) {
				if (a % 4 == 0)
					b4++;
				else
					b2++;
			} else {
				b0++;
			}
		}

		String ans = "Yes";

		if (b0 > b4) {
			ans = "No";
		}
		if (b2 == 0 && b0 - b4 == 1)
			ans = "Yes";

		System.out.println(ans);
	}

}


Measured memory_bytes: 46312
#include <stdio.h>
#include <math.h>
int main(void) {
    int n;
    while(1) {
        scanf("%d", &n);
        if(n < 100 || n > 999) {
            continue;
        }
        else {
            break;
        }
    }
    if(n/100 == 7 || (n/10)%10 == 7 || n%10 == 7) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 1660
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    String ans = "AGC";
    if(r < 2800) ans = "ARC";
    if(r < 1200) ans = "ABC";
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 22228
#include <iostream>
#include <algorithm>

using namespace std;

using ll = long long;

ll a[5000];
bool dp[5001][5000];

int main()
{
    ll N, K;

    cin >> N >> K;
    for (int i = 0; i < N;i++)
    {
        cin >> a[i];
    }

    sort(a, a + N);

    int l, r, m;

    l = 0;
    r = N - 1;

/*
    for (int i = 0; i < N;i++)
    {
        cout << a[i] << " ";
    }
    cout << endl;
*/
    while (true)
    {
        for (int i = 0; i < 5000; i++)
        {
            for (int j = 0; j < 5000; j++)
            {
                dp[i][j] = false;
            }
        }
        dp[0][0] = true;

        m = (r + l) / 2;

        //cout << "l = " << l << " m = " << m  << " r = " << r << endl;

        for (int x = 1; x <= N; x++)
        {
            for (int y = 0; y < K; y++)
            {
                if (x == m + 1 || y - a[x - 1] < 0)
                {
                    dp[x][y] = dp[x - 1][y];
                }
                else
                {
                    dp[x][y] = (dp[x - 1][y - a[x - 1]] || dp[x - 1][y]);
                }
            }
        }

        bool t = false;

        for (int y = K - a[m]; y < K; y++)
        {
            if (y < 0 || dp[N][y] == true)
            {
                //cout << "y = " << y << endl;
                t = true;
                break;
            }
        }

        if (l >= r)
        {
            if (t == true)
            {
                cout << m << endl;
            }
            else
            {
                cout << m + 1 << endl;
            }
            break;
        }

        if (t == true)
        {
            r = m - 1;
        }
        else
        {
            l = m + 1;
        }
    }

    return 0;
}

Measured memory_bytes: 24960
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define line cout<<"----------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define filein freopen("input.text","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll mx=20009;	
struct edge
{
	ll w,s,val; 
};
vector<edge> v; 
bool cmp(edge a,edge b)
{
 	return a.w+a.s<b.w+b.s; 
}
ll dp[mx];  ///maximum value when total weight  is i
int main()
{	
	ll n; 
	cin>>n; 
	for(ll i=0;i<n;i++)
	{
		ll a,b,c; 
		cin>>a>>b>>c; 
		v.pb({a,b,c});
	}
	sort(v.begin(),v.end(),cmp);
	for(auto x:  v)
	{
		for(ll used=x.s;used>=0;used--)
		{
			dp[used+x.w]=max(dp[used+x.w],dp[used]+x.val);
		}
	}
	ll ans=0; 
	for(ll i=0;i<mx;i++) ans=max(ans,dp[i]);
	cout<<ans<<endl; 
}


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

int main(){
    long long n;cin>>n;
    vector<pair<long long, long long>> tasks(n);
    long long a,b;
    for (long long i=0;i<n;i++){
        cin >> a >> b;
        tasks[i] = make_pair(b, a);
    }

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

    long long acc = 0;
    bool judge = true;
    for (auto task : tasks){
        acc += task.second;
        if (acc > task.first){
            judge = false;
            break;
        }
    }
    if (judge){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string s;
    cin >> s;
    rep(i, 0, s.size()){
        if(i % 2 == 0 && s[i] == 'L'){
            cout << "No" << endl;
            return 0;
        }else if(i % 2 == 1 && s[i] == 'R'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- Coding: utf-8 -*-

import sys


def main():
    S = input()
    K = int(input())
    ary = []
    ans = 0
    n = 1

    for i, s in enumerate(S[1:]):
        if s == S[i]:
            n += 1
        else:
            ary.append(n)
            n = 1
    if n != 1:
        ary.append(n)

    if S[0] == S[-1]:
        for num in ary[1:-1]:
            ans += num//2
        ans *= K
        if len(ary) == 1:
            ans += ary[0]*K//2
        elif len(ary) < 1:
            ans = K//2
        else:
            ans += (ary[0]+ary[-1])//2*(K-1)
            ans += ary[0]//2+ary[-1]//2
    else:
        for num in ary:
            ans += num//2
        ans *= K
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int d;
	cin>>d;
	if(d==25){
		cout<<"Christmas"<<endl;
	}
	else if(d==24){
		cout<<"Christmas Eve"<<endl;
	}
	else if(d==23){
		cout<<"Christmas Eve Eve"<<endl;
	}
	else{
		cout<<"Christmas Eve Eve Eve"<<endl;
	}
}

Measured memory_bytes: 256
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
n, m = map(int, input().split())
a = list(map(int, input().split()))
x = (1 / (4 * m)) * sum(a)
cnt = 0
for i in a:
    if i >= x:
        cnt += 1
if cnt >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 5568
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll n;cin>>n;
    ll ans=0;
    for(ll i=2;i*i<=n;i++)
    {
        ll temp=0;
        while(n%i==0)
        {
            n/=i;
            temp++;
        }
        for(ll j=1;j<=temp;j++)
            ans++,temp-=j;
    }
    if(n>1)ans++;
    cout<<ans<<endl;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

//    cin.tie(NULL);cout.tie(NULL);
//    ll t;cin>>t;
//    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,N=1,V;
vp a;
vi b,scc,used;
vvi c,g,rg;
stack<int> stc;

void Order(int v){
	used[v]=1;
	for(auto u:g[v]) if(!used[u]) Order(u);
	stc.push(v);
}

void DFS(int v,int t){
	used[v]=1;
	for(auto u:rg[v]) if(!used[u]) DFS(u,t);
	scc[v]=t;
}

void SCC(){
	for(int i=0;i<2*V;i++){
		if(!used[i]) Order(i);
		for(auto v:g[i]) rg[v].push_back(i);
	}
	int t=0;
	used=vi(2*V);
	while(!stc.empty()){
		int v=stc.top();
		stc.pop();
		if(!used[v]) DFS(v,t++);
	}
}

bool flag=0;

void Add(int u,int v){
	g[u].push_back(v);
	g[(v+V)%(2*V)].push_back((u+V)%(2*V));
}

void Rec(int a,int b,int k,int l,int r,int v){
	if(r<=a||b<=l) return;
	if(a<=l&&r<=b){
		Add(v,k+V);
		return;
	}
	int m=(l+r)/2;
	Rec(a,b,k*2+1,l,m,v);
	Rec(a,b,k*2+2,m,r,v);
}

bool f(int x){
	g=rg=vvi(2*V);
	scc=used=vi(2*V);
	for(int i=1;i<V;i++) Add(i,(i-1)/2);
	for(int i=0;i<n;i++){
		int x=c[i][0],y=c[i][1];
		Add(x+N-1,y+N-1+V);
		Add(x+N-1+V,y+N-1);
	}
	for(int i=0;i<2*n;i++){
		int l=upper_bound(b.begin(),b.end(),b[i]-x)-b.begin(),r=lower_bound(b.begin(),b.end(),b[i]+x)-b.begin();
		Rec(l,i,0,0,N,i+N-1);
		Rec(i+1,r,0,0,N,i+N-1);
	}
	SCC();
	for(int i=0;i<V;i++) if(scc[i]==scc[i+V]) return 0;
	return 1;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	a=vp(2*n);
	b=vi(2*n);
	c=vvi(n);
	while(N<2*n) N*=2;
	V=2*N-1;
	for(int i=0;i<n;i++){
		int x,y;
		cin>>x>>y;
		a[i]={x,i};
		a[i+n]={y,i};
	}
	sort(a.begin(),a.end());
	for(int i=0;i<2*n;i++){
		b[i]=a[i].first;
		c[a[i].second].push_back(i);
	}
	int l=0,r=inf;
	while(r-l>1){
		int m=(l+r)/2;
		if(f(m)) l=m;
		else r=m;
	}
	cout<<l<<endl;
}

Measured memory_bytes: 42012
using System;

namespace ABC070
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long[] T = new long[N];
            for (int i = 0; i < N; i++)
            {
                T[i] = long.Parse(Console.ReadLine());
            }

            if (N == 1) { Console.WriteLine(T[0]); return; }

            long lcm = CalcLCM(T[0], T[1]);
            for (int i = 2; i < N; i++)
            {
                lcm = CalcLCM(lcm, T[i]);
            }

            Console.WriteLine(lcm);

        }
        public static long CalcGCD(long a, long b)
        {
            if (b == 0) { return a; }
            return CalcGCD(b, a % b);
        }

        public static long CalcLCM(long a, long b)
        {
            return a * (b / CalcGCD(a, b));
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll MOD = (ll)1e9 + 7;
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}

const int N = 100100;
const int A = 26;
int a[A];
char s[N];
int n;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d %s", &n, s);
	for (int i = 0; i < n; i++)
		a[(int)(s[i] - 'a')]++;
	ll ans = 1;
	for (int i = 0; i < A; i++)
		ans = mult(ans, a[i] + 1);
	ans--;
	if (ans < 0) ans += MOD;
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 384