akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

        int n=gi();


        if (n%s(n)==0) {
	       System.out.println("Yes");
        } else {
        	System.out.println("No");
        }

//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}
	
	public static int s(int n) {
		String S=String.valueOf(n);
		int c=0;
		for (int i=0; i<S.length();i++) {
			int k=Integer.parseInt(S.substring(i, i+1));
			c+=k;
		}
		return c;
	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35520
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = new String(in.nextLine());
		boolean f1=huiwen(s);
		boolean f2=huiwen(s.substring(0, (s.length()-1)/2));
		boolean f3=huiwen(s.substring((s.length()+3)/2-1, s.length()));
		if(f1&&f2&&f3) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
	public static boolean huiwen(String ss) {
		StringBuffer a = new StringBuffer(ss);
		String s1 = a.toString();
		String s2 = a.reverse().toString();
		return s1.equals(s2);
	}
}

Measured memory_bytes: 23508
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

bool notPrime[50000005]={};

void calcPrimes(int n){
    int sqrtn = static_cast<int>(sqrt(n));
    notPrime[0] = true;
    for (int i = 3; i<=sqrtn; i+=2){
        if (notPrime[i/2]) continue;
        for (int j= i * i; j<=n; j+=2*i) notPrime[j/2] = true;
    }
}

int main()
{
    int N = 0;
    cin >> N;
    vector<int> nums(N);
    for (auto & num : nums) cin >> num;
    int numMax = 0;
    numMax = *max_element(nums.begin(), nums.end());
    calcPrimes(numMax);
    int counter = 0;
    for (auto & num : nums){
        if (num == 2 || ((num & 1) && !notPrime[num/2])) ++counter;
    }
    cout << counter << endl;
    return 0;
}

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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


vi visited;
int n;
int ans = 0;

void dfs(int node, vector<vi>&graph, int cnt)
{
	if(visited[node])
		return;

	if(cnt == n)
		ans++;

	visited[node] = true;

	for(int x: graph[node])
	{
		dfs(x, graph, cnt+1);
	}

	visited[node] = false;

	return;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int m, x, y;
	cin >> n >> m;

	visited = vi(n+1, false);
	vector<vi> graph(n+1);

	for(int i = 0; i < m; i++)
	{
		cin  >> x >> y;
		graph[x].pb(y);
		graph[y].pb(x);
	}

	dfs(1, graph, 1);
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 256
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>n>>x;
     while(n--){
        cin>>a;
        sum+=a;
        if(sum<=x){
            l++;
        }
     }
     cout<<l+1<<endl;

     return EXIT_SUCCESS;
}



Measured memory_bytes: 3660
#include <iostream>
#include <cmath>
using namespace std;
int D;
double V[16];
double interpolate(int n, int E){
	// L(n) を補間多項式により計算する
	// ただし点 (n,V[n]) と (E,V[E]) は使わない
	double sum = 0;
	for(int k=0; k<D+3; ++k){
		if(k==n||k==E)continue;
		double p = V[k];
		for(int i=0; i<D+3; ++i)
			if(i!=k&&i!=n&&i!=E)
				p=p*(n-i)/(k-i);
		sum += p;
	}
	return sum;
}

bool outlier(int E){
	for(int i=0; i<D+3; ++i){
		if(i==E)continue;
		double p = interpolate(i, E);
		if(abs(p-V[i])>0.1)return false;
	}
	return true;
}

