akhauriyash/Code-Regression huggingface dataset:
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
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var pi = Sarray();
            var uf = new UnionFind((int)N + 1);
            for(var i=0;i<M;++i)
            {
                var xy = Sarray();
                uf.merge((int)xy[0], (int)xy[1]);
            }
            var ans = 0L;
            for(var i=0;i<N;++i)
            {
                if (uf.issame(i + 1, (int)pi[i])) 
                    ++ans;
            }
            WriteLine(ans);
        }
        class UnionFind
        {
            int[] par;
            public UnionFind(int n)
            {
                init(n);
            }
            public void init(int n)
            {
                par = new int[n];
                for (var i = 0; i < n; ++i) { par[i] = -1; }
            }
            public int root(int x)
            {
                if (par[x] < 0) return x;
                else return par[x] = root(par[x]);
            }
            public bool issame(int x, int y)
            {
                return root(x) == root(y);
            }
            public bool merge(int x, int y)
            {
                x = root(x);
                y = root(y);
                if (x == y) return false;
                if (par[x] > par[y])
                {
                    var tmp = y;
                    y = x;
                    x = tmp;
                }
                par[x] += par[y];
                par[y] = x;
                return true;
            }
            public int size(int x)
            {
                return -par[root(x)];
            }
        }
    }
}

Measured memory_bytes: 50624
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define DSORT(c, type) sort(ALL(c), greater<type>())

using namespace std;


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

  int d; cin >> d;

  string out = "Christmas";
  string eve = " Eve";

  for(int i=0; i<25-d; ++i)
    out += eve;

  cout << out << "\n";

  return 0;
}


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

int main(void){
  string x;
  cin >> x;
  int count = 0;
  count = x[0] == 'o' ? count+1 : count;
  count = x[1] == 'o' ? count+1 : count;
  count = x[2] == 'o' ? count+1 : count;
  cout << count*100+700 << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

//#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>
#include "random"
#include "chrono"
#include "cstring"

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target_ans("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;

#define int long long
//#define int unsigned int
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vi> vvi;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi xx = { 1, 0, -1, 0 };
vi yy = { 0, 1, 0, -1 };
string dir = "LRUD";

const int N = 2e5 + 50, oo = 5e18 + 500;
const int mod = 998244353;
//const int mod = 1e9 + 7;
//const int mod = 1e9 + 9;
const double eps = 1e-6, PI = 2 * acos(0.0);
int n, m, k;
int cnt = 0;
int lg = 18;
vi g[N];
vi rg[N];
vi visit(N, 0);


signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;

	vi a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];

		if (!a[i])
			continue;

		if (a[i] & 1)
		{
			cnt += a[i] / 2;
			a[i] %= 2;
		}
		else
		{
			cnt += (a[i] - 2) / 2;
			a[i] = 2;
		}
	}

	for (int i = 0; i < n; i++)
	{
		if (a[i] == 1)
		{
			if (i + 1 < n && a[i + 1])
			{
				a[i + 1]--;
				cnt++;
			}
		}

		if (a[i] == 2)
		{
			cnt++;
		}
	}

	cout << cnt;
}



Measured memory_bytes: 14436
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;

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


	int n, y;
	cin >> n >> y;
	rep(i, 0, n + 1) {
		rep(j, 0, n - i + 1) {
			if (y - 10000 * i - 5000 * j == 1000 * (n - i - j)) {
				cout << i << " " << j << " " << n - i - j << endl;
				return 0;
			}
		}
	}
	
	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll int
int main() {
    // int t;
    // cin>>t;
    // while(t--){
    // }
    ll n,k;
    cin>>n>>k;
    if(n%k==0)
    cout<<n/k<<endl;
    else
    cout<<n/k+1<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			long[] val = new long[N];
			for (int i = 0; i < N; ++i) {
				val[i] = sc.nextInt();
				val[i] += sc.nextLong() << 32;
			}
			Arrays.sort(val);
			long sum = 0;
			boolean fail = false;
			for (int i = 0; i < N; ++i) {
				long w = (val[i] & 0x3FFFFFFF);
				long g = val[i] >> 32;
				sum += w;
				if (sum > g) {
					fail = true;
					break;
				}
			}
			System.out.println(fail ? "No" : "Yes");
		}
	}
}

Measured memory_bytes: 12000
from itertools import chain

H,W = map(int,input().split())
grid = tuple(tuple(map(lambda c: c != '#', input())) for _ in range(H))

scores = [[0]*W for _ in range(H)]

for i in range(H):
    s = 0
    for j in range(W):
        if grid[i][j]:
            scores[i][j] += s
            s += 1
        else:
            s = 0

