akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	static FastScanner sc = new FastScanner();
	static PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) {
		int n = sc.nextInt();
		
		out.println(n*n*n);
		
        out.flush();
	}
	static 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;
	    }

	    private void skipUnprintable() {
	      while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
	    }

	    public boolean hasNext() {
	      skipUnprintable();
	      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() {
	      return (int) nextLong();
	    }

	    public int[] nextIntArray(int N, boolean oneBased) {
	      if (oneBased) {
	        int[] array = new int[N + 1];
	        for (int i = 1; i <= N; i++) {
	          array[i] = sc.nextInt();
	        }
	        return array;
	      } else {
	        int[] array = new int[N];
	        for (int i = 0; i < N; i++) {
	          array[i] = sc.nextInt();
	        }
	        return array;
	      }
	    }

	    public long[] nextLongArray(int N, boolean oneBased) {
	      if (oneBased) {
	        long[] array = new long[N + 1];
	        for (int i = 1; i <= N; i++) {
	          array[i] = sc.nextLong();
	        }
	        return array;
	      } else {
	        long[] array = new long[N];
	        for (int i = 0; i < N; i++) {
	          array[i] = sc.nextLong();
	        }
	        return array;
	      }
	    }
	  }

	}	 




		

Measured memory_bytes: 20564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,k,q,aa[2005];
vector<int>v;
int main(){
	cin>>n>>k>>q;
	repn(i,n){
		cin>>aa[i];
		v.pb(aa[i]);
	}
	SORT(v);
	ERASE(v);
	int ans = 2e9;
	for(int i=0;i<v.size();i++){
		int lb = 0,ub = 1e9+50;
		while(ub-lb>1){
			int mid = (lb+ub)/2;
			int a=0,b=0,ok=0;
			repn(j,n+1){
				if(j == n+1 || aa[j] < v[i]){
					ok += max(0,min(a+b+1-k,a));
					a = 0,b = 0;
				}
				else{
					if(aa[j] <= mid) a++;
					else b++;
				}
			}
			if(ok >= q) ub = mid;
			else lb = mid;
		}
		if(ub <= 1e9+10){
			ans = min(ans,ub-v[i]);
		}
	}
	cout<<ans<<endl;
}

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

int main(){
	string s;
	cin >> s;
	int t = 0;
	if(s[0] == 'A'){
		int ccnt = 0;
		int index = 0;
		for(int i = 2; i < s.length() - 1; i++){
			if(s[i] == 'C'){
				ccnt++;
				index = i;
			}
		}
		if(ccnt == 1){
			int flg = 0;
			for(int i = 1; i<s.length(); i++){
				if(i != index){
					if(isupper(s[i])){
						flg = 1;
					} 
				}
			}
			if(flg == 0){
				t = 1;
			}
		}
	}
	if(t == 0){
		cout << "WA" << endl;
	}else{
		cout << "AC" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y, int m) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y, int m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

const int mod = 1000000007;

int n, a[100010];
int p = 1;
int cum[100010];
int ans;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 2; i <= n; i++)p = p * i%mod;
	for (int i = 1; i <= n; i++)cum[i] = (cum[i - 1] + p * mod_pow(i, mod - 2, mod) % mod) % mod;
	for (int i = 0; i < n; i++)ans = (ans + a[i] * ((cum[i + 1] + cum[n - i] - p + mod) % mod) % mod) % mod;
	cout << ans << endl;
}

Measured memory_bytes: 1792
-- Branch on Condition - Small, Large, or Equal

import Control.Applicative

main :: IO ()
main = do
  [a, b] <- map read . words <$> getLine
  putStrLn $ "a " ++ (check a b) ++ " b"

check :: Int -> Int -> String
check a b
  | a > b     = ">"
  | a == b    = "=="
  | otherwise = "<"



Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vi a(n); rep(i,n) cin >> a[i];
	int ans = INF;
	for(int x=-100; x<=100; x++){
		int sum = 0;
		rep(i,n) sum += (a[i]-x)*(a[i]-x);
		ans = min(ans,sum);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int a[5];
    REP(i, 5) cin >> a[i];
    int t = 200;
    int ind;
    int sum = 0;
    int ans = 0;
    REP(i, 5){
        if(a[i]%10 != 0){
            break;
        }else{
            ans += a[i];
            if(i == 4){
                cout << ans << endl;
                return 0;
            }
        }
    }
    ans = 0;
    REP(i, 5){
        if(a[i]%10 != 0 && t >= a[i]%10){
            t = a[i]%10;
            ind = i;
            sum += a[i];
            sum = sum + (10 - a[i]%10);
        }
        else if(a[i]%10 == 0){
            sum += a[i];
        }else{
            sum += a[i];
            sum = sum + (10 - a[i]%10);
        }
        /*cout << sum << endl;
        cout << "ind = " << ind << endl;*/
    }
    //cout << ind << endl;
    ans = sum - (10 - a[ind]%10);
    cout << ans << endl;
    /*REP(i, 5) cout << a[i]%10 << endl;
    cout << t << endl;*/
    
    return 0;
}