int main(){
	for(;cin>>D,D;){
		for(int i=0; i<D+3; ++i)cin >> V[i];
		for(int i=0; i<D+3; ++i)if(outlier(i)){// i を無視すれば全て整合する
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 1232
import           Data.List
import           Control.Applicative
import           Control.Monad
import           Control.Monad.State

judge :: [String] -> State [Int] [String]
judge []         = return []
judge ("+" : xs) = do
  (b : a : rest) <- get
  put rest
  judge $ show (a + b) : xs
judge ("-" : xs) = do
  (b : a : rest) <- get
  put rest
  judge $ show (a - b) : xs
judge ("*" : xs) = do
  (b : a : rest) <- get
  put rest
  judge $ show (a * b) : xs
judge ("/" : xs) = do
  (b : a : rest) <- get
  put rest
  judge $ show (div a b) : xs
judge [x     ] = return [x]
judge (x : xs) = do
  modify (read x :)
  judge xs

main = do
  r <- judge . words <$> getLine
  putStrLn $ head $ evalState r []



Measured memory_bytes: 3908
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = sS[2] + " " + sS[0] + " " + sS[1];

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 25820
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val h, w = sc.nextInt()

  val st = Stream.range(0, h)
    .map(_ => "#" + sc.next + "#")

  val wall = Seq.fill(w + 2)('#').mkString

  Stream.concat(Stream(wall), st, Stream(wall))
    .foreach(println)
}


Measured memory_bytes: 25988
# Aizu Problem 0006: GCD and LCM
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def gcd(a, b):
    while b != 0:
       t = b
       b = a % b
       a = t
    return a


def lcm(a, b):
    return (a * b) // gcd(a, b)


for line in sys.stdin:
    a, b = [int(_) for _ in line.split()]
    print(gcd(a, b), lcm(a, b))

Measured memory_bytes: 7692
N = int(input())
red_points  = sorted([list(map(int, input().split())) for i in range(N)], key = lambda x: (-x[1], -x[0]))
blue_points = sorted([list(map(int, input().split())) for i in range(N)], key = lambda x: (x[0], x[1]))
for blue_point in blue_points:
    blue_point.append(False)

ans = 0
for red_point in red_points:
    for blue_point in blue_points:
        if red_point[0] < blue_point[0] and red_point[1] < blue_point[1] and not blue_point[2]:
            ans += 1
            blue_point[2] = True
            break
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
vector<i64> A;
int K;
int main(){
  cin >> N >> K;
  A.resize(N);
  rep(i,0,N - 1) cin >> A[i];

  int pos = 0;
  rep(i,0,N - 1){
    if(A[i] == 1){
      pos = i;
    }
  }
  int ans = N;
  rep(l,pos - K + 1,pos){
    int r = l + K - 1;
    int ll = l;
    int rr = N - r - 1;
    if(ll >= 0 && rr >= 0){
      ans = min(ans , ll / (K - 1) + min(1 , ll % (K - 1)) + rr / (K - 1) + min(1 , rr % (K - 1)) + 1);
    }
  }

  cout << ans << endl;
}


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

using namespace std;

int main(){

  int n,k;
  long q;
  
  cin>>n>>k>>q;
  
  vector<int> a(q);
  vector<int> ans(n,k-q);
	for(int i=0; i < q;i++){
      cin>>a.at(i);
	}
  
  for(int i=0;i<q; i++){
    ans.at(a.at(i)-1)++;
  }
  
  for(int i=0;i<n;i++){
  
    if(ans.at(i)>0){
    cout<<"Yes"<<endl;
    }
    else{
    cout<<"No"<<endl;
    }
    
  }
    
  return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < 10; ++i)
		{
			int a = stdIn.nextInt();
			list.add(a);
		}
		Collections.sort(list);
		for(int i = 9; i > 6; --i)
		{
			System.out.println(list.get(i));
		}
	}
}

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

int main() {
  int N, x, sum, count;
  cin >> N >> x;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  
  sum = 0;
  int i = 0;
  while (sum < x){
    sum += vec.at(i);
    if (sum > x) break;
    if ((i == N - 1) && sum != x) break;
    i++;
  }
  
  cout << i << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long X,i,m=100;
    scanf("%lld",&X);
    for(i=1;;i++){
        m=m+m*0.01;
        if(m>=X)
           break;
    }
    printf("%lld\n",i);
    return 0;
}


Measured memory_bytes: 3832
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

const int INFTY=(numeric_limits<int>::max())/2;
vector<vector<int>>d;//d[u][v]は辺uvのコスト、ただし存在しないときINFTY,d[i][i]=0,d.resize(V,vector<int>(V,INFTY));とすること

void warshall_floyd(int V){//Vは頂点数
	for(int k=0;k<V;++k){//経由する頂点
		for(int i=0;i<V;++i){//始点となる頂点
			for(int j=0;j<V;++j)//目的地の頂点
      d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		}
	}
}

