akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,ans=0ll;
  cin>>N;
  for(ll i=1ll;i*i<N;i++){
    if(N%i==0 && (N/i-i)!=1){
      ans+=(N/i-1);
    }
  }

  cout<<ans<<endl;

}



Measured memory_bytes: 256
#include <stdio.h>
 int main()
{ int a,b,h;
  scanf("%d%d%d",&a,&b,&h);
  if(a>100||a==0,b>100||b==0,h>100||h==0)
  {
  return 0;
  }
  else
  {
  printf("%d",(a+b)*h/2);
}
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define HASH_SIZE 65536

struct list {
    int num;
    int val;
    struct list *next;
};

struct list *create_htable(void) {
    static struct list htable[HASH_SIZE];
    int i;
    for(i = 0; i < HASH_SIZE; i++) {
        htable[i].next = &htable[i];
    }
    return htable;
}

int get_key(int num) {
    return num & (HASH_SIZE-1);
}

struct list* find(struct list *htable, int num) {
    struct list *head = &htable[get_key(num)];
    struct list *elem;
    for(elem = head->next; elem != head; elem = elem->next) {
        if(elem->num == num) {
            return elem;
        }
    }
    return NULL;
}

int find_val(struct list *htable, int num) {
    struct list *elem = find(htable, num);
    return (elem) ? elem->val : 0;
}

void add_elem(struct list *htable, int num) {
    struct list *elem = find(htable, num);
    if(elem) {
        elem->val++;
        return;
    }
    elem = malloc(sizeof(struct list));
    struct list *head = &htable[get_key(num)];
    elem->next = head->next;
    elem->num = num;
    elem->val = 1;
    head->next = elem;
}

void put_elem(struct list *htable, int num) {
    struct list *elem = find(htable, num);
    if(!elem) return;
    if(elem->val) elem->val--;
    return;
}

#define NUM_MAX 100000

int main(void) {
    static int arr[NUM_MAX];
    int num, divisor;
    get_int2(&num, &divisor);
    fget_array(arr, num);
    struct list *htable = create_htable();
    int i;
    int sum = 0;
    for(i = 0; i < num; i++) {
        sum = (sum + arr[i])%divisor;
        add_elem(htable, sum);
    }

    int64_t ans = find_val(htable, 0);
    int offset = 0;
    for(i = 0; i < num-1; i++) {
        offset = (offset + arr[i])%divisor;
        put_elem(htable, offset);
        ans += find_val(htable, offset);
    }

    printf("%lld\n", ans);
    return 0;
}

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

int main() {
int R;
cin >> R;
if(R < 1200){
	cout << "ABC" << endl;
   }
   else if(R < 2800){
   	cout << "ARC" <<endl;
   }
   else{
   	cout << "AGC" << endl;
   }
}


Measured memory_bytes: 256
/*  
    |\_/|
    |* *|
    \_+_/
*/
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  string str;

  cin>>str;

  for(int i=0;i<str.length()-8;i++){
    cout<<str[i];
  }
  
  cout<<endl;
   
  return 0;
  
}




Measured memory_bytes: 256
a,b=map(int,input().split())
i=0
j=0
while a>0 or b>0:
    for i in range(a):
        if i%2==0:
            for j in range(b):
                if j%2==0:
                    print("#",end='')
                else:
                    print(".",end='')
            print()
        else:
            for j in range(b):
                if j%2==0:
                    print(".",end='')
                else:
                    print("#",end='')
            print()
    print()
    a,b=map(int,input().split())
    


Measured memory_bytes: 7000
#include <bits/stdc++.h>
#include <atcoder/all>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
	if (ref < value) ref = value;
}

using namespace atcoder;

typedef modint998244353 mint;

struct S {
    mint value;
    int length;
};

vector<mint> ones;
vector<mint> tens;

S op(S a, S b) {
    mint val = tens[b.length] * a.value + b.value;
    return { val, a.length + b.length };
}

S e() {
    return { 0, 0 };
}

struct F {
    int d;
};

S mapping(F func, S s) {
    if (func.d == 0) return s;
    mint val = ones[s.length] * func.d;
    return { val, s.length };
}

F composition(F func1, F func2) {
    if (func1.d == 0) return func2;
    return func1;
}

F id() {
    return {0};
}

int main() {
    ll n, q;
    cin >> n >> q;    
    ones.resize(n+1, 0);
    tens.resize(n+1, 0);
    {
        mint v = 0;
        for (int i = 0; i <= n; i++) {
            ones[i] = v;
            v = v * 10 + 1;
        }
        v = 1;
        for (int i = 0; i <= n; i++) {
            tens[i] = v;
            v = v * 10;
        }
    }
    S seed = { 1, 1 };
    lazy_segtree<S, op, e, F, mapping, composition, id> tree(vector<S>(n, seed));
    rep(_, q) {
        int left, right, d;
        cin >> left >> right >> d;
        left--;
        tree.apply(left, right, { d });
        cout << tree.all_prod().value.val() << endl;
    }
    return 0;
}


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