Measured memory_bytes: 256
program main
  implicit none
  
  integer :: n,t(100)=0,m,p(100)=0,x(100)=0,i,j,s=0
  
  read(*,*)n
  read(*,*)(t(i),i=1,n)
  read(*,*)m
  do i= 1, m
    read(*,*)p(i),x(i)
  end do
  
  do i = 1, n
    s = s + t(i)
  end do
  
  do i = 1, m
    write(*,*)s - t(p(i)) + x(i)
  end do
end program main

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int N;
  int V[50]={},C[50]={};
  int sub=0;
  int i;
  scanf("%d",&N);
  for(i=0;i<N;i++)
    scanf("%d",&V[i]);
  for(i=0;i<N;i++)
  {
    scanf("%d",&C[i]);
    if(V[i]>C[i])
      sub+=V[i]-C[i];
  }
  
  printf("%d",sub);
  return 0;
}

Measured memory_bytes: 128
h,w,n = map(int, input().split())
stage = [input() for i in range(h)]
starts = [str(i) for i in range(n)]
goals = [str(i+1) for i in range(n)]
starts_y = [0 for i in range(n)]
starts_x = [0 for i in range(n)]
goals_y = [0 for i in range(n)]
goals_x = [0 for i in range(n)]

starts[0] = "S"
for y in range(h):
	for x in range(w):
		if stage[y][x] in starts:
			starts_y[starts.index(stage[y][x])] = y
			starts_x[starts.index(stage[y][x])] = x
		if stage[y][x] in goals:
			goals_y[goals.index(stage[y][x])] = y
			goals_x[goals.index(stage[y][x])] = x


sum = 0

for start_y, start_x, goal_y, goal_x in zip(starts_y, starts_x, goals_y, goals_x):
	bfs_map = [[-1 for j in range(w)] for i in range(h)]
	data_y = [start_y]
	data_x = [start_x]
	bfs_map[start_y][start_x] = 0
	goal = False
	
	while (data_y) and not goal:
		y = data_y.pop(0)
		x = data_x.pop(0)
		goal = False
	
		for i in range(4):
			ny = y + [0,1,0,-1][i]
			nx = x + [1,0,-1,0][i]
			
			if ny >= 0 and ny < h and nx >= 0 and nx < w:
				if bfs_map[ny][nx] == -1 and stage[ny][nx] != "X":
					bfs_map[ny][nx] = bfs_map[y][x]+1
					data_y.append(ny)
					data_x.append(nx)
			if bfs_map[goal_y][goal_x] != -1:
				sum += bfs_map[goal_y][goal_x]
				goal = True
				break

print(sum)


Measured memory_bytes: 36500
$<.map{|x|a=x.chop.split("").map{|c|{?I=>1,?V=>5,?X=>10,?L=>50,?C=>100,?D=>500,?M=>1000}[c]};i,p,s=a.size-1,0,0;while i>=0 do;n=a[i];if n<p;n=-n;else;p=n;end;s+=n;i-=1;end;p s}

Measured memory_bytes: 6132
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
	vector<int> a(3);
	REP(i, 3) cin >> a[i];

	sort(ALL(a));

	cout << a[0] + a[1] << endl;
}


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

const int mod = 1e9 + 7;


int main(){
	string s;
	cin >> s;
	int x = 0, h1 , h2;
	for (int i = 0; i < s.size(); ++i)
	{
		if (s[i] == 'A'&&x == 0){ x = 1; h1 = i; }
		if (s[i] == 'Z'){ h2 = i; }
	}
	cout << h2 - h1 + 1 << endl;
}

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

