akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

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

bool comp(const string a, const string b) {
	return a.length() < b.length();
}
string six(int num) {
	string ans = to_string(num);
	while (ans.size() < 6) {
		ans = "0" + ans;
	}
	return ans;
}
vector<pair<int, int>> datas[100001];
	string ans[100000];
int main() {
	int n, m; cin >> n >> m;
	

	int p, y;
	for (int i = 0; i < m; i++) {
		cin >> p >> y;
		datas[p].push_back(make_pair(y, i));
	}
	for (int i = 1; i <= n; i++) {
		sort(datas[i].begin(), datas[i].end());
		for (int j = 0; j < datas[i].size(); j++) {
			ans[datas[i][j].second] = six(i) + six(j + 1);
		}
	}



	for (int i = 0; i < m; i++) {
		cout << ans[i] << endl;
	}
	




	//cout << endl;
	return 0;
}

Measured memory_bytes: 12416
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

S = input()
T = input()
ls = len(S)
lt = len(T)
dp = [[0 for _ in range(lt+5)] for i in range(ls+5)]
#最大値を求める
for i in range(ls):
    for j in range(lt):
        if S[i] == T[j]:
            dp[i+1][j+1] = max(dp[i][j]+1, dp[i+1][j], dp[i][j+1])
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

#復元部分
i = ls
j = lt
ans = ''
while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        ans = S[i-1] + ans
        i -= 1
        j -= 1
print(ans)

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


  int n, A[100000+1];
int binarySearch(int key) {
    int left = 0;
    int right = n;
    while(left < right) {
      int mid = (left + right) / 2;
      if(A[mid] == key) {
          return 1;
      } else if(key < A[mid])  {
          right = mid;
      } else {
          left = mid + 1;
      }
    }


      return 0;
}

int main () {
    cin >> n;

    for(int i = 0; i < n; i++) {
        cin >> A[i];
    }
    int q;
    cin >> q;
    int key;

    int sum = 0;
    for(int i = 0; i < q; i++) {
        cin >> key;
        if(binarySearch(key)) sum++;
    }

    cout << sum << endl;


}



Measured memory_bytes: 3396
import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
ans = 0
N = int(input())
c = collections.Counter(prime_factorize(N))
for i in c.values():
    j = 1
    while True:
        i -= j
        j += 1
        ans += 1
        if i - j < 0:
            break
print(ans)

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

class arrayInfo{
  private:
    int element=-1;
    map<string,string> value;
  public:
    bool isInRange(string index){
        return stoi(index)<element;
    }
    void set(string index, string val){
        if(isInRange(index)){
            value[index]=val;
        }else{
            throw 1;
        }
    }
    string get(string index){
        if(isInRange(index) && value.find(index)!=value.end()){
            return value[index];
        }else{
            throw 1;
        }
    }
    void setRange(string range){
        if(element==-1){
            element=stoi(range);
        }else{
            throw 1;
        }
    }
};
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

map<string, arrayInfo> ar;

string parse(string str, string type){
    int l,r;
    if(str.find("[")!=string::npos){
        l=str.find("[");
        r=str.rfind("]");
        if(type=="name") return str.substr(0,l);
        if(type=="index") return parse(str.substr(l+1,r-l-1), "value");
        if(type=="value") return ar[str.substr(0,l)].get(parse(str.substr(l+1,r-l-1), "value"));
    }
    return str;
}

int main(void){
    while(true){
        ar.erase(ar.begin(),ar.end());
        //cout<<"=========\n";
        string ln;
        cin>>ln;
        if(ln=="."){
            break;
        }
        int n=1;
        bool isOccured=false;
        while(ln!="."){
            try{
                if(ln.find("=")==string::npos){
                    ar[parse(ln,"name")].setRange(parse(ln,"index"));
                }else{
                    string ls=ln.substr(0,ln.find("="));
                    string rs=ln.substr(ln.find("=")+1);
                    ar[parse(ls,"name")].set(parse(ls,"index"),parse(rs,"value"));
                }
            }catch(...){
                isOccured=true;
                break;
            }
            n++;
            cin>>ln;
        }
        if(isOccured){
            cout<<n<<endl;
            while(cin>>ln,ln!=".");
        }else{
            cout<<0<<endl;
        }
    }
}

Measured memory_bytes: 3324
package main

import(
    "fmt"
    "sort"
    "strings"
    "strconv"
)



