akhauriyash/Code-Regression huggingface dataset:
#include<bits//stdc++.h>
using namespace std;
int sum;
void solve(bool a[50][50],int h, int w, int i, int j){
	for(int z=-1;z<2;z++){
		for(int x=-1;x<2;x++){
			if(i+z>=0&&i+z<h&&j+x>=0&&j+x<w&&a[i+z][j+x]){
				a[i+z][j+x]=false;
				solve(a,h,w,i+z,j+x);
			}
		}
	}
}
int main(){
	int h,w;
	while(cin>>w>>h&&h!=0&&w!=0){
		bool a[50][50];
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				int x;
				cin>>x;
				if(x==0) a[i][j]=false;
				else a[i][j]=true;
			}
		}
		sum=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(a[i][j]){
					sum++;
					solve(a,h,w,i,j);
				}
			}
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long ll;
typedef struct data {
    ll x,y;
    bool operator<(const data& a) const
    {
        return x < a.x;
    }
} stu;



ll n,m,k,w;
ll a[101];
ll b[101];

ll dp[10000005];

void solve(){

     ll x = 1000000000000ll;
     for (int i = 0; i < 10000005; ++i)
     {
        dp[i]=x;
     }

    cin >> n >> w  ;
    b[0]=0;
    a[0]=0;
    ll sum_vals=0;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i] >> b[i];
        sum_vals+=b[i];
    }

    // DP
    dp[0]=0;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = sum_vals-b[i]; j >=0 ; j--)
        {
            dp[j+b[i]]=min(dp[j+b[i]],dp[j]+a[i]);
        }
    }


    //DP End
       ll ans=0;
    for (ll i = sum_vals; i >= 0; i--)
    {
        if(dp[i]<= w){ans=i;
            break;}
    }
    cout << ans<<endl;
}




int main() {


        //clock_t startTime = clock();

    solve();
    //cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<<  endl;    
    return 0;
}

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

vector < int > arr;
int cache[100010];
int n;

int dpSol(int i)
{
    if(i == n - 1)
        return 0;
        
    int &res = cache[i];
    if(res != -1)
        return res;
        
    int ans = INT_MAX;
    if(i + 1 < n)
        ans = min(ans, abs(arr[i] - arr[i + 1]) + dpSol(i + 1));
    if(i + 2 < n)
        ans = min(ans, abs(arr[i] - arr[i + 2]) + dpSol(i + 2));
        
    return res = ans;
}

int main()
{
    cin >> n;
    
    arr = vector < int >(n);
    for(int i = 0; i < n; ++i)
        cin >> arr[i];
        
    memset(cache, -1, sizeof(cache));
    cout << dpSol(0);
}

Measured memory_bytes: 4096
#include <iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<string>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <map>
using namespace std;
typedef long long ll;
ll a[200001];

int main() {
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(a, a + n);
    ll ans = 0;
    for (int i = 0; i < n - k; i++) {
        ans += a[i];
    }
    cout << ans << '\n';



}