for i in range(H):
    s = 0
    for j in reversed(range(W)):
        if grid[i][j]:
            scores[i][j] += s
            s += 1
        else:
            s = 0

for j in range(W):
    s = 0
    for i in range(H):
        if grid[i][j]:
            scores[i][j] += s
            s += 1
        else:
            s = 0

for j in range(W):
    s = 0
    for i in reversed(range(H)):
        if grid[i][j]:
            scores[i][j] += s
            s += 1
        else:
            s = 0


print(1 + max(chain.from_iterable(scores)))


Measured memory_bytes: 139268
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int a, b;
    cin >> a >> b;

    int ans = -1;
    for (int i = 1; i <= 1000; i++) {
        if (int(i * 0.08) == a && int(i * 0.1) == b) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long long> ar(n);
    long long sum=0,x=0,mn=1000000000000000000LL;
    for(int i=0;i<n;i++)
    {
        cin >> ar[i];
        sum+=ar[i];
    }
    for(int i=0;i<n-1;i++)
    {
        x+=ar[i];
        mn = min(mn, abs(sum-2*x));
    }
    cout << mn << endl;

}


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,p;
    cin>>n>>p;
    vector<int> a(n);
    int odd=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2==1) odd++;
    }
    ll ans=pow(2,n-1);
    if(odd==0){
        if(p==0) cout<<ans*2;
        else cout<<0;
    }
    else cout<<ans;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    int l;
    cin>>l;
    double ans;
    ans=(l*l*l)/(27 * 1.0000);
     cout<<fixed<<setprecision(7);
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define asc(a) sort(a.begin(), a.end())
 
int main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  rep(i,n) {
    cin >> s[i];
  }
  asc(s);
    
  rep(i,n) {
    cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 3604
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    k = int(input())
    x = int(input())
    y = int(input())
    if k >= n:
        print(n * x)
    else:
        print(k * x + (n - k) * y)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
N = int(input())
H = list(map(int, input().split()))
Hs = [H]
T, c = 0, 1
while c<100000:
  List_1 = []
  for H in Hs:
    start = 0
    T += min(H)
    H = [h-min(H) for h in H]
    List_2 = [i for i, x in enumerate(H) if x == 0]
    for l in List_2:
      List_1.append(H[start:l])
      start = l+1
    List_1.append(H[start:])
  Hs.clear()
  for List in List_1:
    Hs.append(List)
  Hs = [H for H in Hs if H != []]
  c += 1
print(T)

Measured memory_bytes: 9232
def main() -> None:
    N, M = map(int, input().split())
    conds = []
    for _ in range(M):
        s, c = map(int, input().split())
        conds.append((s, str(c)))
    for i in range(10 ** N):
        if len(str(i)) < N:
            continue
        flag = True
        for s, c in conds:
            if str(i)[s-1] != c:
                flag = False
                break
        if flag:
            print(i)
            break
    else:
        print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n = int(input()) 
def dfs(s):
    if int(s) > n:
        return 0 #再帰の終了条件
    if s.count('3') > 0 and s.count('5') > 0 and s.count('7') > 0:
        cnt = 1 #３か、５か、７が、１回は出てくる⇒カウントアップ
    else:
        cnt = 0
    cnt += dfs(s + '3') #再帰、３か、５か、７か、を繰り返す
    cnt += dfs(s + '5')
    cnt += dfs(s + '7')
    return cnt #求めたいのは、出現回数
  
print(dfs('0')) #スタートはゼロ

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	long long ans=0;
	for(int i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0){
			ans+=i;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(i);
// sort(arr, arr+n, greater<int>());
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	string s;
	cin>>s;
	if(s[0]=='7'||s[1]=='7'||s[2]=='7')
	{
	    cout<<"Yes"<<endl;
	}
	else
	{
	    cout<<"No"<<endl;
	}
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=1e6+5;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod

// #define LOCAL 1

/************************************


 
*************************************/

vector<int>par,dep,tin,tout;
vector<vector<int>>v;
vector<int>deg;
vector<pll>req;
bool visited[MAX];


ll power(int a,int b){
    int ans=1;
    while(b>0){
        if(b&1)
            ans = (ans%MOD*a%MOD)%MOD;
        b = b>>1;
        a= (a%MOD*a%MOD)%MOD;
    }
    return ans;
}

void bfs(int s,vector<int>&d){
    d[s]=0;
    queue<int>q;
    q.push(s);
    while(!q.empty()){
        int u = q.front();
        q.pop();
        // visited[u]=true;
        for(auto it:v[u]){
            if(d[it]==-1){
                // cout<<it<<" ";
                d[it]=d[u]+1;
                q.push(it);
            }
        }
    }
}


void solve(){
std::cout << std::fixed;
std::cout << std::setprecision(6);
    int t=1;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        double ans = (1.0*n)/3;
        cout<<ans*ans*ans<<endl;

    }
}


signed main() 
{ 
    boost;

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // while (cin.peek() != EOF) {
    //     solve();
    //     cout << endl << endl;
    //     string s;
    //     do getline(cin, s);
    //     while (!cin.eof() && !s.empty());
    //     while (isspace(cin.peek())) cin.get();
    // }
    // #else
    //     solve();
    // #endif

    solve();


    

    
	return 0; 
} 

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int[] c=new int[140];
        for(int i=0;i<s.length();i++){
            c[(int)s.charAt(i)]++;
        }
        boolean ans=true;
        for(int i=0;i<c.length;i++){
            if(c[i]>=2){
                ans=false;
                break;
            }
        }
        if(ans)System.out.println("yes");
        else System.out.println("no");
        

    }
}

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