func main() {
    var a,b string
    fmt.Scan(&a,&b)
    ans := "No"
    c,_ := strconv.Atoi(a + b)
    for i:=1; i*i<=c; i++{
        if i*i == c{
            ans = "Yes"
        }
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
from collections import defaultdict
s = input()
mod = 2019
dct = defaultdict(int)
dct[0] = 1
x = 0
d = 1
for c in s[::-1]:
    x = (x+int(c)*d)%mod
    d = d*10%mod
    dct[x] += 1
ans = 0
for v in dct.values():ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 9836
#include <stdio.h>
#include <stdlib.h>
#define ms_valtype int

//比較関数
int compare_ms(ms_valtype a, ms_valtype b){
	return b - a;
}

//昇順
void sort_sub(ms_valtype *origin, int left, int right, ms_valtype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare_ms(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(ms_valtype *origin, int N){
	ms_valtype *tmp = (ms_valtype *)malloc(sizeof(ms_valtype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int main(){
	int N, H, i, ans;
	scanf("%d%d", &N, &H);
	int *a = (int *)malloc(sizeof(int) * (N + 1));
	int *b = (int *)malloc(sizeof(int) * (N + 1));
	int maxa = 0;
	for(i = 0; i < N; i++){
		scanf("%d%d", &a[i], &b[i]);
		if(a[i] > maxa){
			maxa = a[i];
		}
	}
	b[N] = 0;
	sort(b, N);
	ans = 0;
	for(i = 0; i <= N; i++){
		if(H <= 0){
			printf("%d\n", ans);
			return 0;
		}
		else if(b[i] > maxa){
			H -= b[i];
			ans++;
		}
		else{
			printf("%d\n", ans + (H + maxa - 1) / maxa);
			return 0;
		}
	}
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int n;
    cin >> n;
    int a[n], b[n];
    rep(i,n){
        cin >> a[i];
        b[a[i]-1] = i+1;
    }
    rep(i,n) cout << b[i] << " ";
    cout << endl; 
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int H,W,K;
  cin >> H >> W >> K;
  v(string) G(H);
  rep(i,H) {
    cin >> G[i];
  }
  int ans = 0;
  rep(hb,1<<H) {
    rep(wb,1<<W) {
      int cnt = 0;
      rep(i,H) {
        if((hb>>i)&1) continue;
        rep(j,W) {
          if((wb>>j)&1) continue;
          if(G[i][j]=='#') cnt++;
        }
      }
      if(cnt==K) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int n;
    int b, f, r, v;
    // 初期化
    int houses[4][3][10];
    for (b = 0; b < 4; b++) {
        for (f = 0; f < 3; f++) {
            for (r = 0; r < 10; r++) {
                houses[b][f][r] = 0;
            }
        }
    }

    // 入力の処理
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        // 入力の値を添字の形式に合わせるためにそれぞれ-1している。
        houses[b - 1][f - 1][r - 1] += v;
        if (houses[b - 1][f - 1][r - 1] < 0) {
            houses[b - 1][f - 1][r - 1] = 0;
        }
    }

    // 出力
    for (b = 0; b < 4; b++) {
        for (f = 0; f < 3; f++) {
            for (r = 0; r < 10; r++) {
                cout << " " << houses[b][f][r];
            }
            cout << endl;
        }
        if (b == 3) {
            continue;
        }
        cout << "####################" << endl;
    }
}



Measured memory_bytes: 3064
H, W, K = map(int, input().split())
c = [input() for _ in range(H)]

ans = 0
for R in range(2**H):
  for C in range(2**W):
    n = 0
    for y in range(H):
      if R>>y&1:
        for x in range(W):
          if C>>x&1:
            if c[y][x]=="#":
              n += 1
    if n==K:
      ans += 1
print(ans)


Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define lol long long
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
int i[100005];
lol sum[200005];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol a,b,c=0,d=0;
  lol ans=INF;
  cin >>a;
  cin >>b,sum[0]=b;
  for(int n=1;n<a;n++){
    cin >>b;
    sum[n]=sum[n-1]+b;
  }
  c=sum[a-1];
  for(int n=0;n<a-1;n++){
    ans=min(ans,abs(c-sum[n],sum[n]));
  }
  cout <<ans<<'\n';
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)x.size()
#define int ll

int get(int a, int b) {
	if (a == 0 || b == 0) {
		return 0;
	}
	if (a % b == 0) {
		return b * (a / b * 2 - 1);
	}
	int cnt = a / b;
	return b * cnt * 2 + get(b, a % b);
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, x;
	cin >> n >> x;
	if (2 * x == n) {
		cout << 3 * x << '\n';
		exit(0);
	}
	cout << n + get(max(x, n - x), min(x, n - x)) << '\n';
}

Measured memory_bytes: 256
ABCD = input()
ABCD = list(int(ABCD[i]) for i in range(4))

for i in range(8):
    result = ABCD[0]
    for j in range(3):
        if (1<<j & i)>>j:
            result += ABCD[j+1]
        else:
            result -= ABCD[j+1]

    if result == 7:
        result = i
        break

print(ABCD[0], end='')
print('+' if 1 & result else '-', end='')
print(ABCD[1], end='')
print('+' if 10 & result else '-', end='')
print(ABCD[2], end='')
print('+' if 100 & result else '-', end='')
print(str(ABCD[3]) + '=7')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

ll modinv(ll a, ll m = MOD) {
  ll b = m, u = 1, v = 0;
  while(b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if(u < 0) u += m;
  return u;
}

ll tf[2000000], ts[2000000], f[2000000];
int main() {
  tf[0] = ts[0] = f[0] = 1;
  for(int i = 1; i < 2000000; i++) {
    tf[i] = tf[i - 1] * 25 % MOD;
    ts[i] = ts[i - 1] * 26 % MOD;
    f[i] = f[i - 1] * i % MOD;
  }
  cin.tie(0);
  ios::sync_with_stdio(false);
  int k;
  string s;
  cin >> k >> s;
  int l = s.length();
  ll o = 0;
  for(int i = 1; i <= k + 1; i++) {
    ll c = f[k + l - i] * modinv(f[k - i + 1]) % MOD * modinv(f[l - 1]) % MOD;
    o = o + c * tf[k - i + 1] % MOD * ts[i - 1] % MOD;
    o %= MOD;
  }
  cout << o << '\n';
}

Measured memory_bytes: 51116
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tmp = ReadIntArray();
        int n = tmp[0], d = tmp[1];
        int m = 2 * d + 1; // number of trees per a watcher.
        WriteLine((n+m-1)/m);
    }
}


Measured memory_bytes: 11348
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>

int main () {
    int n;
    std::string s;
    std::cin >> n >> s;
    std::string ans = "";
    char tmp = s[0];
    for (int i = 0; i < n; i++)
    {
        if(tmp != s[i]) {
            ans += tmp;
            tmp = s[i];
        }
    }

    std::cout << ans.size() + 1 << std::endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, N, K);
  vector<pii> vp;
  rep(i, 0, N) {
    VAR(int, ai, bi);
    vp.push_back(pii(ai, bi));
  }
  sort(all(vp));

  rep(i, 0, N) {
    K -= vp[i].second;
    if (K < 1) {
      print(vp[i].first);
      return;
    }
  }
}


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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int n, count = 1, value = 1;
	cin >> n;
	VI p(n);
	IN(n,p);

	FOR(1, n)
	{
		if (p[i] > p[i - value])
		{
			value++;
		}
		else
		{
			count++;
			value = 1;
		}
	}

	cout << count;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = acos(-1.0);

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

int main() {
    char c; cin >> c;
    
    map<char, char> mp;
    mp['A'] = 'T';
    mp['C'] = 'G';
    mp['G'] = 'C';
    mp['T'] = 'A';

    cout << mp[c] << endl;
    return 0;
}


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

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(a*c,b*d), max(a*d, b*c));
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

ll n,k;
vector<long long> a;

inline long long solve(ll x){
  ll ret = 0;
  for(ll i = 0; i < n; i++){
    ret += (a[i]+x-1)/x-1;
    if(ret > k) break;
  }
  return ret;
}

int main(){
  cin >> n >> k;
  a.resize(n);
  int mx = 0;
  for(ll i = 0; i < n; i++){
    cin >> a[i];
    if(mx < a[i]) mx = a[i];
  }
  if(k == 0){
    cout << mx << endl;
    return 0;
  }
  ll right = mx+1,left = 0,mid;
  while(right-left > 1){
    mid = (right+left)/2;

    ll cnt = solve(mid);
    //cout << mid << " " << cnt << " " << left << " " << right << endl;
    if(cnt > k) left = mid;
    else right = mid;
  }
  cout << right << endl;
  return 0;
}


Measured memory_bytes: 4688
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

int main()
{
    int n;
    cin >> n;

    cout << pow(n, 3) << endl;
}

Measured memory_bytes: 256
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define N 100005
#define int long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,k,ans,sum[N],a[N],pre[N],suf[N];
main()
{
	re(n);re(k);
	for(int i=1;i<=n;++i)
		re(a[i]),sum[i]=sum[i-1]+a[i];
	for(int i=1;i<=n;++i)
		pre[i]=pre[i-1]+max(a[i],0ll);
	for(int i=n;i;--i)
		suf[i]=suf[i+1]+max(a[i],0ll);
	for(int i=1;i+k-1<=n;++i)
		ans=max(ans,pre[i-1]+suf[i+k]+max(0ll,sum[i+k-1]-sum[i-1]));
	printf("%lld\n",ans);
}


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

using namespace std;

bool s[100][100];

int min_cnt_w[100][100]; // Whiteの状態でたどりついたときの最小回数
int min_cnt_b[100][100]; // Blackの状態でたどり着いたときの最小回数

struct Data{
  int cnt; // 白黒判定反転カウント
  int i; // 縦方向
  int j; // 横方向
  bool s; // 反転せずに移動できるカラー true white false black

  Data(){
    cnt = 0;
    i = 0;
    j = 0;
    s = true;
  }

  Data(int in_cnt, int in_i, int in_j, bool in_s){
    cnt = in_cnt;
    i = in_i;
    j = in_j;
    s = in_s;
  }
};

int main(){
  int h, w;
  cin >> h >> w;
  cin.ignore();

  string str;

  for(int i = 0; i < h; i++){
    cin >> str;
    cin.ignore();
    for (int j = 0; j < w; j++){
      if(str[j] == '#'){
        s[i][j] = false;
      } else {
        s[i][j] = true;
      }
    }
  }

  // min初期化
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      min_cnt_w[i][j] = INT_MAX;
      min_cnt_b[i][j] = INT_MAX;
    }
  }

  // BFS (ある意味最短路)
  stack<Data> stk;
  Data t;
  if(s[0][0] == false){
    t = Data(1, 0, 0, false); // いきなり黒だった場合
    //min_cnt_b[0][0] = 0;
  } else {
    t = Data();
    //min_cnt_w[0][0] = 0;
  }

  int min_cnt = INT_MAX;

  stk.push(t);

  while(!stk.empty()){

    // qからpop
    t = stk.top();
    stk.pop();

    // 枝狩り　最小値以上のときはもう探索済み
    if(t.s == true){
      if(min_cnt_w[t.i][t.j] <= t.cnt){
        continue;
      } else {
        min_cnt_w[t.i][t.j] = t.cnt;
      }
    } else if(min_cnt_b[t.i][t.j] <= t.cnt){
      continue;
    } else {
      min_cnt_b[t.i][t.j] = t.cnt;
    }
    // すでに(h-1, w-1) ならこれまでの最小値と比較し更新
    if((t.i == h-1) && (t.j == w - 1)){
      if(min_cnt > t.cnt){
        min_cnt = t.cnt;
      }
      continue;
    }
    
    //// .i=h-1でないなら横移動
    if(t.i < h-1){
      if(s[(t.i)+1][t.j] == t.s){
        stk.push(Data(t.cnt, (t.i)+1, t.j, t.s));
      } else {
        // 白から黒にかわるときだけカウントプラス
        if(t.s == true){
          stk.push(Data((t.cnt)+1, (t.i)+1, t.j, !(t.s)));
        } else
          stk.push(Data(t.cnt, (t.i)+1, t.j, !(t.s)));
      }
    }

    if(t.j < w-1){
      if(s[t.i][(t.j)+1] == t.s){
        stk.push(Data(t.cnt, t.i, (t.j)+1, t.s));
      } else {
        if(t.s == true){
          stk.push(Data((t.cnt)+1, t.i, (t.j)+1, !(t.s)));
        } else {
          stk.push(Data(t.cnt, t.i, (t.j)+1, !(t.s)));
        }
      }
    }
  }

  cout << min_cnt << endl;
}


    


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

using namespace std;

typedef long long int64;

int N, A[100000];

int64 rec(int idx, int delta, int64 sum)
{
  if(idx == N) {
    return (0);
  } else if(delta == 1) {
    if(sum + A[idx] > 0) return (rec(idx + 1, -1, sum + A[idx]));
    return (rec(idx + 1, -1, 1) + 1 - (sum + A[idx]));
  } else {
    if(sum + A[idx] < 0) return (rec(idx + 1, 1, sum + A[idx]));
    return (rec(idx + 1, 1, -1) + (sum + A[idx]) - (-1));
  }
}

int main()
{
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  cout << min(rec(0, 1, 0), rec(0, -1, 0)) << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2==0){
        puta((b-a)/2);
    }else{
        puta(min( {(b-1), (n-a), min(a-1,n-b)+1+(b-a-1)/2 }));
    }
    return 0;
}

Measured memory_bytes: 256
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 = sc.nextInt();
   int B = sc.nextInt();
if(N*A >= B){
   System.out.println(B);
  }else{
  System.out.println(N*A);
}
 }
}