void solve(){
    int h,w;
    cin>>h>>w;
    int c;
    d.resize(10,vector<int>(10,INFTY));
    rep(i,10){
        rep(j,10){
            cin>>c;
            d[i][j]=c;
        }
    }
    int sum=0;
    warshall_floyd(10);
    rep(i,h){
        rep(j,w){
            int a;
            cin>>a;
            if(a==-1||a==1)continue;
            sum+=d[a][1];
        }
    }
    cout<<sum;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<"debug... "<<n1<<"\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
class abc
{
    public:
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll n,m;
    cin>>n>>m;
    if (n==m)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int n, m;
    cin >> n >> m;
    vector<LP> A(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        A[i].first = a;
        A[i].second = b; 
    }

    sort(ALL(A));
    ll ans = 0;
    for(auto x : A) {
        if(x.second >= m) {
            ans += x.first * m;
            break;
        } else {
            ans += x.first * x.second;
            m -= x.second;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = list(int(i) for i in input().split())

r = max(a)
Len = abs(a[0] - r/2)
l = a[0]
for i in range(n):
    if abs(a[i] - r/2) <= Len:
        Len = abs(a[i] - r/2)
        l = a[i]

print("%d %d" % (r, l))

Measured memory_bytes: 14428
from math import gcd
n = int(input())
a = list(map(int,input().split()))
l,r = [a[0]]*n,[a[n-1]]*n
for i in range(1,n-1):
  l[i] = gcd(l[i-1],a[i])
  r[n-i-1] = gcd(r[n-i],a[n-i-1])
ans = [0]*n
ans[0] = r[1]
ans[n-1] = l[n-2]
for i in range(1,n-1):
  ans[i] = gcd(l[i-1],r[i+1])
print(max(ans))

Measured memory_bytes: 24900
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    A[a-1]=i;
  }
  for(int i=0;i<N;i++)cout<<(N+1)*i+1<<(i==N-1?'\n':' ');
  for(int i=0;i<N;i++)cout<<(N+1)*(N-i)+A[i]+1<<(i==N-1?'\n':' ');
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a[200005],ans;
int main()
{  cin>>n;
   for(int i=1;i<=n;i++)cin>>a[i];
   for(int i=1;i<=n;i++)
   {  if(i%2==1&&a[i]%2==1)ans++;
   }
   cout<<ans;
}

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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n;
int a[100010];

map<int, int> mp;
int T;

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

	int minv = INF;
	for (int i = 0; i < n; i++) {
		if (a[i] < minv) minv = a[i];
		int val = a[i] - minv;
		mp[val]++;
	}

	auto ite = mp.end(); ite--;

	cout<< ite->second <<endl;
	
	return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

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

    long long stand = sqrt(n);

    long long minv = 1e12;
    for(long long a = 1; a <= stand; a++){
        if(n % a == 0){
            long long b = n / a;
            minv = min(minv, a+b-2);
        }
    }

    cout << minv << endl;

    return 0;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200050
#define ll long long
#define pb push_back
#define x first
#define y second
using namespace std;
int ar[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n; cin>>n;
    for(int i=0;i<n-1;i++){
        int b; cin>>b;
        ar[b]++;
    }
    for(int i=0;i<n;i++)
    cout<<ar[i+1]<<"\n";
    return 0;
}


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

int main()
{
    string s;
    cin >> s;

    int n = s.size();
    int mod = (int)1e9 + 7;

    vector<vector<long long>> dp(n + 1, vector<long long>(13, 0));
    dp[0][0] = 1;

    int mul = 1;
    for (int i = n - 1; i >= 0; i--)
    {
        if (s[i] != '?')
        {
            int num = s[i] - '0';
            for (int j = 0; j < 13; j++)
            {
                dp[n - i][(num * mul + j) % 13] += dp[n - i - 1][j];
                dp[n - i][(num * mul + j) % 13] %= mod;
            }
        }

        else
        {
            for (int num = 0; num < 10; num++)
            {
                for (int j = 0; j < 13; j++)
                {
                    dp[n - i][(num * mul + j) % 13] += dp[n - i - 1][j];
                    dp[n - i][(num * mul + j) % 13] %= mod;
                }
            }
        }
        
        mul = (mul * 10) % 13;
    }

    cout << dp[n][5] << endl;

    return 0;
}

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

int main(){
  char S[3],T[3];
  scanf("%s\n%s", &S, &T);
  
  int yohoHit = 0;
  for(int i=0; i<3; i++){
   	 if(S[i] == T[i]) yohoHit++;
  }
  printf("%d", yohoHit);
}

Measured memory_bytes: 128
import itertools
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
t=[i+1 for i in range(N)]
S=list(itertools.permutations(t))
a=0
b=0
for i in range(len(S)):
    if list(S[i])==P:
        a=i
    if list(S[i])==Q:
        b=i
print(abs(a-b))

Measured memory_bytes: 8052
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Plural Form
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

/* global variables */

char s[MAX_N + 4];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);
  int n = strlen(s);

  if (s[n - 1] == 's') printf("%ses", s);
  else printf("%ss\n", s);
  return 0;
}


Measured memory_bytes: 3796
INFTY = 10**4
N,Ma,Mb = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
dp = [[[INFTY for _ in range(401)] for _ in range(401)] for _ in range(N+1)]
dp[0][0][0] = 0
for i in range(1,N+1):
    for j in range(401):
        for k in range(401):
            dp[i][j][k] = dp[i-1][j][k]
            a = A[i-1][0]
            b = A[i-1][1]
            c = A[i-1][2]
            if j>=a and k>=b:
                dp[i][j][k] = min(dp[i][j][k],dp[i-1][j-a][k-b]+c)
cmin = INFTY
for j in range(1,401):
    for k in range(1,401):
        if j*Mb==k*Ma:
            cmin = min(cmin,dp[N][j][k])
if cmin>=INFTY:
    print(-1)
else:
    print(cmin)

Measured memory_bytes: 99164
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n);
  for (i64 i = 0; i < n; i++)
    cin >> a[i];
  i64 ans = 0, now = 1e18;
  for (i64 i = 0; i < n; i++)
    if (a[i] < now)
    {
      ans = i + 1;
      now = a[i];
    }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3632