#define SIZE 101

int main( void )
{
	char string_data[SIZE] = {};				//????´¢???????????????
	char search_data[SIZE] = {};				//????´¢???????????????
	char queue_data[SIZE + SIZE] = {};		//???????????¬???(????????°??¶????????????)
	
	//?¨??????\??????????????????????????????
	gets( string_data );
	
	//?¨??????\??????????????????????????????
	gets( search_data );
	
	strcpy( queue_data, string_data );

	strcat( queue_data, string_data );
	
	if( strstr( queue_data, search_data ) != NULL )
	{
		printf( "Yes\n" );
	}
	else
	{
		printf( "No\n" );
	}
	
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long l, r; cin >> l >> r;
	if(r - l + 1 >= 2019) {
		cout << "0" << endl;
		return 0;
	}
	set<long long> s;
	for (int i = l; i <= r; i++)
	{
		s.insert(i % 2019);
	}

	vector<long long> a;
	for (auto p : s)
	{
		a.push_back(p);
	}
	long long res = 10000;
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = i+1; j < a.size(); j++)
		{
			res = min(res, a[i] * a[j] % 2019);
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3576
using namespace std;
int p[10001];
int main(){
	for(int i=2;i<101;i++)if(!p[i])for(int j=i+i;j<10001;j+=i)p[j]=1;
	p[0]=p[1]=1;
	int n,c;
	while(cin>>n){
		c=0; for(int i=0;i<n;i++)if(!p[i+1]&&!p[n-i])c++;
		cout<<c<<endl;
	}
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){

  int num,i,j,n,count = 0;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    scanf("%d",&n);
    for(j=2;j*j<=n;j++){
      if(n%j==0)break;
    }
    if(j*j>n)
      count++;
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2112
#include <cstdio>
#include <map>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
bool can_divide(int a)
{
	while(a%2==0)a/=2;
	while(a%5==0)a/=5;
	return a==1;
}
string divide(int a,int b)
{
	a*=10;
	string ret;
	while(a!=0)
	{
		ret+=a/b+'0';
		a%=b;
		a*=10;
	}
	return ret;
}
void solve(int a,int b)
{
	string ret;
	map<int,int> m;
	a*=10;
	int p=-1;
	for(int i=0;;i++)
	{
		if(m.find(a)!=m.end())
		{
			p=m[a];
			break;
		}
		m[a]=i;
		ret+=a/b+'0';
		a%=b;
		a*=10;
	}
	cout << ret << endl;
	for(int i=0;i<ret.size();i++)
	{
		if(i>=p)cout << '^';
		else cout << ' ';
	}
	cout << endl;
	return;
}
		
int main()
{
	int a,b;
	while(cin >> a >> b)
	{
		int g = __gcd(a,b);
		a/=g;b/=g;
		if(can_divide(b))
		{
			cout << divide(a,b) << endl;
		}
		else
		{
			solve(a,b);
		}
	}
	return 0;
}

Measured memory_bytes: 1200
S = input()

work = ""
maxlen = 0
lenwork = 0
for i in range(0, len(S)):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        if i > 0 and (S[i - 1] == "A" or S[i - 1] == "C" or S[i - 1] == "G" or S[i - 1] == "T"):
            work += S[i]
            lenwork += 1
        else:
            work = S[i]
            if lenwork == 0:
                lenwork = 1
    else:
        work = ""
        if lenwork > maxlen:
            maxlen = lenwork
        lenwork = 0

if lenwork > maxlen:
    maxlen = lenwork

print(maxlen)

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

int main(){
  while(true){
    int x, y;
    cin >> x >> y;
    if(x ==0 && y == 0) break;
    else if( x <= y){
      cout << x << " " << y << endl;
    }
    else{
      cout << y << " " << x << endl;
    }
  }
}


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

int main() {
  string s;
  cin >>s;
  int count =0;
  for(int i=0;i<3;i++){
    if(s[i] == 'o'){
      count++;
    }
  }
  cout << 700+count*100 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a == b && b == c) {

			System.out.println("1");

		} else if (a == b || b == c || c == a) {

			System.out.println("2");

		} else {

			System.out.println("3");

		}

	}
}

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