int main()
{
    char s[3][11];
    char ans[4] = {'\0'};
    int i;

    for(i = 0; i < 3; i++){
        scanf("%s", s[i]);
    }

    for(i = 0; i < 3; i++){
        ans[i] = toupper(s[i][0]);
    }

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

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  char s[4], t[4];
  scanf("%s", s);
  scanf("%s", t);
  int hit = 0;
  for (int i = 0; i < 3; i++){
    if (s[i] == t[i]) hit++;
  }
  printf("%d\n", hit);
  return 0;
}

Measured memory_bytes: 128
s = input()

for i in range(len(s) - 2):
    temp = s[i]
    if temp == s[i + 1] or temp == s[i + 2]:
        print(i + 1, i + 3)
        exit()
if len(s) == 2 and len(set(s)) == 1:
    print(1, 2)
else:
    print(-1, -1)

Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;



int main(int argc, char *args[]) {
	int D, N;
	cin >> D >> N;
	if (N != 100) {
		if (D == 0)cout << N << endl;
		else if (D == 1)cout << 100 * N;
		else cout << 100 * 100 * N;
	}
	else {
		if (D == 0)cout << 101 << endl;
		else if (D == 1)cout << 10100 <<endl;
		else cout << 1010000 << endl;
	}
	

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){  
  int n;
  int ans=0;
  vector<int> v(n),c(n); 
  cin >> n;
  rep(i,n){
    cin >> v[i];
  }
  rep(i,n){
    cin >> c[i];
  }
  rep(i,n){
    if(v[i]-c[i]>0){ ans += v[i]-c[i];}
  }

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

Measured memory_bytes: 512
N, A, B, C = map(int, input().split())
nums = [A, B, C]
steps = [input() for i in range(N)]
chars = ["A", "B", "C"]
operations = []
can_select = True
for i in range(N):
    s = steps[i]
    left_idx = chars.index(s[0])
    right_idx = chars.index(s[1])
    if (nums[left_idx] == 0 and nums[right_idx] == 0) or nums[left_idx] < 0 or nums[right_idx] < 0:
        can_select = False
        break
    elif nums[left_idx] == 1 and nums[right_idx] == 1 and i != N-1:
        if chars[left_idx] in list(steps[i + 1]):
            nums[left_idx] += 1
            nums[right_idx] -= 1
            operations.append(chars[left_idx])
        else:
            nums[left_idx] -= 1
            nums[right_idx] += 1
            operations.append(chars[right_idx])
    else:
        if nums[left_idx] < nums[right_idx]:
            nums[left_idx] += 1
            nums[right_idx] -= 1
            operations.append(chars[left_idx])
        else:
            nums[left_idx] -= 1
            nums[right_idx] += 1
            operations.append(chars[right_idx])
if can_select:
    print("Yes")
    for i in operations:
        print(i)
else:
    print("No")


Measured memory_bytes: 16848
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <queue>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
using namespace std;

int main(void){
    int N,K;
    string s;
    cin >> N >> K >> s;
    if(s[K-1] == 'A'){
        s[K-1] = 'a';
    }else if(s[K-1] == 'B'){
        s[K-1] = 'b'; 
    }else{
        s[K-1] = 'c';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ll i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int main() 
{
    fastio();


  string s;
  cin>>s;
  int n = s.length();
  ll dp[n+2][13];
  memset(dp,0,sizeof(dp));
  dp[n][0] = 1;

  ll mult = 1;
  for(int i = n-1;i>=0;i--)
  {
    if(s[i]=='?')
    {
      for(int j = 0;j<=9;j++)
      {
        ll add = (mult*j)%13;
        for(int k = 0;k<13;k++)
        {
          dp[i][(add+k)%13]+= dp[i+1][k];
          dp[i][(add+k)%13]%=MOD;
        }
      }
    }
    else
    {
      ll add = (mult*(s[i]-'0'))%13;
      for(int k = 0;k<13;k++)
      {
        dp[i][(add+k)%13]+= dp[i+1][k];
        dp[i][(add+k)%13]%=MOD;
      }
    }
    mult*=10;
    mult%=13;
  }
  cout<<dp[0][5];


  return 0;
}

Measured memory_bytes: 10604
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    int n;
    cin>>n;
    vector<int> a(n+1,0);
    for(int i=0;i<n;i++)cin>>a[i+1];
    a.push_back(0);
    int cost=0;
    for(int i=1;i<n+2;i++){
        cost+=abs(a[i]-a[i-1]);
    }
    for(int i=1;i<n+1;i++){
        int d = abs(a[i-1]-a[i+1])-abs(a[i]-a[i-1])-abs(a[i]-a[i+1]);
        cout<<cost+d<<endl;
    }
}

Measured memory_bytes: 1656
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		long N = sc.nextInt();
		int count=0;
		for (int i=0; i<N;i++){
			long temp = sc.nextLong();
			if(temp%2!=0){
				count++;
			}
		}
		if(count%2==0){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
		

	}

}

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

int main() {
  	int A, B, K;
	cin >> A >> B >> K;
  
  	set<int> ans;
  	for(int i = A; i < A+K; i++) ans.insert(i);
  	for(int i = B-K+1; i <= B; i++) ans.insert(i);
  	
  	auto itr = ans.begin();
  	while (itr != ans.end()) {
        if( A <= (*itr) && B >= (*itr)) cout << (*itr) << endl;
        itr++;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e9+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(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; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

int main()
{
	int ans = 0;
	int n;
	cin >> n;

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

	int maxval = 0;
	for (int i = 1; i < n; ++i)
	{
		if (a[i - 1] >= a[i])
		{
			++maxval;
		}
		else
		{
			chmax(ans, maxval);
			maxval = 0;
		}
	}
	chmax(ans, maxval);
	maxval = 0;

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

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
using namespace std;

int main(){
  vector<int> v,tmp_v;
  string N,word;
  int num,tmp_num,a,b,c,ans,tmp_2,lim;
  cin>>N;
  num=N.size();
  v.push_back(3);
  v.push_back(5);
  v.push_back(7);
  for(int i=0;i<num-1;++i){
    tmp_num=v.size();
    for(int j=0;j<tmp_num;j++){
      a=v[j]*10+3;
      b=v[j]*10+5;
      c=v[j]*10+7;
      tmp_v.push_back(a);
      tmp_v.push_back(b);
      tmp_v.push_back(c);   
    }
      tmp_v.push_back(3);
      tmp_v.push_back(5);
      tmp_v.push_back(7); 
    v=tmp_v;
    tmp_v={};
  }
  lim=stoi(N);
  ans=0;
  for(int i=0;i<v.size();++i){
      num=v[i];
      if(num>lim){
        continue;
      }
        word=to_string(num);
        if (word.find("3") == std::string::npos) {
          continue;
        }
        else if (word.find("5") == std::string::npos) {
          continue;
        }
        else if (word.find("7") == std::string::npos) {
          continue;
        }
        ans+=1;
      }
  cout<<ans;
  return 0;
  }

Measured memory_bytes: 640
N = int(input())


def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


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


ans = 1
for _ in range(N):
    ans = lcm(ans, int(input()))
print(ans)


Measured memory_bytes: 2940
#include <iostream>

namespace cplib {
    template <typename T>
    T gcd(T m, T n) {
        if (n == 0) {
            return m;
        } else {
            return gcd(n, m % n);
        }
    }

    template <typename T>
    T lcm(T m, T n) {
        return m / cplib::gcd(m, n) * n;
    }
}

int main() {
    int n;
    std::cin >> n;

    int lcm = 1;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        lcm = cplib::lcm(lcm, a);
    }

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



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

#define array_sort_asc(array,size) sort(array, array+size);
#define array_sort_desc(array,size) sort(array, array+size,greater<>());

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

    int tmp = n % 2;
    double kakuritu = 0.0;
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }

    if(tmp == 1){
        kakuritu = double(((n / 2) + 1.0) / n);    
    } else {
        kakuritu = double((n / 2.0) / n);
    }
    cout << kakuritu << endl;
}

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

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define P pair<ll,ll>

using namespace std; 


int main(){
    int n;
    cin>>n;
    vi v(n),ans;
    pan(i,n) cin>>v[i];
    int i=0;
    while(i<n){
        // cout<<i<<endl;
        for(int j=v.size()-1;j>=0;j--){
            // cout<<j<<endl;
            // cout<<v.size()<<" ";
            if(v[j]==j+1){ 
                ans.pb(j+1);
                // cout<<j+1<<endl;
                v.erase(v.begin()+j);
                break;
            }
        }
        i++;
    }
    // cout<<ans.size()<<endl;
    if(ans.size()!=n) cout<<-1;
    else{
        for(i=n-1;i>=0;i--) cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAXCHAR 210000

int main (void)
{
    char S[MAXCHAR];
    scanf("%s", S);
    int N;
    for (N = 0; S[N] != '\0'; N++);

    int dp[MAXCHAR];
    char isLastNext[MAXCHAR + 1];

    if (N == 1) {
        printf("%d", 1);
        return 0;
    }
    if (N == 2) {
        if (S[0] == S[1]) {
            printf("%d", 1);
            return 0;
        } else {
            printf("%d", 2);
            return 0;
        }
    }

    dp[0] = 0;
    isLastNext[0] = 0;
    dp[1] = 1;
    if (S[0] != S[1]) {
        isLastNext[1] = 0;
    } else {
        isLastNext[1] = 1;
    }
    int i;
    for (i = 2; i <= N; i++) {
        if (isLastNext[i - 1] == 0) {
            dp[i] = dp[i - 1] + 1;
            if ((S[i - 1] != S[i]) || (isLastNext[i - 2] == 1)) {
                isLastNext[i] = 0;
            } else {
                isLastNext[i] = 1;
            }
        } else {
            dp[i] = dp[i - 1];
            isLastNext[i] = 0;
        }
        //printf("%d: %d,%d\n", i, dp[i], isLastNext[i]);
    }

    printf("%d", dp[N]);
    return 0;
}

Measured memory_bytes: 1408
def Distance(t_a,t_b):
    return abs(t_a[0]-t_b[0]) + abs(t_a[1]-t_b[1])

n,m = map(int,input().split(' '));
students = []
for p in range(n):
    students.append(tuple(map(int,input().split(' '))))
check = []
for q in range(m):
    check.append(tuple(map(int,input().split(' '))))
ans = ''
for s in students:
    dmin = Distance(s, check[0])
    dindex = 0
    i = 1
    while i < m:
        d0 = Distance(s, check[i])
        if d0 < dmin:
            dmin = d0
            dindex = i
        i += 1
    ans += str(dindex+1) + '\n'
print(ans)
        

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

typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int MID = 1e5 + 3;
const int INF = 1e9 + 5;
const int MOD = 1e9 + 7;

int main(){
	speed;
	int x;
	cin >> x;
	if(x){
		cout << 0;
	}
	else{
		cout << 1;
	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 998244353;
signed main() {
    INCANT;
    int n, res = 1, d[111111], mx = -INF;
    cin>>n;
    int cnt[111111] = {};
    rep(i, n) {
        cin>>d[i], cnt[d[i]]++;
        if(i == 0 && d != 0) res == 0;
    }
    if(cnt[0] != 1) res = 0;
    rep(i, 1, n) {
        res *= cnt[d[i] - 1];
        res %= MOD;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1920
// 解き直し.
// https://img.atcoder.jp/agc014/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int u[101010];

int main(){
    
    // 1. 入力情報.
    int N, M;
    scanf("%d %d", &N, &M);
    rep(i, M){
        int x, y;
        scanf("%d %d", &x, &y);
        u[x]++;
        u[y]++;
    }
    
    // 2. クエリ の a[i], b[i] の 出現回数をチェック.
    bool ans = true;
    repx(i, 1, N + 1){
        if(u[i] & 1){
            ans = false;
            break;
        }
    }
    
    // 3. 出力.
    // repx(i, 1, N + 1) printf("%d\n", u[i]);
    printf("%s\n", ans ? "YES" : "NO");
    return 0;
    
}

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

#define REP(i,n) for(int i=0;i<n;i++)
int main(){
    // Your code
    int s;
    cin >> s;

    map <int,int> MP;

    REP(i,s){
        int a;
        cin >>a;

        MP[a-1]++;
        MP[a]++;
        MP[a+1]++;
    }

    int ans=0;

    for(auto&x:MP){
        
        ans = max(ans,x.second);
    }

    cout << ans <<endl;
}

Measured memory_bytes: 4736
#include <iostream>
#include <vector>

using namespace std;

const int MAX = 100000;

vector<int> G[MAX];
int C[MAX] = {0};

void dfs(int u, int c) {
    if (C[u] == 0) {
        C[u] = c;
        for (auto v : G[u]) {
            if (C[v] == 0) dfs(v, c);
        }
    }
}

int main() {

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    int c = 1;
    for (int i = 0; i < n; i++) {
        if (C[i] == 0) dfs(i, c++);
    }

    //
    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        int s, t;
        cin >> s >> t;
        if (C[s] != 0 && C[s] == C[t]) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 11972
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
void solve()
{
	ll n;
	rl(n);
	VL c(n-1),s(n-1),f(n-1);
	fr(i,0,n-1)
	{
		rl3(c[i],s[i],f[i]);
	}
	ll time=0;
	VL ans(n,0);
	fr(j,0,n)
	{
		time=0;
		fr(i,j,n-1)
		{
			//ans[i]=time;
			if(time<s[i])
			{
				time=s[i];
			}
			ll x=time%s[i];
			if(x%f[i]!=0)
			{
				time+=(f[i]-(x%f[i]));
			}
			time+=c[i];
		}
		cout<<time<<endl;
	}
	
	return;
}
int main()
{
	
	ll t=1;
	//rl(t);

	//cin>>t;
	//scanf()
	while(t--)
	{
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
import fractions

n=int(input())
a=list(map(int,input().split()))

ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

ans-=1
ans1=0
for g in range(n):
    ans1+=ans%a[g]
print(ans1)

Measured memory_bytes: 5344
from collections import Counter
n,k=map(int,input().split())
cnt=sorted(Counter(map(int,input().split())).values())
count=0
p=len(cnt)
if p<=k:
    print(count)
else:
    for c in cnt:
        if p>k:
            p-=1
            count+=c
        else:break
    print(count) 

Measured memory_bytes: 41504
n = int(input())
s,t = [0] * n, [0] * n
for i in range(n):
    s[i],t[i] = map(str, input().split())
x = input()

sub = 0
for i in range(n):
    if s[i] == x:
        sub = i + 1
        break

ans = 0
for i in range(sub, n):
    ans += int(t[i])

print(ans)

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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

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

int res = 0, n;
ll d;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> d; d *= d;
    for(int i = 0; i < n; ++i){
        ll x, y;
        cin >> x >> y;
        res += d >= x * x + y * y;
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <climits>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

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

const int dx[] = {0,0,1,-1};
const int dy[] = {1,-1,0,0};
string field[12];
bool used[12][6];

bool inside(int x, int y){
  return !(x<0 || x>=6 || y>=12 || y<0);
}
int check(int x, int y, char color){
  int ret = 1;
  used[y][x] = true;
  rep(k,4){
    int tx = x + dx[k];
    int ty = y + dy[k];

    if( !inside(tx,ty) ) continue;
    if( field[ty][tx]!=color || used[ty][tx] ) continue;
#if DEB
    printf("k:%d tx:%d , ty:%d  ret:%d  color:%c  f:%c\n",k,tx,ty,ret,color,field[ty][tx]);
#endif
    ret += check(tx, ty, color);
  }
  return ret;
}

void sakujo(int x, int y, char color){

  field[y][x] = '.';

#if DEB
  puts("sakujoooooooooooooooooooooooooooooo");
  rep(i,12)cout<<field[i]<<endl;
  puts("----------------------");
#endif

  rep(k,4)
  rep(k,4){
    int tx = x + dx[k];
    int ty = y + dy[k];
    if( !inside(tx,ty) ) continue;
    if( field[ty][tx]=='O' ){
      field[ty][tx]='.';
    }
    if( field[ty][tx]!=color )continue;
    sakujo(tx,ty,color);
  }
}
void otiru(void){
  bool ok = true;
  while(ok){
    ok = false;
    rep(i,11)rep(j,6)if( field[i][j]!='.' ){
      if( field[i+1][j]=='.' ){
	field[i+1][j] = field[i][j];
	field[i][j] = '.';
	ok = true;
      }
    }
  }
}

int main(){
  int T;
  cin>>T;
  while(T--){
    rep(i,12)cin>>field[i];
#if DEB
    rep(i,12){
      cout << field[i] << endl;
    }
    puts("");
#endif
    int ans = 0;
    bool ok = true;
    while( ok ){
      ok = false;
      memset(used,false,sizeof(used));
      rep(i,12)rep(j,6)if( field[i][j]!='.' && field[i][j]!='O' ){
	if( check(j,i,field[i][j]) >= 4 ){
	  sakujo(j,i,field[i][j]);
	  ok = true;
	}
      }
      otiru();
      if( ok ) ans++;
#if DEB
      rep(i,12)cout<<field[i]<<endl;
      puts("");
#endif
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#![allow(unused)]
use io::*;
use std::collections::HashSet;

fn main() {
    let buf = read_string();
    let mut sc = Scanner::new(&buf);

    let h: usize = sc.next();
    let _: usize = sc.next();

    let v: Vec<String> = (0..h).map(|_| sc.next::<String>()).collect();
    let st: HashSet<_> = v
        .iter()
        .flat_map(|s| {
            s.chars()
                .enumerate()
                .filter(|&(_, c)| c == '#')
                .map(|(i, _)| i)
        }).collect();
    for s in v.iter().filter(|s| s.contains("#")).map(|s| {
        s.chars()
            .enumerate()
            .filter(|&(i, _)| st.contains(&i))
            .map(|(_, c)| c)
            .collect::<String>()
    }) {
        println!("{}", &s)
    }
}

pub mod io {
    use std;
    use std::io::Read;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(buf: &'a String) -> Scanner<'a> {
            Scanner {
                iter: buf.split_whitespace(),
            }
        }

        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            s.parse().ok().expect("cannot parse string")
        }

        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).ok().unwrap();
        buf
    }

    fn read_line<T: std::str::FromStr>() -> T {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim().parse().ok().unwrap()
    }

    fn read_vec<T: std::str::FromStr>() -> Vec<T> {
        read_line::<String>()
            .split_whitespace()
            .map(|e| e.parse().ok().unwrap())
            .collect()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y;
    cin>>x>>y;
    if(y>=2*x && y<=4*x && (4*x-y)%2==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

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

	int cnt = 0;
	rep(i, s.size()/2){
		if(s.at(i) != s.at(s.size()-1-i)) cnt++;
	}

	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 256
a = input()
pos = True
for i in range(0, len(a)):
  if i % 2 == 0 and a[i] == 'L':
    print("No")
    pos = False
    break
  if i % 2 == 1 and a[i] == 'R':
    print("No")
    pos = False
    break
    
if pos == True:
  print("Yes")

Measured memory_bytes: 3060
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


class UnionFind:
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes
        self.parent = [i for i in range(n_nodes)]
        self.rank = [1] * n_nodes
        self.size = [1] * n_nodes

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.parent[y] = x
            self.size[x] += self.size[y]
        else:
            self.parent[x] = y
            self.size[y] += self.size[x]
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def check(self, x, y):
        return self.find(x) == self.find(y)

    def get_parent_list(self):
        return [i for i in range(self.n_nodes) if self.find(i) == i]

    def get_n_groups(self):
        return len(self.get_parent_list())

    def get_members(self, x):
        parent = self.find(x)
        return [i for i in range(self.n_nodes) if self.find(i) == parent]

    def get_members_dict(self):
        return {par: self.get_members(par) for par in self.get_parent_list()}


def main():
    N, M = map(int, input().split())
    Bridge = [list(map(int, input().split())) for _ in range(M)]
    answer = [N * (N - 1) // 2]
    UF = UnionFind(N)
    for i in range(M):
        AB = Bridge[M - i - 1]
        A = AB[0] - 1
        B = AB[1] - 1
        if UF.check(A, B):
            last = answer[-1]
            answer.append(last)
            continue
        else:
            before = UF.size[UF.find(A)]
            UF.unite(AB[0] - 1, AB[1] - 1)
            after = UF.size[UF.find(A)]
            last = answer[-1]
            if before == after:
                answer.append(last)
            else:
                answer.append(last - (after - before) * before)

    answer = answer[::-1]
    print(*answer[1:], sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 42104
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define LLI long long int
#define fst first
#define snd second
#ifdef DEBUG
#include <boost/core/demangle.hpp>
#define dump(x) cerr << "L" << __LINE__ << ": in " << __PRETTY_FUNCTION__ << " \e[32;1m" << boost::core::demangle(typeid(x).name()) << "\e[37m" << " " << (#x) << " = " << (x) << "\e[m" << endl;
#else
#define dump(x)
#endif
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T> ostream& operator<<(ostream &os, vector<T> &v){os << "{";ITR(i,v){if(i!=v.begin())os << ","; os << *i;}os << "}"; return os;}
template <typename T, typename U> ostream& operator<<(ostream& os, pair<T,U> &p){os << "(" << p.first << "," << p.second << ")"; return os;}

template <typename T> T& chmin(T &a, const T &b){return a = min(a,b);}
template <typename T> T& chmax(T &a, const T &b){return a = max(a,b);}

double dp[310][310][310];
bool visit[310][310][310];
int N;

double rec(int one, int two, int thr){
  if(one==0 && two==0 && thr==0) return dp[0][0][0] = 0;
  if(visit[one][two][thr]) return dp[one][two][thr];
  visit[one][two][thr] = true;

  double t = 1;
  if(one>0) t += rec(one-1,two,thr)*one/N;
  if(two>0) t += rec(one+1,two-1,thr)*two/N;
  if(thr>0) t += rec(one,two+1,thr-1)*thr/N;
  int zero = N-(one+two+thr);
    t /= (1.0-(double)zero/N);
  
  return dp[one][two][thr] = t;
}

int main(){
  cin >> N;
  vector<int> a(N); cin >> a;

  map<int,int> c;
  REP(i,N) ++c[a[i]];

  printf("%.012f\n", rec(c[1],c[2],c[3]));
  
  return 0;
}


Measured memory_bytes: 256256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int n,m;
  cin >> n >> m;
  int h[n],a[m],b[m],c[n] = {},d = 0;
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
  for (int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    if (h[a[i]-1] > h[b[i]-1] || h[a[i]-1] == h[b[i]-1]){
      c[b[i]-1] += 1;
    }
    if (h[a[i]-1] < h[b[i]-1] || h[a[i]-1] == h[b[i]-1]){
      c[a[i]-1] += 1;
    }
  }
  for (int i = 0; i < n; i++){
    if (c[i] == 0){
      d += 1;
    }
  }
  cout << d << '\n';
  return 0;
}

Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
int main () {
	long long A, V, B, W, T; cin >> A >> V >> B >> W >> T;
	long long del = abs(A - B);
	if ((V - W) * T >= del) printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 3632
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
#include<sstream>
#include<chrono>
#include<algorithm>
#include<functional>
#include<cstdlib>
#include<numeric>
#include<queue>
#include<stack>
using namespace std;
typedef unsigned long long ull;
int main()
{
	int k = 0;
cin >> k;
ull sum = 0;
for (int a = 1; a <= k; a++)
	for (int b = 1; b <= k; b++)
		for (int c = 1; c <= k; c++)
			sum += std::gcd(std::gcd(a, b), c);

std::cout << sum << std::endl;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    if(a == 1 && b == 2){
        System.out.println(3);
    }else if(a == 1 && b == 3){
        System.out.println(2);
    }else if(a == 2 && b == 1){
        System.out.println(3);
    }else if(a == 2 && b == 3){
        System.out.println(1);
    }else if(a == 3 && b == 1){
        System.out.println(2);
    }else{
        System.out.println(1);
    }

        
    
	}
}

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

using namespace std;

typedef long long int ll;


int main(){
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    if (A >= K){
        cout << K << endl;
        return 0;
    }
    if (B >= (K-A)){
        cout << A << endl;
        return 0;
    }
    cout << A - (K - A - B) << endl;
    return 0;
}

Measured memory_bytes: 3632
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll N;
    cin >> N;
    ll a = N / 1000;
    ll b = (N % 1000) / 100;
    ll c = (N % 100) / 10;
    ll d = N % 10;
    if ((a == b && b == c) || (b == c && c == d)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    ll Min = 10e9, Max = 0;
    for (int i = 0; i < N;i++){
        cin >> A[i];
        Min = min(Min, A[i]);
        Max = max(Max, A[i]);
    }

    ll ans = 10e9;
    for (int i = Min; i <= Max;i++){
        ll tmp = 0;
        for(auto u : A)
            tmp += (u - i) * (u - i);
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
string str;
bool used[MAX_N];
int A[MAX_N], B[MAX_N];
vi G[MAX_N];

void solve() {
	cin >> N >> M;
	cin >> str;
	rep(i, 0, M) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	queue<int> que;
	rep(i, 0, N) {
		rep(j, 0, sz(G[i])) {
			int n = G[i][j];
			if(str[n] == 'A') A[i]++;
			else B[i]++;
		}
		if(!A[i] || !B[i]) {
			que.push(i);
			used[i] = true;
		}
	}
	int sur = N;
	while(!que.empty()) {
		int v = que.front(); que.pop();
		sur--;
		int am = (str[v] == 'A');
		int bm = (str[v] == 'B');
		rep(i, 0, sz(G[v])) {
			int n = G[v][i];
			if(used[n]) continue;
			A[n] -= am;
			B[n] -= bm;
			if(!A[n] || !B[n]) {
				used[n] = true;
				que.push(n);
			}
		}
	}
	if(sur > 0) cout << "Yes\n";
	else cout << "No\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

using namespace std;

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

    vector<int64_t> x;

    x.push_back(a * c);
    x.push_back(a * d);
    x.push_back(b * c);
    x.push_back(b * d);

    std::sort(x.begin(),x.end());

    cout << x[3] << endl;

    return 0;
}


Measured memory_bytes: 3624