//
// author  : Abhishek
//
#include <bits/stdc++.h>
#include<chrono>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;
using namespace chrono;

const ll mod = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif

    auto start = high_resolution_clock::now();

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;

    cin>>a>>b;
    cout<<a*b/(__gcd(a,b));


    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() / 1000.0 << endl;
#endif


    return 0;
}




Measured memory_bytes: 3608
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 105;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string s;
LL k, dp[N][5][2];

int fun(int pos, int cnt, int small) {
    if (cnt > k) {
        return 0;
    }
    if (pos == s.size()) {
        return cnt == k;
    }
    LL &tmp = dp[pos][cnt][small];
    if (tmp != -1) {
        return tmp;
    }
    tmp = 0;
    int j = small ? 9 : s[pos] - '0';
    for (int i = 0; i <= j; i++) {
        tmp += fun(pos + 1, (i != 0) + cnt, i < j ? 1 : small);
    }
    return tmp;
}

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    cin >> s >> k;
    memset(dp, -1, sizeof dp);
    cout << fun(0, 0, 0) << '\n';
    return 0;
}


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int a[5], sum= 0, h= 0, c;

    for(int i=0; i<5; i++)
    {
        cin>> a[i];
        c= ((a[i]+ 9)/10)* 10;
        sum += c;

        h= max ( h, c- a[i]);
    }

    cout << sum- h;
    nl;

    return 0;
}




Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>

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

using namespace std;
using vint = std::vector<int>;

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

	int begin, end;
	int sum = 0;

	rep(i, N) {
		cin >> begin >> end;

		if (begin == end) {
			sum++;
		}
		else {
			sum += end - begin + 1;
		}
	}

	cout << sum << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    rep(i, N) cin >> v[i] >> w[i];
    
    vector<vector<int>> dp(N + 1, vector<int>(W + 1, -1));
    dp[0][0] = 0;
    REP(i, N + 1) rep(j, W + 1) {
        dp[i][j] = dp[i - 1][j];
        if (j < w[i - 1]) continue;
        if (dp[i - 1][j - w[i - 1]] == -1) continue;
        dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
    }
    int ans = 0;
    rep(i, W + 1) ans = max(ans, dp[N][i]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 6828
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, char const* argv[])
{
	string str;
	int ei = 0;
	int ty = 0;
	int don = 0;
	while(getline(cin, str)){
			istringstream iss(str);
			int x, y, z;
			iss >> x >> y >> z;
			int maxi = max(x, max(y, z));
			if(maxi == x){
					if(x < y + z){
							if(y * y + z * z - x * x > 0){
									ei++;
							}else if(y * y + z * z - x * x < 0){
									don++;
							}else{
									ty++;
							}
					}else{
							break;
					}
			}else if(maxi == y){
					if(y < x + z){
							if(x * x + z * z - y * y > 0){
									ei++;
							}else if(x * x + z * z - y * y < 0){
									don++;
							}else{
									ty++;
							}
					}else{
							break;
					}
			}else{
					if(z < x + y){
							if(x * x + y * y - z * z > 0){
									ei++;
							}else if(x * x + y * y - z * z < 0){
									don++;
							}else{
									ty++;
							}
					}else{
							break;
					}
			}
	}
	cout << ei + ty + don << " " << ty << " " << ei << " " << don << endl;
	return 0;
}



