akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int two = 0, four = 0, odd = 0;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			if(a[i] % 4 == 0) four++;
			else if(a[i] % 2 == 0) two++;
			else odd++;
		}
		if(odd <= four || (odd == four + 1 && two == 0)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


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

const long long a=1000000007;

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

	long long f=1;
	for(int i=1;i<=n;i++)
		f = (f*i)%a;
	cout << f << endl;
	return 0;
}

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

using namespace std;

int main(){
    char a;
    int n,b,S[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0},H[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0},C[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0},D[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a >> b;
        if(a=='S'){
            S[b-1] = 1;
        }
        if(a=='H'){
            H[b-1] = 1;
        }
        if(a=='C'){
            C[b-1] = 1;
        }
        if(a=='D') {
            D[b-1] = 1;
        }
    }

    for(int i=0;i<13;i++){
        if(S[i]==0){cout << "S " << i+1 << endl;}
    }

    for(int i=0;i<13;i++){
        if(H[i]==0){cout << "H " << i+1 << endl;}
    }
    for(int i=0;i<13;i++){
        if(C[i]==0){cout << "C " << i+1 << endl;}
    }
    for(int i=0;i<13;i++){
        if(D[i]==0){cout << "D " << i+1 << endl;}
    }
    
    return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
int main()
{
 int num,rem,sum;   
 scanf("%d",&num);  
   rem=num%10; 
    if(rem==2||rem==4||rem==5||rem==7||rem==9)
 printf("hon\n");   
else if(rem==0||rem==1||rem==6||rem==8)    
   printf("pon\n");
  else if(rem==3)  
    printf("bon\n");
    
    return 0;
}

Measured memory_bytes: 1660
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <limits>
#define _USE_MATH_DEFINES
#include <cmath>

#include <functional>
using namespace std;

#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
// For debug
#ifdef _DEBUG
#define DD(x) cerr << #x << ":" << x << endl;
#define DDA(ary) \
cerr << #ary << ":" << endl;\
for (auto v : ary) { cerr << v << ","; }\
cerr << endl;
#else
#define DD(x)
#define DDA(ary)
#endif

#include <queue>
#include <tuple>

const int MAX_T = 105;
priority_queue<pair<int, int>, vector<pair<int,int>>, less<pair<int,int>>> numAndType;

int main() {
	int k, t;
	cin >> k >> t;
	REP(i, t) {
		int a;
		cin >> a;
		numAndType.push((make_pair(a, i)));
	}
	int prevEats = -1;
	int ans = 0;
	while (!numAndType.empty()) {
		auto p = numAndType.top(); numAndType.pop();
		if (prevEats == p.second) {
			if (numAndType.empty()) {
				ans = p.first;
				break;
			}
			else {
				auto q = numAndType.top(); numAndType.pop();
				numAndType.push(p);
				p = q;
			}
		}
		if (p.first == 0) {
			continue;
		}
		p.first -= 1;
		prevEats = p.second;
		numAndType.push(p);
	}

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

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

using namespace std;

#define ll long long
#define F first
#define S second
#define ii pair < int , int >

const int N=1;
map<int , int> mp;
int main()
{

    int n;
    scanf("%d",&n);
    bool q=0;
    for(int i=0;i<n;i++){
        int x;
        scanf("%d",&x);
        mp[x]++;
        if(mp[x]>1)
            q=1;
    }
    if(!q){
        printf("YES");
    }
    else{
        printf("NO");
    }

}


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

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

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

    int mi = INT_MAX;
    for(int i=-100;i<=100;i++){
        int sum = 0;
        for(int j = 0;j<n;j++){
            sum += pow(a[j]-i,2);
        }
        mi = min(mi,sum);
    }

    cout << mi;

    return 0;
}

Measured memory_bytes: 256
def partition(A, p, r):
    x = A[r]
    i = p - 2
    for j in range(p-1, r):
        if A[j] <= x:
            i = i + 1
            hoge = A[i]
            A[i] = A[j]
            A[j] = hoge
    hoge = A[i+1]
    A[i+1] = A[r]
    A[r] = hoge
    return i+1

n = int(input())
S = [*map(int, input().split())]

key = partition(S, 1, n-1)
print(*S[:key],'[{}]'.format(S[key]), *S[key+1:])


Measured memory_bytes: 16380
#include <iostream>
#include <string>

using namespace std;

int main(){
    string a,b;
    cin >> a >> b;

    if(a.size() > b.size())cout << "GREATER" << endl;
    else if(a.size() < b.size())cout << "LESS" << endl;
    else {
        for(int i = 0;i < a.size();i++){
            if(a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
                }
            else if(a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
	double x1,y1,x2,y2;
	double distance = 0;
	double tmp;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	//distance = sqrt(((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
	tmp = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
	distance = sqrt(tmp);
	printf("%lf\n",distance);
	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

	ll n,k,cnt=0;
	cin >> n >> k;
	vector<ll>h(n);
	rep(i, n)cin >> h[i];
	for (ll i = 0; i < n; i++) {
		if (h[i] >= k)cnt++;
		else continue;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    long L[N+1];
    L[0] = 2; L[1] = 1;
    for(int i = 2; i < N+1; i++){
        L[i] = L[i-1] + L[i-2];
    }
    cout << L[N] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pair<bool,int>> cor(n, {false, 0});

    int ac = 0, wa = 0;
    auto cnt = [&](int i, string s){
        if(s == "AC" && !cor[i-1].first){
            ac++;
            wa += cor[i-1].second;
            cor[i-1].first = true;
        }
        else if (s == "WA" && !cor[i-1].first){
            cor[i-1].second++;
        }
    };
    int p;
    string s;
    for(int i = 0; i< m;i++){
        cin >> p >> s;
        cnt(p, s);
    }

    cout << ac << " " << wa << endl;

    return 0;
}

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

int main() {
  int N;
  string S;
  int P = 0;
  int W = 0;
  int G = 0;
  int Y = 0;
  
  cin >> N;

  // ここにプログラムを追記
  for(int i = 0; i < N; i++){
	cin >> S;
    
 	//debug
    //cout << i << endl;
    //cout << S << endl;
    
    if (S == "P"){
      P = 1;
    }
    else if (S == "W"){
      W = 1;
    }
    else if (S == "G"){
      G = 1;
    }
    else if (S == "Y"){
      Y = 1;
    }

	//debug
    //cout << P << W << G << Y << endl;
    
    //4種類が入っている事が確定したらここで終了
    if ((P + W + G + Y) == 4){
      cout << "Four" << endl;
      break;
    }

    //最後まで取り出しても4種類無い場合
    if (i == N -1){
    	cout << "Three" << endl;
    }
    
  }
  
}


Measured memory_bytes: 3620
from fractions import gcd

def lcm(x, y):
  return (x * y) // gcd(x, y)

n = int(input())
a = list(map(int,input().split()))
g = a[0]
for i in range(n):
  g = lcm(g,a[i])
ans = 0
for i in range(n):
  ans += g // a[i]
print(ans%1000000007)


Measured memory_bytes: 6112
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while ((buf = br.readLine())!=null) {
				double l[] = new double[10];
				double v[] = new double[2];
				StringTokenizer st = new StringTokenizer(buf,",");

				double sum = 0;
				for (int i=0;i<10;i++) {
					l[i] = Integer.parseInt(st.nextToken());
					sum += l[i];
				}
				for (int i=0;i<2;i++)
					v[i] = Integer.parseInt(st.nextToken());

				double h = sum/(v[0]+v[1]);
				double d = (v[0]*h);
				double counter = 0;
				for (int i=0;i<10;i++) {
					counter += l[i];
					if (counter>=d) {
						System.out.println(i+1);
						break;
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 16868
#include <bits/stdc++.h>
			using namespace std;
			#define ll long long
			#define mod 1000000007
			#define pll pair<long,long>
			#define se second
			#define fi first
			#define pb push_back
			#include <ext/pb_ds/assoc_container.hpp>
			#include <ext/pb_ds/tree_policy.hpp>
			using namespace __gnu_pbds;

			typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
			typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;
			
			const ll INF = (ll)1e18;
			
			vector<pll> g[100050];
			set<pll> s;
			vector<ll> dist(100050);
			int main()
			{
				ll n,m;
				cin>>n>>m;
				for(ll i=2;i<=n;i++)
				{
					g[i].pb({0,i-1});
				}
				for(ll i=0;i<m;i++)
				{
					ll u,v,w;
					cin>>u>>v>>w;
					g[u].pb({w,v});
				}
				for(ll i=2;i<=n;i++)
				{
					dist[i]=INF;
					s.insert({dist[i],i});
				}
				dist[1]=0;
				
				s.insert({dist[1],1});
				
				while(!s.empty())
				{
					pll node=*s.begin();
					s.erase(s.begin());
					for(auto j:g[node.se])
					{
						if(dist[node.se]+j.fi<dist[j.se])
						{
							s.erase({dist[j.se],j.se});
							dist[j.se]=dist[node.se]+j.fi;
							s.insert({dist[j.se],j.se});
							
						}
					
					}
				}
				if(dist[n]==INF)
					cout<<-1;
				else
					cout<<dist[n];
				
			}
						
			


Measured memory_bytes: 14848
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	string s;
	int r=9999;
	cin>>s;
	for(int i=0;i<=s.length()-3;i++)
	{
		r=min(r,abs(753-stoi(s.substr(i,3))));
	}
	cout<<r<<endl;
}



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

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int T = sc.nextInt();
		int[] a = new int[T];
		for(int i = 0; i<T; i++){
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int x = a[T-1];

		for(int i = T-2; i>=0; i--){
			x -= a[i];
		}
		if(x<=0){
			System.out.println(0);
		}else{
			System.out.println(x-1);
		}
	}
}

Measured memory_bytes: 9812
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
long long n;
int arr[200001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for (int i=0;i<n;i++){
        cin>>arr[i];
    }
    int mini=n+1,res=0;
    for (int i=0;i<n;i++){
        mini=min(mini,arr[i]);
        if (arr[i]==mini) res++;
    }
    cout<<res;
}

Measured memory_bytes: 1024
//ループ検知

#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N; ll K;
  cin >> N >> K;
  vector <int> A(N);
  rep(i,N){
    cin >> A[i];
  }

  vector <int> s;  //訪れた頂点
  vector <int> ord(N + 1, -1);  //各頂点を訪れた順番
  int cycle = 1; //周期
  int initial = 0;  //ループに入るまでの回数
  {
    int v = 1;  //頂点
    //まだ訪れていないならループを続ける
    while (ord[v] == -1){
      ord[v] = s.size();
      s.push_back(v);
      v = A[v - 1];
    }
    cycle = s.size() - ord[v];
    initial = ord[v];
  }
  if (K < initial) cout << s[K] << endl;
  else {
    K -= initial;
    K %= cycle;
    cout << s[initial + K] << endl;
  }
  return 0;
}


Measured memory_bytes: 5868
#include<iostream>
using namespace std;
int n;
int A[1000];

void reverse(int l, int r){
  for ( int i = l; i <= l+(r-l)/2-1; i++ ){
    int j = r-(i-l)-1;
    swap(A[i], A[j]);
  }
}
main(){
  int a, b, q;
  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> A[i];
  cin >> q;
  for ( int i = 0; i < q; i++ ){
    cin >> a >> b;
    reverse(a, b);
  }
  for ( int i = 0; i < n; i++ ){
    if ( i ) cout << " ";
    cout << A[i];
  }
  cout << endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long int sum[9000000]={};
long long mm=1e9+7;
/*long long poww(long long a,long long b){
    if(b==0)
        return 1;
    else if(b==1)
        return a;
    long long v=poww(a,b/2);
    v*=v;
    v%=mm;
    if(b%2==1){
        v*=v;
        v%=mm;
    }
    return v;
}*/    //function to pow
/*long long pow2(long long k){
long long j=2;
while(--k)
    {j*=2;
    j%=mm;}
return j;


}*/
/*bool prime[100000];
vector<long long >v;
void sieve(){
prime[0]=prime[1]=true;
long int n=10000;
int t=sqrt(n);
for(long int i=2;i<=n;++i){
    if(prime[i]==false){
        v.push_back(i);
        for(long int p=i*i;p<=n;p+=i)
            prime[p]=true;
    }
}
}*/
int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
     long long a,sum=0;
     map<string,int> p;
     string s;
     cin>>a;
     for(long long i=0;i<a;++i){
        cin>>s;
        if(p[s]>0)
            continue;
        else{
            p[s]++;
            sum+=1;
        }
     }
     cout<<sum;

    return 0;
}


Measured memory_bytes: 19244
#include <cstdio>
#include <iostream>
#include <string>

int main() {
    int n, k, x, y;
    scanf("%d%d%d%d", &n, &k, &x, &y);
    if (n <= k) {
        printf("%d\n", n * x);
    }
    else {
        printf("%d\n", k * x + (n - k) * y);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int n;cin>>n;
        if(n==0)break;
        vector< pair <string,int> > a(n);
        int ma=0;
        cin>>a[0].first;
        for(int i=1;i<n;i++){
            string s;cin>>s;
            int count=0;
            for(int j=0;j<s.size();j++){
                if(s[j]=='.')count++;
                else break;
            }
            a[i].first=s;
            a[i].second=count;
            ma=max(ma,count);
        }
        for(int i=1;i<=ma;i++){
            bool f=false;
          for(int j=n-1;j>=1;j--){
            if(a[j].second==i){
                f=true;
                a[j].first[i-1]='+';
            }
            if(f&&a[j].second>i){
                a[j].first[i-1]='|';
            }
            if(f&&a[j].second<i)f=false;
          }
        }
        for(int i=1;i<n;i++){
            for(int j=0;j<a[i].first.size();j++){
              if(a[i].first[j]=='.'){
                  a[i].first[j]=' ';
              }
              else if(a[i].first[j]=='+')break;
            }
        }
        for(int i=0;i<n;i++){
            cout<<a[i].first<<endl;
        }
    }
}


Measured memory_bytes: 3420
#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 a,b,c;
  cin >> a >> b >> c;
  char A = a.at(0)-'a'+'A';
  char B = b.at(0)-'a'+ 'A';
  char C = c.at(0)-'a'+ 'A';
  cout << A << B << C << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N + 1];
        for (int i = 0; i <= N; i++) {
            A[i] = sc.nextInt();
        }
        int[] B = new int[N];
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextInt();
        }

        long ans = 0;
        // 勇者でループを組む
        for (int i = 0; i < N; i++) {
            if (A[i] >= B[i]) { // モンスター >= 勇者
                ans += B[i];
            }
            else { // モンスター < 勇者
                ans += A[i];
                int leftB = B[i] - A[i];
                if (A[i + 1] >= leftB) { // 次の街のモンスター >= 勇者の残り
                    ans += leftB;
                    A[i + 1] -= leftB;
                }
                else { // 次の街のモンスター < 勇者の残り
                    ans += A[i + 1];
                    A[i + 1] = 0;
                }
            }
        }
        System.out.print(ans);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}



Measured memory_bytes: 64648
#include<bits/stdc++.h>
using namespace std;
int x,n;
int a[5005],v[5005];
int main()
{
    cin>>x>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        v[a[i]]=1;
    }
    for(int i=0;;i++)
    {
        int a=x+i,b=x-i;
        
        if(!v[b])
        {
            cout<<b;
            return 0;
        }
        if(!v[a])
        {
            cout<<a;
            return 0;
        }
    }
}

Measured memory_bytes: 3640
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

def swap(s,pos):
    s[pos]-=1
    s[pos+1]+=1
    print(s)
    if pos == n-2: return s
    if s[pos+2] == 0: swap(s,pos+1)
    return s


#n = ip()                              #入力整数1つ
h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
a = []

for i in range(h):
    a.append(input())
adj = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        for x in range(-1, 2):
            for y in range(-1, 2):
                if x+y or x*y:
                    if 0 <= i + x < h and 0 <= j + y < w:
                        if a[i + x][j + y] == '#': adj[i][j]+= 1
for i in range(h):
    for j in range(w):
        if a[i][j] == "#": print("#",end='')
        else :print(adj[i][j],end='')
    print()

Measured memory_bytes: 21968
import math

N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]