typedef struct {
	int a; char op1;
	int b; char op2;
	int c; char op3;
	int d;
} forula;

int	calc(int x, char op, int y) {
	if (op == '+')
		return (x + y);
	else if (op == '-')
		return (x - y);
	return (0);
}

bool check(forula a) {
	int x = calc(a.a, a.op1, a.b);
	x = calc(x, a.op2, a.c);
	x = calc(x, a.op3, a.d);
	if (x == 7)
		return (true);
	return (false);
}

void change(forula &a, int n) {
	if (n % 2)	a.op1 = '+';
	else				a.op1 = '-';
	n /= 2;
	if (n % 2)	a.op2 = '+';
	else				a.op2 = '-';
	n /= 2;
	if (n % 2)	a.op3 = '+';
	else				a.op3 = '-';
}

void	sertch(forula &a, int n) {
	change(a, n);
	while (!check(a))
		change(a, ++n);
}

int	main() {
	string line;
	forula a;
	cin >> line;
	a.a = line[0] - '0';
	a.b = line[1] - '0';
	a.c = line[2] - '0';
	a.d = line[3] - '0';
	sertch(a, 0);
	cout << a.a << a.op1 << a.b << a.op2 << a.c << a.op3 << a.d << "=7" << endl;
}

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

int main(){
	int n;
	int ans=0;
	std::string a, b, c;

	std::cin>>n;
	std::cin>>a>>b>>c;

	for(int i=0; i<a.size(); i++){
		std::set<char> aList;
		aList.insert(a[i]);
		aList.insert(b[i]);
		aList.insert(c[i]);

		ans+= aList.size()-1;
	}

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

Measured memory_bytes: 256
N = int(input())
sticks = list(map(int, input().split()))
s_dict = {}
for stick in sticks:
  if stick in s_dict:
    s_dict[stick] += 1
  else:
    s_dict[stick] = 1
sorted_dict = sorted(s_dict.items(), key=lambda x:-x[0])
side1 = 0
side2 = 0
for elem in sorted_dict:
  if elem[1] >= 4:
    if side1 == 0:
      side1 = side2 = elem[0]
    else:
      side2 = elem[0]
  elif elem[1] == 2 or elem[1] == 3:
    if side1 == 0:
      side1 = elem[0]
    else:
      side2 = elem[0]
  if side1 != 0 and side2 != 0:
    print(side1*side2)
    exit()
print(0)

Measured memory_bytes: 24972
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
L, R = ZIP(M)
l, r = max(L), min(R)
print(0 if l > r else r-l+1)


Measured memory_bytes: 59608
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  ll mod=1000000007;
  int n;
  cin>>n;
  vector<ll>a(n);
  rep(i,n) cin>>a[i];
  ll sum=0;
  rep(i,n) {
    sum+=a[i];
  }
  ll ans=0;
  rep(i,n){
    sum-=a[i];
    ll x=sum;
    x%=mod;
    x*=a[i];
    x%=mod;
    ans+=x;
    ans%=mod;
  }
  cout<<ans<<endl;
}

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

class Counter{
    int cnt;
public:
    Counter():cnt(0){}
    int show(){return cnt;}
    void up(){++cnt;}
    void down(){--cnt;}
};

void swap(int& a,int& b){
    int t=a;
    a=b;
    b=t;
}

int main(){
    Counter counter;
    int n;
    cin>>n;
    int* array=new int[n];
    for(int i=0;i<n;++i){
        cin>>array[i];
    }

    for(int i=0;i<n;++i){
        int min=i;
        for(int j=i;j<n;++j){
            if(array[j]<array[min]){
                min=j;
            }
        }
        if(i!=min){
            swap(array[i],array[min]);
            counter.up();
        }
    }
    for(int i=0;i<n;++i){
        cout<<array[i];
        if(i!=n-1){
            cout<<" ";
        }
    }
    cout<<"\n";
    cout<<counter.show()<<"\n";
}

Measured memory_bytes: 3060
inp1 = input()
n = int(inp1.split(" ")[0])
k = int(inp1.split(" ")[1])
q = int(inp1.split(" ")[2])

each_point = []
for i in range(n):
  each_point.append(k-q)
 
for j in range(q):
  each_point[int(input())-1] += 1
 
for x in range(n):
  if (each_point[x] < 1):
    print("No")
  else:
    print("Yes")

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