Measured memory_bytes: 3188
using System;

class AOJ
{
	public static void Main()
	{
		var input = Console.ReadLine().Trim().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);
		int large = Math.Max(a, b);
		int small = Math.Min(a, b);
		if(small == 0)
		{
			Console.WriteLine(small);
			return;
		}

		while(true)
		{
			int mod = large % small;
			if(mod == 0)
			{
				Console.WriteLine(small);
				break;
			}
			large = small;
			small = mod;
		}
	}
}

Measured memory_bytes: 19932
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int[] d = new int[n];
		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int[] t = new int[m];
		for (int i = 0; i < m; i++) {
			t[i] = sc.nextInt();
		}
		TreeMap<Integer, Integer> dmap = new TreeMap<>();
		for (int i = 0; i < n; i++) {
			if (!dmap.containsKey(d[i])) {
				dmap.put(d[i], 1);
			} else {
				dmap.put(d[i], dmap.get(d[i]) + 1);
			}
		}
		TreeMap<Integer, Integer> tmap = new TreeMap<>();
		for (int i = 0; i < m; i++) {
			if (!tmap.containsKey(t[i])) {
				tmap.put(t[i], 1);
			} else {
				tmap.put(t[i], tmap.get(t[i]) + 1);
			}
		}
		boolean ok = true;
		for (int key: tmap.keySet()) {
			int need = tmap.get(key);
			if (!dmap.containsKey(key) || dmap.get(key) < need) {
				ok = false;
				break;
			}
 		}
		if (ok) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 72656
#include<stdio.h>

#include<algorithm>


using namespace std ;

typedef long long llong ;

struct Data
{
	llong size ;
	llong value ;

} ;

#define N_MAX 500000
Data art[ N_MAX ] ;

inline bool cmp( const Data& a ,const Data& b )
{
	return a.size == b.size ? a.value < b.value : a.size < b.size ;
}

inline llong Max( llong a ,llong b )
{
	return a > b ? a : b ;
}


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

	int i ;
	for( i = 0 ; i < N ; ++i )
	{
		scanf( "%lld %lld" ,&art[ i ].size ,&art[ i ].value ) ;
	}

	sort( art ,art + N ,cmp ) ;

	llong min_size	= art[ 0 ].size		;
	llong sum_value	= art[ 0 ].value	;

	llong ans = art[ 0 ].value ;
	for( i = 1 ; i < N ; ++i )
	{
		llong value	= art[ i ].value	;
		llong size	= art[ i ].size		;

		llong tmp =  sum_value + value  - ( size -  min_size ) ;
		if( tmp < value )
		{
			ans = Max( ans ,value ) ;

			sum_value	= value	;
			min_size	= size	;
		}

		else
		{
			ans = Max( ans ,tmp ) ;

			sum_value += value ;
		}
	}

	printf( "%lld\n" ,ans ) ;

	return 0 ;
}


Measured memory_bytes: 10592
#include<stdio.h>
#include<string.h>
int main(void){
  char alf[27]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int l,i,j,n;
  scanf("%d",&l);
  char str[10000],moji;
  scanf("%s",str);
  for(i=0;i<strlen(str);i++){
    for(j=0;j<27;j++){
      if(str[i]==alf[j]){
        moji=j;
      }
    }
    n=moji+l;
    while(n>25){
      n-=26;
    }
    printf("%c",alf[n]);
  }
  return 0;
}


Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
carry = 0
for a, b in zip(A, B):
    a2 = max(0, a - carry)

    if a2 < b:
        ans += a
        carry = b - a2
    else:
        ans += carry + b
        carry = 0

ans += min(carry, A[-1])
print(ans)

Measured memory_bytes: 97720
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;

long long int dp[105][100005];

