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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-5;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const int64 mod = 1e9+7;

int main(void) {
	string s;
	cin >> s;
	int64 res = 0;
	int64 sum = 0;
	REP(i, s.size()) {
		sum += s[i]-'0';
		res = max(res, sum+9*(int64)(s.size()-i-1)-(int64)1);
	}
	cout << max(res, sum) << endl;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main()
{
   int a,b;
   cin>>a;
   if(a<100){
        if(a<=9){
        cout<<a<<endl;
    }
        else{
      cout<<"9"<<endl;
     }
   }
   else if(a<=999){
      b= a-99;
      cout<<b+9<<endl;
   }
    else if(a>999&&a<10000){
    cout<<"909"<<endl;
}
   else if(a<=100000){
       b=a-9999;
        if(a==100000){
        b=b-1;
    }
       cout<<b+9+900<<endl; 
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>

int main() {
    bool result = true;
    int n, half; char s[101];
    scanf("%d%100s", &n, s);
    if (n & 1)result = false;
    half = n / 2;
    for (int i = 0; i < half && result; ++i)
        if (s[i] != s[half + i])result = false;
    puts(result ? "Yes" : "No");
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>

struct Point { double x, y; };

void koch(int n, Point a, Point b) {
	if (n == 0) { return; }

	Point s, t, u;
	double roll = M_PI*(60.0 / 180.0);

	s.x = (2.0*a.x + 1.0*b.x) / 3.0;
	s.y = (2.0*a.y + 1.0*b.y) / 3.0;
	t.x = (1.0*a.x + 2.0*b.x) / 3.0;
	t.y = (1.0*a.y + 2.0*b.y) / 3.0;
	u.x = ((t.x - s.x)*cos(roll) - (t.y - s.y)*sin(roll) + s.x);
	u.y = ((t.x - s.x)*sin(roll) + (t.y - s.y)*cos(roll) + s.y);

	koch(n - 1, a, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(n - 1, t, b);
}

int main()
{
	Point a, b;
	int n;

	a.x = 0.0;
	a.y = 0.0;
	b.x = 100.0;
	b.y = 0.0;

	scanf("%d", &n);
	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);

    return 0;
}

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

using namespace std;

int main(){

    string S;
    cin >> S;

    int cnt = 0;
    int rest = 15 - (int)S.size();
    for(int i = 0; i < (int)S.size(); i++){
        if(S[i] == 'o'){
            cnt++;
        }
    }

    if(cnt + rest >= 8){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()

	next := 1
	broken := 0
	for i := 0; i < N; i++ {
		tmp := nextInt()
		if tmp == next {
			next++
		} else {
			broken++
		}
	}

	if broken == N {
		fmt.Println(-1)
	} else {
		fmt.Println(broken)
	}
}


Measured memory_bytes: 2304
#include <iostream>

using namespace std;

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

    int x, a, b;

    cin >> x >> a >> b;

    if(a >= b)
        cout << "delicious" << endl;
    else if(b - a > x)
        cout << "dangerous" << endl;
    else
        cout << "safe" << endl;

    return 0;
}


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

int main() {
	for(int N; cin >> N, N; ) {
		static int field[1000][1000];
		memset(field, 0, sizeof field);

		for(int i = 0; i < N; i++) {
			string s;
			cin >> s;
			for(int j = 0; j < (int)s.length(); j++)
				field[i][j] = (s[j] == '.' ? 1 : 0);
		}

		static int dp[1000 + 1][1000 + 1];
		memset(dp, 0, sizeof dp);

		dp[1][1] = field[0][0];
		for(int i = 2; i <= N; i++) {
			dp[1][i] = field[0][i - 1] + dp[1][i - 1];
			dp[i][1] = field[i - 1][0] + dp[i - 1][1];
		}

		for(int i = 2; i <= N; i++)
			for(int j = 2; j <= N; j++)
				dp[i][j] = field[i - 1][j - 1] + dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];

		int maxv = 0;
		for(int i = 1; i <= N; i++) {
			for(int j = 1; j <= N; j++) {
				for(int k = 1; min(i - k, j - k) >= 0; k++) {
					if(dp[i][j] == dp[i - k][j] + dp[i][j - k] - dp[i - k][j - k] + k * k) {
						maxv = max(maxv, k);
					}
				}
			}
		}

		cout << maxv << endl;
	}
}

Measured memory_bytes: 8748
#include<iostream>
#include<cstdio>
#include<cstring>
#include<math.h>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<cstdlib>
#include<deque>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>P;
const int len=2e5+10;
const double pi=acos(-1.0);
const ll mod=998244353;
const int inf=0x3f3f3f3f;
const int maxn=1e9+5;
int a[len]; 
int main()
{
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;++i)cin>>a[i],ans^=a[i];
	if(ans==0)puts("Yes");
	else puts("No");
	
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main
{

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

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());

		String answer = ((a < c) &&(c < b)) || ((b < c) &&(c < a)) ?  "Yes" : "No";

		System.out.println(answer);

		sc.close();
	}

}


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

int main()
{
  auto sum {700u};
  for (auto i {3}; i != 0; --i) {
    char c;
    cin >> c;
    if (c == 'o')
      sum += 100;
  }
  cout << sum << '\n';
  return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	var inputNum string = input()
	var num int
	var outputNum int
	num, _ = strconv.Atoi(inputNum)
	outputNum = num * num * num
	fmt.Println(outputNum)
}

func input() string {
// 	fmt.Print("input? ")
	// Scannerを使って一行読み
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	return scanner.Text()
}


Measured memory_bytes: 1088
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int               long long
#define ff                first
#define ss                second
#define md                1000000007
#define md1               998244353
#define inf               1000000000000000
#define minf              -1000000000000000
#define pb                push_back
#define in                insert
#define mkp               make_pair
#define mpll              map<ll,ll>
#define len(p)            (ll)p.size()
#define pll               pair<ll,ll>
#define all(v)            v.begin(),v.end()
#define mem(a,t)          memset(a,t,sizeof(a))
#define endl              "\n"
#define ar                array
#define vl                vector<ll>
#define vpll              vector<pair<ll,ll>>
#define f(i,yha,wha)      for(ll i=yha;i<wha;i++)
#define rf(i,wha,yha)     for(ll i=wha;i>=yha;i--)
#define f0(n)             for(ll i=0;i<n;i++)
#define f1(n)             for(ll i=1;i<=n;i++)
#define fg(i,yha,wha,gap) for(ll i=yha;i<wha;i+=gap)


void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll pw(ll x, ll y)
{
    if (y == 0)
        return 1;
    if (y == 1)
        return x;
    ll ans = pw(x, y / 2);
    ans = ans * ans;
    if (y % 2 == 1)
        ans = ans * x;
    return ans;
}






void solve()
{
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll n2 = t.size();
    if (n2 > n + 1)
    {
        cout << "No";
        return;
    }
    if (t.substr(0, n) == s)
        cout << "Yes";
    else
        cout << "No";


}

int32_t main()
{
    flash();
    int t;
    t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <set>


using namespace std;

int main() {
	int length[100];
	int ary[100][100];

	while (true) {
		int N;
		scanf("%d", &N);
		if (N == 0)
			break;
		for (int i = 0; i < N; ++i) {
			scanf("%d", &length[i]);
			for (int j = 0; j < length[i]; ++j) {
				scanf("%d", &ary[i][j]);
			}
		}


		int K;
		scanf("%d", &K);
		
		int exposed[100];
		for (int i = 0; i < K; ++i) {
			int p;
			scanf("%d", &p);
			exposed[i] = p;
		}

		int prisoner = -1;
		for (int i = 0; i < N; ++i) {
			bool founded[100] = {};
			int j = 0;
			for (; j < K; ++j) {
				int k = 0;
				for (; k < length[i]; ++k) {
					if (exposed[j] == ary[i][k]) {
						founded[j] = true;
						break;
					}
				}

			}

			j = 0;
			for (; j < K; ++j) {
				if (!founded[j])
					break;
			}
			if (j == K) {
				if (prisoner > 0) {
					prisoner = -1;
					break;
				} else {
					prisoner = i+1;
				}
			}
				

		}

		printf("%d\n", prisoner);

	}
}

Measured memory_bytes: 1068
/*
 * ARC089_C.cpp
 *
 *  Created on: May 22, 2018
 *      Author: 13743
 */
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}



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

	int N;
	int t0=0, x0=0, y0=0;
	int t1,x1,y1;
	cin >> N;

	REP(i, N) {
		cin >> t1 >> x1 >> y1;
		int time = t1 - t0;
		int path = abs(x1-x0) + abs(y1-y0);
		if(path > time || ((path+time)&1)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}






Measured memory_bytes: 256
N = int(input())
S = [0,0,0,0,0]
for i in range(N):
    st = input()
    if st[0] == "M":
        S[0] += 1
        continue
    elif st[0] == "A":
        S[1] += 1
        continue
    elif st[0] == "R":
        S[2] += 1
        continue
    elif st[0] == "C":
        S[3] += 1
        continue
    elif st[0] == "H":
        S[4] += 1
        continue

L = [(0,1,2),(0,1,3),(0,1,4),(0,2,3),(0,2,4),(0,3,4),(1,2,3),(1,2,4),(1,3,4),(2,3,4)]
res = 0
for i,j,k in L:
    res += S[i]* S[j] *S[k]

print(res)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;



int main(){

    int n;
    cin >> n;

    vector<ll> scount;
    vector<string> s(n);

    for(int i = 0; i< n;i++){
        cin >> s.at(i);
    }
    
    for(int i = 0; i< n; i++){
        sort(s.at(i).begin(),s.at(i).end());
    }

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

    int count = 1;
    for(int i = 0; i< n-1; i++){
        if(s.at(i) == s.at(i+1)){
            count++;
            if(i == n-2){
                scount.push_back(count);
            }
        }else{
            scount.push_back(count);
            count  = 1;
        
        }
    } 


    ll answer = 0;

    for(int i= 0; i< scount.size(); i++){
        ll r = scount.at(i);
        answer += (r*(r-1))/2;
    }
        
    cout << answer << endl;
}


Measured memory_bytes: 8444
#include<stdio.h>
int main() {
	int a, b, c;
	int i;

	scanf("%d%d%d", &a, &b, &c);
	for (a; a<=b; a++) {
		if (c%a == 0)
			i++;
	}
	printf("%d\n", i);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define in int
#define ll long long
#define sc(n) scanf("%d",&n)
#define PI 3.14159265358979323846
using namespace std;
int main()
{
    in n,i,j,k,l;
    sc(n);
    cout<<setprecision(20)<<(double)2*PI*n<<endl;

}


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

void solve()
{
	ll n, k; cin >> n >> k;
	ll arr[n];
	for (auto &x : arr) cin >> x;
	sort(arr , arr + n);
	ll res = 0LL;
	for (int i = 0; i < k; ++i)
	{
		res += arr[i];
	}
	cout << res;

}
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll t = 1; //cin >> t;
	while (t--)
		solve();
	return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(void){
        int n;
        int* a=(int*)malloc(sizeof(int)*n);
        cin>>n;
        for(int i=0; i<n; i++) {
                cin>>a[i];
        }
        for(int i=n-1; i>=0; i--) {
                cout<<a[i];
                if(i>0) {
                        cout<<" ";
                }
        }
        cout<<endl;
        return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <utility>

using namespace std;


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


#define INF 		2000000007
#define MOD			998244353

#define MAX 		100005

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


int main(){
	int N,M;cin>>N>>M;
	int left=0,right=MAX;

	REP(i,M){
		int L,R;cin>>L>>R;
		left = max(left,L);
		right = min(right,R);
	}

	cout << max(right-left+1,0) << endl;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, i;
    double sum = 0, d = 1;
    cin>>n;
    vector<pair<double, double>> v(n);
    for(i=0; i<n; i++) {
    	cin>>v[i].ff>>v[i].ss;
    	d = d * (i + 1);
    }
    vector<ll> o;
    for(i=0; i<n; i++) {
    	o.pb(i);
    }
    do {
    	for(i=1; i<n; i++) {
    		ll i1  = o[i];
    		ll i2 = o[i-1];
    		sum += sqrt((v[i1].ff - v[i2].ff)*(v[i1].ff - v[i2].ff) + (v[i1].ss - v[i2].ss)*(v[i1].ss - v[i2].ss));
    	}
    } while(next_permutation(all(o)));
    sum = sum/d;
    printf("%.9lf\n", sum);
}

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

int main() {
    ll ans, n;
    ans = 0;
    cin >> n;
    vector<int> a(n), b(n, 0);
    ll sumA = 0;
    int sign = 1;
    rep(i, n) {
        cin >> a[i];
        sumA += a[i]*sign;
        sign *= -1;
    }
    ll y = sumA/2;
    rep(i, n - 1){
        cout << 2*y << ' ';
        y = a[i] - y;
    }
    cout << 2*y << endl;
    return 0;
}



Measured memory_bytes: 4060
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    print(len(S.split('ABC')) - 1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
  int N, X, r, D, L;
  cin >> N >> X;
  D = 0;
  r = 1;
  for (int i = 0; i < N; i++) {
    cin >> L;
    D += L;
    if (D > X) break;
    r++;
  }
  cout << r << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  rep(i, 1, N + 1) {
    if(i%2 == 0) continue;
    int a = i;
    int cnt = 0;
    rep(j, 1, a + 1) {
      if(a%j == 0) cnt++;
    }
    if(cnt == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vll;
ll gcd(ll a, ll b){if(b==0){return a;}return gcd(b, a%b);}
int main(){
  ll n, k, z;
  cin >> n >> k;
  vll a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0) z = a[i];
    else z = gcd(z, a[i]);
  }
  sort(a.begin(), a.end());
  
  string ans = "IMPOSSIBLE";
  if (k % z == 0 && k <= a[n - 1]) ans = "POSSIBLE";
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

using namespace std;
using ll = long long;

const int kInf = 1e9;
const ll kLInf = 1e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
   int N, W;
   cin >> N >> W;
   int w[105], v[105];
   REP(i, N) cin >> w[i] >> v[i];
   ll **dp = new ll*[105];
   REP(i, 105) {
      dp[i] = new ll[100010];
      REP(j, 10010) dp[i][j] = 0;
   }
   
   REP(i, N) {
      REP(j, W+1) {
         chmax(dp[i+1][j], dp[i][j]);
         if (j+w[i] > W) continue;
         chmax(dp[i+1][j+w[i]], dp[i][j] + v[i]);
         eprintf("i+1,j+w[i],dp: %d,%d,%lld\n", i+1,j+w[i],dp[i+1][j+w[i]]);
      }
   }
   ll ans = 0;
   REP(j, W+1) {
      chmax(ans, dp[N][j]);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 301;

int n, m, pow2[N], mod = 998244353;
vector <bitset <N> > b;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    pow2[0] = 1;
    for(int i = 1 ; i < N ; i++){
        pow2[i] = 2 * pow2[i - 1] % mod;
    }
    cin >> n >> m;
    b.resize(n);
    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < m ; j++){
            int x;
            cin >> x;
            if(x) b[i].set(j);
        }
    }
    vector <int> vis(n);
    int h = n;
    for(int j = 0 ; j < m ; j++){
        int idx = -1;
        for(int i = 0 ; i < n ; i++){
            if(vis[i]) continue;
            if(b[i][j]) idx = i;
        }
        if(idx == -1) continue;
        vis[idx] = 1;
        h--;
        for(int i = 0 ; i < n ; i++){
            if(vis[i]) continue;
            if(b[i][j]) b[i] ^= b[idx];
        }
    }
    cout << 1LL * pow2[m - 1] * (pow2[n] - pow2[h] + mod) % mod << endl;
}


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

int n,a[54],b[54];
LL mask;

int dp[54][54];

int call(int x, int y)
{
    if(x==y)return 1;
    if(x<y)return 0;
    if(dp[x][y]!=-1)return dp[x][y];
    dp[x][y]=0;
    for(int i=1;i<=x;i++)
    {
        if((mask&(1LL<<i))==0)continue;
        dp[x][y]=max(dp[x][y],call(x%i,y));
    }
    return dp[x][y];
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    mask=(1LL<<51)-1LL;
    mask^=1LL;
    memset(dp,-1,sizeof dp);
    bool flag1=1;
    for(int i=1;i<=n;i++)
    {
        if(call(a[i],b[i])==0)flag1=0;
    }
    if(flag1==0)
    {
        cout<<-1<<endl;
        return 0;
    }
    for(int i=50;i>=1;i--)
    {
        mask^=(1LL<<i);
        memset(dp,-1,sizeof dp);
        bool flag=1;
        for(int j=1;j<=n;j++)
        {
            if(call(a[j],b[j])==0)flag=0;
        }
        if(flag)continue;
        mask^=(1LL<<i);
    }
    cout<<mask<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int SIZE=5000;
int n,m;
int cnt=0;
int depth[SIZE+2]={0},low[SIZE+2];
struct edge{
	int x,y,nxt;
}edges[SIZE+2];
int sz=0,h[SIZE+2]={0};
void add_edge(int x,int y){
	sz++;
	edges[sz].x=x;
	edges[sz].y=y;
	edges[sz].nxt=h[x];
	h[x]=sz;
	return;
}
void dfs(int p,int x){
	low[x]=depth[x];
	for(int i=h[x];i;i=edges[i].nxt){
		int y=edges[i].y;
		if(y==p) continue;
		if(!depth[y]){
			depth[y]=depth[x]+1;
			dfs(x,y);
		}
		low[x]=min(low[x],low[y]);
	}
	if(low[x]==depth[x]&&x!=1) cnt++;
	return;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		add_edge(x,y);
		add_edge(y,x);
	}
	depth[1]=1;
	dfs(0,1);
	printf("%d\n",cnt);
	return 0;
} 
/*
7 7
1 3
3 4
4 5
4 6
5 6
6 7
7 2
*/

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
 
const int inf = 1<<29;
 
array<int, 26> sum[2][4010];
 
typedef unsigned long long ull;
 
const ull B = 1^9+7;
 
int main() {
 
  string S[2];
  int N[2];
 
  rep(i, 2) {
    cin >> S[i];
    N[i] = S[i].size();
  }
 
  rep(k, 2) rep(i, N[k]) {
    rep(j, 26) sum[k][i + 1][j] += sum[k][i][j];
    sum[k][i + 1][S[k][i]-'a']++;
  }
 
  int ans = 0;
 
  REP(length, 1, min(N[1], N[0]) + 1) {
    set<ull> st;
    rep(i, N[1] - length + 1) {
      auto subsum = sum[1][i + length];
      rep(k, 26) subsum[k] -= sum[1][i][k];
      ull hash = 0;
      rep(k, 26) hash = hash * B + subsum[k];
      st.insert(hash);
    }
 
    rep(i, N[0]) {
      auto subsum = sum[0][i + length];
      rep(k, 26) subsum[k] -= sum[0][i][k];
      ull hash = 0;
      rep(k, 26) hash = hash * B + subsum[k];
      if(st.count(hash)) {
        ans = max(ans, length);
      }
    }
  }
 
  cout << ans << endl;
 
  return 0;
}

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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int m;
int s[N];
int c[N];
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        /// freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

    cin >> n >> m;
    for(int i = 1; i <= m; i ++){
        cin >> s[i] >> c[i];
    }
    for(int i = 0; i <= 1000; i ++){
        string x = to_string(i);
        if((int)x.size() == n){
            int good = 1;
            for(int j = 1; j <= m; j ++){
                if(x[s[j] - 1] != (c[j] + '0')){
                    good = 0;
                }
            }
            if(good == 1){
                cout << x << "\n";
                return 0;
            }
        }
    }
    cout << "-1\n";
}



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

x = a[0]
y = a[1]
z = a[2]

if (x == 5 && y == 5 && z == 7) || (x == 5 && y == 7 && z == 5)  || (x == 7 && y == 5 && z == 5)
  print("YES")
else
  print("NO")
end


Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;

class PaizaSample
{

    

    static void Main()
    {
        while (true)
        {
            int[] input = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
            if (input[0] == 0 && input[1] == 0)
            {
                break;
            }

            int x = input[0] >= input[1] ? input[0] : input[1];
            int y = input[0] >= input[1] ? input[1] : input[0];

            int step = 0;
            while (true)
            {
                if (y == 0) break;

                x = x % y;
                int temp = x;
                x = y;
                y = temp;

                step++;
            }

            Console.WriteLine("{0} {1}", x, step);

        }

        //Console.ReadKey();

    }
}

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

using namespace std;

#define mod 1000000007
#define int long long int
#define pii pair<int,int>
#define vpii vector<pii>
#define vi vector<int>
#define fi first
#define se second
#define psb push_back
#define ppb pop_back
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define all(x) x.begin(),x.end()

int32_t main()
{
	int a,b;
	cin>>a>>b;
	cout<<(a*b)<<endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   ll n;
   cin>>n;
   
   ll arr[n];
   rep(n)
        cin>>arr[i];
   
   ll ans = 0;
   ll pmax = 0;
   for(ll i=0;i<n;i++)
   {
       ll req = max(0ll,pmax-arr[i]);
       pmax = max(pmax,arr[i]+req);
       ans+=req;
   }
   
   cout<<ans;
   
   return 0;        
}  

  
          
   

Measured memory_bytes: 5188
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
inline int read()
{
	int f = 1, x = 0;
	char ch;

	do{
		ch = getchar();
		if (ch == '-')
			f = -1;
	}while(ch < '0' || ch > '9');
	do{
		x = x * 10 + ch - '0';
		ch = getchar();
	}while(ch >= '0' && ch <= '9');
	return f * x;
}
const int N = 1e5;

int n;
int val[N + 1];
struct Edge {
	int to, next;
} edge[(N << 1) + 1];
int start[N + 1], tot;
int d[N + 1], up[N + 1];

inline void addedge(int u, int v)
{
	edge[++tot] = Edge{ v, start[u] };
	start[u] = tot;
	edge[++tot] = Edge{ u, start[v] };
	start[v] = tot;
	d[u]++;
	d[v]++;
	return;
}
inline bool dfs(int u, int fa)
{
	if (d[u] == 1) {
		up[u] = val[u];
		return false;
	}
	int sum = 0, maxx = 0;
	for (int i = start[u]; i; i = edge[i].next) {
		int v = edge[i].to;
		if (v != fa) {
			if (dfs(v, u))
				return true;
			sum += up[v];
			maxx = max(maxx, up[v]);
		}
	}
	up[u] = (val[u] << 1) - sum;
	if (up[u] < 0 || up[u] > val[u] || val[u] < maxx) {
		printf("NO\n");
		return true;
	}
	return false;
}
int main()
{
	n = read();
	for (int i = 1; i <= n; i++)
		val[i] = read();
	for (int i = 1; i < n; i++) {
		int u = read(), v = read();
		addedge(u, v);
	}
	if (n == 2) {
		if (val[1] == val[2])
			printf("YES\n");
		else
			printf("NO\n");
		return 0;
	}

	for (int i = 1; i <= n; i++) {
		if (d[i] > 1) {
			if (!dfs(i, 0)) {
				if (up[i])
					printf("NO\n");
				else
					printf("YES\n");
			}
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 13344
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
for i in range(n - m + 1):
    for j in range(n - m + 1):
        o = True
        for k in range(i, i + m):
            for l in range(j, j + m):
                if a[k][l] != b[k-i][l-j]:
                    o = False
        if o:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 3064
S = input()
S1, S2 = S[0:2], S[2:5]
if (int(S1) >= 1 and int(S1) <=12) and (int(S2) >= 1 and int(S2) <=12):
	print('AMBIGUOUS')
elif int(S2) >= 1 and int(S2) <= 12:
	print('YYMM')
elif int(S1) >= 1 and int(S1) <=12:
	print('MMYY')
else:
	print('NA')



Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define each(i, a) for (auto &&i : (a))
using namespace std;

using vi = vector<int>;
using seti = set<int>;

template <class T>
void COUT(const T &x) { cout << x << endl; }

struct prime_factors_osa_k {
  vi spf; // smallest prime factor
  prime_factors_osa_k(int n): spf(n + 1) {
    spf[1] = 1;
    for (int i = 0; i <= n; i++) spf[i] = i;
    for (int i = 2; i * i <= n; i++) if (spf[i] == i)
      for (int j = i * i; j <= n; j += i)
        if (spf[j] == j) spf[j] = i;
  }
  seti operator()(int x) {
    seti ret;
    while (x != 1) {
      ret.insert(spf[x]);
      x = x / spf[x];
    }
    return ret;
  }
} prime_factors(1000000);

int main() {
  int N;
  cin >> N;
  vi A(N);
  each(x, A) cin >> x;

  vi cnt(1000001);
  each(x, A) each(f, prime_factors(x)) cnt[f]++;
  int mx = 1;
  each(x, cnt) if (mx < x) mx = x;

  if (mx == 1) COUT("pairwise coprime");
  else if (mx < N) COUT("setwise coprime");
  else COUT("not coprime");
}

Measured memory_bytes: 14860
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
using namespace std;
typedef	long long int ll;

int main(){
    int n;
    int a;
    vector<int> v1, v2;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        if(i%2==0){
            v1.push_back(a);
        }
        else{
            v2.push_back(a);
        }
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    int sn, sv, nv, nn;
    nn = 100000000;
    sn = 0;
    sv = 1;
    nv = 1;
    for(int i = 0; i < n/2; i++){
        if(nn != v1[i]){
            if(nv >= sv){
                sv = nv;
                sn = nn;
            }
            nv = 1;
            nn = v1[i];
        }
        else{
            nv++;
        }
    }
    if(nv >= sv){
        sv = nv;
        sn = nn;
    }
    int sn1 = sn;
    int sv1 = sv;
    nn = 100000000;
    sn = 0;
    sv = 1;
    nv = 1;
    for(int i = 0; i < n/2; i++){
        if(nn != v2[i]){
            if(nv >= sv){
                sv = nv;
                sn = nn;
            }
            nv = 1;
            nn = v2[i];
        }
        else{
            nv++;
        }
    }
    if(nv >= sv){
        sv = nv;
        sn = nn;
    }
    int sn2 = sn;
    int sv2 = sv;
    if(sn1 != sn2){
        cout << n-sv1-sv2 << endl;
    }
    else{
        nn = 100000000;
        sn = 100000000;
        sv = 1;
        nv = 1;
        for(int i = 0; i < n/2; i++){
            if(v1[i] == sn1) continue;
            if(nn != v1[i]){
                if(nv >= sv){
                    sv = nv;
                    sn = nn;
                }
                nv = 1;
                nn = v1[i];
            }
            else{
                nv++;
            }
        }
        if(nv >= sv){
            sv = nv;
            sn = nn;
        }
        int sn_1 = sn;
        int sv_1 = sv;
        nn = 100000000;
        sn = 100000000;
        sv = 1;
        nv = 1;
        for(int i = 0; i < n/2; i++){
            if(v2[i] == sn2) continue;
            if(nn != v2[i]){
                if(nv >= sv){
                    sv = nv;
                    sn = nn;
                }
                nv = 1;
                nn = v2[i];
            }
            else{
                nv++;
            }
        }
        if(nv >= sv){
            sv = nv;
            sn = nn;
        }
        int sn_2 = sn;
        int sv_2 = sv;
        if(sn_1 == 100000000 && sn_2 == 100000000){
            cout << min(n-sv1, n-sv2) << endl;
        }
        if(sn_1 != 100000000 && sn_2 == 100000000){
            cout << n-sv_1-sv2 << endl;
        }
        if(sn_1 == 100000000 && sn_2 != 100000000){
            cout << n-sv1-sv_2 << endl;
        }
        if(sn_1 != 100000000 && sn_2 != 100000000){
            cout << min(n-sv1-sv_2, n-sv2-sv_1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	int a,odd=0,even=0;
	rep(i,n){
		cin >> a;
		if(a%2==1) odd++;
		else even++;
	}
	if(odd%2==0) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int S(int n) {
  int sum = 0;
  for (int i = 0; i < 100; i++) {
    if (n != 0) {
      sum += n % 10;
      n = n / 10;
    }
    else
      break;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  
  if(N % S(N) == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let number: u32 = iter.next().unwrap().parse().unwrap();
    let amount: u32 = iter.next().unwrap().parse().unwrap();

    let mut result = String::from("-1 -1 -1");
    'loop10000: for c10000 in 0..number + 1 {
        'loop5000: for c5000 in 0..(number - c10000) + 1 {
            let c1000 = number - (c5000 + c10000);
            if c10000 * 10000 + c5000 * 5000 + c1000 * 1000 == amount {
                result = format!(
                    "{} {} {}",
                    c10000.to_string(),
                    c5000.to_string(),
                    c1000.to_string()
                );
                break 'loop10000;
            }
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N;
  cin>>N;
  while(N--){
    int v[9],u[9];
    REP(i,9)cin>>v[i];
    REP(i,9)cin>>u[i];
    int sum = 0;
    int win = 0;
    int win2 = 0;
    sort(v, v+9);
    do{
      int t = 0;
      REP(i,9){
        if(v[i] > u[i])t += v[i] + u[i];
        else t -= v[i] + u[i];
      }
      if(t > 0) win ++;
      if(t < 0) win2 ++;
      sum++;
    }while(next_permutation(v, v+9));
    cout<<(double)win/sum<<" "<<(double)win2/sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 924
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll n, m;
vector<string> a, b;

int main() {
    fast_io; cout_precision;
    cin >> n >> m;
    a.resize(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    b.resize(m);
    for (ll i = 0; i < m; i++) {
        cin >> b[i];
    }
    for (ll i = 0; i <= n - m; i++) {
        for (ll j = 0; j <= n - m; j++) {
            for (ll x = 0; x < m; x++) {
                for (ll y = 0; y < m; y++) {
                    if (a[x + i][y + j] != b[x][y]) {
                        goto invalid;
                    }
                }
            }
            cout << "Yes" << endl;
            return 0;
            invalid:
            continue;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
/* 素数判定 */

#include <iostream>
#include <cmath>
#define NUM 10000
#define rep(i,a,b) for(i = a; i < b; i++)
using namespace std;

int isPrime(int);

int main(void) {

  int i, n, judge, count = 0;
  int T[NUM] = {};

  cin >> n;

  rep(i,0,n) {
    cin >> T[i];
  }

  rep(i,0,n) {
    judge = isPrime(T[i]);
    if(judge == 1) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

int isPrime(int x) {

  int i;

  if(x == 2) {
    return 1;
  } else if(x <= 1 || x % 2 == 0) {
    return 0;
  }

  for(i = 3; i <= sqrt(x); i += 2) {
    if (x % i == 0) {
      return 0;
    }
  }
  return 1;
}

Measured memory_bytes: 1208
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#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)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

map<LL, LL> m;

map<LL, LL> primes(LL n) {

	for (LL i = 2; i*i <= n; i++) {

			while (n%i == 0) {
				m[i]++;
				n /= i;
			}
		
	}

	if (n != 1)m[n]++;

	return m;

}

int main() {

	LL n; cin >> n;

	for (LL i = 1; i <= n; i++) {
		primes(i);
	}

	LL ans = 1;
	for (auto i : m) {
		ans = ans*((i.second+1)%MOD)%MOD;
	}

	cout << ans << endl;

	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 pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<int> v;

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

    sort(ALL(v));

    int ans = 1;
    int tmph = v[0];

    for(int i = 1; i < n; i++){
        if(v[i] > tmph){
            ans++;
            tmph = v[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())

def c(n):
  digit_sum = 0
  length = n
  for i in range(length):
    digit = n % 10
    digit_sum += digit
    n = n // 10
    if n == 0:
      break
      
  return digit_sum

min_sum = n
for a in range(1, n):
  b = n - a
  digit_sum = c(a) + c(b)
  if digit_sum < min_sum:
    min_sum = digit_sum

print(min_sum)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	for (int i = n - 1; i >= 0; i--) {
		printf("%d%c", v[i], i ? ' ' : '\n');
	}
}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
  long long X, A, B;
  cin >> X;

  for (int i = -200; i <= 200; i++) {
    for (int j = -200; j <= 200; j++) {
      if (X == (pow(i, 5) - pow(j, 5))) {
        A = i;
        B = j;
        break;
      }
    }
  }

  cout << A << ' ' << B << endl;
}

Measured memory_bytes: 3952
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<string> s(n);
	vector<int> p(n);
	for (int i = 0; i < n; i++) cin >> s[i] >> p[i];
	vector<int> tmp(n);
	for (int i = 1; i <= n; i++) {
		tmp[i - 1] = i;
	}
	int tmp1 = 0, tmp3 = 0;
	string tmp2 = "";
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i] < s[j]) {
				tmp2 = s[i];
				s[i] = s[j];
				s[j] = tmp2;
				tmp1 = p[i];
				p[i] = p[j];
				p[j] = tmp1;
				tmp3 = tmp[i];
				tmp[i] = tmp[j];
				tmp[j] = tmp3;
				int tmp1 = 0, tmp3 = 0;
				string tmp2 = "";
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i] == s[j] && p[i] > p[j]) {
				tmp1 = p[i];
				p[i] = p[j];
				p[j] = tmp1;
				tmp3 = tmp[i];
				tmp[i] = tmp[j];
				tmp[j] = tmp3;
				int tmp1 = 0, tmp3 = 0;
				string tmp2 = "";
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << tmp[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            int K = sc.nextInt();

            boolean[][] S = new boolean[H][W];
            int[] C = new int[H];
            for (int i = 0; i < H; i++) {
                int c = 0;

                char[] chars = sc.next().toCharArray();
                for (int j = 0; j < W; j++) {
                    if (chars[j] == '#') {
                        S[i][j] = true;
                        c++;
                    }
                }

                C[i] = c;
            }

            String[] ans = new String[H];
            int index = 1;
            for (int i = 0; i < H; i++) {
                if (C[i] == 0) {
                    if (i >= 1) {
                        ans[i] = ans[i - 1];
                    }
                    continue;
                }

                StringBuilder sb = new StringBuilder();
                boolean flag = false;
                for (int j = 0; j < W; j++) {
                    if (S[i][j]) {
                        if (flag) {
                            index++;
                        } else {
                            flag = true;
                        }
                    }
                    sb.append(index).append(" ");
                }
                ans[i] = sb.toString();
                index++;
            }

            for (int i = H - 2; i >= 0; i--) {
                if (ans[i] == null) {
                    ans[i] = ans[i + 1];
                }
            }

            StringBuilder ans2 = new StringBuilder();
            for (int i = 0; i < H; i++) {
                ans2.append(ans[i].substring(0, ans[i].length() - 1)).append("\n");
            }

            System.out.print(ans2.toString());
        }
    }

}


Measured memory_bytes: 35252
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N):
    ans+=B[A[i]-1]
    if i > 0:
        if A[i]-A[i-1]==1:
            ans+=C[A[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

struct edge {
    int to;
    int cost;
};
const int  INF = 1001001001;
signed main(){
    int n,m; cin >> n >> m;
    vector<edge> G[n];
    int d[n],prev[n];
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        G[b].pb({a,1});
        G[a].pb({b,1});
    }
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d,d+n,INF);
    fill(prev,prev+n,-1);
    d[0]=0; que.push(P(0,0));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        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;
                que.push(P(d[e.to], e.to));
                prev[e.to]=v;
            }
        }
    }
    cout << "Yes" << endl;
    rep(i,n){
        if(i==0) continue;
        cout << prev[i]+1 << endl;
    }
}



Measured memory_bytes: 13672