int main(){
	string s,p;
	cin>>s>>p;
	string part;
	bool ans=false;
	for(int i=0;i<s.length();++i){
		if(s[i]==p[0]){
			part=(s+s).substr(i,p.length());
			if(part==p){
				ans=true;
				break;
			}
		}
	}
	if(ans==true)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 3204
# ARC102C - Triangular Relationship (ABC108C)
def main():
    N, K = list(map(int, input().rstrip().split()))
    a = N // K
    if K % 2 != 0:  # K: odd
        print(a ** 3)
    else:  # K: even
        b = (N + K // 2) // K
        print(a ** 3 + b ** 3)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, ans;
	cin >> n;
	vector<long long> a(n + 1), dp(n + 1, 0);
	for (i = 1; i <= n; i++) cin >> a[i];
	dp[0] = 1000;
	for (i = 1; i <= n; i++) {
		dp[i] = dp[i - 1];
		for (j = 0; j < i; j++) {
			dp[i] = max(dp[i], dp[j] / a[j + 1] * a[i] + (dp[j] % a[j + 1]));
		}
	}

	ans = dp[n];
	cout << ans << "\n";

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll x, ans=0, num=0;
	cin >> x;
	while(num < x){
		++ans;
		num = (ans*(ans+1))/2;
	}
	cout << ans;

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    ll N,M,D[200100],T[200100];
    cin>>N;
    rep(i,0,N){
        cin>>D[i];
    }
    cin>>M;
    rep(i,0,M){
        cin>>T[i];
    }
    sort(D,D+N);
    sort(T,T+M);
    ll now=0,ok=0;
    rep(i,0,M){
        rep(j,now,N){
            if(T[i]==D[j]){
                D[j]=0;
                ok=1;
                now=j;
                break;
            }
        }
        if(!ok){
            cout<<"NO"<<endl;
            return 0;
        }
        ok=0;
    }
    cout<<"YES"<<endl;
}






Measured memory_bytes: 3328
#include<iostream>
#include<string.h>
#include<algorithm>
#include<map>
#include<stdio.h>
using namespace std;
int main() {
	int tmp;
	int n;
	scanf("%d", &n);
		map<int, int> a;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &tmp);
			a[tmp]++;
		}
		int k = a.size();
		if (k % 2 == 1)printf("%d\n", k);
		else printf("%d\n", k - 1);

	return 0;
}


Measured memory_bytes: 4992
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static final long mod = 1_000_000_007;

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

        long[] primeNums = new long[N + 1];
        for (int i = 1; i <= N; i++) {
            int num = i;
            for (int j = 2; j <= N; j++) {
                while (num % j == 0) {
                    primeNums[j]++;
                    primeNums[j] %= mod;
                    num /= j;
                }
            }
        }

        long cnt = 1;
        for (int i = 1; i < primeNums.length; i++) {
            cnt = (cnt * (primeNums[i] + 1)) % mod;
        }

        out.println(cnt);
    }
}

Measured memory_bytes: 22100
#include<iostream>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<list>
#include<climits>
#define endl '\n'
#define ll long long
#define ld long double
#define mod 1000000007
#define mod1 998244353
#define PI acos(-1)
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin>>n;
    int w;
	cin>>w;
	if(w>=n)
	  cout<<"unsafe";
	else
	{
		cout<<"safe";
	}
	
	return 0;
}

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

int solve(){
    double d, ans = 0.0;
    cin >> d;
    for(int i=0;i<=int(d);i++){
        double a = sqrt(d*d-i*i);
        ans = max(ans, max(1.0,a)+i);
    }
    ans = max(ans, d/sqrt(2)*2);
    printf("%.10lf\n",ans);
    return 0;
}

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



Measured memory_bytes: 3204
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
using namespace std;
int v[100001];
int chg(char x) {
    return 26-(x-'a');
}
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,x;
    string s;
    cin >> s >> n;
    for(int i=0; i<s.size(); i++) {
        x=chg(s[i]);
        if(x==26) {
            v[i]=0;
        } else if(x<=n) {
            v[i]=0;
            s[i]='a';
            n-=x;
        } else v[i]=x;
        if(!n) break;
    }
    if(n) {
        int cur = 26-v[s.size()-1];
        //if(cur==26) cur=0;
        n+=cur;
        n%=26;
        s[s.size()-1]='a'+n;
    }
    printf("%s\n", s.c_str());
    return 0;
}

Measured memory_bytes: 976
import java.util.Scanner;

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

        if ((S.charAt(2) == S.charAt(3)) && (S.charAt(4) == S.charAt(5))) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define all(a)      (a).begin(),(a).end()
#define si(x)       (int)((x).size())
#define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
#define se second 
#define endl        '\n'
#define f(i,a,b)    for(int i=a;i<b;i++)
#define mem(a,x)          memset(a,x,sizeof(a))

// === Debug macro starts here ===

int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
    os<<"[";
    for(auto& x:v){os<<x<<", ";}
    return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
    return os<<"{"<<p.first<<", "<<p.second<<"}";
}

// === Debug macro ends here ===