int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if ((abs(a-b) <= d && abs(c-b) <= d ) ||  abs(a-c) <=d  )  {
      cout << "Yes" <<endl;
    }else{
      cout << "No" <<endl;
    }


    // cout <<  max( max(a+b,a*b) , a-b ) ;
    
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w,r;
string s,s1,s2;
//vvl v;
//vl vis,d;

ll f[3000000],inv[3000000];

int main() {
    IOS;
    f[0]=1;
    fo(i,2999999)f[i+1]=f[i]*(i+1)%mod;
    inv[2999999]=bpow(f[2999999],mod-2,mod);
    for(int i=2999998;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    cin>>p>>q;
    if((p+q)%3>0)return cout<<0,0;
    x=p-(p+q)/3;
    y=q-(p+q)/3;
    if(x<0||y<0)return cout<<0,0;
    //cout<<x<<y<<el;
    cout<<f[x+y]*inv[x]%mod*inv[y]%mod<<el;
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

ll DP[60][60][3000];

int main(){
    ll N, A;
    cin >> N >> A;
    vector<ll> X(N);
    REP(i,N){
        ll x;
        cin >> x;
        X[i] = x;
    }

    DP[0][0][0] = 1;
    REP(i,N){
        ll x = X[i];
        REP(j,i+1){
            REP(k,50*50){
                DP[i+1][j+1][k+x] += DP[i][j][k];
                DP[i+1][j][k] += DP[i][j][k];
            }
        }
    }

    ll ans = 0;
    REPi(i,1,N+1){
        ans += DP[N][i][A*i];
    }

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


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

int main() {
	ll n;
	cin >> n;
	map<ll,ll>mp;
	for (ll i = 0; i < n; i++) {
		ll s;
		cin >> s;
		mp[s - 1] = i + 1;

	}
	for (ll i = 0; i < n; i++) {
		cout << mp[i] <<" ";
	}
	cout << endl;

}

Measured memory_bytes: 7040
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

func check(y, x, h, w int, s []string) bool {
	dx := []int{0, -1, 1, 0}
	dy := []int{-1, 0, 0, 1}

	prev := 0
	next := 0
	for i := 0; i < 2; i++ {
		px := x + dx[i]
		py := y + dy[i]
		if px < 0 || py < 0 || px >= w || py >= h {
			continue
		}
		if s[y][x] == '#' && s[py][px] == '#' {
			prev++
		}
	}
	for i := 2; i < 4; i++ {
		nx := x + dx[i]
		ny := y + dy[i]
		if nx < 0 || ny < 0 || nx >= w || ny >= h {
			continue
		}
		if s[y][x] == '#' && s[ny][nx] == '#' {
			next++
		}
	}
	// fmt.Print(x, y, ":", prev, next, " ")

	if x == 0 && y == 0 {
		if next == 1 {
			return true
		} else {
			return false
		}
	}
	if x == w-1 && y == h-1 {
		if prev == 1 {
			return true
		} else {
			return false
		}
	}
	if prev != next {
		return false
	} else {
		return true
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	H, W := getInt(), getInt()
	a := make([]string, H)
	for i := 0; i < H; i++ {
		a[i] = getString()
	}
	// out(H, W, a)

	ans := "Possible"
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			f := check(y, x, H, W, a)
			// out(f)
			if !f {
				ans = "Impossible"
				break
			}
		}
	}

	out(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 500010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;


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

	string S;
	cin >> S;

	rep(i,S.size()){
		if(i==5 || i==13) cout << " ";
		else cout << S[i];
	}

	cout << endl;

	return 0;
}


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

typedef long long ll;

ll n, k, low, up;

int main(){
    cin >> n >> k;
	low = k - k / 2;
	up = k / 2;
	for(ll i = 1; i <= low; i++){
		cout << i << " " << ( 2 * low ) - i + 1 << '\n';
	}
	for(ll i = 1; i <= up; i++){
		cout << low * 2 + i << " " << 2 * ( low + up + 1 ) - i << '\n';
	}
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
#include <cctype>
#include <ctype.h>
#include <math.h>
#define ll long long
char toupper(char c);
char toupper(char c)
{
    return (c - 0x20);
}

using namespace std;
int main()
{
  int a,b;
  cin >> a>>b;
  if(a+b<24)
  {
    cout << a+b<<endl;
  }
  else
  {
    cout<< (a+b)-24 << endl;
  }
  
  

return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll MOD = 1000000007;
const ll INF = 1LL << 60;
#define PI (acos(-1))

ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}
vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
ll COM(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 文字列t　->整数　atoi(t.c_str());
ll solve()
{

    string s;
    cin >> s;
    ll ans = 0;
    for(int i=0; i < (1 << (s.length() - 1)); i++){
        string t = "";
        t+=s[0];
        for (int j = 0; j < s.length() - 1; j++)
        {
            if(i & (1 << j)){
                t += s[j + 1];
            }else{
                // cout << t << endl;
                ans += stoll(t);
                t = s[j + 1];
            }
        }
        // cout << t << endl;
        ans += stoll(t);
    }
    cout << ans << endl;



    return 0;
}

int main()
{
    //cout.precision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

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

    ll d;
    cin>>d;
    cout<<((360)/__gcd(d,360ll));
}

Measured memory_bytes: 3616
A= int(input())
B= int(input())
C= int(input())
X= int(input())
count=0

for a in range(min(A, int(X/500))+1):
    for b in range(min(B, int((X-a*500)/100))+1):
        if (X-a*500-b*100)/50 <= C:
            count+=1
print(count)



Measured memory_bytes: 3060
n=[0 for i in range(30)]

while True:
    try:
        s=input()
    except EOFError:
        break
    n[0]+=s.count('a')+s.count('A')
    n[1]+=s.count('b')+s.count('B')
    n[2]+=s.count('c')+s.count('C')
    n[3]+=s.count('d')+s.count('D')
    n[4]+=s.count('e')+s.count('E')
    n[5]+=s.count('f')+s.count('F')
    n[6]+=s.count('g')+s.count('G')
    n[7]+=s.count('h')+s.count('H')
    n[8]+=s.count('i')+s.count('I')
    n[9]+=s.count('j')+s.count('J')
    n[10]+=s.count('k')+s.count('K')
    n[11]+=s.count('l')+s.count('L')
    n[12]+=s.count('m')+s.count('M')
    n[13]+=s.count('n')+s.count('N')
    n[14]+=s.count('o')+s.count('O')
    n[15]+=s.count('p')+s.count('P')
    n[16]+=s.count('q')+s.count('Q')
    n[17]+=s.count('r')+s.count('R')
    n[18]+=s.count('s')+s.count('S')
    n[19]+=s.count('t')+s.count('T')
    n[20]+=s.count('u')+s.count('U')
    n[21]+=s.count('v')+s.count('V')
    n[22]+=s.count('w')+s.count('W')
    n[23]+=s.count('x')+s.count('X')
    n[24]+=s.count('y')+s.count('Y')
    n[25]+=s.count('z')+s.count('Z')

print(f"a : {n[0]}")
print(f"b : {n[1]}")
print(f"c : {n[2]}")
print(f"d : {n[3]}")
print(f"e : {n[4]}")
print(f"f : {n[5]}")
print(f"g : {n[6]}")
print(f"h : {n[7]}")
print(f"i : {n[8]}")
print(f"j : {n[9]}")
print(f"k : {n[10]}")
print(f"l : {n[11]}")
print(f"m : {n[12]}")
print(f"n : {n[13]}")
print(f"o : {n[14]}")
print(f"p : {n[15]}")
print(f"q : {n[16]}")
print(f"r : {n[17]}")
print(f"s : {n[18]}")
print(f"t : {n[19]}")
print(f"u : {n[20]}")
print(f"v : {n[21]}")
print(f"w : {n[22]}")
print(f"x : {n[23]}")
print(f"y : {n[24]}")
print(f"z : {n[25]}")



Measured memory_bytes: 5616
n, W = map(int, input().split())
B = []
for _ in range(n):
  v, w = map(int, input().split())
  B.append((v, w))

dp = [[0 for _ in range(W+1)] for _ in range(n+1)]
#print(dp)

for i in reversed(range(n)):
#  print(i)
  for w in range(W+1):
    if w < B[i][1]:
      dp[i][w] = dp[i+1][w]
    else:
      dp[i][w] = max(dp[i+1][w], dp[i+1][w - B[i][1]] + B[i][0])
      
#print(dp)
print(dp[0][W])


Measured memory_bytes: 24732
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
int s;
const int nax=3005;
ll mod=998244353;
int a[nax];
inline ll adds(ll a, ll b){
    a+=b;
    if(a>=mod) a-=mod;
    return a;
} 
ll fun(int st, int end){
    if(st == end){
        return a[st]==s;
    }
    int mid=(st+end)/2;
    ll ans=(fun(st,mid)+fun(mid+1,end))%mod;
    int n=end-st+1;
    ll dp[n][s+1];

    for(int i=mid+1;i<=end;i++){
        for(int j=0;j<=s;j++){

            if(j==0){
                dp[i-st][j]=1; continue;
            }
            if(i==mid+1){
                if(a[i]==j) dp[i-st][j]=1;
                else dp[i-st][j]=0;
            }
            else{
                dp[i-st][j]=adds(dp[i-1-st][j],(a[i]<=j ? dp[i-1-st][j-a[i]] : (ll)0));
            }
        }
    }
    for(int i=mid;i>=st;i--){
        for(int j=0;j<=s;j++){
            if(j==0){
                dp[i-st][j]=1; continue;
            }
            if(i==mid){
                if(a[i]==j) dp[i-st][j]=1;
                else dp[i-st][j]=0;
            }
            else{
                dp[i-st][j]=adds(dp[i+1-st][j],(a[i]<=j ? dp[i+1-st][j-a[i]] : (ll)0));
            }
        }
    }
    ll t1[s+1]={0};
    for(int j=0;j<=s;j++){
        for(int i=mid+1;i<=end;i++){
            t1[j]=adds(t1[j],dp[i-st][j]);
        }
    }
    for(int j=0;j<=s;j++){
        ll g=0;
        for(int i=mid;i>=st;i--){
            g=adds(g,dp[i-st][j]);
        }
        ans=adds(ans, (g*t1[s-j])%mod );
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n;
    cin>>n>>s;
    for(int i=0;i<n;i++) cin>>a[i];
    cout<<fun(0,n-1)<<"\n";
}


Measured memory_bytes: 70656
/*input
6
6 5 4 3 2 1
*/
#include <bits/stdc++.h>
using namespace std;

typedef priority_queue<int, vector<int>, greater<int> > Dat;
queue<Dat> q;

void Merge(Dat &a, Dat &b) {
	if(a.size() < b.size()) a.swap(b);
	while(b.size()) a.push(b.top()), b.pop();
}

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

	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		Dat cur; cur.push(a[i]);
		q.push(cur);
	}

	sort(a.begin(), a.end());
	long long Ans = 0;
	for(int i = 0; i < n; ++i) {
		Dat cur = std::move(q.front()); q.pop();

		while(cur.top() != a[i])
			Merge(cur, q.front()), q.pop();

		cur.pop();
		if(cur.size()) Ans += cur.size(), q.push(std::move(cur));
	}
	printf("%lld\n", Ans);
}


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

const int MAX_N = 100005;
int field[MAX_N];

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

  for (int i = 0; i < MAX_N; i++)
  {
    field[i] = 0;
  }

  int l, r;
  for (int i = 0; i < m; i++)
  {
    cin >> l >> r;
    l--;
    r--;
    field[l] += 1;
    field[r + 1] += -1;
  }

  for (int i = 1; i < MAX_N; i++)
  {
    field[i] += field[i - 1];
  }

  int res = 0;
  for (int i = 0; i < MAX_N; i++)
  {
    if (field[i] == m)
    {
      res++;
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>

int pop();
void push(int);
int stack[2000];
int kazu=0;
void push(int j){
  stack[kazu++]=j;
}
int pop(){
  if(kazu<=0) return 0;
  return stack[--kazu];
}

int main(){
  int i,j,k=0,l,n,Ans;
  char s[100];
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      l=pop();
      n=pop();
      Ans=l+n;
      push(Ans);
    }
    else if(s[0]=='-'){
      l=pop();
      n=pop();
      Ans=n-l;
      push(Ans);
    }
    else if(s[0]=='*'){
      l=pop();
      n=pop();
      Ans=l*n;
      push(Ans);
    }
    else{
      j=atoi(s);
      push(j);
    }
  }
  Ans=pop();
  printf("%d\n",Ans);
  return 0;
}




Measured memory_bytes: 2108
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; ++i) {
        cin >> a[i];
    }
    cout << string(w+2, '#') << "\n";
    for (int i = 0; i < h; ++i) {
        cout << "#";
        cout << a[i];
        cout << "#" << endl;
    }
    cout << string(w+2, '#') << "\n";

    return 0;
}

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

bool judge(vector<int> a, vector<int> b) {
	for (int i = 1; i < a.size(); i++)
	{
		if (a[i] < a[i - 1]) return false;
	}
	for (int i = 1; i < b.size(); i++)
	{
		if (b[i] < b[i - 1]) return false;
	}
	return true;
}

int main() {

	int num;
	int data[10];
	vector<int> a, b;
	cin >> num;
	for (int i = 0; i < num; i++)
	{
		
		for (int j = 0; j < 10; j++)
		{
			cin >> data[j];
		}
		int j;
		for (j = 0; j <= 1024 ; j++)
		{
			a.clear();
			b.clear();
			for (int k = 0; k < 10; k++)
			{
				if ((j >> k) & 1)
				{
					a.push_back(data[k]);
				}
				else
				{
					b.push_back(data[k]);
				}
			}
			if (judge(a,b))
			{
				cout << "YES" << endl;
				break;
			}
		}
		if (j==1025)
		{
			cout << "NO" << endl;
		}

	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 1208
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h,w,k = LI()
    a = [list(map(int, input())) for i in range(h)]
    s = [[0]*(w+1)]+[[0]+list(accumulate(i)) for i in a]
    for j in range(w+1):
        for i in range(h):
            s[i+1][j] += s[i][j]
    ans = float("inf")
    for b in range(1<<(h-1)):
        l = [0]
        for i in range(h-1):
            if b&(1<<i):
                l.append(i+1)
        l.append(h)
        ll = len(l)-1
        su = [0]*ll
        m = bin(b).count("1")
        p = 0
        f = 0
        for j in range(1,w+1):
            for i in range(ll):
                u = l[i]
                d = l[i+1]
                su[i] += s[d][j]-s[d][p]-s[u][j]+s[u][p]
                if su[i] > k:
                    m += 1
                    p = j-1
                    su = [0]*ll
                    for ii in range(ll):
                        u = l[ii]
                        d = l[ii+1]
                        su[ii] = s[d][j]-s[d][p]-s[u][j]+s[u][p]
                        if su[ii] > k:
                            f = 1
                    break
            p = j
            if f:
                m = float("inf")
                break
        if m < ans:
            ans = m
    print(ans)
    return

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


Measured memory_bytes: 44252
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  string s,t;
  cin >> s >> t;
  
  int l = s.length();
  int ans = 0;
  
  for(int i=0;i<l;i++){
    if(s[i] != t[i]) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3896
n, k = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)

MOD = 10 ** 9 + 7


def pow(a, n):
    if n == 0:
        return 1
    else:
        temp = pow(a, n // 2)
        if n % 2 == 0:
            return temp * temp % MOD
        else:
            return temp * temp * a % MOD
        
        
ans = 0
combinations = list()
for j, i in enumerate(range(k - 1, n)):
    if i == (k - 1):
        combinations.append(1)
    else:
        combinations.append(combinations[-1] * i * pow(i - k + 1, MOD - 2))
    combinations[-1] = combinations[-1] % MOD
    # print(i, 'C', k - 1, '=', combinations[-1])

# print(combinations)
# print(A)
combinations = combinations[::-1]
for j, i in enumerate(range(k - 1, n)):
    ans += (A[-j - 1] * combinations[j] % MOD)

for j, i in enumerate(range(k - 1, n)):
    ans -= (A[j] * combinations[j] % MOD)
    if ans < 0:
        ans = ans + (- ans // MOD + 1) * MOD

ans %= MOD
print(ans)


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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++)
  {   
    cin >> vec.at(i);
  }
  
  int cnt = 0, min_cnt = n;
  int now = 0;
  bool two_find = false;

  for (int i = 0; i < n; i++)
  {
    if(now == 1){
      two_find = true;
      break;
    } 
    now = vec.at(now) - 1;
    cnt++;
  }

  if(two_find)
    cout << cnt << endl;
  else
  {
    cout << -1 << endl;
  }
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define lp(i, x, n) for (int i = x; i < (int)n; ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define N 1000001
int n, m, x, y;
int main() {
        cin >> n>> m>> x>> y;
        int mx = -1000001;
        lp (i, 0, n) {
                int a;
                cin >> a;
                mx = max(a, mx);
        }
        int mn = 1000001;
        lp (i, 0, m) {
                int a;
                cin >> a;
                mn = min(mn, a);
        }
        mx++;
        if (mx <= mn && mx > x && mx <= y) {
                cout << "No War";
                return 0;
        }
        cout << "War";
        return 0;
}


Measured memory_bytes: 256
namespace diverta2019.D
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;

    public class Program
    {
        public static void Main(string[] args)
        {
            var n = long.Parse(ReadLine());
            WriteLine(Solve(n));
        }

        public static IEnumerable<long> GetDividors(long n)
        {
            var max = (long)Math.Sqrt(n);
            for (int i = 1; i <= max; i++)
            {
                if (n % i == 0)
                {
                    yield return i;
                    if (i * i != n) yield return n / i;
                }
            }
        }

        public static long Solve(long n) => GetDividors(n).Where(k => k >= 2).Select(k => k - 1)
                .Where(i => n % i == n / i)
                .Sum();
    }
}

Measured memory_bytes: 11348
import heapq
 
 
h, w = map(int, input().split())
meiro = []
for i in range(h):
    line = input()
    meiro.append(line)
 
 
def dfs(y, x):
    dist = [[-1]*w for _ in range(h)]
    if meiro[y][x] == '#':
        return 0
    dist[y][x] = 0
 
    pattern = [[-1, 0], [1, 0], [0, -1], [0, 1]]
    todo = []
    for dy, dx in pattern:
        ny, nx = y + dy, x + dx
        if 0 <= ny <= h-1 and 0 <= nx <= w-1:
            if meiro[ny][nx] == '.':
                heapq.heappush(todo, [1, ny, nx])
 
    while todo:
        d, y, x = heapq.heappop(todo)
        if meiro[y][x] == '#':
            continue
        if dist[y][x] != -1:
                continue
 
        dist[y][x] = d
        for dy, dx in pattern:
            ny, nx = y + dy, x + dx
            if 0 <= ny <= h - 1 and 0 <= nx <= w - 1:
                if dist[ny][nx] == -1 and meiro[ny][nx] == '.':
                    heapq.heappush(todo, [d+1, ny, nx])
 
    res = 0
    for line in dist:
        res = max(max(line), res)
 
    return res
 
 
ans = []
for y in range(h):
    for x in range(w):
        ans.append(dfs(y, x))
 
print(max(ans))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <utility>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

// 基本的な演算
namespace BasicMath {
    // 絶対値を求める
    static UInt Abs(const Int a);
    // 二つの値の最小値を求める関数
    static Int Min(const Int a, const Int b);
    // 絶対値を求める
    UInt Abs(const Int a) {
        return a > 0 ? a : -a;
    }
    // 二つの値の最小値を求める関数
    Int Min(const Int a, const Int b) {
        if (a <= b) {
            return a;
        } else {
            return b;
        }
    }
}
using namespace BasicMath;

// ビット演算
namespace Bits {
    // 整数x の 下から i 桁目が1かどうかを返す
    static bool IsFlagUp(Int x, Int i);
    // 整数x の 下から i 桁目が1かどうかを返す
    bool IsFlagUp(Int x, Int i) {
        return ((x & (1 << i)) != 0);
    }
}
using namespace Bits;

int main(void) {
    Int n, a, b, c;
    cin >> n >> a >> b >> c;
    VI l(n);
    for (Int i = 0; i < n; ++i) {
        cin >> l[i];
    }
    Int size = pow(2, n);
    VI bamboo(size);
    VI cost(size);
    for (Int i = 0; i < size; ++i) {
        bamboo[i] = 0;
        cost[i] = 0;
        for (Int j = 0; j < n; ++j) {
            if (IsFlagUp(i, j)) {
                bamboo[i] += l[j];
                cost[i]++;
            }
        }
    }
    VI da(size);
    VI db(size);
    VI dc(size);
    for (Int i = 1; i < size; ++i) {
        da[i] = Abs(bamboo[i] - a) + 10 * (cost[i] - 1);
        db[i] = Abs(bamboo[i] - b) + 10 * (cost[i] - 1);
        dc[i] = Abs(bamboo[i] - c) + 10 * (cost[i] - 1);
    }
    Int answer = INT_MAX;
    for (Int i = 1; i < size; ++i) {
        for (Int j = 1; j < size; ++j) {
            for (Int k = 1; k < size; ++k) {
                bool flag = true;
                for (Int x = 0; x < n; ++x) {
                    bool xa = IsFlagUp(i, x);
                    bool xb = IsFlagUp(j, x);
                    bool xc = IsFlagUp(k, x);
                    if (xa && xb) {
                        flag = false;
                    }
                    if (xb && xc) {
                        flag = false;
                    }
                    if (xc && xa) {
                        flag = false;
                    }
                }
                if (flag) {
                    answer = Min(answer, da[i] + db[j] + dc[k]);
                }
            }
        }
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int m=n;
  int s=0;
  for( int i=0;i<9;i++){
    s+=m%10;
    m/=10;
  }
  if(n%s ==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256