int main(){
    int n, sack_size;

    cin >> n >> sack_size;

    vector<pair<int, int>>things;
    pair<int, int>input;

    input.first = 0, input.second = 0;

    things.push_back(input);

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

        cin >> input.first >> input.second; // first -> weight, second -> price
        things.push_back(input);
    }

    sort(things.begin() + 1, things.end());

    for(int i = 1; i <= n; i++){
        for(int j = 1; j < things[i].first; j++){
            dp[i][j] = dp[i - 1][j];
            //cout << "   " <<dp[i][j] << " " << dp[i - 1][j];
        }
        //cout << endl << endl;
        for(int j = things[i].first; j <= sack_size; j++){
            dp[i][j] = max(dp[i - 1][j], things[i].second + dp[i - 1][j - things[i].first]);
            //cout << dp[i][j] << " ";
        }
       // cout << endl << endl;
    }

    cout << dp[n][sack_size] << endl;
    /*int i = n, j = sack_size;
    while(i > 0 && j > 0){
        if(dp[i][j] == dp[i - 1][j]){
            i--;
        }else{
            cout << things[i].first << " " << things[i].second << endl;
            i--;
            j -= things[i].second;
        }
    }*/

    return 0;
}

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

bool isp(int n) {
  if (n < 2) return false;
  else if (n == 2) return true;
  else if (n % 2 == 0) return false;
  int s = (int)sqrt(n);
  for (int i = 3; i <= s; i += 2) if (n % i == 0) return false;
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  vector<int> V(100001);
  for (int i = 1, cnt = 0; i < 100001; i++) {
    if (!((i + 1) % 2) && isp(i) && isp((i + 1) / 2)) cnt++;
    V.at(i) = cnt;
  }
  int Q;
  cin >> Q;
  for (int l, r; cin >> l >> r;) cout << V.at(r) - V.at(l - 1) << "\n";
}

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

typedef long long LL;
const int MOD=1e9+7;
int INF=0x3f3f3f3f;
//memset(a,0x3f,sizeof(a));

LL fun(int n){
	LL res=1;
	for(int i=1;i<=n;i++){
		res=(res*i)%MOD;
	}
	return res%MOD;
}