// const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846
void inp(ll *arr,ll n)
{
  for(int i=0;i<n;i++)
    cin>>arr[i];
}
void inp_mat(ll *arr,ll n,ll m)
{
    for(int i=0;i<n;i++)
      for(int j=0;j<m;j++)
        {
          ll x;cin>>x;
          *((arr+i*m) + j)=x;
        }
}
// syntax for inp_mat inp_mat((ll *)arr,n,m);
// int x2[]={+1,-1,+0,+0};
// int y2[]={+0,+0,+1,-1};
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //  #ifndef ONLINE_JUDGEc
    //   freopen ("INPUT.txt" , "r" , stdin);
    //   freopen ("OUTPUT.txt", "w" , stdout);
    // #endif 
    int t=1;
    // cin>>t;
    while(t--)
    {
      ll n,k;
      cin>>n>>k;ll arr[n];inp(arr,n);
      ll ans[n];
      f(i,0,n)
      ans[i]=mod;
      ans[0]=0;
      f(i,1,n)
      {
        int x=1;
        while(x<=k and i-x>=0)
        {
          ans[i]=min(ans[i],ans[i-x]+abs(arr[i]-arr[i-x]));
          x++;
        }
        dbg(ans[i]);
      }
      cout<<ans[n-1];
    }    
} 

Measured memory_bytes: 5140
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int n;
	vector<int> as;

	scanf("%d", &n);
	as.resize(n + 2);
	for(int i = 0; i < n; ++i)
		scanf("%d", &as[i + 1]);
	as[0] = as[n + 1] = 0;

	int total = 0;
	for(int i = 0; i < n + 2; ++i)
		total += abs(as[i] - as[i + 1]);

	vector<int> ans(n);

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

		int left = as[i];
		int mid = as[i + 1];
		int right = as[i + 2];

		int x = abs(left - mid) + abs(right - mid);
		int y = abs(left - right);
		int s = total - x + y;

		ans[i] = s;
	}

	for(auto& x : ans)
		printf("%d\n", x);

	return 0;
}

/* waffle */


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int a,b;
  cin >> a >> b;
  cout << 100 << " " << 100 << endl;
  int ans[100][100];
  rep(i,50)rep(j,100)ans[i][j]=0;
  rep(i,50)rep(j,100)ans[50+i][j]=1;
  int h=0;
  int w=0;
  while(a-1!=0){
    a--;
    ans[h][w]=1;
    if(w+2<100)w+=2;
    else{
      h+=2;
      w=0;
    }
  }
  h=60;
  w=0;
  while(b-1!=0){
    b--;
    ans[h][w]=0;
    if(w+2<100)w+=2;
    else{
      h+=2;
      w=0;
    }
  }
  rep(i,100){
    rep(j,100){
      if(ans[i][j]==1)cout << '.';
      else cout << '#';
    }
    cout << endl;
  }
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

string find(string t, string s)
{
    string a = "No";
    for (int i = 0; i < s.size() - t.size(); i++)
    {
        string b = s.substr(i, t.size());
        if (b == t)
        {
            a = "Yes";
        }
    }
    return a;
}

int main()
{
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < t.size(); i++)
    {
        s += s.at(i);
    }

    string ans;
    ans = find(t, s);
    cout << ans << endl;

    return 0;
}


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