Measured memory_bytes: 21716
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, T;
    cin >> N >> T;
    vector<int> A(N), B(N);
    for (int n = 0; n < N; ++n) {
        cin >> A[n] >> B[n];
    }
    int MaxA = 0;
    for (int n = 0; n < N; ++n) {
        if (MaxA < A[n]) MaxA = A[n];
    }

    vector<vector<int>> DP(N+1, vector<int>(T, 0));
    for (int n = 0; n < N; ++n) {
        for (int t = 1; t < T; ++t) {
            DP[n+1][t] = DP[n][t];
            if (t >= A[n]) {
                int Tmp = DP[n][t-A[n]] + B[n];
                if (Tmp > DP[n+1][t]) {
                    DP[n+1][t] = Tmp;
                }
            }
        }
    }
    
    vector<vector<int>> RDP(N+1, vector<int>(T, 0));
    for (int n = N-1; n >= 0; --n) {
        for (int t = 1; t < T; ++t) {
            RDP[n][t] = RDP[n+1][t];
            if (t >= A[n]) {
                int Tmp = RDP[n+1][t-A[n]] + B[n];
                if (Tmp > RDP[n][t]) {
                    RDP[n][t] = Tmp;
                }
            }
        }
    }
    
    int Res = 0;
    for (int n = 0; n < N; ++n) {
        int Max = 0;
        for (int t = 0; t < T; ++t) {
            int Tmp = DP[n][t] + RDP[n+1][T-1-t];
            if (Max < Tmp) Max = Tmp;
        }
        Max += B[n];
        if (Res < Max) Res = Max;
    }
    cout << Res << endl;
    
    return 0;
}