int main(){
	ios_base::sync_with_stdio(false);
	int n,m;
	cin>>n>>m; 
	if(abs(n-m)>=2) {cout<<0<<endl;return 0;}
	if(abs(n-m)==1){
		LL ans1=fun(m);
		LL ans2=fun(n);
		cout<<(ans1*ans2)%MOD<<endl;
		return 0;
	}
	else if(abs(n-m)==0){
		LL ans1=fun(m);
		LL ans2=fun(n);
		cout<<(ans1*ans2*2)%MOD<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int MOD = 1000000007;

int N, M;
bool ng[100010];
int dp[100010];

signed main()
{
	cin >> N >> M;

	rep(_, M) {
		ng[read()] = true;
	}

	dp[0] = 1;

	for (int i = 0; i <= N; ++i) {
		if (not ng[i + 1]) (dp[i + 1] += dp[i]) %= MOD;
		if (not ng[i + 2]) (dp[i + 2] += dp[i]) %= MOD;
	}

	cout << dp[N] << endl;
}




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

int main(void){
    int n,a[100];
    int n1,n2,m=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;i<n-1;i++){
        n1 = a[i]-a[i-1];
        n2 = a[i]-a[i+1];
        if(n1>0 && n2<0 || n1<0 && n2>0) m++;
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] l = new int[n+1];
        l[0]=0;
        for(int i=0;i<n;i++){
            l[i+1] = l[i] + sc.nextInt();
        }
        int ans = 0;
        for(int i=0;i<n+1;i++){
            if(l[i]<=x){
                ans = i+1;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

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

		String s1 = sc.next();
		String s2 = new StringBuilder(sc.next()).reverse().toString();

		System.out.println((s1.equals(s2)) ?  "YES" : "NO");

		sc.close();


	}

}




Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define MAXN 100000

std::vector <int> G[1 + MAXN];
int p[1 + MAXN];
int seen[1 + MAXN];
std::vector <int> V;
std::map <int, int> M;

void dfs(int node){
    V.push_back(node);
    M[p[node]]++;
    for(auto y: G[node]) if(!seen[y]){
        seen[y] = 1;
        dfs(y);
    }
}

int main(){
    FILE*fi,*fo;
    //fi = fopen("a.in","r");
    //fo = fopen("a.out","w");
    fi = stdin;
    fo = stdout;

    int n, m;
    fscanf(fi,"%d%d", &n, &m);
    for(int i = 1; i <= n; i++)
        fscanf(fi,"%d", &p[i]);

    for(int i = 1; i <= m; i++){
        int x, y;
        fscanf(fi,"%d%d", &x, &y);
        G[x].push_back(y);
        G[y].push_back(x);
    }

    int con = 0;
    for(int i = 1; i <= n; i++)
        if(!seen[i]){
            seen[i] = 1;
            dfs(i);
            for(auto y: V)
                if(M[y]) con++;
            for(auto y: V)
                M[p[y]]--;
            V.clear();
        }
    fprintf(fo,"%d", con);

    fclose(fi);
    fclose(fo);
    return 0;
}


Measured memory_bytes: 16632
#!/usr/bin/env python3
n,m = map(int,input().split())
digit = [-1]*3
for i in range(m):
    s,c =map(int,input().split())
    if digit[s-1] == -1: digit[s-1] = c
    elif digit[s-1] != c: 
        print(-1)
        exit()
if digit[0] == 0 and n != 1:
    print(-1)
    exit()
if (digit[0] == 0 and n == 1) or (n == 1 and m == 0):
    print(0)
    exit()
for i in range(n):
    if digit[i] == -1:
        print(max(1-i,0),end="")
    else: print(digit[i],end="")
        

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
#define mod (int)(1000000007)
using namespace std;
int test[123456];
signed main() {
	int n, m, a, b = 0, ans = 0; cin >> n >> m;
	for (int h = 0; h < m; h++) {
		cin >> a; b += a;
	}
	if (n <= b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    ll mx = 0;
    ll ans = 0;
    rep(i,N){
        ll a;
        cin>>a;
        ans+=a;
        chmax(mx,a);
    }
    cout << ans-mx/2 << endl;


    return 0;
    

}

Measured memory_bytes: 3640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
    int k;
    cin >> k;

    string s;
    cin >> s;

    if(s.size()<=k){
        cout << s << endl;
    }
    else{
        string ss;
        ss = s.erase(k);
        ss = ss.insert(k,"...");
        cout << ss << endl;
    }
    
    return 0;
}

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

using namespace std;

long long int mylb(vector<long long int> &V, long long int t){
  long long int first = -1LL;
  long long int last = V.size();
  long long int mid = 0LL;
  while(last - first > 1){
    mid = first + (last - first) / 2;
    if(V[mid] > t) last = mid;
    else if(V[mid] <= t) first = mid;
    //else return mid//if V[mid] == t
  }
  return last;
}

long long int myub(vector<long long int> &V, long long int t){
  long long int first = -1LL;
  long long int last = V.size();
  long long int mid = 0LL;
  while(last - first > 1){
    mid = first + (last - first) / 2;
    if(V[mid] >= t) last = mid;
    else if(V[mid] < t) first = mid;
    //else return mid//if V[mid] == t
  }
  return first;
}



int main(){
  int N;
  cin >> N;
  vector<long long int> A(N);
  vector<long long int> B(N);
  vector<long long int> C(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 0; i < N; i++) cin >> B[i];
  for(int i = 0; i < N; i++) cin >> C[i];
  sort(A.begin(), A.end());
  sort(C.begin(), C.end());
  long long int  ans = 0LL;
  for(int i = 0; i < N; i++){
    long long int a = myub(A, B[i]);
    long long int c = mylb(C, B[i]);
    if(a == -1 || c == -1) continue;
    ans += (a+1) * (N - c);
    //cout  << a+1 << " " << N - c << endl;
  }
  cout << ans;
}


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

int main() {
    using vi = vector<int>;
    
    int a,b,k;
    cin >> k >> a >> b;
    for(int i = a;i <= b;i++){
        if(i%k==0){
            cout << "OK" << endl;
            exit(0);
        }
    }
    cout << "NG" << endl;
}

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

using edges = vector<int>;
using Graph = vector<edges>;

int main() {
    int n;
    cin >> n;
    Graph g(n);
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; ++j) {
            int v;
            cin >> v;
            v--;
            g[u].push_back(v);
        }
    }
    queue<int> que;
    que.emplace(0);
    vector<int> dis(n, -1);
    dis[0] = 0;
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (int nv : g[v]) if (dis[nv] < 0) {
            dis[nv] = dis[v] + 1;
            que.emplace(nv);
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << i + 1 << " " << dis[i] << endl;
    }
}