int main() {

	string s;
	cin >> s;

	int x = 0;
	for (char c : s) {
		x += (int)(c - '0');
	}

	if (x % 9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){fastio
    ll a,c,b;cin>>a>>c>>b>>c;
    if(a==b){
        cout<<0;
    }else{
        cout<<1;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    int n;
    ll ans=0;
    cin >>n;
    ans=n/500*1000;
    n%=500;
    ans+=(n/5)*5;
    cout<<ans<<endl;
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(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;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

#include <atcoder/string>
//python3 ac-library/expander.py sol.cpp

int main(){
   string s; cin>>s; int n=s.size();
   auto sa=atcoder::suffix_array(s);
   auto lcp=atcoder::lcp_array(s,sa);
   ll res=1LL*n*(n+1)>>1;
   for(auto& x:lcp)res-=x;
   cout<<res<<endl;
   return 0;
}

Measured memory_bytes: 15580
def modinv(a,m):
    return pow(a,m-2,m)


n,k = map(int,input().split())
P = 10**9+7



if n-1 <= k:
    N = n + min(n-1,k)
    ans = 1
    for i in range(1,n):
        ans = ans*(N+1-i)*modinv(i,P)%P

else:
    ans = 1
    nCl = 1
    n1Cl = 1
    for l in range(1,k+1):
        nCl = nCl*(n+1-l)*modinv(l,P)%P
        n1Cl = n1Cl*(n-l)*modinv(l,P)%P
        ans = (ans+nCl*n1Cl)%P

print(ans)


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

using namespace std;

#define pb push_back
#define fo(i, n) for(int i =1 ; i <= n; ++i)

typedef long long ll;
const int N = 2000200;
const ll inf = 1e18;
const int mod = 1e9 + 7;

ll a, b, c, x, y;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> a >> b >> c >> x >> y;

    ll ans = 1e18;
    for(int i = 0; i <= max(x, y); ++i) {
        ll cntc = 2 * i;
        ll pricec = cntc * c;
        ll cnta = max(0ll, x - i);
        ll cntb = max(0ll, y - i);
        ans = min(ans, pricec + cnta * a + cntb * b);
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n, c[10000] = { 0 }, i, j, ban;
	while (1)
	{
		scanf("%d", &n);
		if (n == 0)
			break;
		for (i = 0; i < n; i++)
		{
			scanf("%d", &ban);
			c[ban] += 1;
		}
		for (i = 0; i < 10; i++)
		{
			for (j = 0; j < c[i]; j++)
			{
				printf("*");
			}
			if (c[i] == 0)
				printf("-\n");
			else
				printf("\n");
		}
		for (i = 0; i<n; i++)
		{
			c[i] = 0;
		}
	}
	return 0;
}

Measured memory_bytes: 616
#!/usr/bin/env python
# coding: utf-8


def main():
    n, m = list(map(int, input().split()))
    p2y = dict()
    for i in range(m):
        p, y = list(map(int, input().split()))
        p2y.setdefault(p, [])
        p2y[p].append((y, i))
    ids = dict()
    for p in sorted(p2y):
        for i, a in enumerate(sorted(p2y[p])):
            ids[a[1]] = "{:0>6}{:0>6}".format(p, i+1)
    for x in sorted(ids):
        print(ids[x])


if __name__ == '__main__':
    main()


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

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

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

  int n; cin >> n;
  vector<vector<int>> v(n, vector<int>(3));
  vector<vector<int>> dp(n+1, vector<int>(3, -inf));
  for (auto &i : v)
    for (auto &j : i)
      cin >> j;

  dp[n][0] = dp[n][1] = dp[n][2] = 0;
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j < 3; ++j) {
      if (j == 0)
        dp[i][j] = max({dp[i][j], dp[i+1][1] + v[i][1], dp[i+1][2] + v[i][2]});
      else if (j == 1)
        dp[i][j] = max({dp[i][j], dp[i+1][0] + v[i][0], dp[i+1][2] + v[i][2]});
      else
        dp[i][j] = max({dp[i][j], dp[i+1][0] + v[i][0], dp[i+1][1] + v[i][1]});
    }
  }

  cout << max({dp[0][0], dp[0][1], dp[0][2]}) << ende;
  return 0;
}


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

int main() {
  string str, ans = "";
  cin >> str;
  for (int i = 0; i <str.size(); i++ ){
    if(i % 2 == 0){
      ans += str.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int W, H;
	cin >> W >> H;
	VI A(W);
	priority_queue<int> Q;
	REP(i, W)cin >> A[i];
	REP(i, H) {
		int a;
		cin >> a;
		if(a)Q.push(a);
	}
	REP(i, W) {
		//cout << Q.size() << endl;
		VI tmp;
		if (Q.size() < A[i]) {
			cout << 0 << endl;
			return 0;
		}
		while (A[i]) {
			int a = Q.top();
			Q.pop();
			a--;
			if (a)tmp.push_back(a);
			A[i]--;
		}
		REP(j, tmp.size())Q.push(tmp[j]);
	}
	if (Q.empty())cout << 1 << endl;
	else cout << 0 << endl;

	return 0;
}




Measured memory_bytes: 3240
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;
using static ConsoleApplication.Utils;

namespace ConsoleApplication
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var w = ReadLine().OrderBy(c => c);
            var res = w.GroupBy(c => c)
                .Select(g => g.Count())
                .All(Utils.IsEven);
            WriteLine(res ? "Yes" : "No");
        }
    }

    public static class Utils
    {
        #region Extensions for IO

        public static int ReadInt()
            => ReadInts().First();

        public static IEnumerable<int> ReadInts()
            => ReadStrings().Select(int.Parse);

        public static IEnumerable<String> ReadStrings()
            => ReadLine().Split(' ');

        #endregion

        #region Extensions of int

        public static bool IsOdd(this int n)
            => !n.IsEven();

        public static bool IsEven(this int n)
            => n % 2 == 0;
        
        public static bool CanDivideWith(this int n, int divisor)
            => n % divisor == 0;

        #endregion

        #region Extensions of string

        public static int ToInt(this string str)
            => int.Parse(str);

        public static long ToLong(this string str)
            => long.Parse(str);

        public static bool IsNullOrEmpty(this string str)
            => string.IsNullOrEmpty(str);

        #endregion

        public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
            {
                action(item);
            }
        }

        public static IEnumerable<T> Peek<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
            {
                action(item);
            }
            return source;
        }
    }
}


Measured memory_bytes: 3160
N = int(input())
H = list(map(int, input().split()))
ans = 0
c = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    c += 1
  else:
    ans = max(ans, c)
    c = 0
ans = max(ans, c)
print(ans)

Measured memory_bytes: 85492
//Name: Packet Transportation
//Level: 2
//Category: グラフ,Graph,全点対間最短距離
//Note:

/**
 * 全点対間の最短距離を求めておけば良い。
 * オーダーは O(N^3)。
 */
#include <iostream>
#include <vector>

using namespace std;