Measured memory_bytes: 70912
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
int dh[]={1,-1,0,0};
int dw[]={0,0,1,-1};


int main(){
      int n;
      cin>>n;
      int h[n];
      rep0(i,n){
            cin>>h[i];
      }
      int ans=0;
      while(1){
            int max_=0;
            int min_=inf;
            rep0(i,n){
                  if(h[i]>max_) max_=h[i];
                  if(h[i]>0&&h[i]<min_) min_=h[i];
            }
            if(max_==0) break;
            rep0(i,n){
                  if(h[i]==min_){
                        int j=i-1;
                        while(1){
                              if(j<0) break;
                              if(h[j]<min_) break;
                              h[j]-=min_;
                              j--;
                        }
                        int k=i;
                        while(1){
                              if(k>=n) break;
                              if(h[k]<min_) break;
                              h[k]-=min_;
                              k++;
                        }
                        ans+=min_;
                        i=n;
                  }
            }
      }
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int64_t N, ans;
  cin >> N;
  vector<int64_t> A(N);
  for (int64_t i=0; i<N; i++) {
    cin >> A[i];
  }
  ans=A[0];
  for (int64_t i=0; i<N; i++) {
    ans=gcd(ans,A[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4032
// D - String Equivalence
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	set<string> s{"a"};
	while(--N){
		set<string>t; swap(s,t);
		for(auto pre:t){
			char mx='a'; for(auto c:pre) mx = max(mx, c); mx++;
			for(char c='a'; c<=mx; ++c) s.insert(pre + c);
		}

	}
	for(auto x:s) cout<< x <<endl;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end



int main(){
   int n; scanf("%d",&n);
   if(n==1){
      printf("1\n0\n");
   }
   else if(n==2){
      printf("2\n0\n11\n");
   }
   else{
      printf("%d\n",n-1);
      rep(i,2,n+1){
         string s; rep(_,0,i)s+='0';
         s[0]=s[i-1]='1';
         cout<<s<<endl;
      }
   }
   return 0;
}


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

int main(){
    int n;
    cin >> n;

    bool can = false;
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if(n == i*j){
                can = true;
                break;
            }
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
X, K, D = map(int, input().split())
# まずは0に近づける

if X < 0:
    t = min(X//(-D), K)
    X = X + D*t
    K -= t
else:
    t = min(X//(D), K)
    X = X - D*t
    K -= t

if K % 2 == 1:
    if X >= 0:
        X -= D
    else:
        X += D

print(abs(X))


Measured memory_bytes: 9184
#include<iostream>
using namespace std;
int main()
{
  long long int n,a=1,b=1,c=1,count=0,temp;
  cin>>n;
  temp=n;
  for(a=1;a<n;a++)
  {
    for(b=1;b<temp;b++)
    {
      if(a*b<n)
        count++;
      else
        break;
    }
    temp=b;
  }
  cout<<count;
  return 0;
}  

Measured memory_bytes: 3656
#include <bits/stdc++.h>
              
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
//#define int ll
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

using namespace std;

const int maxn = (int) 2e5 + 100;
const int mod = (int)1e9 + 7;
const int P = (int) 1e6 + 7; 

#define inf mod

typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;                        


int n, a[maxn], dp[maxn];                                      
int main () {
  cin >> n;
  forn(i, 1, n) cin >> a[i];
  forn(i, 2, n) dp[i] = inf;
  dp[1] = 0;
  forn(i, 1, n){
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i + 1] - a[i]));
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i + 2] - a[i]));
  }
  cout << dp[n];
}


Measured memory_bytes: 1024
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] speed = new int[n-1];
        int[] first = new int[n-1];
        int[] start = new int[n-1];
        
        for(int i = 0; i < n-1; i++){
          speed[i] = sc.nextInt();
          first[i] = sc.nextInt();
          start[i] = sc.nextInt();
        }
      
        for(int i = 0; i < n; i++){
        int time = 0;
         for(int j = i; j < n-1; j++){
          if(time < first[j]){
            time = first[j] + speed[j];
          }else if(time % start[j] ==0){
            time += speed[j];
          }else{
            time = time + start[j] - (time % start[j]) + speed[j];
         }
       }
           System.out.println(time);
     }
  }
}