def check(t):
    cnt = 0
    bt = B * t
    for i in range(N):
        cnt += max(0, math.ceil((h[i] - bt) / (A - B)))
    return cnt <= t


left = 1
right = max(h)
while right - left > 1:
    mid = (left + right) // 2
    if check(mid):
        right = mid
    else:
        left = mid
print(right)


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

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    a, b = rli()
    start = 1
    print(((b-1)+a-2)//(a-1))


if __name__ == '__main__':
    main()


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

bool triangle(int i,int j,int k){
    if(i<j+k && j<i+k && k<j+i){
        return true;
    }
    return false;
}


int main(){
    int n,cnt=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){cin>>a[i];}
    int unused[n]={};
    int j,k,l,number_triangle=0;
    sort(a,a+n);
    for(int j=0;j<n-2;j++)
    {
        for(int k=j+1;k<n-1;k++)
        {
                   for(int l=k+1;l<n;l++)
            {
               // cout<<a[j]<<" "<<a[k]<<" "<<a[l]<<endl;
               // cout<<"+++++++++++++++++++++++++"<<endl;
               // cout<<unused[j]<<" "<<unused[k]<<" "<<unused[l]<<endl;
               // cout<<"********************"<<endl;
               // if(unused[j]!=1 || unused[k]!=1 || unused[l]!=1){

                
                    if(a[j]+a[k]>a[l])
                    {
                 //       cout<<"yes"<<endl;
                        unused[j]=1;
                        unused[k]=1;
                        unused[l]=1;
                        number_triangle++;
                    }
              //  }
            }
        }
    }
        cout<<number_triangle;
        return 0;

}

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