Measured memory_bytes: 1792
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		for (int i = A; i <= 1_000_000; i += A) {
			if (i % B == C) {
				System.out.println("YES");
				return;
			}
		}

		System.out.println("NO");
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b, int[] c) throws IOException {
			if (a.length != b.length || b.length != c.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
				c[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 21332
/* Arunava Chakraborty [ @iArunava ] */

/* Otoshidama - AtCoder */

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n = 0, y = 0, i = 0, j = 0, k = 0;
    bool flag = 0;

    scanf("%d%d", &n, &y);

    for (i = 0; i <= n; ++i) {
        for (j = 0; j <= n; ++j) {
            k = n-(i+j);
            if (k < 0) break;
            if ((10000*i)+(5000*j)+(1000*k) == y) {
                printf ("%d %d %d\n", i, j, k);
                flag = 1;
                break;
            }
        }
        if (flag) break;
    }

    if (!flag) printf ("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<string.h>
using namespace std;
long long dp[100005][105];
int N, W;
struct Item{
    int weight;
    int value;
};
vector <Item> item;
int main(int argc, char const *argv[])
{
    int temp1, temp2;
    cin >> N >> W;
    item.push_back({0, 0});
    for(int i = 0 ; i<N ; i++){
        cin >> temp1 >> temp2;
        item.push_back({temp1, temp2});
    }
    memset(dp, 0, sizeof(dp));
    for(int i = 1 ; i<=N ; i++){
        int temp_w = item[i].weight;
        int temp_v = item[i].value;
        for(int w = 1 ; w<=W ; w++){
            if(temp_w <= w) dp[w][i] = max(dp[w][i-1], dp[w - temp_w][i-1] + temp_v);
            else dp[w][i] = dp[w][i-1];
        }
    }
    cout << dp[W][N] << endl;
}

Measured memory_bytes: 85224
#include<stdio.h>
#include<string.h>
using namespace std;
int a[5];
int main()
{
    int temp;
    for(int i=0; i<3; i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0; i<2; i++)
    {
        for(int j=i+1; j<3; j++)
        {
            if(a[i]>a[j])
            {
                temp=a[i];
                a[i]=a[j];
                a[j]=temp;
            }
        }
    }
    printf("%d",a[0]+a[1]);
    return 0;
}


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

using namespace std;

int main()
{
	int n;
	while(true)
	{
		cin >> n;
		if(n==0)
			break;
		vector<vector<bool> > mp(25,vector<bool>(25,true));
		for(int i=0;i<n;i++)
		{
			int x,y;
			cin >> x >> y;
			mp[x][y]=false;
		}
		int m;
		cin >> m;
		int nx=10,ny=10;
		mp[nx][ny]=true;
		for(int i=0;i<m;i++)
		{
			char c;
			int d;
			cin >> c >> d;

			if(c=='N')
				for(int i=0;i<d;i++)
				{
					ny++;
					mp[nx][ny]=true;
				}
			else if(c=='S')
			for(int i=0;i<d;i++)
				{
					ny--;
					mp[nx][ny]=true;
				}
			else if(c=='E')
				for(int i=0;i<d;i++)
				{
					nx++;
					mp[nx][ny]=true;
				}
			else if(c=='W')
				for(int i=0;i<d;i++)
				{
					nx--;
					mp[nx][ny]=true;
				}
		}
		bool flag=true;
		for(int i=0;i<=20;i++)
			for(int j=0;j<=20;j++)
				if(mp[i][j]==false)
					flag=false;
		cout << (flag ? "Yes":"No") << endl;
		
	}
}


Measured memory_bytes: 3088
#include<stdio.h>
int main(void){
    int ia,ib,ic,a,b,c,na,nb,nc,ans;
    scanf("%d %d %d",&ia,&ib,&ic);
    a=ia;
    b=ib;
    c=ic;
    ans=0;
    while(1){
        if(a%2==1 || b%2==1 || c%2==1){
            break;
        }
        na = b/2 + c/2;
        nb = c/2 + a/2;
        nc = a/2 + b/2;
        if(ia==na&&ib==nb&&ic==nc){
            printf("-1\n");
            return 0;
        }
        ans++;
        a=na;
        b=nb;
        c=nc;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3

def switch_on_off(n, keta):
    bin_str = format(n, '0{}b'.format(keta))
    return list(bin_str)

def check_light(n, N, s, index, P):
    switch = switch_on_off(n, N)
    sum = 0
    for v in s:
        sum += int(switch[int(v) - 1])
    if sum % 2 == P[index]:
        return 1
    return 0

N, M = map(int, input().rstrip().split())
K = []
S = []
for _ in range(M):
    tmp = list(map(int, input().rstrip().split()))
    K.append(tmp[0])
    S.append(tmp[1:])
P = list(map(int, input().rstrip().split()))


ans = 0
for n in range(2 ** N):
    sum = 0
    for index, s in enumerate(S):
        sum += check_light(n, N, s, index, P)
    if sum == M:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<set>
#include<queue>
#include<vector>
using namespace std;

// ???
int main(){
    int n;
    cin >> n;
    vector<int> v(1<<n);
    set<pair<int,int>> m;
    priority_queue<pair<int,int>> q;
    for(int i = 0; i < 1<<n; i++){
        int x;  cin >> x;
        m.insert({x, i});
    }
    q.push(*(m.rbegin()));
    m.erase(--m.end());
    for(int i = 0; i < n; i++){
        priority_queue<pair<int,int>> nextq = q;
        while(!q.empty()){
            pair<int,int> from = q.top();    q.pop();
            auto it = m.lower_bound({from.first, -1});
            if(it == m.begin()){
                cout << "No" << endl;
                return 0;
            }
            it--;
            pair<int,int> to = *it;
            m.erase(it);
            nextq.push(to);
        }
        q = nextq;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 17640
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x;
	cin >> x;
	ll p = 100, ct = 0;
	while (p < x) {
		p += p / 100;
		++ct;
	}
	cout << ct << "\n";

}



Measured memory_bytes: 3640
n, x, y = map(int, input().split())
ans = [0 for i in range(n-1)]
for i in range(n-1):
  k = i + 1
  b_1 = k - x
  for j in range(i+1, n):
    l = j + 1
    a = l - k
    b = abs(k - x) + abs(l - y) + 1
    if b < a:
      a = b
    ans[a-1] += 1
for i in range(n-1):
  print(ans[i])

Measured memory_bytes: 3444
#require 'prime'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
l=gi
puts (l.to_f/3)**3


Measured memory_bytes: 1916
nums = list(map(int, input().strip()))
nums = nums[::-1]
nums.append(0)
ans = 0
for i in range(len(nums) - 1):
    if nums[i] > 5:
        ans += 10 - nums[i]
        nums[i+1] += 1
    elif nums[i] == 5:
        if nums[i + 1] >= 5:
            nums[i + 1] += 1
        ans += 5
    else:
        ans += nums[i]
ans += nums[-1]
print(ans)


Measured memory_bytes: 116132
/*
ID: aryan_luffy
LANG: C++
TASK: ride
*/
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O2")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <pair<lli,int>,vt <pair<lli,int>>,greater <pair<lli,int>>>
using namespace std;
using namespace __gnu_pbds; 

//USE AT YOUR OWN RISK
lli tmod(lli x,lli m=mod){return (x%m+m)%m;}

template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

//make sure x is below mod
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}

// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 1;
//     if(r<0)return 0;
//     if(n<0)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
void normalize(lli &a,lli &b){
    if(a==0 && b==0)return;
    if(a<0){
        a=-a;
        b=-b;
    }
    else if(a==0){
        if(b<0)b=-b;
    }
    lli g=__gcd(abs(a),abs(b));
    if(g!=0){
        a/=g;
        b/=g;
    }
}
const int N=2e5+5;

//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
// int smallestprime[(int)1e7+10];
// int nodivisors[(int)1e7+5];

int main() 
{ 
    // fact[0]=1;
    // f(i,1,2000001)fact[i]=(i*fact[i-1])%mod;
    // f(i,2,10000001){
    //     if(smallestprime[i]==0)
    //     for(lli j=1;j*i<=10000000;j++){
    //         if(smallestprime[j*i]==0)
    //         smallestprime[j*i]=i;
    //     }
    // }
    // nodivisors[1]=1;
    fastio;
    int t=1;
    // cin>>t;
    // int temp=t;
    // cout<<smvalallestprime[5]<<"\n";
	while(t--){
        // cout<<"Case #"<<temp-t<<": ";
        // clock_t t=clock();
        ifstream in("ride.in");
        ofstream out("ride.out");
        // lli n,k;cin>>n>>k;
        // int mat[n][n],isvalid[n][n];
        // f(i,0,n)f(j,0,n)isvalid[i][j]=0;
        lli n;cin>>n;
        cout<<((n+999)/1000)*1000-n<<"\n";
        // cout<<clock()-t<<"\n";
    }   
    return 0; 	
}


Measured memory_bytes: 3660
// https://atcoder.jp/contests/abc098/tasks/abc098_a

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int a, b;

  cin >> a >> b;

  cout << max(max(a + b, a - b), a * b) << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int n,k;
int main()
{
	scanf("%d%d",&n,&k);
	if(k&1)
	{
		int ans=0;
		int i=1;
		while(1)
		{
			if(i*k<=n){
				ans++;
				i++;
			}
			else break;
		}
		long long answer=pow(ans,3);
		printf("%lld\n", answer);
	}
	else
	{
		int ans=0;
		int i=1;
		while(1)
		{
			if(i*k<=n){
				ans++;
				i++;
			}
			else break;
		}
		long long answer=pow(ans,3);
		ans=0;i=0;
		while(1)
		{
			if(k/2+i*k<=n){
				ans++;
				i++;
			}
			else break;
		}
		answer+=pow(ans,3);
		printf("%lld\n", answer);
	}
	return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)

template <typename T>
T gcd(T a, T b){
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}

template <typename T>
T lcm(T a, T b){
    return a * (b / gcd(a, b));
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};

int main(){
    ll N; cin >> N;
    vl ts(N, 0); REP(i, N) cin >> ts[i];
    sort(ts.begin(), ts.end());
    ts.erase(unique(ts.begin(), ts.end()), ts.end());
    
    ll ret = ts[0];
    REP(i, N){
        ret = lcm(ret, ts[i]);
    }
    
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 256
n,l = map(int,input().split())
lis = []
for i in range(1,n+1):
    lis.append(l + i - 1)
m = 100
for i in lis:
    m = min(m,abs(i))
if not m in lis:
    lis.remove(m * (-1))
else:
    lis.remove(m)
print(sum(lis))

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

int main(){
    int n,a,b;
    int x,m,y,res=0;
    cin >> n >> a >> b;
    for(int i=1;i<=n;i++){
        x=i;
        y=0;
        while(true){
            m=x%10;
            x/=10;
            y+=m;
            if(x==0)break;
        }
        if(y>=a && b>=y){
            res+=i;
        }
    }
    cout << res << endl;
}

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

const int N = 100005;
const int K = 105;

int dp[K];
int vet[N];

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	for (int i=0; i<n; i++)
	{
		scanf("%d", &vet[i]);
	}
	dp[(n-1)%(k+1)] = 0;
	for (int i=n-2; i>=0; i--)
	{
		dp[i%(k+1)] = oo;
		for (int j=i+1; j<min(n, i+k+1); j++){
			dp[i%(k+1)] = min(dp[i%(k+1)], dp[j%(k+1)] + abs(vet[i] - vet[j]));
		}
	}
	printf("%d\n", dp[0]);
}

Measured memory_bytes: 640
n,c = [int(i) for i in input().split()]
effort = []
group1 = []
group2 = []
group3 = []

effort1 = []
effort2 = []
effort3 = []

color1 = [0 for i in range(c)]
color2 = [0 for i in range(c)]
color3 = [0 for i in range(c)]

for i in range(c):
    effort.append(list(map(int,input().split())))

for i in range(n):
    k = 0
    for j in input().split():
        k+=1
        tot = i+1+k
        if tot % 3 == 0:
            group1.append(int(j))
        elif tot % 3 == 1:
            group2.append(int(j))
        elif tot % 3 == 2:
            group3.append(int(j))

for i in group1:
    color1[i-1] +=1
for i in group2:
    color2[i-1] +=1
for i in group3:
    color3[i - 1] += 1


for i in range(c):
    eff = 0
    for k in range(c):
        eff += color1[k] * effort[k][i]
    effort1.append([eff,i])
for i in range(c):
    eff = 0
    for k in range(c):
        eff += color2[k] * effort[k][i]
    effort2.append([eff, i])
for i in range(c):
    eff = 0
    for k in range(c):
        eff += color3[k] * effort[k][i]
    effort3.append([eff, i])

effort1 = sorted(effort1)
effort2 = sorted(effort2)
effort3 = sorted(effort3)
toteff = 10000000000000000000
for i in range(3):
    col1 = effort1[i][1]
    for k in range(3):
        col2 = effort2[k][1]
        for j in range(3):
            col3 = effort3[j][1]
            if col1 != col2 and col2 !=col3 and col1!=col3:
                toteff = min(toteff,effort1[i][0]+effort2[k][0]+effort3[j][0])

print(toteff)

Measured memory_bytes: 5304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn = 1e5 + 20;
vector<int> adj[maxn];
int p[maxn] , d[maxn] , t[maxn];
void dfs(int v)
{
	t[v] = 1;
	for(auto u : adj[v])
	{
		if(u == p[v])
			continue;
		p[u] = v;
		d[u] = d[v] + 1;
		dfs(u);
		t[v] += t[u];
	}
}
int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; i++)
	{
		int a , b;
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	dfs(1);
	int k = d[n] - 1 , v = n;
	k /= 2;
	while(k--)
	{
		v = p[v];
	}
	if(t[v] >= n - t[v])
		cout << "Snuke\n";
	else 
		cout << "Fennec\n";
}


Measured memory_bytes: 11520
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int x;
    x=read();
    printf("%lld\n",x*800- (x/15)*200);
    return 0;
}

Measured memory_bytes: 3728
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn solve(s: i64, c: i64) -> i64 {
    if c <= 1 {
        return 0;
    }

    if s * 2 >= c {
        return c/2;
    }


    // s*2 < c の場合
    // s個は絶対作る。残りのパーツでできるだけsccを作る
    let ans = s + (c - s * 2) / 4;
    return ans;
}

fn main() {
    let s = getline();
    let vec: Vec<i64> = s.trim().split(' ').map(|s| s.parse().unwrap()).collect();
    let s = vec[0];
    let c = vec[1];

    let ans = solve(s, c);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define loop(i,a,b) for(int i=a;i<b;i++)
#define scnarr(arr, n) for (int i = 0; i < n; ++i) cin >> arr[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>

//Constants
const int MOD = 1000000007; /* 1e9 + 7*/
const int MAXN = 1000005; /*1e6 +5 */


int spf[1000009]; // stores the smallest prime factor of a number

void sieve()
{
spf[1] = 1;
    for (int i=2; i<MAXN; i++)
        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;
    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}

/* Iterative Function to calculate (x^y)%p in O(log y) */
int power(int x,  int y, int p)
{
    int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
                // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

void solve()
{
    int x;cin>>x;
    if(x>=30)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

int32_t main()
{
   // faster;
    /*sieve();
    int t;cin>>t;
    while(t--)*/
        solve();

    return 0;
}


Measured memory_bytes: 3568
h,w = (int(i) for i in input().split())

q_h,mod_h = divmod(h,2)

if h == 1 or w == 1:
	print(1)
elif mod_h == 0: 	
	print(w * q_h)
else:
	q_w,mod_w = divmod(w,2)
	if mod_w == 0:
		print(w * q_h + q_w)
	else:
		print(w * q_h + q_w + 1)

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

void output(int M[], int N) {
	for (int i = 0; i < N-1; i++) {
		cout << M[i] << " ";
	}
	cout << M[N - 1] << endl;
}

void Sort(int M[], int N) {
	for (int i = 1; i < N; i++) {
		int v = M[i];
		int j = i - 1;
		while (j >= 0 && M[j] > v) {
			M[j + 1] = M[j];
			j -= 1;
		}
		M[j + 1] = v;
		output(M, N);
	}
}

int main() {
	int N, M[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> M[i];
	}
	output(M, N);
	Sort(M, N);
	return 0;

}


Measured memory_bytes: 3120
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int bingo = 9;
		int[] bingo_Number = new int[bingo];
        for(int i = 0;i < bingo;i++) {
        	int A = sc.nextInt();
        	bingo_Number[i] += A;
        	if(i == 8) {
            	int N = sc.nextInt();
                int[] bingo_Select = new int[N];
                for(int j = 0;j < N;j++) {
                	int b = sc.nextInt();
                	bingo_Select[j] += b;
                	if(bingo_Select[j] == bingo_Number[0]) {
                		bingo_Number[0] = 0;
                	}else if(bingo_Select[j] == bingo_Number[1]) {
                		bingo_Number[1] = 0;
                	}else if(bingo_Select[j] == bingo_Number[2]) {
                		bingo_Number[2] = 0;
                	}else if(bingo_Select[j] == bingo_Number[3]) {
                		bingo_Number[3] = 0;
                	}else if(bingo_Select[j] == bingo_Number[4]) {
                		bingo_Number[4] = 0;
                	}else if(bingo_Select[j] == bingo_Number[5]) {
                		bingo_Number[5] = 0;
                	}else if(bingo_Select[j] == bingo_Number[6]) {
                		bingo_Number[6] = 0;
                	}else if(bingo_Select[j] == bingo_Number[7]) {
                		bingo_Number[7] = 0;
                	}else if(bingo_Select[j] == bingo_Number[8]) {
                		bingo_Number[8] = 0;
                	}
                }
                if(bingo_Number[0] == 0 &&bingo_Number[1] == 0 && bingo_Number[2] == 0) {
                	System.out.println("Yes");
                }else if(bingo_Number[3] == 0 &&bingo_Number[4] == 0 && bingo_Number[5] == 0) {
                	System.out.println("Yes");
                }else if(bingo_Number[6] == 0 &&bingo_Number[7] == 0 && bingo_Number[8] == 0) {
                	System.out.println("Yes");
                }else if(bingo_Number[0] == 0 &&bingo_Number[3] == 0 && bingo_Number[6] == 0) {
                	System.out.println("Yes");
                }else if(bingo_Number[1] == 0 &&bingo_Number[4] == 0 && bingo_Number[7] == 0) {
                	System.out.println("Yes");
                }else if(bingo_Number[2] == 0 &&bingo_Number[5] == 0 && bingo_Number[8] == 0) {
                	System.out.println("Yes");
                }else if(bingo_Number[0] == 0 &&bingo_Number[4] == 0 && bingo_Number[8] == 0) {
                	System.out.println("Yes");
                }else if(bingo_Number[2] == 0 &&bingo_Number[4] == 0 && bingo_Number[6] == 0) {
                	System.out.println("Yes");
                }else {
                	System.out.println("No");
                }
            }
        }
	}
}

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

int BubbleSort( int* a, int b )
{
    bool flag = true;
    int count = 0;

    while( flag )
    {
        flag = false;
        for( int j = b - 1; j >= 1; j-- )
        {
            if( a[j] < a[j-1] )
            {
                int temp = a[j];
                a[j] = a[j-1];
                a[j-1] = temp;
                count++;
                flag = true;                    //バブルソートが実行される際は、flagがtrueになって次のwhile文内の処理を行う。
            }                                   //ソートが実行されない場合、flagはfalseのままになり、while文を抜ける。
        }
    }
    return count;
}

int main()
{
    int n, c;

    cin >> n;

    int r[n];

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

    c = BubbleSort( r, n );

    for( int i = 0; i < n - 1; i++ )
        cout << r[i] << " ";
    cout << r[n-1] << endl;

    cout << c << endl;   

    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

struct Circle {
    double x, y, r;
};
vector<pair<double, double>> CrossPointsofCircles(Circle c1, Circle c2) {
    double x1, y1, r1, x2, y2, r2;
    x1 = c1.x, y1 = c1.y, r1 = c1.r;
    x2 = c2.x, y2 = c2.y, r2 = c2.r;
    vector<pair<double, double>> ret;
    if ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) > (r1 + r2) * (r1 + r2))
        return ret;
    if ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) < (r1 - r2) * (r1 - r2))
        return ret;
    double a = 2 * (x1 - x2), b = 2 * (y1 - y2),
           c = -x1 * x1 - y1 * y1 + x2 * x2 + y2 * y2 + r1 * r1 - r2 * r2;

    double d = a * x1 + b * y1 + c;
    double x, y;
    x = (-a * d + b * sqrt((a * a + b * b) * r1 * r1 - d * d)) /
            (a * a + b * b) +
        x1;
    y = (-b * d - a * sqrt((a * a + b * b) * r1 * r1 - d * d)) /
            (a * a + b * b) +
        y1;
    ret.emplace_back(x, y);
    x = (-a * d - b * sqrt((a * a + b * b) * r1 * r1 - d * d)) /
            (a * a + b * b) +
        x1;
    y = (-b * d + a * sqrt((a * a + b * b) * r1 * r1 - d * d)) /
            (a * a + b * b) +
        y1;
    ret.emplace_back(x, y);
    sort(all(ret));
    return ret;
}
int main() {
    cout << fixed << setprecision(20);
    Circle c1, c2;
    cin >> c1.x >> c1.y >> c1.r;
    cin >> c2.x >> c2.y >> c2.r;
    auto ans = CrossPointsofCircles(c1, c2);
    for (auto p : ans) cout << p.first << " " << p.second << endl;
}


Measured memory_bytes: 3296
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = (int)s.size();
	if(s[0] == s[n - 1]) {
		if(n % 2) {
			cout << "Second" << endl;
		} else {
			cout << "First" << endl;
		}
	} else {
		if(n % 2) {
			cout << "First" << endl;
		} else {
			cout << "Second" << endl;
		}
	}
	return 0;
}
/* --------------------------------------- */


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int h, w;
char a[1000][1000];
bool used[1000][1000];
queue<P> q;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
void solve() {
	cin >> h >> w;
	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
			if (a[i][j] == '#') {
				q.push({ i,j });
				used[i][j] = true;
			}
		}
	}
	int ans = -1;
	while (!q.empty()) {
		ans++;
		int len = q.size();
		rep(aa, len) {
			P p = q.front(); q.pop();
			rep(j, 4) {
				int nx = p.first + dx[j];
				int ny = p.second + dy[j];
				if (nx < 0 || ny < 0 || nx >= h || ny >= w)continue;
				if (used[nx][ny])continue;
				q.push({ nx,ny });
				used[nx][ny] = true;
			}
		}
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 10384
/********************/
                    /*user -> tushar284*/
                    /******************/
#include<bits/stdc++.h>
                                                    /*********/            
using namespace std;                             /*   __   __   */
#define  f              first                    /*   @ ) ( @   */
#define  s              second                   /*     / \     */            
#define  mp             make_pair                /*  __  -  __  */
#define  loop(i,s,e)    for(int i=s;i<e;i++)     /*    ..^..    */
#define  rev(i,s,e)     for(int i=s;i>=e;i--)     /*     |     */
#define  mod            1000000007                  /*   |   */
#define  pb             push_back                      /***/
#define  start	        int main()                     
#define  fast           ios_base::sync_with_stdio(false);cin.tie(0);
#define  test           fast int t; cin>>t;while(t--)
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
int no_of_fact(int num){
    int cnt =0;
    loop(i,1,int(sqrt(num))+1){
        if(num%i==0){
            cnt++;
            if(num/i != i)cnt++;
        }
    }
    return cnt;
}

start
{   
    int r;
    cin>>r;
    double ans;
    ans = 2.0 * 22.0 * r /7;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<cmath>
#include<map>
using namespace std;
int main()
{
  long long int copyA, copyB, A, B,count=1;
  cin>>A>>B;
  copyA=A;
  copyB=B;
 
  map<int, bool> keep_check;
  map<int, bool>::iterator it;
  keep_check[1] = 0;
  if(B%2==0) {keep_check[2] = 1; while(B%2==0) B/=2;}
  for(int i=3;i<=sqrt(B); i+=2)
  {
      if(B%i==0)
      {
        keep_check[i]=1;
        while(B%i==0)
            B/=i;
      }
  }
  if (B>2) keep_check[B]=1;
  if (A%2==0)
  {
  	it = keep_check.find(2);
    if(it!=keep_check.end()) count++;
    while(A%2==0)
      A/=2;
  }
  
  for(int i=3;i<=sqrt(A); i+=2)
  {
      if(A%i==0)
      {
        it = keep_check.find(i);
        if(it!=keep_check.end()) 
        	count++;
          while(A%i==0)
           A/=i;
      }
  }
  it = keep_check.find(A);
  if (it!=keep_check.end() && A>2) count++;
  cout<<count;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
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; }

int main() {
  int W, H, N;
  cin >> W >> H >> N;

  int l = 0, r = W, b = 0, t = H;
  for (int i = 0; i < (int)N; ++i) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      chmax(l, x);
    } else if (a == 2) {
      chmin(r, x);
    } else if (a == 3) {
      chmax(b, y);
    } else {
      chmin(t, y);
    }
  }

  cout << max(0, r - l) * max(0, t - b) << endl;

  return 0;
}


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