Measured memory_bytes: 39536
#include<stdio.h>
int main(void)
{
int k, x, y, n, a, b;
	scanf("%d",&n);
	scanf("%d",&k);
	scanf("%d",&x);
	scanf("%d",&y);
	a=n-k;
	if(a>=1){
	b=k*x+a*y;
	}
	if(a<1){
	b=n*x;
	}
	printf("%d\n",b);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
using namespace std;
using P = pair<int,int>; //to,length
using Graph = vector<vector<P>>;

int main() {
    int n;
    cin >> n;
    Graph g(n);
    rep(i,n-1) {
        int u,v,w;
        cin >> u >> v >> w;
        u--; v--;
        g[u].push_back({v,w});
        g[v].push_back({u,w});
    }
    vector<int> ans(n);
    ans[0] = 0;
    queue<P> q; //now,parent
    q.push({0,-1});
    while(!q.empty()) {
        P nq = q.front();
        q.pop();
        for(P p : g[nq.first]) {
            int pf = p.first;
            int ps = p.second;
            if(pf == nq.second) continue;
            if(ps%2 == 0) ans[pf] = ans[nq.first];
            else ans[pf] = 1-ans[nq.first];
            q.push({pf,nq.first});
        }
    }
    rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 6784
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var Ai = Sarray();

            var p = Ai[0];
            var q = 0L;
            var r = Ai[1] + Ai[2];
            var s = Ai.Sum() - Ai.Take(3).Sum();
            var diff = long.MaxValue;
            for (long bc = 1, de = 2, ef = 3; de < N - 1; ++de)
            {
                q = q + Ai[de - 1];
                for (var i = bc + 1; i < de; ++i)
                {
                    var d = Abs(p - q);
                    var np = p + Ai[i - 1];
                    var nq = q - Ai[i - 1];
                    if (Abs(np - nq) < d)
                    {
                        p = np;
                        q = nq;
                        bc = i;
                    }
                    else
                        break;
                }
                r = r - Ai[de - 1];
                for (var i = ef + 1; i < N; ++i)
                {
                    var d = Abs(r - s);
                    var nr = r + Ai[i - 1];
                    var ns = s - Ai[i - 1];
                    if (Abs(nr - ns) < d)
                    {
                        r = nr;
                        s = ns;
                        ef = i;
                    }
                    else
                        break;
                }
                var maxPqrs = Max(Max(p, q), Max(r, s));
                var minPqrs = Min(Min(p, q), Min(r, s));
                diff = Min(diff, maxPqrs - minPqrs);
            }
            WriteLine(diff);
        }
 
        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 44708
n, m, x = gets.split(" ").map(&:to_i)
as = gets.split(" ").map(&:to_i)

left = (0..n).to_a[1...x]
right = (0..n).to_a[x+1..-1]

l_count =left.reduce(0){|a,e|a+=as.include?(e) ? 1 : 0}
r_count = right.reduce(0){|a,e|a+=as.include?(e) ? 1 : 0}

puts [l_count, r_count].min

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
const ll inf=1e15;
const int mod=1e9+7;
ll num[maxn];
ll ans;
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>num[i];
    for(int i=1;i<=n;i++)
        if(num[i-1]<num[i])
            ans+=num[i]-num[i-1];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def getKetaSum(val):
    sum = 0
    while val != 0:
        sum += val % 10
        val //= 10
    return sum

N,A,B = map(int, input().split())
ans = 0
for i in range(1, N + 1):
    sum = getKetaSum(i)
    if A <= sum and sum <= B:
        ans += i

print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <cctype>
#include <climits> // INT_MAX ...
#include <cstring> //

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    string as = "", bs = "";
    for (int i = 0; i < a; ++i) as += b + 0x30;
    for (int i = 0; i < b; ++i) bs += a + 0x30;
    if (stoi(as) < stoi(bs)) cout << bs << endl;
    else cout << as << endl;

    return 0;
}

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

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