template <typename T>
struct Maybe {/*{{{*/
    T val;
    bool valid;

    Maybe() : valid(false) {}
    Maybe(T &t) : val(t), valid(true) {}

    T& operator =(const T &rv) {
        val = rv;
        valid = true;
        return val;
    }

    operator T() {
        return valid ? val : T();
    }

    template<typename Cond>
    bool update(const T &v, Cond cond) {
        if(!valid || cond(v, val)) {
            val = v;
            valid = true;
            return true;
        }
        return false;
    }

    bool update(const T &v) {
        return update(v, less<T>());
    }
};/*}}}*/

template<typename T>
struct WarshallFloyd {
    vector<vector<Maybe<T>>> graph;
    int N;

    WarshallFloyd(int size) : graph(size), N(size) {
        for(auto &v : graph) {
            v.resize(size);
        }
    }

    void add_edge(int from, int to, const T &dist) {
        graph[from][to] = dist;
    }

    void freeze() {
        for(int k = 0; k < N; ++k) {
            for(int i = 0; i < N; ++i) {
                for(int j = 0; j < N; ++j) {
                    if(graph[i][k].valid && graph[k][j].valid) {
                        graph[i][j].update(graph[i][k] + graph[k][j]);
                    }
                }
            }
        }
    }

    const Maybe<T>& query(int from, int to) {
        return graph[from][to];
    }
};

bool solve(bool first) {
    int N;
    if(!(cin >> N)) return false;
    if(!N) return false;

    WarshallFloyd<int> wf(N);
    for(int i = 0; i < N; ++i) {
        int from, k;
        cin >> from >> k;
        --from;
        while(k--) {
            int v;
            cin >> v;
            wf.add_edge(from, v-1, 1);
        }
    }
    wf.freeze();
    int P;
    cin >> P;
    while(P--) {
        int s, d, t;
        cin >> s >> d >> t;
        const auto &dist = wf.query(s-1, d-1);
        if(dist.valid && dist.val+1 <= t) {
            cout << dist.val+1 << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(2);

    bool first = true;
    while(solve(first)) {
        first = false;
    }
    return 0;
}

Measured memory_bytes: 1284
#include <iostream>
#include <tuple>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
	int T;
	cin >> T;
	while(T--) {
		int n, k;
		cin >> n >> k;
		vector<int> vs(n, 0);
		vector<int> ws(n-1, 0);
		for(int i = 0; i < n; i++) {
			cin >> vs[i];
		}
		for(int i = 0; i < n - 1; i++) {
			ws[i] = vs[i+1] - vs[i];
		}
		sort(ws.begin(), ws.end());
		//範囲for文
		//for (int w : ws) {
		//	cout << w << " ";
		//}
		int ans = 0;
		for (int i = 0; i < n - k; i++) {
			ans += ws[i];
		}

		cout << ans << endl;
	}
}




Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    cin >> n >> m;
 
    vl a(m), b(m), c(m);
    rep(i, m) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;  b[i]--;
        c[i] *= -1;
    }
    
    // ベルマンフォード法。計算量はO(V*E)
    vl dist(n, INF);  // dist[v] : 頂点svから頂点vへの最短距離
    const ll sv = 0;  // 始点となる頂点。デフォルトでは0
    dist[sv] = 0;
    rep(loop, n-1) {
        rep(i, m) {
            if(dist[a[i]] == INF) {
                continue;
            }
            if(dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
            }
        }
    }
 
    vl negativeCycle(n);  // negativeCycle[v] : 頂点vへのパスに負閉路が含まれるとき1
    rep(loop, n) {
        rep(i, m) {
            if(dist[a[i]] == INF) {
                continue;
            }
            if(dist[b[i]] > dist[a[i]] + c[i]) {
                dist[b[i]] = dist[a[i]] + c[i];
                negativeCycle[b[i]] = 1;
            }
            if(negativeCycle[a[i]]) {
                negativeCycle[b[i]] = 1;
            }
        }
    }
 
    if(negativeCycle[n-1]) {
        out("inf");
    }
    else {
        out(-dist[n-1]);   
    }
 
    re0;
}

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

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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    priority_queue<int,vector<int>,greater<int>> que;
    rep(i,n){
        cin >> h[i];
    }

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

    int mi = INT_MAX;
    rep(i,n-k+1){
        mi = min(mi,h[i+k-1] - h[i]);
    }

    cout << mi;
}

Measured memory_bytes: 640
s = int(input())
l = []