Measured memory_bytes: 3132
#include<stdio.h>
#include<map>
#define maxn 100005
using namespace std;
long long remainder[maxn];
long long a[maxn];
map<long long,long long>number_l;
int main()
{
    long long n,m,answer=0;
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        remainder[i]=remainder[i-1]+a[i];
        remainder[i]%=m;
        answer+=number_l[remainder[i]];
        number_l[remainder[i]]++;
    }
    answer+=number_l[0];/**自己为起点自己为终点没有算进去，要补上**/
    printf("%lld\n",answer);
    return 0;
}
/**https://blog.csdn.net/qq_41061455/article/details/81591292**/

Measured memory_bytes: 5760
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	k, _ := strconv.Atoi(stringLineScan())
	v := make([]int, n)
	ans := 0
	for i := 0; i < n; i++ {
		v[i], _ = strconv.Atoi(stringLineScan())
	}
	for i := 0; i <= smaller(n, k); i++ {
		t := smaller(k-i, i)
		for r := 0; r < i; r++ {
			l := i - r
			x := make([]int, 0)
			for j := 0; j < l; j++ {
				x = append(x, v[j])
			}
			for j := 0; j < r; j++ {
				x = append(x, v[n-j-1])
			}
			sort.Ints(x)
			a := sum(x)
			for j := 0; j < t; j++ {
				if x[j] < 0 {
					a -= x[j]
				} else {
					break
				}
			}
			if ans < a {
				ans = a
			}
		}
	}
	fmt.Println(ans)
}
func sum(x []int) int {
	y := 0
	for _, v := range x {
		y += v
	}
	return y
}
func smaller(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
  	cin>>n;
    vector<long long>v;
    for(int i=0; i<n; i++){
        long long k;
        cin>>k;
        v.push_back(k);
    }
  cout<<*max_element(v.begin(),v.end())-*min_element(v.begin(),v.end())<<endl;
}

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

struct Circle
{
	int x,y,r,c,m;
};

int N;
char mem[1<<24];
Circle s[24];

int solve(int state)
{
	if(mem[state]>=0)
	{
		return mem[state];
	}

	vector<int> del[4];
	for(int i=0; i<N; i++)
	{
		if(state & (1<<i))
		{
			if(state & s[i].m) continue;
			del[s[i].c-1].push_back(i);
		}
	}

	int res=0;

	for(int k=0;   k<4; k++)
	for(int i=0;   i<del[k].size(); i++)
	for(int j=i+1; j<del[k].size(); j++)
	{
		int newstate = state;
		newstate &= ~(1<<del[k][i]);
		newstate &= ~(1<<del[k][j]);
		res = max(res, solve(newstate)+2);
	}

	mem[state] = res;

	return res;
}

int main()
{
	while(cin>>N, N)
	{
		memset(mem, -1, sizeof(mem));

		for(int i=0; i<N; i++)
		{
			cin>>s[i].x>>s[i].y>>s[i].r>>s[i].c;
		}

		for(int i=0; i<N; i++)
		{
			s[i].m=0;
			for(int j=0; j<i; j++)
			{
				int dx = s[i].x-s[j].x;
				int dy = s[i].y-s[j].y;
				int dr = s[i].r+s[j].r;
				if(dx*dx+dy*dy < dr*dr)
				{
					s[i].m |= 1<<j;
				}
			}
		}

		cout << solve((1<<N)-1) << endl;
	}
}

Measured memory_bytes: 16000
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var N = cin.ReadInt();
            if (N == 0) { WriteLine(2); return; }
            if (N == 1) { WriteLine(1); return; }
            var L0 = 2L;
            var L1 = 1L;
            var L = 0L;
            for (int i = 1; i < N; ++i)
            {
                L = L0 + L1;
                L0 = L1;
                L1 = L;
            }
            WriteLine(L);
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}

Measured memory_bytes: 11220
#include<cstdio>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
		int n,k;cin>>n>>k;int a;
		int counter[200001];memset(counter,0,sizeof(counter));
		for(int i=0;i<n;i++){
			cin>>a;
			counter[a]++;
			}//for
			int ans=0;
		sort(counter,counter+200001);
		for(int i=0;i<200001-k;i++){
			ans+=counter[i];
		}
		cout<<ans<<endl;
}

Measured memory_bytes: 1024