int main (){
    cin.tie(0);
    int nn,n,s;
    int a[8] ={};
    cin >> n ;
    nn = n;
    REP(i,8){
        a[i] = n % 10;
        n = (n- n%10)/10;
    }
    s = 0;
    REP(i,8){
        s += a[i];
    }
    cout << ((nn % s == 0)? "Yes":"No") << "\n";
    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()

dict1, dict2 = {}, {}

for i in list(S):
    dict1[i] = dict1.get(i, 0) + 1

for i in list(T):
    dict2[i] = dict2.get(i, 0) + 1


if sorted(dict1.values()) == sorted(dict2.values()) :
    print("Yes")
else :
    print("No")


Measured memory_bytes: 5168
#include <stdio.h>

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    
    int a[n][m];
    int b[m];
    
    int i, j;
    int c[n];

    for(i = 0;i<n;i++){
        for(j = 0;j < m;j++){
            scanf("%d", &a[i][j]);
        }
    }

    for(j = 0;j < m;j++){
            scanf("%d", &b[j]);
        }

    for(i = 0;i < n;i++){
      c[i] = 0;
    }

    
    for(i = 0;i<n;i++){
        for(j = 0;j < m;j++){
	  c[i] += a[i][j]*b[j];
        }
    }
    
    for(i = 0;i < n;i++){
        printf("%d\n", c[i]);
    }
    
    
    return 0;
}



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