string S;
int main(){
	cin >> S;
	map<char,long long> m;
	for(int i=0;i<S.size();i++){
		m[S[i]]++;
	}
	long long ans = 0;
	for(auto x:m){
		ans += x.second*(x.second-1)/2;
	}
	long long N = S.size();
	cout << N*(N-1)/2 - ans + 1 << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

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

        System.out.println(result);
    }
}


Measured memory_bytes: 21972
fun main(args: Array<String>) {
    var (n, x, y) = readLine()!!.split(" ").map{ it.toInt() }
    x -= 1
    y -= 1
    var dis = Array(n){0}.toMutableList()
    for (i in 0..n-2) {
        for (j in i+1..n-1) {
            dis[Math.min(Math.abs(i-j), Math.abs(i-x)+Math.abs(j-y)+1)] += 1
        }
    }
    println(dis.slice(1..n-1).joinToString(separator="\n"))
}


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

int partition(int A[], int p, int r){
	int x = A[r - 1];
	int i = p - 1;

	for(int j = 0; j < r - 1; j ++){
		if(A[j] <= x){
			i ++;
			swap(A[i], A[j]);
		}
	}
	swap(A[++ i], A[r - 1]);
	return i;
}

int main(int argc, char const *argv[])
{
	int N;
	cin >> N;
	int st[N];
	for(auto& x:st){
		cin >> x;
	}
	size_t len = sizeof(st) / sizeof(int);
	int i = partition(st, 0, len);
	for (size_t j = 0; j < len; j ++){
		if(i != j){
			cout << st[j];
		}else{
			cout << "[" << st[j] << "]";
		}
		if(j == len - 1){
			cout << endl;
		}else{
			cout << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 3380
toInt :: String -> Int
toInt = read :: String -> Int

gcd3 :: Int -> Int -> Int -> Int
gcd3 a b c = gcd (gcd a b) c

main = do
  n <- toInt <$> getLine
  print $ sum [gcd3 a b c | a <- [1..n], b <- [1..n], c <- [1..n]]


Measured memory_bytes: 3928
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        h: usize, w: usize,
        c: [chars; h]
    }

    for y in 0..h {
        for _ in 0..2 {
            for x in 0..w {
                print!("{}", c[y][x]);
            }
            println!("");
        }
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;


typedef long long       ll;
typedef struct edge_ { ll to; ll cost; } edge;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX numeric_limits<ll>::max()
#define INT_MAX numeric_limits<int>::max()
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}



int main()
{
	vi a(3), b(3);
	rep(i, 3) {
		cin >> a[i] >> b[i];
	}

	vi m(4, 0);
	for (int i = 0; i < 3; i++) {
		m[a[i] - 1]++;
		m[b[i] - 1]++;
	}

	int n1 = 0, n2 = 0;
	for (int i = 0; i < 4; i++) {
		if (m[i] == 1) n1++;
		if (m[i] == 2) n2++;
	}

	if (n1 > 2) cout << "NO" << endl;
	else cout << "YES" << endl;


	/*vi prime(1, 1);

	for (int i = 1; i <= 100; i++) {
		int count = 0;
		for (int j = 1; j <= i; j++)
			if (i % j == 0)
				count++;

		if (count == 2 && i != 2) {
			prime.push_back(i);
		}
	}

	int N, K;
	cin >> N >> K;

	int num = 0;
	for (int i = 0; i < prime.size(); i++) {
		if (prime[i] <= N) 
			num++;
	}

	YN(num >= K);*/

	return 0;
}

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

#define _LL long long
#define NMAX 200000

#define _LL long long
#define rep(i, n) for(_LL i = 0; i < (_LL)(n); i++)
vector<pair<int,int>> b[NMAX];
int ans[NMAX];
int maxcolor = -1;

void search(int c, int p, int pc)
{
    maxcolor = max(maxcolor, pc);
    int index = 1;
    for( auto itr = b[c].begin(); itr != b[c].end(); itr++ )
    {
        if( itr->first != p ) 
        {
            if( index == pc ) index++;
            ans[itr->second] = index;
            search(itr->first, c, index++);
        }
    }
}

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; i++ )
    {
        int u, v;
        cin >> u >> v;
        u--; v--;
        b[u].push_back(make_pair(v, i));
        b[v].push_back(make_pair(u, i));
    }
    search(0, -1, -1);
    cout << maxcolor << endl;
    for( int i = 0; i < n - 1; i++ ) cout << ans[i] << endl;
}

