akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
const int sz = (1 << 21);
vel bit_in(sz+1, 0);
vel bit_out = bit_in;
void change(vel &bit, int pot, int val) {
	pot++;
	for (int x = pot; x <= sz; x += x & -x) bit[x] += val;
}
int sum(vel &bit, int pot) {
	int ret = 0;
	pot++;
	for (int x = pot; x > 0; x -= x & -x) ret += bit[x];
	return ret;
}
void add(int st, int to,set<int> &all_st) {
	if (to < 0) { to =  0; }
	change(bit_out, st, 1);
	change(bit_in, to, 1);
	auto itr_to = all_st.upper_bound(to);
	auto itr_st = all_st.upper_bound(st);
	if (itr_to != itr_st) {
		itr_st--;
		all_st.erase(itr_st);
	}
}
void del(int st, int to, set<int> &all_st) {
	if (to < 0) { to = 0; }
	change(bit_out, st, -1);
	change(bit_in, to, -1);
	if (sum(bit_in, to) == sum(bit_out, to)) {
		all_st.insert(to + 1);
	}
}
signed main(){
	int n; cin >> n;
	int m; cin >> m;
	vel a(n);
	int np = n + 1;
	set<int> all_st;
	rep(i, np) { all_st.insert(i); }
	vel count(n + 1,0);
	rep(i, n) { 
		cin >> a[i];
		count[a[i]]++; 
		add(a[i], a[i] - count[a[i]], all_st);
	}
	rep(i, m) {
		int x, aft; cin >> x >> aft; x--;
		int bef = a[x];
		del(bef, bef - count[bef], all_st);
		count[bef]--;
		count[aft]++;
		add(aft, aft - count[aft], all_st);
		a[x] = aft;
		cout << all_st.size() - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 49664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
int a,b;
int count = 0;
cin >> a>> b;
for(int i = 0;i<=a;++i){
  for(int j= 0;j<=a;++j){
     int z = b-i-j;
     if(0<=z && z<=a){
       count = count +1;
     }
  }
}
cout << count << endl;
return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var G = new List<List<int>>();

            for (int i = 0; i < n; i++) 
            {
                G.Add(new List<int>());
            }

            for(int i = 0; i < n - 1; i++)
            {
                var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var a = ab[0] - 1;
                var b = ab[1] - 1;

                G[a].Add(b);
                G[b].Add(a);
            }

            //各ノードの色,-1:色なし,1:黒,0:白
            var colors = Enumerable.Repeat(-1, n).ToArray();
            colors[0] = 1;
            colors[n - 1] = 0;

            //BFS回すためのキュー
            var que = new Queue<(int, int)>();
            que.Enqueue((0, 1));
            que.Enqueue((n - 1, 0));

            //BFS
            while (que.Count > 0)
            {
                var (x, color) = que.Dequeue();
                foreach(var nx in G[x])
                {
                    if(colors[nx] == -1)
                    {
                        colors[nx] = color;
                        que.Enqueue((nx, color));
                    }
                }
            }

            //黒白マスの個数をカウント
            var black = colors.Sum();
            var white = n - black;

            /*
            Console.WriteLine(black);
            Console.WriteLine(white);
            */

            Console.WriteLine(black > white ? "Fennec" : "Snuke");
        }
    }
}


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

vector<bool> canUse(10, true);

bool isValid(int n) {
    while (n > 0) {
        if (!canUse[n % 10]) {
            return false;
        }
        n /= 10;
    }
    return true;
}

int main() {
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        canUse[d] = false;
    }

    for (int i = N; i < INT32_MAX; i++) {
        if (isValid(i)) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        int ans = main.solve();
        System.out.println(ans);
    }

    int solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[] s = sc.next().toCharArray();
        HashSet<String> rec = new HashSet<>(1000);
        boolean[] res = new boolean[1000];
        int[] first = new int[10];
        for(int i=0;i<10;i++) first[i]= N+1;
        first[s[1]-'0'] = 1;
        first[s[0]-'0'] = 0;
        int[] sec = new int[10];
        for(int i=0;i<10;i++) sec[i]=-1;
        sec[s[0]-'0'] = 0; sec[s[1]-'0'] = 1;
        for(int idx=2;idx<N;idx++){
            int cur = s[idx]-'0';
            // check the 2nd digit;
            for(int j=0;j<10;j++){
                if(sec[j]<0) continue; // meaning that the number j hasn't appeared
                // Returns the greatest element in this set strictly less than the given element, or null if there is no such element.
                for(int k=0;k<10;k++){
                    // lower(E e)
                    // Returns the greatest element in this set strictly less than the given element, or null if there is no such element.
                    if(first[k] < sec[j]){
                        res[100*k+10*j+cur] = true;
                    }
                }
            }
            sec[cur] = idx;
            first[cur] = Math.min(first[cur],idx);
        }
        int ans = 0;
        for(int i=0;i<1000;i++) ans += res[i]?1:0;
        return ans;
    }
}

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