#define MAX 1000

int N;
long long V;
long long a[4][MAX];

long long v1[MAX * MAX];

int main()
{
	cin >> N >> V;
	for( int i = 0; i < 4; i++ ) {
		for( int j = 0; j < N; j++ ) {
			cin >> a[i][j];
		}
	}

	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			v1[i * N + j] = a[0][i] + a[1][j];
		}
	}
	sort( v1, v1 + N*N );
	long long ans = 0;
	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) {
			long long v = V - a[2][i] - a[3][j];
			ans += upper_bound( v1, v1 + N*N, v ) - lower_bound( v1, v1 + N*N, v );
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 11020
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    rep(i, N) cin >> A[i];
    sort(A, A + N);
    int sum = A[0];
    int cnt = 0;
    rep(i, N - 1) {
        if (sum * 2 >= A[i + 1]) cnt++;
        else cnt = 0;
        sum += A[i + 1];
    }
    cout << cnt + 1 << endl;

    return 0;
}


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

using namespace std;

#define ll long long

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	ll n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; ++i)
		cin >> a[i];
	vector<ll> primes = { 2, 3, 5, 7, 11, 13 };
	for (ll i = 17; i < 100000; i += 2) {
		bool ok = true;
		for (ll j = 0; primes[j] * primes[j] <= i; ++j) {
			if (i % primes[j] == 0) {
				ok = false;
				break;
			}
		}
		if (ok)
			primes.emplace_back(i);
	}
	
	map<ll, ll> cnt;
	for (ll i : a) {
		ll t = i;
		for (ll j = 0; primes[j] * primes[j] <= t; ++j) {
			if (t % primes[j] == 0) cnt[primes[j]]++;
			while (t % primes[j] == 0) t /= primes[j];
		}
		if (t != 1) cnt[t]++;
	}
	
	ll hi = 0;
	for (auto p : cnt) hi = max(hi, p.second);
	if (hi <= 1) {
		printf("pairwise coprime");
		return 0;
	}
	
	printf(hi < n ? "setwise coprime" : "not coprime");
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;