Measured memory_bytes: 14712
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.math;

void solve(int a, int b, int c, int d, int e, int f) {
  double det = a * e - b * d;
  double xt  = c * e - b * f;
  double yt  = a * f - c * d;

  double x = xt / det;
  double y = yt / det;

  if(x >= -0.0005 && x < 0.0005) x = 0.0;
  if(y >= -0.0005 && y < 0.0005) y = 0.0;
  
  writefln("%.3f %.3f", x, y);
}

void main() {
  int[][] data;

  while(true) {
    auto input = readln();
    if(stdin.eof()) break;

    auto d = split(input);
    data ~= [to!int(d[0]), to!int(d[1]), to!int(d[2]), to!int(d[3]), to!int(d[4]), to!int(d[5])];
  }

  foreach(d; data) {
    solve(d[0], d[1], d[2], d[3], d[4], d[5]);
  }  
}

Measured memory_bytes: 1072
class UnionFind():
    def __init__(self, n):
        self.parents = list(range(n))
        self.size = [1] * n
    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.size[x] < self.size[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[y]
            self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m=map(int,input().split())
num=[list(map(int,input().split())) for _ in range(m)]
ans=0
for i in range(m):
    uf=UnionFind(n)
    for j in range(m):
        if i!=j:
            uf.union(num[j][0]-1,num[j][1]-1)
    if uf.size[uf.find(0)]!=n:
        ans+=1
print(ans)


Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
# define LL          long long
# define pr          pair
# define mkp         make_pair
# define lowbit(x)   ((x)&(-x))
# define PI          acos(-1.0)
# define INF         0x3f3f3f3f3f3f3f3f
# define eps         1e-8
# define MOD         1000000007
# define MX          500

int n;
LL num[MX];

int main()
{
    num[0]=2; num[1]=1;
    for (int i=2;i<=86;i++)
        num[i]=num[i-2]+num[i-1];
    scanf("%d",&n);
    printf("%lld\n",num[n]);
    return 0;
}


Measured memory_bytes: 256
from collections import Counter


def m():
    N = int(input())
    V = [int(i) for i in input().split()]
    vodds = V[0::2]
    vevens = V[1::2]

    odds_commons = Counter(vodds).most_common()
    even_commons = Counter(vevens).most_common()

    odds_top = odds_commons[0]
    evens_top = even_commons[0]
    if odds_top[0] != evens_top[0]:
        return N - odds_top[1] - evens_top[1]
    else:
        if len(odds_commons) > 1 and len(even_commons) > 1:
            return min(
                N - odds_commons[1][1] - even_commons[0][1],
                N - even_commons[1][1] - odds_commons[0][1]
            )
        elif len(odds_commons) > 1:
            return N - odds_commons[1][1] - even_commons[0][1]
        elif len(even_commons) > 1:
            return N - even_commons[1][1] - odds_commons[0][1]
        else:
            return N // 2


print(m())


Measured memory_bytes: 64876
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,card[200],tmp[200];
	cin>>n;
	for(int i=0;i<2*n;i++){
		card[i]=tmp[i]=i+1;
	}
	cin>>m;
	int k;
	while(m--){
		cin>>k;
		if(k==0){
			for(int i=0;i<n;i++){
				tmp[i*2]=card[i];
				tmp[i*2+1]=card[i+n];
			}
		}else{
			for(int i=0;i<k;i++){
				tmp[2*n-k+i]=card[i];
			}
			for(int i=k;i<2*n;i++){
				tmp[i-k]=card[i];
			}
		}
		for(int i=0;i<2*n;i++){
			card[i]=tmp[i];
		}
	}
	for(int i=0;i<2*n;i++){
		cout<<card[i]<<endl;
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
#define N 100

int matrixChain(int*,int);

int main(){
  int num,n[N][2],i,p[N];

  scanf("%d",&num);
  
  for(i=0; i<num; i++) scanf("%d%d",&n[i][0],&n[i][1]);
  for(i=0; i<num; i++) p[i] = n[i][0];
  p[i] = n[i-1][1];
  
  
  printf("%d\n",matrixChain(p,num));

  return 0;
}


int matrixChain(int *p,int num){
  int i,j,k,l,min,q,m[N][N];
  for(i=1; i<=num; i++) m[i][i] = 0;
  
  for(l=2; l<=num; l++){
    for(i=1; i<=num-l+1; i++){
      j = i+l-1; 
      for(k = i; k<=j-1; k++){
        q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
	if(i==k)min = q;
	else if(q < min) min = q;
      }
      m[i][j] = min;
    }
  } 
  return m[1][num];
}

Measured memory_bytes: 632
# include"stdio.h"
int main(){
    char s[200001];
    scanf("%s",s);
    int i=0;
    while(s[i]!='A') i++;
    int start=i,last;
    while(s[i]!='\0'){
         if(s[i]=='Z')last=i;
         i++;
    }
    printf("%d\n",last-start+1);
}


Measured memory_bytes: 1908
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;
ll mod = 1e9+7;

int main() {
    ll h, w, k;
    cin >> h >> w >> k;
    ll dp[105][10] = {};
    dp[0][0] = 1;
    for (int i = 0; i < h; i++) {
        for (int bit = 0; bit < (1<<(w-1)); bit++) {
            bool x = false;
            for (int j = 0; j < w-2; j++) {
                if (1 & (bit>>j) & (bit>>(j+1))) {
                    x = true;
                }
            }
            if (x) continue;
            // dump(bit);
            for (int j = 0; j < w-1; j++) {
                if (bit & (1<<j)) {
                    dp[i+1][j] += dp[i][j+1];
                    dp[i+1][j] %= mod;
                    dp[i+1][j+1] += dp[i][j];
                    dp[i+1][j+1] %= mod;
                }
                else {
                   if (j == 0) {
                       dp[i+1][j] += dp[i][j];
                       dp[i+1][j] %= mod;
                   }
                   else if (j == w-2) {
                       dp[i+1][j+1] += dp[i][j+1];
                       dp[i+1][j+1] %= mod;
                        if (!(bit & (1<<(j-1)))) {
                           dp[i+1][j] += dp[i][j];
                           dp[i+1][j] %= mod;
                       }
                   }
                   else {
                       if (!(bit & (1<<(j-1)))) {
                           dp[i+1][j] += dp[i][j];
                           dp[i+1][j] %= mod;
                       }
                   }
                }
            }
        }
    }
    /* for (int i = 0; i <= h; i++) {
        for (int j = 0; j < w; j++) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    } */
    if (w == 1) dp[h][k-1] = 1;
    dump(dp[h][k-1]);
    return 0;  
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
m = [a-b, a-c, b-c]
mr = []
for x in m:
  if x<0:
    mr.append(-x)
  else:
    mr.append(x)

if mr[0] <= d and mr[2] <= d:
  print("Yes")
elif mr[1] <= d:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    vector<vector<int>> road(N);

    rep(i, N) cin >> H[i];
    rep(i, M) {
        int A, B;
        cin >> A >> B; A--, B--;
        road[A].emplace_back(B);
        road[B].emplace_back(A);
    }

    int ans = 0;
    rep(i, N){
        if(road[i].size() == 0) ans++;
        else {
            bool good = true;
            for(auto& k : road[i]) good &= (H[i] > H[k]);
            if(good) ans++;
        }
    }

    Cout(ans);
}


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

int countDigit(int a) {
    return to_string(a).length();
}

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

    int N, cnt = 0;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        if (countDigit(i) % 2 == 1) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    final int A, B;

    AtCoder(FastScanner sc) {
        A = sc.nextInt();
        B = sc.nextInt();
    }

    void solve(PrintWriter out) {
        if (A == B) {
            out.println(A + B);
        } else if (A > B) {
            out.println(2 * A - 1);
        } else {
            out.println(2 * B - 1);
        }
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
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 || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <numeric>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

ll gcd(ll m, ll n){
    while(m!=0){
        ll x;
        x=m;
        m=n%x;
        n=x;
    }
    return n;
}
ll lcm(ll m, ll n){
    return m/gcd(m,n)*n;
}

int main() {
    ll n;
    cin>>n;
    vector<ll>t(n);
    ll ans=1;

    for(int i=0;i<n;i++){
        ll x;
        cin>>t.at(i);
    }
    sort(t.begin(),t.end(),greater<ll>());
    for(int i=0;i<n;i++){
        ans=lcm(ans,t.at(i));
        if(ans>1000000000000000000)break;
    }
    cout<<ans<<endl;







    return 0;
}


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

const int nmax=8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]) {

    bool all_visited=true;

    for(int i=0; i<N; i++){
        if(visited[i]==false){
            all_visited=false;
        }
    }
  
    if(all_visited){
        return 1;
    }

    int ret=0;

    for(int i=0; i<N; i++){     
        if(graph[v][i]==false) continue;
        if(visited[i]) continue;

        visited[i]=true;
        ret+=dfs(i,N,visited);
        visited[i]=false;
  }

  return ret;
}

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

    for(int i=0; i<M; i++){
        int A,B;
        cin >> A >> B;
        graph[A-1][B-1]=graph[B-1][A-1]=true;
    }

    bool visited[nmax];
    for(int i=0; i<N; i++){
        visited[i]=false;
    }

    visited[0]=true;
    cout << dfs(0,N,visited) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

//int X[100000];
//int Y[100000];
//int Z[100000];
vector <int> edges[100000];
bool visited[100000];
int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int X;
        int Y;
        int Z;
        cin >> X >> Y >> Z;
        edges[X - 1].push_back(Y - 1);
        edges[Y - 1].push_back(X - 1);
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(visited[i]){
            continue;
        }
        ans ++;
        queue <int> q;
        q.push(i);
        while(!q.empty()){
            int cur = q.front();
            q.pop();
            for(int j = 0; j < edges[cur].size(); j++){
                int next = edges[cur][j];
                if(!visited[next]){
                    visited[next] = true;
                    q.push(next);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7552
h, w = map(int, input().split())
a = []
for i in range(h):
    t = list(input())
    a.append(t)
id = []
jd = []
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            if i not in id:
                id.append(i)
            if j not in jd:
                jd.append(j)
jd.sort()
for i in id:
    for j in jd:
        print(a[i][j], end="")
    print()

Measured memory_bytes: 42984
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    int N = S.size();

    map<ll, ll> dic;
    vector<int> dp(N+1,1e9);
    dp[0] = 0;
    dic[0] = 0;
    ll val = 0;
    rep(i,N) {
        int k = S[i] - 'a';
        val ^= 1LL<<k;
        if (dic.count(val)) chmin(dp[i+1],dic[val]+1);
        rep(j,26) {
            ll a = val^(1LL<<j);
            if (dic.count(a)) chmin(dp[i+1],dic[a]+1);
        }
        if (dic.count(val)) chmin(dic[val],dp[i+1]);
        else dic[val] = dp[i+1];
    }

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

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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

int main() {
	fastio;
	
    int n,k; cin >> n >> k;
    vi a(n),b(n,INT_MAX);
    forn(i,n) cin >> a[i];
    b[n-1] = 0;
    dforn(i,n) forsn(j,1,k+1) if(i-j >= 0) b[i-j] = min(b[i-j],abs(a[i-j]-a[i])+b[i]); 
	cout << b[0] << endl; 
	return 0;
}


Measured memory_bytes: 1024