int main() {
  	string A;
    cin >> A;
    int s = 700;
    if (A[0]=='o') s+=100;
    if (A[1]=='o') s+=100;
  	if (A[2]=='o') s+=100;
    cout << s << endl;
}


Measured memory_bytes: 3576
n = int(input())
nums = list(map(int,input().split()))
if n == 2:
    print(max(nums[0],nums[1]))
else:
    temp =[0]
    for i in range(n):
        if i%2 == 0:
            temp += [temp[-1]+nums[i]]
    dp = [[0,0,0] for _ in range(n)]
    dp[0][0] = nums[0]
    dp[1][0],dp[1][1],dp[1][2] = nums[1],nums[0],-float("inf")
    dp[2][0],dp[2][1],dp[2][2] = nums[2],nums[1],nums[0]
    for i in range(3,n):
        if i%2 == 0:
            dp[i][0] = max(dp[i-2]) + nums[i]
            dp[i][1] = max(dp[i-3]) + nums[i-1]
            dp[i][2] = temp[i//2]
        else:
            dp[i][0] = max(dp[i-2]) + nums[i]
            dp[i][1] = temp[(i-1)//2] + nums[i-1]
            dp[i][2] = -float("inf")
    print(max(dp[n-1]))

Measured memory_bytes: 66236
#include <bits/stdc++.h>
#define il inline
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN 2050
#define MAXM 
#define mod
#define inf (1<<30)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(register int i = x; i <= y; ++i)
#define repd(i, x, y) for(register int i = x; i >= y; --i)
#define file(s) freopen(s".in", "r", stdin), freopen(s".my", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> il bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> il bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
template <typename T> il void read(T &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
template <typename T, typename... Args> il void read(T &x, Args &...args) {
	read(x), read(args...);
}
int n;
bitset <MAXN> a[MAXN], l[MAXN], r[MAXN];
char s[MAXN];
int main() {
	read(n);
	rep(i, 2, n) {
		scanf("%s", s+1);
		rep(j, 1, i-1) 
			if(s[j] == '1') a[i][j] = 1, a[j][i] = 0;
			else a[j][i] = 1, a[i][j] = 0;
	}
	rep(i, 1, n) l[i][i] = r[i][i] = 1;
	// rep(i, 1, n) cout << a[i] << endl;
	// cout << a[3] << endl << "QWQ " << a[3][1] << endl;
	rep(d, 2, n)
		rep(i, 1, n - d + 1) {
			int x = i, y = x + d - 1;
			r[x][y] = (r[x] & l[y-1] & a[y]).any();
			l[y][x] = (l[y] & r[x+1] & a[x]).any();
			// cout << x << ' ' << y << ' ' << l[x][y] << ' ' << r[x][y] << endl;
		}
	cout << (r[1] & l[n]).count() << endl;
	return 0;
}

Measured memory_bytes: 1792
import sys

n = int(raw_input())
i = 1
while i <= n:
    x = i
    if x%3 == 0:
        sys.stdout.write(' '+str(i))
        i += 1
        continue
    while x != 0:
        if x%10 == 3:
            sys.stdout.write(' '+str(i))
            break
        x /= 10
    i += 1
print 

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

a = 0

a += B[0]
a += B[N-2]

for n in range(N):
    if n == 0 or n == N-1:
        pass
    else:
        a += min(B[n-1], B[n])

print(a)



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct edge{
  long to,cap,rev;//capは残りどれだけ流せるか, revはv[to][rev]が自分への逆辺を表す
  edge(){}
  edge(long t,long c,long r):to(t),cap(c),rev(r){}
};
class flow{
  long n;
  vector<vector<edge>>v;
  vector<bool>used;
  public:
  
  long dfs(long s,long t,long f){
    if(s==t)return f;
    used[s]=1;
    for(long i=0;i<v[s].size();i++){
      edge e=v[s][i];
      if(!used[e.to]&&e.cap>0){
        long r=dfs(e.to,t,min(f,e.cap));
        if(r>0){
          v[s][i].cap-=r;v[e.to][e.rev].cap+=r;
          return r;
        }
      }
    }
    return 0;
  }
  long solve(long s,long t){//最大流を求める
    long ans=0;
    while(1){
      used.clear();used=vector<bool>(n,0);
      long f=dfs(s,t,LONG_MAX);
      if(f==0)return ans;
      else ans+=f;
    }
  }
  flow(){}
  flow(const vector<vector<edge>>&v_)
    :n(v_.size()),v(vector<vector<edge>>(v_.size())){
      for(long i=0;i<n;i++)for(long j=0;j<v_[i].size();j++){
        edge e=v_[i][j];
        v[i].push_back(edge(e.to,e.cap,v[e.to].size()));//辺の追加
        v[e.to].push_back(edge(i,0,v[i].size()-1));//逆辺の追加
      }
    }
};

int main(){
  long H,W;cin>>H>>W;
  vector<string>S(H);for(long i=0;i<H;i++)cin>>S[i];
  vector<vector<edge>>A(H+W+2);
  long sx,sy,tx,ty;
  for(long i=0;i<H;i++)for(long j=0;j<W;j++){
    if(S[i][j]=='S'){
      sx=i;sy=j;
      A[0].push_back(edge(1+i,LONG_MAX,0));
      A[0].push_back(edge(1+H+j,LONG_MAX,0));
    }
    if(S[i][j]=='T'){
      tx=i;ty=j;
      A[1+i].push_back(edge(H+W+1,LONG_MAX,0));
      A[1+H+j].push_back(edge(H+W+1,LONG_MAX,0));
    }
    if(S[i][j]=='o'){
      A[1+i].push_back(edge(1+H+j,1,0));
      A[1+H+j].push_back(edge(1+i,1,0));
    }
  }
  flow f(A);cout<<(sx==tx||sy==ty?-1:f.solve(0,H+W+1));
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int n,m;
string s;
int main()
{
	cin>>n>>m>>s;
	for(int i=0;i<n;i++)
	{
		if(i==m-1) cout<<(char)tolower(s[i]);
		else cout<<s[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
struct TTL{
	int x,v;
}p[200010];
const int mod=1000000007;
int L[200010],R[200010];
int f[200010],q[200010];
int lsh[600010],cnt;
int read()
{
	int ans=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') ans=ans*10+ch-'0',ch=getchar();
	return ans;
}
bool cmp(TTL a,TTL b)
{
	return a.x<b.x;
}
int ycl()//左边最大 右边最小 
{
	int maxn=0,minn=2e9;
	for (int i=1;i<=n;i++)
	{
		maxn=max(maxn,p[i].v);
		R[i]=maxn;
		lsh[++cnt]=maxn;
	}
	for (int i=n;i>=1;i--)
	{
		minn=min(minn,p[i].v);
		L[i]=minn;
		lsh[++cnt]=minn;
	}
///	for (int i=1;i<=n;i++)
//		printf("%d %d\n",L[i],R[i]);
}
int main()
{
	n=read();
	for (int i=1;i<=n;i++)
		p[i].x=read(),p[i].v=read(),lsh[++cnt]=p[i].v;
	sort(p+1,p+1+n,cmp);
	ycl();
	sort(lsh+1,lsh+1+cnt);
	cnt=unique(lsh+1,lsh+1+cnt)-1-lsh;
	for (int i=1;i<=n;i++)
	{
		L[i]=lower_bound(lsh+1,lsh+1+cnt,L[i])-lsh;
		R[i]=lower_bound(lsh+1,lsh+1+cnt,R[i])-lsh;
	//	printf("%d %d\n",L[i],R[i]);
	}
	int head=0,tail=1;
	int sum=1;
	L[0]=0;R[0]=0;f[0]=1;
	n++;
	L[n]=n;R[n]=n;
	for (int i=1;i<=n;i++)
	{
		while (head<tail&&L[i]>R[q[head+1]]+1)
			sum=(sum-f[q[head+1]]+mod)%mod,head++;
		f[i]=sum;
		sum=(sum+f[i])%mod;
		q[++tail]=i;
	//	cout<<sum<<endl;
	}
	printf("%d",f[n]);
} 

Measured memory_bytes: 7296
from collections import deque
import sys
input = sys.stdin.readline

H ,W = map(int, input().split())#↓H行数 →W列数
List = [list(str(input())) for i in range(H)]
#H=3
#W=3
#List=[['.', '.', '.'], ['.', '#', '.'], ['.', '.', '.']]
cheak=[['0' for i in range(W)] for j in range(H)]

q = deque([])

for h in range(H):
    for w in range(W):
        if List[h][w]=='#':
            cheak[h][w]='1'
            q.append([h,w])
#print(List)
#print(cheak)
move=[[1,0],[-1,0],[0,1],[0,-1]]
num=-1
#print(q)
while q:
    for rt in range(len(q)):
        i=q.popleft()
        for u in move:
            if 0<=i[0]+u[0]<=H-1 and 0<=i[1]+u[1]<=W-1 and cheak[i[0]+u[0]][i[1]+u[1]]=='0':
                q.append([i[0]+u[0],i[1]+u[1]])
                cheak[i[0]+u[0]][i[1]+u[1]]='1'
    #print(cheak)
    num+=1
print(num)  

Measured memory_bytes: 177244
#include <cstdio>
#include <algorithm>
#include <cmath>

using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
	int n, d;
	int cnt = 0;
	scanf("%d", &n);
	scanf("%d", &d);
	int x[10][10];
	rep(i, n) {
		rep(j, d) {
			scanf("%d", &x[i][j]);
		}
	}
	
	rep(i, n-1) {
		for (int j = i + 1; j < n; j++) {
			int sum = 0;
			rep(k, d) {
				sum += (x[j][k] - x[i][k]) * (x[j][k] - x[i][k]);
			}
			if (std::sqrt(sum) == int(std::sqrt(sum))) {
				cnt++;
			}
		}
	}

	printf("%d\n",cnt);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 30;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

bool collision_detection( double x1, double y1, double x2, double y2, double x3, double y3, double xp, double yp ) {
	x2 -= x1;
	x3 -= x1;
	xp -= x1;
	y2 -= y1;
	y3 -= y1;
	yp -= y1;
	double t_size = fabs( ( x2 * y3 - y2 * x3 ) / 2 );
	t_size -= fabs( ( x2 * yp -  y2 * xp ) / 2 );
	t_size -= fabs( ( x3 * yp -  y3 * xp ) / 2 );
	x2 -= xp;
	x3 -= xp;
	y2 -= yp;
	y3 -= yp;
	yp = xp = 0;
	t_size -= fabs( ( x2 * y3 - y2 * x3 ) / 2 );
	return fabs( t_size ) < 1e-10;
}

int main() {
	double x1, y1, x2, y2, x3, y3, xp, yp;
	while ( ~scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp ) ) {
		printf( "%s\n", collision_detection( x1, y1, x2, y2, x3, y3, xp, yp ) ? "YES" : "NO" );
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define fr(i,f,t) for(ll i=(f);i<t;i++)
#define fb(i,f,t) for(ll i=(f);i>=t;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    int flag =0;
    for(int i=0;i<=2;i++){
    	if(s[i]=='7'){
    		flag =1;
    	}
    }
    if(flag==1){
    	cout<<"Yes"<<endl;
    }
    else{
    	cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
n,k = map(int,input().split())
ans = []
for i in range(n):
    a,b = map(int,input().split())
    ans.append([a,b])
ans.sort()
for i in range(len(ans)):
    k = k - ans[i][1]
    if k<=0:
        print(ans[i][0])
        break


Measured memory_bytes: 24496
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  double h,w,x,y;
  cin >> w >> h >> x >> y;
  int ans = 0;
  if(w / 2 == x && h / 2 == y)ans = 1;
  printf("%lf %d\n",(h*w)/2,ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static int[][] color = 
	{
	{0,0,0},
	{0,0,255},
	{0,255,0},
	{0,255,255},
	{255,0,0},
	{255,0,255},
	{255,255,0},
	{255,255,255},
	};
	static String anss[] =
	{ "black","blue","lime","aqua","red","fuchsia","yellow","white"};
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			String str = cin.next();
			if(str.equals("0")){
				break;
			}
			int r = hex(str.substring(1,3));
			int g = hex(str.substring(3,5));
			int b = hex(str.substring(5,7));
//			System.out.println(r+" " +g+" " +b);
			double min = 9999999999.0;int ans=0;
			for(int i = 0;i<8;i++){
				double a = 0;
				a = d(r,g,b,i);
				if(min > a){
					min = a;
					ans = i;
				}
			}
			System.out.println(anss[ans]);
		}
	}
	static double d(int r, int g, int b ,int x){
		double re = Math.pow(r-color[x][0],2);
		re += Math.pow(g-color[x][1],2);
		re += Math.pow(b-color[x][2],2);
		re = Math.sqrt(re);
		return re;
	}
	static int hex(String str){
		char[] s = str.toCharArray();
		int re = 0;
		if(Character.isDigit(s[0])){
			re += (s[0]-'0')*16;
		}
		else{
			re += (s[0]-'a' + 10)*16;
		}
		if(Character.isDigit(s[1])){
			re += (s[1]-'0');
		}
		else{
			re += (s[1]-'a' + 10);
		}
		return re;
	}
}

Measured memory_bytes: 12000
#include<cstdio>
#include<vector>
using namespace std;
int n,m,k,l,visit[200001];
vector<int> g[200001];

void dfs(int x){
    visit[x]=1;
    for(int i=0;i<g[x].size();i++){
        if(visit[g[x][i]]==0){
            dfs(g[x][i]);
        }
    }
}
int main(){
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d",&k);
        for(int j=0;j<k;j++){
            scanf("%d",&l);
            g[i].push_back(n+l);
            g[n+l].push_back(i);
        }
    }
    dfs(0);
    int flag=1;
    for(int i=0;i<n;i++){
        flag*=visit[i];
    }
    if(flag){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}

Measured memory_bytes: 8960
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void){
  int n,t1,t2,t;
  int i;
  cin>>n;

  t1=10000000;
  t2=-1;
  for(i=0;i<n;i++){
    cin>>t;
    t1=min(t,t1);
    t2=max(t,t2);
  }
  cout<<t2-t1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 

*/

//================== INPUT ========================
int N;
vector<int> A;
//=================================================
void input()
{
    cin >> N;
    A = vector<int>(N);
    rep(i, N)
    {
        cin >> A[i];
    }
}

//=================================================
void solve()
{
    deque<int> d;
    rep(i, N)
    {
        auto iter = lower_bound(d.begin(), d.end(), A[i]);

        if (iter == d.begin())
        {
            d.push_front(A[i]);
        }
        else
        {
            --iter;
            *iter = A[i];
        }
    }
    cout << d.size() << endl;
}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 1792
/*input
10 4
7 8 100
6 10 100
8 10 100
7 10 201
*/
#include <bits/stdc++.h>
using namespace std;

vector <pair<pair<int,int>, long long int> > myv;
map<int, pair<int, long long int> >cur;
vector<int> pk[112345];
int main(){
    int n,m,l,r, ans = 1, t= 0, t1, t2, diff;
    long long int d;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>l>>r>>d;
        myv.push_back(make_pair(make_pair(l,r),d));
    }
    sort(myv.begin(), myv.end());
    for(int i=0;i<m;i++){
        l = (myv[i].first).first;
        r = (myv[i].first).second;
        d = (myv[i].second);
        //cout<<l<<" "<<r<<" "<<d<<endl;
        if(cur.find(l)==cur.end()){
            if(cur.find(r)==cur.end()){
                cur[r] = make_pair(t,d);
                pk[t].push_back(r);
                t++;
            }
            pk[cur[r].first].push_back(l);
            cur[l] = make_pair(cur[r].first, cur[r].second-d);
        } else{
            if(cur.find(r)==cur.end()){
                cur[r] = make_pair(cur[l].first, cur[l].second+d);
                pk[cur[l].first].push_back(r);
            } else{
                if(cur[l].first == cur[r].first){
                    if(cur[r].second-cur[l].second != d){
                        ans=0;
                        break;
                    }
                } else{
                    t1 = cur[l].first;
                    t2 = cur[r].first;
                    //cout<<t1<<" "<<t2<<endl;
                    if(pk[t1].size() < pk[t2].size()){
                        diff = cur[r].second - d - cur[l].second;
                        for(int j=0;j<pk[t1].size();j++){
                            pk[t2].push_back(pk[t1][j]);
                            cur[pk[t1][j]] = make_pair(t2, cur[pk[t1][j]].second+diff);
                        }
                        pk[t1].clear();
                    } else{
                        diff = d + cur[l].second - cur[r].second;
                        for(int j=0;j<pk[t2].size();j++){
                            pk[t1].push_back(pk[t2][j]);
                            cur[pk[t2][j]] = make_pair(t1, cur[pk[t2][j]].second+diff);
                        }
                        pk[t2].clear();
                    }
                }
            }
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 15600
#include<stdio.h>

int main()
{
  char s[4];
  
  scanf("%s",s);
  
  int i;
  
  int count[3]={};
  
  for(i=0;i<3;i++)
  {
    if(s[i]=='a')
    {
      count[0]++;
    }
    else if(s[i]=='b')
    {
      count[1]++;
    }
    else if(s[i]=='c')
    {
      count[2]++;
    }
  }
  
  for(i=0;i<3;i++)
  {
    if(count[i]!=1)
    {
      printf("No\n");
      return 0;
    }
  }
  
  printf("Yes\n");
  
  return 0;
}

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

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

const int max_N = 10000 + 6;

long long int a[max_N];

int main(){
	IOS;
	int n;
	while(cin>>n){
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		int sum = 0;
		for(int i=0;i<n;i++){
			if(a[i] % 2 == 0){
				while(a[i] % 2 == 0){
					a[i] /= 2;
					sum++;
				}
			}
		}
		
		cout<<sum<<endl;
		
	}
	return 0;
}

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

using namespace std;

int n;

int main()
{
    cin >> n;

    int ok = 0, nr;
    for(int i = 1; i <= n; i ++)
    {
        cin >> nr;
        ok = ok || (nr & 1);
    }

    cout << (ok == 1 ? "first" : "second") << "\n";

    return 0;
}


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

#define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));

#define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

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

map<int,int> near; 

int parent[100010];
int marked[100010];
int uf[100010];
int get(int x){
	return marked[x] ? x : parent[x] = get(parent[x]);
}
int main(){
	int N,Qq;
	while(cin >> N >> Qq && N){
		memset(marked,0,sizeof(marked));
		vector< pair<int,int> > Q;
		for(int i = 1 ; i < N ; i++){
			cin >> parent[i];
			parent[i]--;
		}
		marked[0] = true; 
		rep(i,Qq){
			char c;
			int v;
			cin >> c >> v;
			--v;
			if( c == 'M' ){
				if( marked[v] ) continue;
				marked[v] = true;
			}
			Q.push_back({c=='M',v});
		}
		reverse(Q.begin(),Q.end());
		long long ans = 0;
		for( auto q : Q ){
			if( q.first ){
				marked[q.second] = false;
			}else{
				ans += get(q.second)+1;
			}
		}
		cout << ans << endl;
	}
}

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

int hms2s(int h, int m, int s) {
    int ret = s;
    for (int i = 0; i < h; i++) {
        ret += 3600;
    }
    for (int i = 0; i < m; i++) {
        ret += 60;
    }
    return ret;
}

void printhms(int s) {
    int h = 0, m = 0;
    while (s >= 3600) {
        s -= 3600;
        h++;
    }
    while (s >= 60) {
        s -= 60;
        m++;
    }
    printf("%02d:%02d:%02d\n", h, m, s);
}

int main() {
    while (true) {
        int h, m, s;
        cin >> h >> m >> s;
        if (h == -1 && m == -1 && s == -1) {
            break;
        }
        int rest = 7200 - hms2s(h, m, s);
        printhms(rest);
        printhms(rest * 3);
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	int N;
	cin >> N;

	set<int>ans;
	int sum = 0;
	for (int i = 1;sum < N; i++) {
		sum += i;
		ans.insert(i);
	}
	if (N < sum) {
		ans.erase(sum - N);
	}

	for (auto x : ans) {
		cout << x << endl;
	}

}

Measured memory_bytes: 512
n = int(input())
s = []
for i in range(n):
  s_ = int(input())
  s.append(s_)

s.sort() 
total = sum(s)
t = [i for i in s if i % 10 != 0]
if total % 10 != 0:
  print(total)
elif len(t) > 0:
  print(total - t[0])
else:
  print(0)

Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

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

int n;

int d[500][500];

bool used[500][500];

inline bool in(int x, int y) { return 0 <= x && x < n && 0 <= y && y < n; }

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

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

    cin >> n;

    rep(i, n) rep(j, n) d[i][j] = min({i, j, n - i - 1, n - j - 1});

    int p;
    ll ans = 0;
    deque<pair<int, int>> que;
    rep(t, n * n) {
        cin >> p;
        p--;
        int x = p / n;
        int y = p % n;
        ans += d[x][y];
        que.emplace_back(x, y);
        used[x][y] = true;
        while(!que.empty()) {
            tie(x, y) = que.front();
            que.pop_front();
            rep(i, 4) {
                int xx = x + dx[i];
                int yy = y + dy[i];
                if(in(xx, yy) && chmin(d[xx][yy], d[x][y] + !used[x][y])) {
                    if(used[x][y])
                        que.emplace_front(xx, yy);
                    else
                        que.emplace_back(xx, yy);
                }
            }
        }
    }

    cout << ans << "\n";

    return 0;
}

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

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

    long long A[N], B[M];
    long long Asum[N], Bsum[M];

    for(int i=0; i<N; i++){
        cin >> A[i];
        if(i==0){
            Asum[i] = A[i];
        }else{
            Asum[i] = Asum[i-1] + A[i];
        }
    }

    for(int i=0; i<M; i++){
        cin >> B[i];
        if(i==0){
            Bsum[i] = B[i];
        }else{
            Bsum[i] = Bsum[i-1] + B[i];
        }
    }

    int ans = 0;
    int tmp;

    auto it = upper_bound(Bsum, Bsum+M, K);
    int j = it - Bsum - 1;

    ans = max(j+1, ans);    

    for(int i=0; i<N; i++){
        if( Asum[i] > K ) continue;

        long long Kb = K - Asum[i];
        it = upper_bound(Bsum, Bsum+M, Kb);
        j = it - Bsum - 1;
        if( j<0 ){
            tmp = i + 1;
        }else{
            tmp = i + j + 2;
        }

        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9876
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		long K = nextInt();
		int[] A = nextInts();
		int[] g = new int[N];
		int[] l = new int[N];
		Arrays.fill(g, 0);
		Arrays.fill(l, 0);
		for(int i=0;i<N;i++){
			for(int k=0;k<N;k++){
				if(A[i]>A[k]){
					g[k]++;
				}
				if(A[i]>A[k]&&i<k){
					l[k]++;
				}
			}
		}
		long ans =0;
		for(int i=0;i<N;i++){
			ans+=l[i]*K%MOD;
			ans%=MOD;
			long tmp=(K-1)*K/2%MOD*g[i]%MOD;
			ans+=tmp;
			ans%=MOD;
		}
//		for(int i=0;i<N;i++){
//			ans+=K*l[i]%MOD;
//			ans%=MOD;
//		}


		System.out.println(ans);

//		test(new int[]{1,2});
//		test(new int[]{2,1});
	}
	public static void test(int[] A){
		System.out.println(Arrays.toString(A));
		int[] x = new int[10];
		for(int K=1;K<10;K++){
			int N=A.length;
			int[] B = new int[A.length*K];
			for(int i=0;i<N;i++){
				for(int k=0;k<K;k++){
					B[k*N+i]=A[i];
				}
			}

			int cnt=0;
			for(int i=0;i<K*N;i++){
				for(int k=i+1;k<K*N;k++){
					if(B[i]>B[k]){
						cnt++;
					}
				}
			}
			System.out.println("K="+K+" :"+cnt);
			x[K]=cnt;
		}
		x[0]=0;
		for(int i=1;i<x.length;i++){
			System.out.println(x[i]-x[i-1]);
		}
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1125899906842624
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll xpowy(ll x, ll y)
{
    ll res = 1LL;
    while (y > 0)
    {
        if ((y & 1))
            res = res * x % MOD;
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}

int n;
ll a, b;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> a >> b;
    vector<ll> v(n);
    rep(i, 0, n) cin >> v[i];
    sort(v.begin(), v.end(), greater<ll>());
    ll sum = 0LL;
    rep(i, 0, a) {
        sum += v[i];
    }
    double average = sum / (double)a;

    ll ans = 0LL;
    ll cmb[110][110];
    memset(cmb, 0, sizeof(cmb));
    erep(i, 0, 51) {
        for (int j = 0; j <= i; j++) {
            if (i == j || j == 0) cmb[i][j] = 1;
            else cmb[i][j] = cmb[i-1][j-1] + cmb[i-1][j];
        }
    }

    int x = 0, y = 0;
    rep(i, 0, n) {
        if (v[i] == v[a-1]) {
            x++;
            if (i < a) y++;
        }
    }
    if (y != a) {
        ans += cmb[x][y];
    } else {
        erep(i, a, b) {
            ans += cmb[x][i];
        }
    }
    printf("%.6f\n", average);
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  int n=s.length();
  map<int ,int > comp;
   for(int i=0;i<n;i++)
  comp[s[i]-'a']=1;
  if(n<26)
  {
  
    
    for(int i=0;i<26;i++)
  {
    if(comp[i]==0){
        s+=(char)('a'+i);cout<<s;
        return 0;
  }  
  }
  }
int now = s.size() - 1;
		while (now > 0 && s[now - 1] > s[now])
			--now;
		if (now == 0) {
			cout << -1 << "\n";
		}
		else {
			for (int j = now; j < s.size(); ++j)
				comp[s[j] - 'a'] = 0;
			s.resize(now);
			int cur = s.back() + 1 - 'a';
			while (comp[cur])
				++cur;
			s.back() = 'a' + cur;
			cout << s << "\n";
		}
	
	return 0;
}






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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> dp(n + 1, INF);
  dp[0] = 0;

  for (int m = 1; m <= n; m *= 6) {
    rep(i, n) if (i + m <= n) dp[i + m] = min(dp[i + m], dp[i] + 1);
  }

  for (int m = 1; m <= n; m *= 9) {
    rep(i, n) if (i + m <= n) dp[i + m] = min(dp[i + m], dp[i] + 1);
  }

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


Measured memory_bytes: 640
#include <stdio.h>
int main(){
    int d[5],a[4];
    while(1){
        scanf("%d",&d[0]);
        if(d[0]==0)return 0;
        a[1]=a[2]=a[3]=0;
        a[d[0]]++;
        for(int i=1;i<=4;i++){
            scanf("%d",&d[i]);
            a[d[i]]++;
        }
        if(a[1]==0){
            if(a[2]==0||a[3]==0)for(int i=0;i<5;i++)printf("3\n");
            else for(int i=0;i<5;i++)printf("%c\n",d[i]==2?'1':'2');
        }
        else if(a[3]==0){
            if(a[2]==0||a[1]==0)for(int i=0;i<5;i++)printf("3\n");
            else for(int i=0;i<5;i++)printf("%c\n",d[i]==1?'1':'2');
        }
        else if(a[2]==0){
            if(a[1]==0||a[3]==0)for(int i=0;i<5;i++)printf("3\n");
            else for(int i=0;i<5;i++)printf("%c\n",d[i]==3?'1':'2');
        }
        else for(int i=0;i<5;i++)printf("3\n");
    }
}

Measured memory_bytes: 2596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)



int main() {
	int n, a, b; cin >> n >> a >> b;
	int one = 0, two = 0, three = 0;
	rep(i, n) {
		int p; cin >> p;
		if (p <= a) one++;
		else if (a + 1 <= p && p <= b) two++;
		else three++;
	}
	cout << min(one, min(two, three)) << endl;
}

Measured memory_bytes: 256
class Main{
	public static void main(String[] args){
	    int[] x = {1,2,3,4,5,6,7,8,9};
	    int[] y = {1,2,3,4,5,6,7,8,9};
	    for(int n=0;n<9;n++){
		    for(int m=0;m<9;m++){
			    int s = x[n]*y[m];
			    System.out.println(x[n]+"x"+y[m]+"="+s);
		    }
	    }
	}
}


Measured memory_bytes: 24240
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        ls: [usize; n],
    };

    let mut ls = ls;

    ls.sort();

    let longest = ls.pop().unwrap();

    if ls.iter().sum::<usize>() <= longest {
        println!("No", );
    } else {
        println!("Yes", );
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#pragma GCC optimize("O2")
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define leastsigbit(x)     __builtin_ffs(x)
#define mod             1e9+7
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll,ll>
#define vpii vector<pii>
#define tt ll tt;cin >> tt;while(tt--)
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n";}
const double PI = acos(-1);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm( ll x, ll y) { return (x*y)/gcd(x,y);}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
bool isPowerOfTwo(int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}
const int MAXN = 1e6+ 10;
const ll inf = 1e18;

int intlog(double base, double x) {
    return (int)(log(x) / log(base));
}
bool spf[MAXN];
bool check(int x) {
    if(spf[x])return false;
   if(x%2 == 0) {
       if(spf[2])return false;
       spf[2] = true;
       while(x%2==0)x/=2;
   }
    for (int i = 3; i * i <= x ; i+=2) {
        if(x%i == 0) {
            if(spf[i])return false;
            spf[i] = true;
            while(x%i == 0) x/=i;
        }
    }
    if(x > 1) {
        if(spf[x])return false;
        spf[x] = true;
        return true;
    }
    return true; // for 1 1 1 1 1 case
}
int32_t main() {
    fio
    int n;
    cin >> n;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int gc = a[0];
    for (int j = 0; j < n; ++j) {
        gc = gcd(gc,a[j]);
    }
    if(gc > 1) {
        cout << "not coprime";
        return 0;
    }
    for (int i = 0; i < n; ++i) {
        if(!check(a[i])) {
                cout << "setwise coprime";
                return 0;
        }
    }

    cout << "pairwise coprime";
    return 0;



}






Measured memory_bytes: 10968
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  double a[n];
  double sum = 0;
  for (int i=0; i<n; i++) {
    cin >> a[i];
  }
  for (int i=0; i<n; i++) {
    sum += 1.0/a[i];
  }
  sum = 1.0 / sum;
  cout << fixed << setprecision(16);
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N, K;	cin >> N >> K;
	int num = 1;
	for (int i = 0; i < N; ++i) {
		if (num <= K) {
			num *= 2;
		}
		else {
			num += K;
		}
	}
	cout << num << endl;
	cin >> N;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n,k;
    cin >> n >> k;
    if (k == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << n-k << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a*b << "\n";
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

ll fact[2000001];
ll modinverse(ll n,ll p){
    return modpow(n,p-2,p);
}

ll ncr(ll n,ll r){
    if(r==0)return 1;
    return (fact[n]*modinverse(fact[r],mod)%mod*modinverse(fact[n-r],mod)%mod)%mod;
}

int main(){
    IOS;
    fact[0]=1;
    for(ll i=1;i<2000001;i++){
        fact[i]=(fact[i-1]*i)%mod;
        //cout<<fact[i]<<endl;
    }
    ll x,y;cin>>x>>y;
    if((x+y)%3){cout<<0<<endl;}
    else if (max(x, y) > 2*min(x, y)) {
        cout << 0 << endl; return 0;
    }
    else {
       // cout<<fact[2]<<endl;
        // cout<<(x+y)/3<<endl;
        // cout<<(2*x-y)/3<<endl;
        cout<<ncr((x+y)/3,(2*x-y)/3);
    }
    return 0;
}   

Measured memory_bytes: 15872
H, W = gets.split.map( &:to_i )
C = Array.new( 10 ) do
	gets.split.map( &:to_i )
end
A = Array.new( H ) do
	gets.split.map( &:to_i )
end.flatten

10.times do |k|
	10.times do |i|
		10.times do |j|
			C[i][j] = [ C[i][j], C[i][k] + C[k][j] ].min
		end
	end
	end

res = 0
A.each do |a|
	if a != -1 then
		res += C[a][1]
	end
end

puts res


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            int tmp = Integer.parseInt(sc.next());
            a[i] = tmp;
        }
        int start = n - 1;
        int ans = 0;
        while (start > 0) {
            ans++;
            start -= k - 1;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 48876
#include <iostream>
#include <vector>
#include <string>
using namespace std;
using ull = unsigned long long;

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(i%2==0){
            if(s[i]=='L'){
                cout<<"No\n";
                return 0;
            }
        }else{
            if(s[i]=='R'){
                cout<<"No\n";
                return 0;
            }
        }
    }
    cout<<"Yes\n";
    return 0;
}


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

int a,b;

string s;

int main()
{
	cin >> a >> b >> s;    
	if(s[a] != '-') { cout << "No" << endl; return 0; }
	for(int i = 0; i < s.length(); ++i)
		if(i == a) continue;
		else if(!(s[i] - '0' >= 0 && s[i] - '9' <= 0)) { cout << "No" << endl; return 0; }
	cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256