int main() {
    int N, a, ans = 0;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> a;
        while((a & 1) != 1) {
            a /= 2;
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!python3

iim = lambda: map(int, input().rstrip().split())

import sys
from collections import defaultdict

def resolve():
    N, M = iim()
    H = list(iim())
    d1 = defaultdict(list)

    it = iter(map(int, sys.stdin.read().split()))
    for a, b in zip(it, it):
        a -= 1; b -= 1
        d1[a].append(b)
        d1[b].append(a)

    ans = 0
    for i, hi in enumerate(H):
        for j in d1[i]:
            if H[j] >= hi:
                break
        else:
            ans += 1
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 46200
#B - Bounding(ABC130)
A=list(map(int, input().split()))
L=list(map(int, input().split()))
D=0
C=1
for i in L:
    D+=i
    if D<=A[1]:
        C+=1
    else:
        print(C)
        break
else:
    print(A[0]+1)

Measured memory_bytes: 3060
#include <iostream>

#include <map>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <set>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

vector<int> palindromes;

int reverse(int n)
{
    int rev = 0;

    while (n)
    {
        rev *= 10;
        rev += (n % 10);
        n /= 10;
    }

    return rev;
}

void precomp()
{
    set<int> ns;

    for (int j = 10; j < 100; ++j)
        for (int k = 0; k < 10; ++k)
            ns.insert(reverse(j) + 100*k + 1000*j);

    palindromes = vector<int>(ns.begin(), ns.end());
    palindromes.push_back(100000);
}
 
int main()
{
    ios::sync_with_stdio(false);

    precomp();

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

    auto x = lower_bound(palindromes.begin(), palindromes.end(), A);
    auto y = lower_bound(palindromes.begin(), palindromes.end(), B + 1);

    cout << y - x << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main{
  public static void main(String[] args) {

    InputStreamReader sr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(sr);
    try{
      String[] str = br.readLine().split(" ");
      int a = Integer.parseInt(str[0]);
      int b = Integer.parseInt(str[1]);
      int c = Integer.parseInt(str[2]);
      int s = 0;

      if(a > b){
        s = a;
        a = b;
        b = s;
      }
      if(b > c){
        s = b;
        b = c;
        c = s;
      }
      if(a > b){
        s = a;
        a = b;
        b = s;
      }
      System.out.println(a+" "+b+" "+c);
    }
    catch(IOException e) {
            e.printStackTrace();
    }
  }
}

Measured memory_bytes: 24452
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,n) for(int i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = 1;
  int tmp = a;
  
  if(b != 1){
  while(true){
    if(a * ans - (ans-1) >= b){
      break;
    }
    ans++;
  }
  
  cout << ans << endl;
  }else{
    cout << 0 << endl;
  }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define ps(x,y) fixed<<setprecision(y)<<x
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out <<  "(" << a.F << ", " << a.S << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
	out << "[";
	for (auto it = a.begin(); it != a.end(); ++it) {
		if (it != a.begin())
			out << ", ";
		out << *it;
	}
	return out << "]";
}
int main()
{
    boost;
    ll n,i,j,x,t,y;
	cin>>x>>y;
	if(y>=x) cout<<"unsafe";
	else cout<<"safe";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign

int used[100001];
vvi g(100001);
bool dfs(int st, int r);
int solve(int st);

signed main()
{
    int2(n, m);

    rep(i, m) {
        int2(u, v);
        g[u-1].eb(v-1);
        g[v-1].eb(u-1);
    }
    memset(used, -1, sizeof(used));

    int ans[3] = {0};
    rep(i, n) {
        if (used[i] == -1) {
            int tmp = solve(i);
            ans[tmp]++;
        }
    }

//    for (int i : ans) {cout << i << " ";} cout << endl;

    cout << ans[0] * ans[0] + (n - ans[0]) * ans[0] + (n - ans[0]) * ans[0]
        + ans[2] * ans[1] * 2 + ans[2] * ans[2] + ans[1] * ans[1] * 2
         << endl;

    return 0;
}

int solve(int st)
{
    if (g[st].size()) {
        return (dfs(st, 1)) ? 1 : 2;
    } else {
        return 0;
    }
}


bool dfs(int st, int r)
{
    bool ret = true;
    if (used[st] != -1) {
        if ((r - used[st] + 1) % 2) {
            return true;
        } else {
            return false;
        }
    } else {
        used[st] = r;
        for (int i : g[st]) {
            if (used[i] != r-1) {
                ret &= dfs(i, r+1);
            }
        }
    }
    return ret;
}



Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	int N,X;
	cin>>N>>X;
	V<int> a(N);
	rep(i,N) cin>>a[i];
	V<bool> Awin(X+1);
	rep(x,X+1){
		rep(i,N) if(x>=a[i] && !Awin[x-a[i]]) Awin[x]=1;
	}
	if(Awin[X]) puts("First");
	else puts("Second");
}

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

int main() {
    //入力
    int N;
    cin >> N;
    vector<int> vec(N * 3);
    for (int i = 0; i < N * 3; i++) {
      cin >> vec.at(i);
    }

    //処理
    int time = 0;
    int x = 0;
    int y = 0;
    bool can = true;
    for (int i = 0; i < N; i++) {
        int dt = vec.at(i * 3) - time;
        int dist = abs(vec.at(i * 3 + 1) - x) + abs(vec.at(i * 3 + 2) - y);

        if(dt < dist) {
            can = false;
            break;
        }

        if((dt % 2) != (dist % 2)) {
            can = false;
            break;
        }

        time = vec.at(i * 3);
        x = vec.at(i * 3 + 1);
        y = vec.at(i * 3 + 2);
    }

    if(can) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 4220
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!


int _find(string &a,string &b){
    
    for(int i=0;i<a.l();i++){
        if(a[i]!=b[i]){
            return (a[i]>b[i]) ? 1 : -1;
        }
    }
    return 0;
}
void equality(string &a,string &b){
    if(a.l()<b.l()){
        reverse(all(a));
        while(a.l()<b.l()){
            a.pb('0');
        }
        reverse(all(a));
    }
    
    if(a.l()>b.l()){
        reverse(all(b));
        while(a.l()>b.l()){
            b.pb('0');
        }
        reverse(all(b));
    }
}
void solve(){
    
    string a,b;
    cin>>a>>b;
    
    equality(a,b);
    
    int f=_find(a,b);
    if(f>0){
        cout<<"GREATER";
    }
    else if(f==0){
        cout<<"EQUAL";
    }
    else{
        cout<<"LESS";
    }
}



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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

  ll x;
  cin >> x;
  if(x >= 30)
    cout << "Yes";
  else
  {
    cout << "No";
  }
  
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<array>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(int& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(int& si: s[d]) std::cin >> si;
  }
  std::vector<int> t(D);
  for(int& ti: t) std::cin >> ti;
  
  int ans = 0;
#if 0
  // plus
  for(int d = 0; d < D; ++d) ans += s[d][t[d]-1];
  // minus
  for(int cx = 0; cx < 26; ++cx) {
    int last = -1;
    for(int d = 0; d < D; ++d) {
      if(t[d]-1 == cx) last = d;
      ans -= (d-last)*c[cx]; 
    }
  }
  fin(ans);
#else
  int last[26];
  std::fill_n(last, 26, -1);
  for(int d = 0; d < D; ++d) {
    ans += s[d][t[d]-1];
    last[t[d]-1] = d;
    for(int cx = 0; cx < 26; ++cx) {
      ans -= (d-last[cx])*c[cx];
    }
    std::cout << ans << "\n";
  }
#endif
  return 0;
}


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

int main(){
  int k;
  cin >> k;
  typedef set<string> set_t;
  set_t A;
  for(int i = 0;i < k; i++){
    string command;
    string word;
    cin >> command >> word;
    if(command == "insert"){
      A.insert(word);
    }else if(command == "find"){
      if(A.count(word)>0){
	cout << "yes" << endl;
      }else{
	cout << "no" <<endl;
      }
    }
  }
}

Measured memory_bytes: 32144