const int X = 3e8;

void add(vi &t, int x, int a, int y, int b) {
    int q = (x - y) / (b - a);
    if (q > 0 && q <= X * 2) {
        t.push_back(q);
    }
}

ll calc(int x[], int y[], char d[], int n, int t) {
    int x0 = X, x1 = -X, y0 = X, y1 = -X;
    for (int i = 0; i < n; i++) {
        int cx = x[i], cy = y[i];
        if (d[i] == 'R') {
            cx += t;
        } else if (d[i] == 'L') {
            cx -= t;
        } else if (d[i] == 'U') {
            cy += t;
        } else if (d[i] == 'D') {
            cy -= t;
        }

        x0 = min(x0, cx);
        x1 = max(x1, cx);
        y0 = min(y0, cy);
        y1 = max(y1, cy);
    }

    return 1ll * (x1 - x0) * (y1 - y0);
}

int main() {
    int n;
    cin >> n;
    int x[n], y[n];
    char d[n];
    int x0[6], y0[6];
    x0[0] = x0[2] = x0[4] = y0[0] = y0[2] = y0[4] = X;
    x0[1] = x0[3] = x0[5] = y0[1] = y0[3] = y0[5] = -X;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> d[i];
        x[i] *= 2, y[i] *= 2;
        if (d[i] == 'R') {
            x0[4] = min(x0[4], x[i]);
            x0[5] = max(x0[5], x[i]);
            y0[2] = min(y0[2], y[i]);
            y0[3] = max(y0[3], y[i]);
        } else if (d[i] == 'L') {
            x0[0] = min(x0[0], x[i]);
            x0[1] = max(x0[1], x[i]);
            y0[2] = min(y0[2], y[i]);
            y0[3] = max(y0[3], y[i]);
        } else if (d[i] == 'U') {
            x0[2] = min(x0[2], x[i]);
            x0[3] = max(x0[3], x[i]);
            y0[4] = min(y0[4], y[i]);
            y0[5] = max(y0[5], y[i]);
        } else if (d[i] == 'D') {
            x0[2] = min(x0[2], x[i]);
            x0[3] = max(x0[3], x[i]);
            y0[0] = min(y0[0], y[i]);
            y0[1] = max(y0[1], y[i]);
        }
    }

    vector<int> t;
    for (int i = 0; i < 3; i++) {
        for (int j = i + 1; j < 3; j++) {
            for (int k = 0; k < 2; k++) {
                add(t, x0[i*2+k], i - 1, x0[j*2+k], j - 1);
                add(t, y0[i*2+k], i - 1, y0[j*2+k], j - 1);
            }
        }
    }
    t.push_back(0);
    sort(t.begin(), t.end());

    ll ans = calc(x, y, d, n, 0);
    for (int i = 1; i < t.size(); i++) {
        int l = t[i-1], r = t[i];
        while (r - l >= 2) {
            int m1 = (l * 2 + r - 1) / 3 + 1;
            int m2 = (l + r * 2) / 3;

            ll a1 = calc(x, y, d, n, m1);
            ll a2 = calc(x, y, d, n, m2);

            if (a1 < a2) {
                r = m2;
            } else {
                l = m1;
            }
        }

        ans = min(ans, calc(x, y, d, n, t[i]));
        ans = min(ans, calc(x, y, d, n, l));
        ans = min(ans, calc(x, y, d, n, r));
    }

    cout << ans / 4 << "." << ans % 4 * 25 << endl;

    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>

#pragma warning(disable : 4996)

int N, M, K, P, L[100]; bool ok[100][100];

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

		if (N == 0) break;

		memset(ok, false, sizeof(ok));

		for (int i = 0; i < N; i++)
		{
			scanf("%d", &M);

			for (int j = 0; j < M; j++)
			{
				scanf("%d", &P);

				ok[i][P - 1] = true;
			}
		}

		scanf("%d", &K);

		for (int i = 0; i < K; i++) scanf("%d", &L[i]);

		int count_ = 0, ptr = -1;

		for (int i = 0; i < N; i++)
		{
			bool flag = true;

			for (int j = 0; j < K; j++)
			{
				if (!ok[i][L[j] - 1])
				{
					flag = false; break;
				}
			}

			if (flag)
			{
				count_++; ptr = i + 1;
			}
		}

		printf("%d\n", count_ == 1 ? ptr : -1);
	}

	return 0;
}

Measured memory_bytes: 2688