akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a_n =  list(map(lambda x:int(x), input().split()))

def mul_sum(list):
    mulsum = 0
    for i in range(len(list)):
        tmp = list[:]
        tmp.pop(i)
        mulsum = mulsum + mul(tmp)
    return(mulsum)


def mul(list):
    mul = 1
    for i in range(len(list)):
        mul = mul*list[i]
    return(mul)


print(mul(a_n)/mul_sum(a_n))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793238;
int main()
{
	int n;
	cin >> n;
	vector<int> a(n+1,0), b(n+1,0);
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for (int i = n; i > 0; i--)
	{
		int tmp = i;
		int count = 0;
		while (tmp <= n)
		{
			count += b.at(tmp);
			tmp += i;
		}
		if (count % 2 != a.at(i))
		{
			b.at(i) = 1;
		}
		else
		{
			b.at(i) = 0;
		}
	}
	int m = 0;
	for (int i = 1; i <= n; i++)
	{
		m += b.at(i);
	}
	cout << m << endl;
	for (int i = 1; i <= n; i++)
	{
		if (b.at(i))
			cout << i << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 2432
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean ans = true;
        String[] s = new String[n];
        s[0] = sc.next();
        for(int i =1;i<n;i++){
            String tmp = sc.next();
            if(Arrays.asList(s).contains(tmp)){
                ans = false;
                break;
            }
            s[i] = tmp;
            if(s[i].charAt(0)!=s[i-1].charAt(s[i-1].length()-1)){
                ans = false;
                break;
            }
        }
        if(ans){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a; i<n; i++)
using namespace std;
  
int main() {
int w,n; cin >> w >> n;
int a[31];
rep(i,0,w) a[i] = i+1;
  
rep(i,0,n) {
int x,y;
scanf("%d,%d",&x,&y);
swap(a[x-1],a[y-1]);
}
rep(i,0,n) cout << a[i] << endl;
return 0;
}

Measured memory_bytes: 1240
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
x = LIST()


ans = INF
idx = bisect(x, 0)
for i in range(idx-K, idx+1):
	if 0 <= i <= N-K:
		if i == idx-K:
			ans = min(ans, abs(x[i]))
		elif i == idx:
			ans = min(ans, x[i+K-1])
		else:
			ans = min(ans, 2*abs(x[i])+x[i+K-1], abs(x[i])+2*x[i+K-1])
print(ans)


Measured memory_bytes: 15456
using System;

namespace ITP1_4_B
{
    class Program
    {
        static void Main(string[] args)
        {
            //半径をinput
            string str = Console.ReadLine();
            double r = double.Parse(str);

            if (r <= 0 && 10000 <= r)
                Environment.Exit(0);

            double area, circumference;

            area = r * r * 3.14159265358979323846; //面積計算

            circumference = r * 2 * 3.14159265358979323846; //周計算

            Console.WriteLine("{0,-8:F6} {1,-8:F6}",area,circumference);
        }
    }
}


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

struct Card{
	char suit, value;
};

void bubble(struct Card A[], int N){
	for(int i=0; i<N; i++){
		for(int j=N-1; j >=i+1; j--){
			if(A[j].value < A[j-1].value){
				Card t = A[j]; A[j] = A[j-1]; A[j-1]=t;
			}
		}
	}
}

void selection(struct Card A[], int N){
	for (int i =0; i<N; i++){
		int minj = i;
		for(int j =i; j <N; j++){
			if(A[j].value < A[minj].value) minj = j;
		}
		Card t = A[i]; A[i] = A[minj]; A[minj]=t;
	}
}

void print(struct Card A[], int N){
	for(int i =0; i <N; i++){
		if(i>0) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N){
	for(int i =0; i< N; i++){
		if(C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

int main(){
	Card C1[100], C2[100];
	int N;
	char ch;

	cin >> N;
	for(int i = 0; i<N; i++){
		cin >> C1[i].suit >> C1[i].value;
	}

	for(int i=0; i< N; i++) C2[i] = C1[i];

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if(isStable(C1, C2, N)){
		cout << "Stable" << endl;
	}else{
		cout << "Not stable" << endl;
	}

	return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define ll long long
//不要再爆long long了！！！！！！！！不要再爆long long了！！！！！！！ 

int main()
{
	int x,y;
	cin>>x>>y;
	if(y%2)cout<<"No";
	else
	{
		if(y>=x*2&&y<=x*4)cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3592
int main(){
  int m[10];
  int i,j,tmp;
  for(i=0;i<10;i++)
    scanf("%d", &m[i]);
  for(i=0;i<3;i++){
    for(j=i+1;j<10;j++){
      if(m[i]<m[j]){
        tmp = m[i];
        m[i]= m[j];
        m[j]= tmp;
      }
    }
  }
  for(i=0;i<3;i++)
    printf("%d\n", m[i]);
  return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S)
{
    string ans = YES;
    for (int i = 0; i < S.length(); i++) {
        if (((i + 1) % 2) == 0) {
            if (S[i] == 'R') {
                ans = NO;
                // cout << "R" << i << endl;
                break;
            }
        } else {
            if (S[i] == 'L') {
                ans = NO;
                // cout << "L" << i << endl;
                break;
            }
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main(){
    int d[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin>>n;
    cout<<d[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 892
#include <iostream>


using namespace std;
int main(){

  int A;
  int B;
  cin >> A >> B;

  int max;
  if (A + B < A - B){
    max = A - B;
  }else{
    max = A + B;
  }

  if (max < A * B){
    max = A * B;
  }
  cout << max;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=105;
int ansd=1e9,n,mx[N];
LL ansf;
vector<int>g[N];
void dfs(int x,int fa,int dep){
	int cnt=0;
	for(auto v:g[x]){
		if(v!=fa)cnt++,dfs(v,x,dep+1);
	}
	mx[dep]=max(mx[dep],cnt);
}
int main(){
	scanf("%d",&n);
	for(int i=1,u,v;i<n;i++){
		scanf("%d%d",&u,&v);
		g[u].push_back(v),g[v].push_back(u);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)mx[j]=0;
		dfs(i,0,1);
		int d=1;LL f=1;
		for(int j=1;j<=n;j++){
			if(mx[j])f*=mx[j],d=j+1;
			else break;
		}
		if((d<ansd)||(d==ansd&&f<ansf)){
			ansd=d,ansf=f;
		}
	}
	for(int i=1;i<=n;i++){
		for(auto j:g[i]){
			for(int k=1;k<=n;k++)mx[k]=0;
			dfs(i,j,1);
			dfs(j,i,1);
			int d=1;LL f=2;
			for(int j=1;j<=n;j++){
				if(mx[j])f*=mx[j],d=j+1;
				else break;
			}
			if((d<ansd)||(d==ansd&&f<ansf)){
				ansd=d,ansf=f;
			}
		}
	}
	printf("%d %lld\n",ansd,ansf);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  int n = s.size();
  bool a = true;
  if(s.at(0)!='A') a = false;
  int count = 0;
  for(int i = 2; i<n-1; i++){
    if(s.at(i)=='C')count++;
  }
  if(count!=1) a = false;
  int acount = 0;
  int ccount = 0;
  rep(i,n){
    if(s.at(i)=='A'){
      acount++;
    }else if(s.at(i)=='C'){
      ccount++;
    }else if(s.at(i)>='A'&&s.at(i)<='Z'){
      a = false;
    }
  }
  if(acount!=1) a = false;
  if(ccount!=1) a=false;
  if(a){
    cout << "AC" << endl;
  }else{
    cout << "WA" << endl;
  }
}


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

int main(){
	int a, b;
  	cin >> a >> b;
  	if(a > 9 || b > 9) cout << -1 << endl;
  	else cout << a * b << endl;
}

Measured memory_bytes: 3624
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());
        String[] s = new String[H];
        String[][] S = new String[H][W];
        int[] dx = { 1, 0, -1, 0, 1, -1, -1, 1 };
        int[] dy = { 0, 1, 0, -1, 1, 1, -1, -1 };
        Integer count;
        String line = "";

        for (int i = 0; i < H; i++) {
            s[i] = sc.next();
            for (int j = 0; j < W; j++) {
                S[i][j] = s[i].split("")[j];
            }
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                count = 0;
                for (int d = 0; d < 8; d++) {
                    int nx = j + dx[d];
                    int ny = i + dy[d];

                    if (nx >= 0 && nx < W && ny >= 0 && ny < H) {
                        if (S[ny][nx].equals("#") && !S[i][j].equals("#")) {
                            count++;
                        }
                    }

                    if (!S[i][j].equals("#")) {
                        S[i][j] = count.toString();
                    }

                }
            }
        }

        PrintWriter out = new PrintWriter(System.out);

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

            line = "";
            for (int j = 0; j < W; j++) {
                line += S[i][j];
            }

            out.println(line);
        }

        sc.close();
        out.flush();
    }
}

Measured memory_bytes: 56236
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> d(N);
    for(int i=0; i<N; i++) {
        cin >> d[i];
    }

    int ans = accumulate(d.begin(), d.end(), 0);
    ans *= ans;
    for(int i=0; i<N; i++) {
        ans -= d[i]*d[i];
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d,x;cin>>n>>d>>x;
    int a;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>a;
        ans+=(d-1)/a+1;
    }
    ans+=x;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
bool is_prime(ll m){
    for(int i = 2; i * i <= m; i++){
        if(m % i == 0) return false;
    }
    return m != 1;
}
int main(){
    int q; cin >> q;
    vector<int> l(q), r(q);
    rep(i, q) cin >> l[i] >> r[i];

    vector<bool> is_like2017(100000, false);
    for(int i = 1; i < 100000; i += 2){
        if(is_prime(i) and is_prime((i + 1) / 2)) is_like2017[i] = true;
    }
    //rep(i, 100) cout << is_like2017[i] << endl;
    vector<int> is_like2017sum(100001, 0);
    is_like2017sum[0] = 0;
    for(int i = 1; i <= 100000; i++){
        if(is_like2017[i - 1]){
            is_like2017sum[i] = is_like2017sum[i - 1] + 1;
        }else{
            is_like2017sum[i] = is_like2017sum[i - 1];
        }
    }
    //rep(i, 100) cout << is_like2017sum[i] << endl;

    rep(i, q){
        cout << is_like2017sum[r[i] + 1] - is_like2017sum[l[i]] << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  string s;
  cin>>s;
  int cou=0;
  rep(i,0,s.size()) if(s[i]=='1') cou++;
  cout<<cou<<endl;
}


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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int r, D, x;
    cin >> r >> D >> x;
    for(int i=0; i<10; i++){
        int m = r*x-D;
        x = m;
        cout << m << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;cin>>k;
    ll a[k];
    rep(i,k){cin>>a[k-1-i];}
    ll _min[k+1]={},_max[k+1]={};
    _min[0]=_max[0]=2;
    rep(i,k){
        _min[i+1] = ((_min[i]-1LL)/a[i]+1LL)*a[i];
        _max[i+1] = (_max[i]/a[i]+1LL)*a[i]-1LL;
        if(_min[i+1]>_max[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    printf("%lld %lld\n",_min[k], _max[k]);
    return 0;
}


Measured memory_bytes: 2560
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll rgb[3], n;
        rep(i, 3) cin >> rgb[i];
        cin >> n;

        ll ans = 0;
        for (int i = 0; i <= n; ++i) {
            for (int j = 0; j <= n; ++j) {
                if ((n - i * rgb[0] - j * rgb[1]) >= 0 && (n - i * rgb[0] - j * rgb[1]) % rgb[2] == 0) {
                    ans++;
                }
            }
        }
        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
struct node{
  int key;
  int cost;
  struct node *next;
};
typedef struct node *GG;
 
GG G[10001];
GG MNode(int,int,GG);
void Insert(int,int,int);
int main()
{
  int i,j,n,count=0,v,c,c1,v1;
  int color[10001],d[10001],pi[10001],mincost,ii;
  GG GGG;
  scanf("%d",&n);
  for(i=0;i<n;i++)G[i]=MNode(0,0,NULL);
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&c);
    for(j=0;j<c;j++){
      scanf("%d%d",&v1,&c1);
      Insert(i,v1,c1);
    }
  }
  for(i=0;i<n;i++){
    color[i]=0;
    pi[i]=-1;
    d[i]=10000001;
  }
  d[0]=0;
  
  while(1){
    mincost=10000001;
    for(i=0;i<n;i++){
      if(color[i]!=2 && d[i]<mincost){
        mincost=d[i];
        ii=i;
      }
    }
    if(mincost==10000001)break;
    color[ii]=2;
    for(GGG=G[ii];GGG!=NULL;GGG=GGG->next){
      if(color[GGG->key]!=2 && (GGG->cost+d[ii])<d[GGG->key]){
	pi[GGG->key]=ii;
	d[GGG->key]=GGG->cost+d[ii];
	color[GGG->key]=1;
      }
    }
  }
  for(i=0;i<n;i++)printf("%d %d\n",i,d[i]);
  
  return 0;
}
 
GG MNode(int key,int cost,GG Node)
{
  GG n;
  n=(GG)malloc(sizeof(struct node));
  n->key=key;
  n->cost=cost;
  n->next=Node;
  return n;
}
void Insert(int s,int t,int u)
{
  GG GGG;
  GGG=MNode(t,u,G[s]->next);
  G[s]->next=GGG;
}

Measured memory_bytes: 16260
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<vector<int>>dis(N, vector<int>(N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			dis[i][j] = min({ i,N - i - 1,j,N - j - 1 });
		}
	}
	vector<vector<int>>used(N, vector<int>(N));
	deque<pair<int, int>>Q;
	int ans = 0;
	K = N * N;
	int dir[] = { 1,0,-1,0,1 };
	while (K--) {
		cin >> M;
		M--;
		int y = M / N, x = M % N;
		used[y][x] = 1;
		ans += dis[y][x];
		Q.emplace_back(y, x);
		while (!Q.empty()) {
			int cy = Q.front().first;
			int cx = Q.front().second;
			int add = 1 - used[cy][cx];
			Q.pop_front();
			for (int i = 0; i < 4; i++) {
				int ny = cy + dir[i], nx = cx + dir[i + 1];
				if (ny < 0 || nx < 0 || ny >= N || nx >= N)continue;
				if (add == 0) {
					if (dis[ny][nx] > dis[cy][cx] + add) {
						Q.emplace_front(ny, nx);
						dis[ny][nx] = dis[cy][cx] + add;
					}
				}
				else {
					if (dis[ny][nx] > dis[cy][cx] + add) {
						Q.emplace_back(ny, nx);
						dis[ny][nx] = dis[cy][cx] + add;
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6576
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	a = list(map(int,input().split()))
	if(a.count(5)==2 and a.count(7)==1):
		print('YES')
	else:
		print('NO')
	

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


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

using namespace std;

int n;
long long dp[3002][3002][2], a[3002];

long long memo (int st, int dr, int p) {
  int semn;
  if (dp[st][dr][p])
    return dp[st][dr][p];
  if (p)
    semn = -1;
  else
    semn = 1;
  if (st == dr)
    return dp[st][dr][p] = semn * a[st];
  long long aux1 = memo(st + 1, dr, !p) + semn * a[st];
  long long aux2 = memo(st, dr - 1, !p) + semn * a[dr];
  if (p)
    return dp[st][dr][p] = min(aux1, aux2);
  else
    return dp[st][dr][p] = max(aux1, aux2);
}


int main()
{
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 1; i <= n; i++)
    dp[i][i][0] = a[i], dp[i][i][1] = -a[i];
  cout << memo(1, n, 0);
  return 0;
}


Measured memory_bytes: 139776
N, M = map(int, input().split())
did_ac = [False] * N
pn_cnt = [0] * N
for _ in range(M):
    p, s = input().split()
    p = int(p) - 1
    if did_ac[p]:
        continue
    s = s == 'AC'
    if s:
        did_ac[p] = True
    else:
        pn_cnt[p] += 1
print(sum(did_ac), sum(pn_cnt[i] for i in range(N) if did_ac[i]))


Measured memory_bytes: 4596
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		String[] tokensA = in.readLine().split(" ");
		String[] tokensB = in.readLine().split(" ");
		String[] tokensC = in.readLine().split(" ");
		int[] A = new int[N];
		int[] B = new int[N];
		int[] C = new int[N - 1];
		for (int i = 0; i < N; ++i) {
			A[i] = Integer.parseInt(tokensA[i]) - 1;
			B[i] = Integer.parseInt(tokensB[i]);
		}
		for (int i = 0; i < N - 1; ++i) {
			C[i] = Integer.parseInt(tokensC[i]);
		}

		int result = 0;
		int prev = A[0];
		result += B[prev];
		for(int i = 1; i < N; ++i) {
			int current = A[i];
			result += B[current];
			if(prev +1 == current) {
				result += C[prev];
			}
			prev = current;
		}
		System.out.println(result);

	}

}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  Int a,b,c,d;
  cin>>a>>b>>c>>d;
  Int x=abs(a-c),y=abs(b-d);

  if(x==0||y==0) drop(0);

  Int g=__gcd(x,y);
  cout<<g*(x/g+y/g-1)<<endl;
  return 0;
}


Measured memory_bytes: 256
# 数値が入っているかチェック、入っていたら*に置き換えるメソッド
# 縦横斜めでビンゴが達成されているかチェックするメソッド

# ビンゴカードをつくる
a = []
3.times do
  a << gets.chomp.split(' ').map(&:to_i)
end

# ビンゴの数字を抽選する回数
n = gets.chomp.to_i

n.times do
  b = gets.chomp.to_i
  3.times do |i|
    3.times do |j|
      a[i][j] = -1 if a[i][j] == b
    end
  end
end

# ビンゴ判定
def judge(a)
  3.times do |i|
    # 横判定
    return print('Yes') if a[i][0] == -1 && a[i][0] == a[i][1] && a[i][1] == a[i][2]
    # 縦判定
    return print('Yes') if a[0][i] == -1 && a[0][i] == a[1][i] && a[1][i] == a[2][i]
  end

  # 斜め判定
  return print('Yes') if 3.times.all? {|i| a[i][i] == -1}
  return print('Yes') if a[0][2] == a[1][1] && a[1][1] == a[2][0]
  
  # ビンゴでないとき
  print('No')
end

judge(a)

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

int main() {
    int n;
    cin >> n;
    ll int count = 0;
    for(int i = 1; i < n; i++) {
        count += (n - 1) / i;
    }
    cout << count << '\n';
}

Measured memory_bytes: 3612
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque




def main():
    num , k = map(int, input().split())
    data = list(input())

    ans = 0
    for i in range(num - 1):
        if data[i] == data[i + 1]:
            ans += 1
    ans = min(num - 1, ans + 2 * k)
    print(ans)



if __name__ == '__main__':
    main()



Measured memory_bytes: 50028
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 100007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

struct UnionFind
{
    vector<ll> par;
    vector<ll> siz;
    UnionFind(ll n) : par(n), siz(n, 1)
    {
        rep(i, n) par[i] = i;
    }
    ll root(ll x)
    {
        while (par[x] != x) x = par[x] = par[par[x]];
        return x;
    }
    //グループを統合して、違うグループだったかを返す
    bool unite(ll x, ll y)
    {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return false;
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
        return true;
    }
    //同じグループに属するか
    bool same(ll x, ll y)
    {
        return root(x) == root(y);
    }
    //属するグループの大きさ
    ll size(ll x)
    {
        return siz[root(x)];
    }
};

void solve()
{
    IN(n, m);
    UnionFind uf(n);
    rep(i, m) {
        IN(a, b); --a; --b;
        uf.unite(a, b);
    }
    ll ans = 0;
    rep(i, n) {
        chmax(ans, uf.siz[i]);
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 6344
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
#include <math.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int i,j,k,N;
string s;
int cnt[5];
ll ans;

int main() {
	cin >> N;
	
	REPI(0, N) {
		cin >> s;
		if (s[0] == 'M') cnt[0]++;
		if (s[0] == 'A') cnt[1]++;
		if (s[0] == 'R') cnt[2]++;
		if (s[0] == 'C') cnt[3]++;
		if (s[0] == 'H') cnt[4]++;
	}
	
	for (i=0;i<3;i++) for (j=i+1;j<4;j++) for (k=j+1;k<5;k++) 
	ans += (ll)cnt[i]*(ll)cnt[j]*(ll)cnt[k];
	
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <limits>

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

using namespace std;
const int INF = numeric_limits<int>::infinity();

int main() {
    char S[100010];
    scanf("%s", S);

    int len = 0, cnt = 0;
    while (S[len]) len++;

    rep (i, len) {
        if (i % 2) {
            if (S[i] == '0') cnt++;
        } else {
            if (S[i] == '1') cnt++;
        }
    }
    if (len/2 < cnt) cnt = len - cnt;
    printf("%d\n", cnt);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int arr[5];
    int sum=0, sum2=0;
    for(int i=0; i<5; i++){
        sum = sum+i+1;
        cin>>arr[i];
        sum2=sum2+arr[i];
    }
    cout<<sum-sum2<<'\n';
    return 0;
}

Measured memory_bytes: 3552
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<unordered_map>

using namespace std;
typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

vector<int> E[110000];
int d1[110000], d2[110000];

void func(int pos, int pre, int cost, int d[]){
  d[pos] = cost;
  for(int to : E[pos]){
    if(to != pre){
      func(to, pos, cost + 1, d);
    }
  }
}

int main(){
  int N;
  cin >> N;
  for(int i = 0; i < N - 1; i++){
    int a, b;
    cin >> a >> b;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  func(1, 0, 0, d1);
  func(N, 0, 0, d2);
  int cnt = 0;
  for(int i = 1; i <= N; i++){
    cnt += d1[i] <= d2[i];
  }
  if(cnt > N / 2){
    cout << "Fennec" << endl;
  }else{
    cout << "Snuke" << endl;
  }
  return 0;
}


Measured memory_bytes: 12928
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw3(15,1);vector<ll> pw10(19,1);
int main(){
    {rep1(i,14) pw3[i]=3*pw3[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll X; cin>>X;
    
    ll now=0;
    while((1+now)*now<X*2){
        now++;
    }
    cout<<now<<endl;
}


Measured memory_bytes: 3640
def check(m):
    global n, k, w, presum
    s = 0
    for j in range(k):
        ok = s
        ng = n + 1
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if presum[mid] - presum[s] <= m:
                ok = mid
            else:
                ng = mid
        s = ok
    if s == n:
        return True
    else:
        return False


def resolve():
    global n, k, w, presum
    n, k = [int(i) for i in input().split()]
    w = [int(input()) for _ in range(n)]
    presum = [0 for _ in range(n + 1)]
    for i in range(n):
        presum[i + 1] = presum[i] + w[i]
    if n <= k:
        print(max(w))
        return
    ok = 100000 * 10000
    ng = 0
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    print(ok)


resolve()



Measured memory_bytes: 13428
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

int N;    
P is[25];
int sum = 0;

bool can(){
    bool used[25];
    std::fill(used, used+N, false);

    REP(i, N){
        int v = -1;
        REP(j, N){
            if(is[j].first >= sum && !used[j] && (v == -1 || is[j].second > is[v].second)){
                v = j;
            }
        }
        if(v == -1){return false;}

        used[v] = true;
        sum -= is[v].second;
    }

    return true;
}

int main(){
    while(std::cin >> N, N){
        sum = 0;
        REP(i, N){
            std::cin >> is[i].second >> is[i].first;
            sum += is[i].second;
        }

        std::sort(is, is+N);

        if(can()){puts("Yes");}
        else{puts("No");}
    }
}

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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    if(X == 7 || X == 5 || X == 3){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a==b&&b==c) cout<<1<<endl;
else if(a!=b&&b!=c&&c!=a) cout << 3 << endl;
else cout << 2 << endl;
}

Measured memory_bytes: 256
import Foundation

func readInts() -> [Int]{
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main(){
    let abck = readInts()
    let (a,b,_,k) = (abck[0],abck[1],abck[2],abck[3])
        
    if k <= a{
        print(k)
        return
    }
    
    var ans = a
    
    if k - a - b > 0 {
        ans -= (k - a - b)*1
    }
    print(ans)
}
    
main()


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

int main(void) {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] != T[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}

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


int main(){
  string s,t;
  cin >> s >> t;
  ll ans = 0;
  rep(i,s.size()){
    if( s.at(i) != t.at(i) ) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3864
n = gets.to_i
tc, xc, yc = [0, 0, 0]

ans = "Yes"

n.times do |i|
  tn, xn, yn = gets.split.map(&:to_i)

  t = tn - tc
  x = (xn - xc).abs
  y = (yn - yc).abs

  if x + y > t || (t - (x + y)).odd?
    ans = "No"
    break
  end

  tc, xc, yc = tn, xn, yn
end

puts ans


Measured memory_bytes: 1788
#coding:UTF-8

n = input()
arr = {'S':range(13),'H':range(13),'C':range(13),'D':range(13)}

for i in range(n):
    a,b = raw_input().split()
    b = int(b)
    arr[a][b-1] = 14

for j in ['S','H','C','D']:
    for k in range(13):
        if arr[j][k] == 14:
            continue
        print j+" "+str(k+1)

Measured memory_bytes: 4232
a = ("a".."z").to_a

while line = gets
  result = ""
  words = line.chomp.split(//)
  0.upto(25) do |i|
    words.each do |c|
      if c =~ /[a-z]/
        result += a[(a.index(c)+i)%26]
      elsif c =~ /\.|\s/
          result += c
      end
    end
    break if result.index(/(the|this|that)\.?/)
    # break if result.split.include?(/(the|this|that)\.?/)
    result = ""
  end
  puts result
end

Measured memory_bytes: 6112
// One Batch Two Batch Penny and Dime

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int long long
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAXN = 1e6 + 5;
const int M = 1e6 + 5;
const int mod = 998244353;
const int MOD = 998244353;
const int INF = 1e18 + 8;
const int LG = 21;

int arr[N];
int query = 1;

void print(int x)
{
    cout << "Case #" << query++ << ": " << x;
    cout << endl;
}

void solve()
{
	int k;
	cin >> k;
	while(k--)
	{
		cout << "ACL";
	}
}


 
int32_t main() 
{	
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

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

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

public class Main {

	public int A[];
	public int B[];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Main main = new Main();
		main.A= new int[N+1];
		main.B= new int[N+1];
		for (int i=0;i<N+1;i++) {
			main.A[i]=i;
		}
		for (int i=0;i<M;i++) {
			int a= sc.nextInt();
			int b = sc.nextInt();
			main.unit(a, b);
		}
		int C[] = new int[N];
		for (int i=1;i<N+1;i++) {
			C[i-1] = main.find(i);
		}
		int count =0;
		Arrays.sort(C);
		for (int i=1;i<N;i++) {
			if (C[i]!=C[i-1]) {
				count ++;
			}
		}
		System.out.println(count);
	}

	public int find(int x) {
		if (this.A[x]==x) {
			return x;
		}
		return A[x]=find(A[x]);

	}

	public void unit(int x,int y) {
		x = find(x);
		y = find(y);
		if (x==y) {
			return ;
		}
		if (B[x]<B[y]) {
			A[x]= y;
		} else {
			A[y]= x;
			if (B[x]==B[y]) {
				B[x]++;
			}
		}
	}

}

Measured memory_bytes: 60948
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int flag =0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='7')
            flag=1;
    }
    if(flag)
        cout<<"Yes";
        else
            cout<<"No";
    return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

ll gcd(ll a, ll b)
{
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

void solve()
{
    ll A, B; cin >> A >> B;
    cout << lcm(A, B) << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using static System.Math;

class P
{
    static void Main()
    {
        long[] np = Console.ReadLine().Split().Select(long.Parse).ToArray();
        Console.WriteLine(factors(np[1]).GroupBy(x => x).Aggregate(1L, (x, y) => x * Max(1, Power(y.Key, y.Count() / np[0]))));    
    }

    static long Power(long n, long m)
    {
        long pow = n;
        long res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res *= pow;
            pow *= pow;
            m >>= 1;
        }
        return res;
    }
  
    static long[] factors(long n)
    {
        long firstn = n;
        long i = 2;
        List<long> res = new List<long>();
        while (i * i <= firstn + 100)
        {
            while (n % i == 0)
            {
                res.Add(i);
                n /= i;
            }
            i++;
        }
        if (n > 1) res.Add(n);
        return res.ToArray();
    }
}


Measured memory_bytes: 13524
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K, H, W, L, R, l, r, u, d, sum, Q;
LL ans;
LL no;
bool b, bb[100001];
string s, t;
LL num(LL a) {
	if (a == 1)return 1;
	else return 2 * num(a / 2) + 1;
}
int main() {

	cin >> N;
	vector<LL> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	LL num = 1;
	ans = 0;
	for (int i = 0; i < N; i++) {
		if (v[i] == num) {
			num++;
		}
		else {
			ans++;
		}
	}
	if (num == 1) {
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1792
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

vector<vector<int>> atom(26, vector<int>(27, -1));


int shiki(string& s, int& i);
int genshiA(string& s, int& i);
int genshiP(string& s, int& i);
int genshi(string& s, int& i);
int number(string& s, int& i);


bool flag = true;
int start(string& s, int& i) {
	flag = true;
	int a = shiki(s, i);
	if (flag) {
		return a;
	}
	else {
		return -1;
	}
}

int shiki(string& s, int& i) {
	int sum = 0;
	while (s[i] != '?'&&s[i] != ')') {
		int a = genshiA(s, i);
		sum += a;
	}
	
	return sum;
}

int genshiA(string& s, int& i) {
	int a = genshiP(s, i);
	
	if (isdigit(s[i])) {
		int b = number(s, i);
		a = a*b;
	}
	return a;
}

int genshiP(string& s, int& i) {
	if (s[i] == '(') {
		i++;
		int a = shiki(s, i);
		i++;
		return a;
	}
	else {
		int a = genshi(s, i);
		return a;
	}
}

int genshi(string& s, int& i) {
	char atomA = s[i];
	i++;
	char atomB = 'a' - 1;
	if ('a' <= s[i] && s[i] <= 'z') {
		atomB = s[i];
		i++;
	}
	int a = atom[atomA - 'A'][atomB - 'a' + 1];
	if (a == -1) {
		flag = false;
		return 0;
	}
	else {
		return a;
	}
}

int number(string& s, int& i) {
	int a = s[i] - '0';
	i++;
	if (isdigit(s[i])) {
		a = a * 10 + (s[i] - '0');
		i++;
	}
	return a;
}

int main()
{

	while (true) {
		string ss;
		cin >> ss;
		if (ss.size() ==17) {
			break;
		}
		int num;
		cin >> num;
		if (ss.size() == 1) {
			atom[ss[0] - 'A'][0] =num;
		}
		else {
			atom[ss[0] - 'A'][ss[1] - 'a' + 1] = num;
		}
	}
	while (true) {
		string ss;

		cin >> ss;
		ss = ss + "??????";
		if (ss[0] == '0') { break; }
		int k = 0;
		int nyaan = start(ss,k);
		if (nyaan == -1) {
			cout << "UNKNOWN" << endl;
		}
		else {
			cout << nyaan << endl;
		}

	}

}

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

int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if (c-a-b<1){
        cout << "No" << endl;
    } else {
        if (4*a*b < (c-a-b)*(c-a-b)){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;

const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;

const int MAXN = 113, MAXK = 100013;
int N, K, A[MAXN], DP[MAXK], miny = INF;

bool WinLose(int x){
    if(x < miny) return 0;
    if(DP[x] != -1) return DP[x];
    //cout << x << endl;
    
    for(int i = 0; i < N; ++i){
        if(x - A[i] >= 0 and !WinLose(x - A[i]))
            return DP[x] = 1;
    }

    return DP[x] = 0;
}

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    memset(DP, -1, sizeof DP);
    cin >> N >> K;
    for(int i = 0; i < N; ++i){ cin >> A[i]; miny = min(miny, A[i]); }

    cout << (WinLose(K) ? "First" : "Second") << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 3712