def f(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3 * n + 1


for i in range(1000000):
    if i == 0:
        l.append(s)
    else:
        l.append(f(l[i - 1]))

count = [0] * len(l)
for i in range(len(l)):
    count[int(l[i])] += 1
    if 1 < count[int(l[i])]:
        print(i+1)
        break


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

unsigned tree[1<<18];
int n, q;
const unsigned inf=-1;

void build(int id=0, int l=0, int r=n)
{
    if (r-l<2) {
        tree[id]=(1LL<<31)-1;
        return;
    }
    int m=l+r>>1;
    build(2*id+1, l, m);
    build(2*id+2, m, r);
    tree[id]=(1LL<<31)-1;
}

void update(int x, int y, int v, int id=0, int l=0, int r=n)
{
    if (x>=r or y<=l) return;
    if (x<=l and r<=y) {
        tree[id]=v;
        return;
    }
    int m=l+r>>1;
    int L=2*id+1, R=L+1;
    update(x, y, v, L, l, m);
    update(x, y, v, R, m, r);
    tree[id]=min(tree[L], tree[R]);
}

unsigned find(int x, int y, int id=0, int l=0, int r=n)
{
    if (x>=r or y<=l) return inf;
    if (x<=l and r<=y) return tree[id];
    int m=l+r>>1;
    return min(find(x, y, 2*id+1, l, m), find(x, y, 2*id+2, m, r));
}

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

    cin>>n>>q;
    build();
    while (q--) {
        int c, x, y; cin>>c>>x>>y;
        if (c==0)
            update(x, x+1, y);
        else
            cout<<find(x, y+1)<<'\n';
    }
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

struct UnionFind {
private:
    vector<int> par,depth;
public:
    UnionFind (int n) {
        par.resize(n);
        depth = vector<int>(n,0);
        for (int i = 0;i < n;++i) par[i] = i;
    }

    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x,int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (depth[x] < depth[y]) par[x] = y;
        else {
            par[y] = x;
            if (depth[x] == depth[y]) depth[x]++;
        }
    }

    bool same(int x,int y) {
        return find(x) == find(y);
    }
};

template <typename T>
void dijkstra(int s,vector<vector<pair<int,T>>>& edges,vector<T>& dist) {
    priority_queue<pair<T,int>,vector<pair<T,int>>,greater<pair<T,int>>> que;
    dist[s] = 0;
    que.push(make_pair(0,s));
    while (!que.empty()) {
        pair<ll,int> p = que.top();
        que.pop();
        int v =  p.second;
        if (dist[v] < p.first) continue;
        for (pair<int,T>& e : edges[v]) {
            if (dist[e.first] > dist[v]+e.second) {
                dist[e.first] = dist[v]+e.second;
                que.push(make_pair(dist[e.first],e.first));
            }
        }
    }
}

int main() {
    int INF = 1e6;
    int h,w,d[2] = {0,1};
    cin >> h >> w;
    int a = 0;
    string s[100];
    for (int i = 0;i < h;++i) cin >> s[i];
    if (s[0][0] == '#') a = 1;
    vector<vector<int>> dist(h,vector<int>(w,INF));
    dist[0][0] = 0;
    priority_queue<pair<int,P>,vector<pair<int,P>>,greater<pair<int,P>>> que;
    que.push(make_pair(0,P(0,0)));
    while (!que.empty()) {
        pair<int,P> f = que.top();
        P t = f.second;que.pop();
        for (int i = 0;i < 2;++i) {
            int x = t.first+d[i],y = t.second+d[i^1];
            if (x >= h || y >= w) continue;
            int b = f.first+(s[t.first][t.second] == '.' && s[x][y] == '#');
            if (dist[x][y] > b) {
                dist[x][y] = b;
                que.push(make_pair(b,P(x,y)));
            }
        }
    }
    cout << dist[h-1][w-1]+a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(ll i = (ll)(a); i < (ll)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

ll N, A, B, C;
vector<ll> l;
    
ll dfs(ll cur, ll a, ll b, ll c){
    if(cur == N){
        if(min(a,min(b,c))>0) return abs(a-A)+abs(b-B)+abs(c-C)-30;
        else return INF;
    }
    ll ret0 = dfs(cur+1, a, b, c);
    ll ret1 = dfs(cur+1, a+l[cur], b, c)+10;
    ll ret2 = dfs(cur+1, a, b+l[cur], c)+10;
    ll ret3 = dfs(cur+1, a, b, c+l[cur])+10;
    return min(ret0, min(ret1, min(ret2, ret3)));
}

int main(){
    cin >> N >> A >> B >> C;
    REP(i,N){
        int tmp;
        cin >> tmp;
        l.push_back(tmp);
    }
    cout << dfs(0,0,0,0) << endl;
    return 0;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a + b == c || b + c == a || c + a == b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long k){
    int mo = 7 % k;
    int mi = 7 % k;
    for(int i = 1; i < k + 100; ++i){
        if(mo == 0){
            cout << i << endl;
            return;
        }
        mo += (mi * 10) % k;
        mi *= 10;
        mi %= k;
        mo %= k;
    }
    cout << -1 << endl;
}


signed main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int V, E;
vector<vector<edge>> es;
bool used[10000];

pair<int, vector<edge>> prim()
{
	memset(used, false, sizeof(used));
	vector<edge> res;
	int sum = 0;

	priority_queue<edge, vector<edge>, greater<edge>> que;
	que.push(edge{ -1, 0, 0 });

	while (!que.empty())
	{
		edge e = que.top(); que.pop();
		if (used[e.to]) continue;
		if (e.from >= 0) res.push_back(e);
		sum += e.cost;
		used[e.to] = true;
		for (edge i : es[e.to])
		{
			if (!used[i.to]) que.push(i);
		}
	}
	return pair<int, vector<edge>>(sum, res);
}

int main()
{
	while (cin >> V >> E, V)
	{
		es.clear();
		es.resize(V);
		REP(i, E)
		{
			int a, b, c;
			scanf("%d,%d,%d", &a, &b, &c);
			es[a].push_back(edge{ a, b, c });
			es[b].push_back(edge{ b, a, c });
		}
		cout << prim().first / 100 - (V - 1) << endl;
	}
}

Measured memory_bytes: 1556
#include <iostream>

using namespace std;

int main() {
  int h, n;
  cin >> h >> n;
  while (n--) {
    int a;
    cin >> a;
    h -= a;
    if (h <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
L, R = [None] * Q, [None] * Q

S = input()

for i in range(Q):
    L[i], R[i] = map(int, input().split())

counts = [0] * N
count_tmp = 0

for i in range(1, N):
    if S[i-1] == 'A' and S[i] == 'C':
        count_tmp += 1
    counts[i] = count_tmp

# print(counts)

for i in range(Q):
    print(counts[R[i] - 1] - counts[L[i] - 1])

Measured memory_bytes: 14284
n, m = gets.split.map(&:to_i)
ary  = gets.split.map(&:to_i).sort
bet  = []

if n >= m
  puts 0
else
  (m - 1).times do |i|
    bet << ary[i + 1] - ary[i]
  end
  bet = bet.sort
  ans = 0
  (m - n).times do
    ans += bet.shift
  end
end

puts ans


Measured memory_bytes: 11248
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include <numeric>
typedef long l;
typedef long long ll;
using namespace std;
int main(){
int N,K,X,Y;
cin>>N>>K>>X>>Y;
if(N>K)
cout<<K*X+(N-K)*Y<<endl;
else if(N<=K)
cout<<N*X<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio std::ios_base::sync_with_stdio(false), std::cout.tie(0), std::cin.tie(0);
#define N 1000007
#define mxx INT_MAX

typedef long long ll;



int main() {
	std::string name1, name2;
	std::cin >> name1 >> name2;

	if (name2.size() == name1.size() + 1 && name2.substr(0, name1.size()) == name1) {
		std::cout << "Yes";
	}
	else {
		std::cout << "No";
	}



}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        int n,m;
        cin>>n>>m;
        vector<int>a[n+1];
        for(int i=0;i<m;i++)
        {
            int x,y;
            cin>>x>>y;
            a[x].push_back(y);
            a[y].push_back(x);
        }

    int *visit=new int[n+1];
    int *dist=new int[n+1];
    for(int i=1;i<=n;i++)
        {
            visit[i]=0;
            dist[i]=0;
        }
    dist[1]=0;
    visit[1]=1;
    queue<int>q;
    q.push(1);
    while(!q.empty())
    {
        int v=q.front();
        //cout<<v<<" ";
        q.pop();
        int xx=a[v].size();
        for(int i=0;i<xx;i++)
        {

            if(visit[a[v][i]]==0)
            {
                 //cout<<a[v][i];
                visit[a[v][i]]=1;
                dist[a[v][i]]=dist[v]+1;
                q.push(a[v][i]);
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        //cout<<dist[i]<<" ";
        if(visit[i]==0)
            {
                cout<<"No\n";
                return 0;
            }
    }
    cout<<"Yes\n";
    int *sign=new int[n+1];
    for(int i=2;i<=n;i++)
    {
        int l=a[i].size();
        int min=m;
        int pos=INT_MAX;
        for(int j=0;j<l;j++)
        {

            if(dist[a[i][j]]<min)
            {
                min=dist[a[i][j]];
                pos=a[i][j];
            }
        }
        sign[i]=pos;
    }
    for(int i=2;i<=n;i++)
        cout<<sign[i]<<"\n";

    }



Measured memory_bytes: 11360
n,k = map(int,input().split())
X = list(map(int,input().split()))
ans = float("inf")
for i in range(n - k + 1):
  ans = min(ans,X[i + k - 1] - X[i] + abs(X[i]),X[i + k - 1] - X[i] + abs(X[i + k - 1]) )
print(ans)

Measured memory_bytes: 14228
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]
all_a=[]
def make_a(t):
  if len(t)==n:
    return [t]
  ret=[]
  for ti in range(t[-1],m+1):
    ret.extend(make_a(t+[ti]))
  return ret
for i in range(1,m+1):
  all_a.extend(make_a([1]))
ans=0
for an in all_a:
  ansi=0
  for a,b,c,d in abcd:
    if an[b-1]-an[a-1]==c:
      ansi+=d
  ans=max(ans,ansi)
print(ans)

Measured memory_bytes: 192740