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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] tmpArray = br.readLine().split(" ");

			int n = Integer.parseInt(tmpArray[0]);
			int m = Integer.parseInt(tmpArray[1]);

			if(n == 0 && m == 0){
				break;
			}

			int sum = -1;
			int x1, x2;

			tmpArray = br.readLine().split(" ");
			for(int i = 0; i < n; i++){
				x1 = Integer.parseInt(tmpArray[i]);
				for(int j = i + 1; j < n; j++){
					x2 = Integer.parseInt(tmpArray[j]);
					if(x1 + x2 <= m){
						sum = Math.max(sum, x1 + x2);
					}
				}
			}

			if(sum == -1){
				System.out.println("NONE");
			}
			else {
				System.out.println(sum);
			}
		}
	}

}



Measured memory_bytes: 31168
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-9
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	speed;
	ll n, mx = 0, ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if (a > mx)
			mx = a;
		else
			ans += mx - a;
	}
	cout << ans;
}

Measured memory_bytes: 3168
#include <stdio.h>

int FIND_MIN(int A,int B){
   if(A >= B){
      return B;
   }
   else {
      return A;
   }
}

int main(void){
   
   int N,A,B;
   
   scanf("%d %d %d",&N,&A,&B);
   
   if(A + B <= N){
      printf("%d %d\n",FIND_MIN(A,B),0);
   }
   else {
      printf("%d %d\n",FIND_MIN(A,B),A+B-N);
   }
   
   return 0;
}


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

using namespace std;

using int64 = long long;

int main()
{
  int64 dp[100];
  dp[0] = 2;
  dp[1] = 1;
  for(int i = 2; i < 100; i++) {
    dp[i] = dp[i - 1] + dp[i - 2];
  }
  int N;
  cin >> N;
  cout << dp[N] << endl;

}

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


int main(void){

	while (true){
		int n;
		cin>>n;
		if (cin.eof()) break;
		bool f=false;
		int i=1;
		while (n>0){
			if (n%2==1){
				if (f) cout<<" ";
				else f=true;
				cout<<i;
			}
			n/=2;
			i*=2;
		}
		cout<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{

int n;
cin>>n;
if(n>=400 && n<=599){cout<<8;}
if(n>=600 && n<=799){cout<<7;}
if(n>=800 && n<=999){cout<<6;}
if(n>=1000 && n<= 1199){cout<<5;}
if(n>=1200 && n<=1399){cout<<4;}
if(n>=1400 && n<=1599){cout<<3;}
if(n>=1600 && n<=1799){cout<<2;}
if(n>=1800 && n<=1999){cout<<1;}



    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 100000;
typedef pair<long long,long long> P;
int main()
{
  long long n,m,i,res=0;
  P a[N_MAX];
  cin >> n >> m;
  for(i=0;i<n;i++)
    cin >> a[i].first >> a[i].second;
  sort(a,a+n);
  for(i=0;i<n;i++)
    if(a[i].second>=m){
      res+=m*a[i].first;
      cout << res << endl;
      return 0;
    }else{
      res+=a[i].second*a[i].first;
      m-=a[i].second;
    }
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
set<ll> used;
map<ll, ll> power;
int main() {
  ll n;
  cin >> n;
  for (ll i = 2; i <= sqrt(n); i++) {
    while (n % i == 0) {
      power[i]++;
      n /= i;
    }
  }
  if (n != 1)
    power[n]++;
  ll ans = 0;
  for (pair<ll, ll> i : power) {
    // cout << i.first << ' ' << i.second << endl;
    int j = 1;
    ll sum = 0;
    while (sum + j <= i.second)
      sum += j, j++, ans++;
    // cout << j << endl;
  }
  cout << ans << endl;
}

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

int main() {
  int n, k, x, tmp = 0;
  cin >> n >> k;

  for (int i = 0; i < n; i++) {
    cin >> x;
    if (k - x < x) tmp += 2 * (k - x);
    else tmp += 2 * x;
  }

  cout << tmp << endl;
  return 0;
}


Measured memory_bytes: 256
class Unionfind:
    __slots__ = ["nodes","diff_weight"]

    def __init__(self, n):
        self.nodes = [-1]*n
        self.diff_weight = [0]*n

    def root(self, x):
        if self.nodes[x] < 0:
            return x
        else:
            root_x = self.root(self.nodes[x])
            self.diff_weight[x] += self.diff_weight[self.nodes[x]]
            self.nodes[x] = root_x
            return root_x
    
    def unite(self, x, y, w=0):
        w += self.weight(x); w -= self.weight(y)
        x = self.root(x); y = self.root(y)
        if x == y:
            return
        rank_x = -self.nodes[x]; rank_y = -self.nodes[y]
        if rank_x < rank_y:
            x, y = y, x; w = -w
        if rank_x == rank_y:
            self.nodes[x] -= 1
        self.nodes[y] = x
        self.diff_weight[y] = w

    def weight(self, x):
        self.root(x)
        return self.diff_weight[x]
    
    def diff(self, x, y):
        return self.weight(y) - self.weight(x)
    
    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def rank(self, x):
        return -self.nodes[self.root(x)]
    
N,M = map(int,input().split())
uf = Unionfind(N)
ans = "Yes"
for _ in range(M):
    L, R, D = map(int,input().split())
    L -= 1; R -= 1
    uf.unite(L, R, D)
    if uf.diff(L, R) != D:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
 
int main(){

  int N;
  cin >> N;
  
  int a,b,c;
  a=N/100;
  b=(N-a*100)/10;
  c=N-a*100-b*10;
  
  if(a==7 || b==7 || c==7){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <algorithm>

using namespace std;

struct people
{
	int num;
	int x;
	
	bool operator < (const people &y) const
	{
		return x < y.x;
	}
};

int n;
people a[100010];

int main(void)
{
	scanf("%d", &n);
	
	for(int i = 0 ; i < n ; i++)
	{
		scanf("%d", &a[i].x);
		a[i].num = i + 1;
	}
	
	sort(a, a + n);
	
	for(int i = 0 ; i < n ; i++)
	{
		printf("%d ", a[i].num);
	}
	
	return 0;
}

Measured memory_bytes: 1536
#include<cstdio>
#include<cstring>

char s[11], result[11];

int main() {
    scanf("%s", s);
    for(int i=0, j=0; i<int(strlen(s)); i++) {
    	if(s[i] == 'B') {
    		if(j > 0) result[--j] = '\0';
    		continue;
    	}
    	result[j++] = s[i];
    }
    printf("%s", result);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int x,i,r=0,n;
 cin>>x>>n;
 int a[n];
 for(i=0;i<n;i++)
 {
     cin>>a[i];
     r=r+a[i];
 }
 int s;
 if(x-r>=0)
 {
 cout<<x-r;
 }
 else
 {
     cout<<"-1"<<endl;
 }
return 0;
}


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

using namespace std;

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

    if (s.length() <= k)
    {
        cout << s << endl;
    }
    else
    {
        cout << s.substr(0, k) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();
		int k = 0;
		int ans = 0;
		for(int i = 0; i <= K; i++) {
			for(int j = 0; j <= K; j++) {
				k = S - i - j;
				if((k <= K) && (k >= 0)) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		}
}


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

int a[100];
int main() {
	int n,count=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n-1; i++) {
		int minj = 101,p;
		for (int j = i; j < n; j++) {
			if (a[j] < minj) {
				minj = a[j];
				p = j;
			}
		}
		if (a[i] > minj) {
			swap(a[i], a[p]);
			count++;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << a[i];
		if (i != n - 1)cout << " ";
		else cout << endl;
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3100
import std;

auto input()
{
    return readln().chomp();
}

alias sread = () => readln.chomp();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    long n;
    scan(n);
    if (n % 2 == 0)
    {
        writeln(n / 2);
    }
    else
    {
        writeln(n / 2 + 1);
    }

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

auto binary_search(long key, long[] l)
{
    long left = 0; //lの左端
    long right = l.length - 1; //lの右端
    while (right >= left)
    {
        long mid = left + (right - left) / 2; //区間の真ん中
        if (l[mid] == key)
        {
            return mid;
        }
        else if (l[mid] > key)
        {
            right = mid - 1;
        }
        else if (l[mid] < key)
        {
            left = mid + 1;
        }

    }
    return -1;
}

// auto a = [1, 14, 32, 51, 51, 51, 243, 419, 750, 910];
// auto a = aryread();
// writeln(a);
// long len_a = a.length;
// writeln(len_a);
// long ans;
// ans = binary_search(51, a);
// writeln(ans);


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int am, bm, cm;
  
  am = min(a, k);
  bm = min(b, k-am);
  cm = min(c, k-am-bm);
  
  cout << am - cm << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <locale>
using namespace std;
#define FORN(i,m,n) for(int i=m; i<(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
#define p_b(x) push_back(x)
#define m_p(a,b) make_pair(a,b)
typedef long long ll;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n; cin>>n;
  vector<int> v(n);
  FORN(i,0,n) cin>>v[i];
  int cnt = 0;
  FORN(i,0,n){
    if(v[i] != i+1) cnt++;
  }
  if(cnt==0 || cnt==2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    int lim = (1 << 15) + 1;
    auto dp = vectors(5,lim,0);
    int n;
    dp[0][0] = 1;
    for(int i = 1; i * i < lim; i++){
        for(int k = 0; k < 4; k++){
            for(int j = 0; j + i*i < lim;j++){
                dp[k+1][j+i*i] += dp[k][j];
            }
        }
    }
    while(cin >> n,n){
        int res = 0;
        rep(i,4)res+=dp[i+1][n];
        cout << res << endl;
    }
}





Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#define N 105
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, s, d[N][70];

bool f(ll p, ll q) {
	if (p >= 0 && p % q == 0 && p / q < 4) return 1;
	return 0;
}

int main()
{
	ll i, j;
	cin >> n;
	d[0][0] = 1;
	for (i = 1; i <= n; i++) {
		for (j = 0; j < 256; j++) {
			if (f(j - 27, 64)) continue;
			if (f(j - 30, 64)) continue;
			if (f(j - 54, 64)) continue;
			if (f(j - 78, 16)) continue;
			if (f(j - 114, 4)) continue;
			d[i][j % 64] = (d[i][j % 64] + d[i - 1][j / 4]) % M;
		}
	}
	for (i = 0; i < 256; i++) s = (s + d[n][i]) % M;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk

const int MAXN = 3 * 105000;
const int mod = (int) 1e9 + 7;

int n;
long long a[MAXN];

int main() { 

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }

  long long ans = 0;

  for (int i = 0; i < 60; i++) {
    int ones = 0, zeros = 0;
    long long p = 1ll << i;
    for (int j = 0; j < n; j++) {
      if (a[j] & p) {
        ones++;
      } else {
        zeros++;
      }
    }
    p %= mod;
    long long add = 1ll * ones * zeros % mod;
    add = add * p % mod;
    ans = (ans + add) % mod;
  }

  cout << ans << endl;

  return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll a,b;
  cin >> a >> b;
  ll ans = max(0ll,a-b*2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,b;
  long ans=0;
  scanf("%d",&n);
  int a[n+1];
  for(int i=0;i<n+1;i++){
    scanf("%d",&a[i]);
  }
  for(int i=0;i<n;i++){
   scanf("%d",&b);
    if(a[i]>b){
      ans=ans+b;
    }
    else{
      if(a[i+1]>b-a[i]){
        ans=ans+b;
        a[i+1]=a[i+1]+a[i]-b;
      }
      else{
        ans=ans+a[i]+a[i+1];
        a[i+1]=0;
      }
    }
  }
  printf("%ld",ans);
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> dp(f + 1, -1);
	dp[0] = 0;

	for (int i = 0; i < f; i++) {
		if (dp[i] == -1) {
			continue;
		}

		int sugar = dp[i];
		int water = i - dp[i];

		int next1 = i + 100 * a;
		int next2 = i + 100 * b;
		int next3 = i + c;
		int next4 = i + d;

		if (next1 <= f) {
			dp[next1] = max(dp[next1], dp[i]);
		}
		if (next2 <= f) {
			dp[next2] = max(dp[next2], dp[i]);
		}
		if (next3 <= f && (sugar + c) <= water * e / 100) {
			dp[next3] = max(dp[next3], dp[i] + c);
		}
		if (next4 <= f && (sugar + d) <= water * e / 100) {
			dp[next4] = max(dp[next4], dp[i] + d);
		}
	}

	pair<int, int> ans = make_pair(100 * a, 0);
	for (int i = 0; i < dp.size(); i++) {
		if (dp[i] == -1) {
			continue;
		}

		int sugar = dp[i];
		int water = i - dp[i];
		if (dp[i] * ans.first > ans.second * i) {
			ans = make_pair(i, dp[i]);
		}
	}

	cout << ans.first << " " << ans.second << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<typename T, typename E>
struct FGCE{
  typedef function<T(T, E)> F;
  typedef function<E(E, E)> G;
  typedef function<bool(T,T)> C;
  F f;
  G g;
  C c;
  E e;
  FGCE(F f,G g,C c,E e):f(f),g(g),c(c),e(e){}
};

template<typename T, typename E>
struct SkewHeap{
  using FS=FGCE<T, E>;
  FS fs;
  SkewHeap(FS fs):fs(fs){}

  struct Node{
    Node *l,*r;
    T val;
    E add;
    Node(T val,E add):val(val),add(add){l=r=NULL;}
  };

  void eval(Node *a){
    if(a->add==fs.e) return;
    if(a->l) a->l->add=fs.g(a->l->add,a->add);
    if(a->r) a->r->add=fs.g(a->r->add,a->add);
    a->val=fs.f(a->val,a->add);
    a->add=fs.e;
  }
  
  T top(Node *a){
    return fs.f(a->val,a->add);
  }
  
  Node* push(T v){
    return new Node(v,fs.e);
  }
  
  Node* meld(Node *a,Node *b){
    if(!a) return b;
    if(!b) return a;
    if(fs.c(top(a),top(b))) swap(a,b);
    eval(a);
    a->r=meld(a->r,b);
    swap(a->l,a->r);
    return a;
  }
  
  Node* pop(Node* a){
    eval(a);
    auto res=meld(a->l,a->r);
    free(a);
    return res;
  }
  
};
//END CUT HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  using Heap=SkewHeap<int, int>;
  Heap::FS::F f=[](int a,int b){return a+b;};
  Heap::FS::G g=[](int a,int b){return a+b;};
  Heap::FS::C c=[](int a,int b){return a<b;};
  
  Heap::FS fs(f,g,c,0);

  Heap heap(fs);
  auto base=heap.push(0);
  
  string s;
  while(cin>>s,s!="end"){
    int x;
    if(s=="insert"){
      cin>>x;
      auto v=heap.push(x);
      base=heap.meld(base,v);
    }
    if(s=="extract"){
      x=heap.top(base);
      base=heap.pop(base);
      cout<<x<<endl;
    }
  }
  return 0;
}
/*
  verified on 2018/01/04
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_C&lang=jp
*/



Measured memory_bytes: 34380
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

def main():
    A, V = LI()
    B, W = LI()
    T = I()
    
    if V - W > 0:
        print("YES" if (V - W) * T >= abs(A - B) else "NO")
    else:
        print("NO")

main()


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

// Description: ????????????
// Verifyed: various problem 
using namespace placeholders;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const R INF = 1E40L;
const R PI = acos(-1.0L);
using P=complex<R>;
using L=struct{P s,t;};
using VP=vector<P>;
using C=struct{P c;R r;};

auto& operator >> (istream& is,P& p){ R x,y; is >> x >> y,p=P(x,y); return is;}
auto& operator << (ostream& os,P& p){ os << real(p) << " " << imag(p); return os;}

inline R dot(P o,P a,P b){return real(conj(a-o)*(b-o));}
inline R det(P o,P a,P b){return imag(conj(a-o)*(b-o));}
inline P vec(L l){return l.t-l.s;}
auto sdot = bind(sgn,bind(dot,_1,_2,_3));
auto sdet = bind(sgn,bind(det,_1,_2,_3));

//projection verify AOJ CGL_1_A
P proj(L l,P p){ R u=real((p-l.s)/vec(l)); return (1-u)*l.s+u*l.t;}

// vertical parallel
// verified: AOJ CGL_2_A
bool vertical(L a,L b) {return sdot(0,vec(a),vec(b))==0;}
bool parallel(L a,L b) {return sdet(0,vec(a),vec(b))==0;}
bool eql(L a,L b){ return parallel(a,b) and sdet(a.s,a.t,b.s)==0;}

// crossing determination
// verified: AOJ CGL_2_B 
bool iss(L a,L b){
	int sa=sdet(a.s,a.t,b.s)*sdet(a.s,a.t,b.t);
	int sb=sdet(b.s,b.t,a.s)*sdet(b.s,b.t,a.t);
	return max(sa,sb)<0;
}

// crossing point 
// verified: AOJ CGL_2_C
P cross(L a,L b){
	R u=det(a.s,b.s,b.t)/det(0,vec(a),vec(b));
	return (1-u)*a.s+u*a.t;
}
	
// distance 
// verified: AOJ CGL_2_D
R dsp(L l,P p){
	P h=proj(l,p);
	if(sdot(l.s,l.t,p)<=0) h=l.s;
	if(sdot(l.t,l.s,p)<=0) h=l.t;
	return abs(p-h);
}

R dss(L a,L b){return iss(a,b)?0:min({dsp(a,b.s),dsp(a,b.t),dsp(b,a.s),dsp(b,a.t)});}


int main(void){
	int n;
	cin >> n;
	cout.precision(20);
	rep(i,n){
		P a,b,c,d;
		cin >> a >> b >> c >> d;
		L s1={a,b},s2={c,d};
		P ans=cross(s1,s2);
		cout << fixed << ans << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	int N, M, Q;

	cin >> N >> M >> Q;
	vector<vector<int>> cities, csum;
	vector<int> ans;

	cities.resize(N + 1);
	csum.resize(N + 1);
	for (int i = 0; i <= N; i++) {
		cities[i].resize(N + 1);
		csum[i].resize(N + 1);
		for (int j = 0; j <= N; j++) {
			cities[i][j] = 0;
			csum[i][j] = 0;
		}
	}

	for (int i = 0; i < M; i++) {
		int l, r;
		cin >> l >> r;
		cities[l][r]++;
	}

	//２次元累積和の計算
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			csum[i][j] = csum[i][j - 1] + csum[i - 1][j] + cities[i][j]
				- csum[i - 1][j - 1];
		}
	}

	for (int i = 0; i < Q; i++) {
		int p, q;
		cin >> p >> q;

		ans.push_back(csum[q][q] - csum[p - 1][q] - csum[q][p - 1] + csum[p - 1][p - 1]);
	}

	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3452
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		String s=sc.next();
		if(a%2==1){
			System.out.println("No");
			return;
		}
		if(s.substring(0,a/2).equals(s.substring(a/2,a))){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


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

using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define INF (ll)2e9
#define MOD ((ll)1e9+7)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(n))

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 InputIterator>
InputIterator adv(InputIterator x, typename std::iterator_traits<InputIterator>::difference_type n) {
    advance(x, n);
    return x;
}

class mod {
    static ll fact[];
public:

    template<class... A>
    static ll mul(A... args) {
        ll res = 1;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    static ll power(ll base, ll exp) {
        if (exp == 0) return 1;
        if (exp & 1) {
            return mul(base, power(base, exp - 1));
        } else {
            ll p = power(base, exp / 2);
            return mul(p, p);
        }
    }

    static ll factorial(int n) {
        if (fact[n] != 0) return fact[n];
        if (n == 0) return 1;
        return fact[n] = mul(n, factorial(n - 1));
    }

    static ll inverse(int n) {
        return power(n, MOD - 2);
    }

    static ll comb(int n, int r) {
        if (r < 0 || r > n) return 0;
        return mul(factorial(n), inverse(factorial(n - r)), inverse(factorial(r)));
    }

    template<class... A>
    static ll div(ll dividend, A... args) {
        ll res = dividend;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = mul(res, inverse(i));
        }
        return res;
    }

    template<class... A>
    static ll add(A... args) {
        ll res = 0;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    template<class... A>
    static ll sub(ll l, A... args) {
        ll res = l;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res - i + MOD) % MOD;
        }
        return res;
    }
};
ll mod::fact[(int) 1e6 + 1];

int ni() {
    int i;
    cin >> i;
    return i;
}

int main() {
    int N = ni();

    ll ans = 0;
    ll sum = 0;
    ll m = INF;
    REP(i, N) {
        ll s = ni();
        if (s % 10 == 0) {
            sum += s;
        } else {
            m = min(m, s);
            ans += s;
        }
    }

    if (ans % 10 != 0) {
        ans += sum;
    } else if (ans != 0) {
        ans -= m;
        ans += sum;
    }

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

Measured memory_bytes: 256
p[2];char s[128];main(i){for(;p[0]=p[1]=scanf("%s",s)-1,s[0]-48;p[p[0]<p[1]]++,printf("%d %d\n",p[0],p[1]))for(i=1;s[i];p[s[i++]-65]++);exit(0);}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long n, d;
    cin >> n >> d;
    
    int ans = 0;
    for (int i = 0; i < n; i++){
        long long a, b;
        cin >> a >> b;

        if (a * a + b * b <= d * d)
            ans += 1;
    }

    cout << ans << '\n';

    return 0;
}


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

#define mx 500008

#define pii pair<int,int>
#define pi acos(-1.0)
#define pb push_back
#define ss second
#define ff first
typedef long long int ll;
///adjacent move
int fx[4]={0,+1,0,-1};
int fy[4]={+1,0,-1,0};
///knight
ll prime[mx];

vector<pii>v[mx];
double d(int x1,int x2,int y1,int y2)
{
    double x=(x1-x2);
    x=x*2;
    double y=(y1-y2);
    y*=2;
    return sqrt(x+y);
}
int main()
{
    int t=1;

    while(t--){
        ll n,k;
        cin>>n>>k;
        ll ans=0;
        for(int i=1;i<=n;i++){
            ll l,r;
            cin>>l>>r;
            ll x,y;
            x=l*l;
            y=r*r;
            double z=sqrt(x+y);
            if(z<=k) ans++;
        }
        cout<<ans<<endl;
    }
}


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

using namespace std;

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

	int a,b,c,x,y; cin >> a >> b >> c >> x >> y;

	int d = max(x,y);
	int e = min(x,y);
	int f;
	if(x>y)  f = a;
	else  f = b;
	int a1 = a*x + b*y;
	int a2 = c*e*2 + f*(d-e);
	int a3 = c*d*2;
	int a4 = min(a2,a3);
	cout << min(a1,a4) << endl;

	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int fib(int a[], int n){
    a[0] = 1;a[1] = 1;
    for(int i = 2; i<=n; i++){
        a[i] = a[i-1]+a[i-2];
    }
    return a[n];
}

int main()
{
    int n;
    scanf("%d",&n);
    int a[n+1];
    printf("%d\n",fib(a,n));
}


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

int main(){
    int A, B;
    cin >> A >> B;
    double Amin, Amax, Bmin, Bmax;
    Amin= A/0.08;
    Amax= (A+1)/0.08;
    Bmin= B/0.1;
    Bmax= (B+1)/0.1;

    if(Bmin<=Amin && Amin<Bmax){
        for(int i=0; i<Bmax; i++){
            if(i>=Amin){
                cout << i << endl;
                return 0;
            }
        }
    }
    else if(Amin<=Bmin && Bmin<Amax){
        for(int i=0; i<Amax; i++){
            if(i>=Bmin){
                cout << i << endl;
                return 0;
            }
        }
    }
    else{
        cout << -1 << endl;
    }

    return 0;
}

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

typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

int main(){

    int n,ans = 0;
    cin >> n;
    
    REP(i,n){
        ll a;
        cin >> a;
        while(a%2 == 0){
            a=a/2;
            ans++;
        }
    }
    cout << ans;
    
}


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

int main(){
  int w=0;
  int n=0;
  cin>>w>>n;
  vector<int> vec;
  vec.resize(w);
  for(int i=0;i<w;i++)
    vec[i]=i+1;
  for(int i=0;i<n;i++){
    int a,b;
    scanf("%d,%d",&a,&b);
    swap(vec[a-1],vec[b-1]);
  }
  for(int i=0;i<w;i++)
    cout<<vec[i]<<endl;
  return 0;
}

Measured memory_bytes: 1244
// Implementation practice (Have seen the editorial)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define loop(i, a) for (int i = 0; i < a; i++)
#define revloop(i, a) for (int i = a-1; i > -1; i--)
#define show(a) cout << a << "\n"
#define showloop(a, len) for (int i = 0; i < len; i++) cout << a[i] << "\n"
#define debug(a) cout << #a << ": " << a << "\n"
#define MOD 1000000007
#define V vector
#define S set
#define P pair
#define M map;
#define PQ priority_queue

int main() {
//    freopen("inputs.txt", "w", stdout);
//    int n = maxN;
//    loop(i, n) cout << i+1 << " ";
    //freopen("inputs.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    int type;
    type = (s1[0] == s2[0])?1:0;
    int i = 1;
    bool skipped = false;
    if (!type) i++;
    ull ans = (s1[0] == s2[0])?3:6;
    for (; i < n; i++) {
        int c_type = (s1[i] == s2[i])?1:0;
        if (c_type == type) {
            if (type) ans=(ull)((ans*2)%MOD);
            else {
                if (!skipped) {
                    skipped = true;
                    continue;
                }
                else {
                    ans=(ull)((ans*3)%MOD);
                    skipped = false;
                }
            }
        }
        else {
            if (type) ans=(ull)((ans*2)%MOD);
            type = c_type;
            skipped = false;
        }
    }
    show(ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	long int n, m;
	cin >> n >> m;
	long int nf = 1, mf = 1;
	for(int i=1;i<=n;i++){
		nf = (nf*i)%1000000007;
	}
	for(int i=1;i<=m;i++){
		mf = (mf*i)%1000000007;
	}
	if(n == m){
		cout << (nf*mf*2)%1000000007 << endl; 
	}else if(n-m == 1 || n-m == -1){
		cout << (nf*mf)%1000000007 << endl;
	}else{
		cout << 0 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
// Problem : C - gacha
// Contest : AtCoder - AtCoder Beginner Contest 164
// URL : https://atcoder.jp/contests/abc164/tasks/abc164_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define lb "lower_bound"
#define ub "upper_bound"
#define bs "binary_search"

int dif(int a,int b){if(a > b)return a - b;else return b - a;}
int min(int a,int b){if(a > b)return b;else return a;}
int max(int a,int b){if(a > b)return a;else return b;}
int gcd(int a,int b){if(a == 0)return b;else return (a%b,b);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int n;
    cin>>n;
    string s;
    set<string> arr;
    for(int i = 0;i < n;i++)
    {
    	cin>>s;
    	arr.insert(s);
    }
    cout<<arr.size();
	return 0;
}


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

#define lli long long int
#define ld long double
#define DEFO(n) lli n = 0;
#define MAX_L lli max = 9000000000000000000;
#define MIN_L lli min = 9000000000000000000;
#define MAX_D ld max = 4500;
#define MIN_D ld min = -4500;
#define LLI(n) \
  lli n;       \
  cin >> n;
#define LD(n)  \
  ld n;        \
  cin > n;
#define LLIV(a, n)            \
  vector<lli> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define LLIV2(a, b, n)            \
  vector<lli> a(n), b(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i) >> b.at(i);           \
  };
#define LDV(a, n)            \
  vector<ld> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define STR(n) \
  string n;    \
  cin >> n;
#define SUM(n) accumulate(n.begin(), n.end(), 0);
#define SORT(n) sort(n.begin(), n.end());
#define REVE(n) reverse(n.begin(), n.end());
#define yes cout << "Yes" << endl; return 0;
#define no cout << "No" << endl; return 0;
#define C45(n) (n + 1) / 2
#define OUT(n) cout << n << endl;
#define SRC(n, c)                    \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    if (s.at(i) == c)                \
    {                                \
      n++;                           \
    }                                \
  };
//こぴー
/*#define ZISYO(s, S)                  \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    S.at(i) = s.at(i);               \
  }                                  \
  Sort(S) Reve(S) for (lli i = 0; i < s.size(); i++) { s.at(i) = S.at(i); };
*/

//素数
bool IsPrime(lli num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}
//各桁の和
lli KSum(lli n)
{
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

//数値反転
bool KReve(lli n)
{
  int reverse = 0;
  int remaind;
  int tmp = n;
  while (tmp != 0)
  {
    remaind = tmp % 10;
    reverse = reverse * 10 + remaind;
    tmp /= 10;
  }
  if (reverse == n) 
    return true;
  else
    return false;
}

int main(void)
{
  ios::sync_with_stdio(false);
  LLI(N) LLIV(a, N) SORT(a) DEFO(A) DEFO(B)
  for(lli i = 0;i < a.size();i++) {
    if(i % 2 == 0) A += a[i];
    else B += a[i];
  }
  OUT(abs(A - B))
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n;
		Stack<Integer> stack = new Stack<Integer>();
		
		while( scan.hasNextInt() ) {
			n = scan.nextInt();
			
			if(n > 0) {
				stack.push(n);
			}
			
			else if(n == 0) {
				System.out.println(stack.pop());
			}
		}
	}
}

Measured memory_bytes: 17208
#include<stdio.h>
struct SalesPerformance {
	int number;
	unsigned long sales_price;
	unsigned long sales_volume;
	unsigned long sales_amount;
};

int main(void)
{
	int n,i,j,flag1,flag2;
	struct SalesPerformance data[1000];

	while (1) {
		scanf("%d", &n);
		if (n == 0)break;
		flag2 = 0;
		for (i = 0; i < n; i++) {
			flag1 = 0;
			scanf("%d %lu %lu", &data[i].number, &data[i].sales_price, &data[i].sales_volume);
			for (j = 0; j < i; j++) {
				if (data[j].number == data[i].number) {
					data[j].sales_amount += data[i].sales_price * data[i].sales_volume;
					data[i].sales_amount = 0;
					flag1 = 1;
				}
			}
			if(flag1 == 0)
				data[i].sales_amount = data[i].sales_price * data[i].sales_volume;
		}
		for (i = 0; i < n; i++) {
			if (data[i].sales_amount >= 1000000) {
				printf("%d\n", data[i].number);
				flag2 = 1;
			}
		}
		if (flag2 == 0)
			printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 648
SX, SY, TX, TY = map(int, input().split())
way1 = 'U' * (TY - SY) + 'R' * (TX - SX)
way2 = 'D' * (TY - SY)+ 'L' * (TX - SX)
way3 = 'L' + 'U' * (TY - SY + 1) + 'R' * (TX - SX + 1) + 'D'
way4 = 'R' + 'D' * (TY - SY + 1) + 'L' * (TX - SX + 1) + 'U'
print(way1 + way2 + way3 + way4)


Measured memory_bytes: 38384
Scanf.scanf "%d %d" (fun n s ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let dp = Array.make_matrix (n + 1) (s + 1) 0 in
    let m = 998244353 in
    let (+@) a b = (a + b) mod m in

    for i = 0 to n - 1 do
        let x = a.(i) in
        if x <= s then
            dp.(i + 1).(x) <- dp.(i + 1).(x) +@ (i + 1);
        for j = 0 to s do
            dp.(i + 1).(j) <- dp.(i + 1).(j) +@ dp.(i).(j);
            if j + x <= s then 
                dp.(i + 1).(j + x) <- dp.(i + 1).(j + x) +@ dp.(i).(j)
        done
    done;
    let rec loop i acc =
        if i > n then acc else loop (i + 1) (acc +@ dp.(i).(s))
    in
    loop 0 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 73848
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    char b;
    cin >> b;
    if (b == 'A'){ 
        println("T");
    }
    else if (b == 'T') {
        println("A");
    }
    else if (b == 'C') {
        println("G");
    }
    else if (b == 'G') {
        println("C");
    }
    return 0;
}

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        long m = sc.nextLong();

        if (n > m) {
            long tmp = n;
            n = m;
            m = tmp;
        }

        long ans = 0;

        if (n == 1) {
            if (m == 1)
                ans = 1;
            else
                ans = m - 2;
        } else {
            ans = (n - 2) * (m - 2);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long M = sc.nextLong();
    long answer = (Math.abs(N-2))*(Math.abs(M-2));
    System.out.println(answer);
  }
  
  //最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}


//素数判定
static boolean isPrime (int n) {
	if (n==2) return true;
	if (n<2 || n%2==0) return false;
	double d = Math.sqrt(n);
	for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
	return true;
}


//倍数判定（10進数以外のときに有用）
static boolean isMultiple (String s, int base, int m) {
	int temp = 0;
	for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	}
	if (temp==0) {return true;}
	return false;
}


//階乗
static long factorial (int i) {
	if (i==1) {return 1;}
	else {return i*factorial(i-1);}
}


//進数変換
static String toNbase (String sm, int m, int n) {
	return Long.toString(Long.parseLong(sm,m),n);
}
  
}

Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
int a , b , c , d ;
while(scanf("%d %d",&a,&b)!=EOF)
{
  c = a+b ;
  d = 0;
  while(c)
  {
    c /= 10;
    d++;
  }
  cout<<d<<endl;
}
return 0;
}

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

int main() {
	int n;
	
	while (cin >> n) {
		bool prime[1000000];
		for (int i = 2;i <= n;i++) {
			prime[i] = true;
		}
		for (int i = 2;i <= sqrt(n);i++) {
			for (int j = i * 2;j <= n;j += i) {
				prime[j] = false;
			}
		}
		int count = 0;
		for (int i = 2;i <= n;i++) {
			if (prime[i] == true) count++;
		}
		cout << count << endl;
	}

}

Measured memory_bytes: 2136
/*
2020-04-26
atcoder ABC
C - Rally
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main() {
    int s, w;
    cin >> s >> w;
    if(s <= w) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3592
N = int(input())
S = input()

ans = 0
for i in range(1000):
    judge = False
    p = 0
    if i >= 0 and i < 10:
        number = "00" + str(i)
    elif i >= 10 and i < 100:
        number = '0' + str(i)
    else:
        number = str(i)
    
    for j in range(N):
        if number[p] == S[j]:
            p += 1
            if p == 3:
                ans += 1
                break
            

print(ans)

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

int main(){
    int n, cnt=1;
    string s;

    cin >> n >> s;
    for(int i=0; i<n-1; i++){
        if(s[i]==s[i+1]) continue;
        else cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 512
from itertools import product
n = int(input())
xy = []

for _ in range(n):
    a = int(input())
    tmp = []
    for j in range(a):
        x,y = [int(x) for x in input().split()]
        tmp.append((x,y))
    xy.append(tmp)


ans = 0

for ts in product([0,1], repeat=n):
    for i, t in enumerate(ts):
        if t:
            if not all(ts[q-1] == z for q,z in xy[i]):
                break
    else:
        ans = max(ans, sum(ts))

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
constexpr int INF = 1 << 30;
int main()
{
    int N;
    cin >> N;
    vector<int> bp(N), wp(N);
    vector<vector<int>> bl(N + 1, vector<int>(2 * N, 0)), wl(N + 1, vector<int>(2 * N, 0));
    for (int i = 0; i < 2 * N; i++) {
        char c;
        int a;
        cin >> c >> a;
        if (c == 'B') { bp[a - 1] = i; }
        if (c == 'W') { wp[a - 1] = i; }
    }
    for (int i = 0; i < N; i++) {
        bl[i + 1] = bl[i], wl[i + 1] = wl[i];
        for (int j = bp[i] + 1; j < 2 * N; j++) { bl[i + 1][j]++; }
        for (int j = wp[i] + 1; j < 2 * N; j++) { wl[i + 1][j]++; }
    }
    vector<vector<int>> dp(N + 1, vector<int>(N + 1, INF));
    dp[0][0] = 0;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            if (i < N) { dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + abs(wl[i][wp[i]] - i) + abs(bl[j][wp[i]] - j)); }
            if (j < N) { dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + abs(wl[i][bp[j]] - i) + abs(bl[j][bp[j]] - j)); }
        }
    }
    cout << dp[N][N] << endl;
    return 0;
}


Measured memory_bytes: 78848
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e18;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
     
      // int a,b,c;
      // cin>>a>>b>>c;
      // a-=b;
      // c-=min(a,c);
      // cout<<c;
      int n;
      cin>>n;
      int ans=0;
      for(int i=1;i<=n;i++)
      {
            int x=i;
            int cnt=0;
            while(x) x/=10,cnt++;
            if(cnt&1) ans++;
      }
      cout<<ans;
}
// I never lose. I either win or I learn


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back;
using namespace std;
int main()
{
    ll n,w,a,b;
    cin>>n>>w;
    pair<ll,ll> l[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a>>b;
        l[i]={a,b};
    }
    ll m[n][w];
    for(int x=0;x<=w;x++)
    {
        for(int i=0;i<n;i++)
        {
            if (l[i].first<=x)
            {   if (i-1<0)
                    m[i][x]=l[i].second;
                else
                    {m[i][x]=max((m[i-1][x]),(l[i].second+m[i-1][x-(l[i].first)]));}
            }
            else
            {   if (i-1<0)
                   m[i][x]=0;
                else
                  { m[i][x]=m[i-1][x];}
            }
        }
    }
    cout<<m[n-1][w]<<endl;
}


Measured memory_bytes: 81616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	int n;
	cin >> n;
	vi a1(n), a2(n);
	rep(i, n)cin >> a1[i];
	rep(i, n)cin >> a2[i];

	int ans = 0;
	rep(i, n) {
		int t = 0;
		rep(j, i+1) {
			t += a1[j];
		}
		repr(j, i, n) {
			t += a2[j];
		}
		ans = max(ans, t);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
bool cmp(char a, char b){
return a > b;
}
int main(){
string s, t;
cin >> s; //"cd"
cin >> t; //"abc"
sort(s.begin(), s.end());
sort(t.begin(), t.end(), cmp);
if (s < t)
 cout << "Yes" << endl;
else
 cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())

w = set()
for i in range(F // (100 * A) + 1):
    for j in range(F // (100 * B) + 1):
        a = (A * i + B * j) * 100
        if a < F:
            w.add(a)
w.remove(0)

s = set()
for i in range(F // C + 1):
    for j in range(F // D + 1):
        b = C * i + D * j
        if b < F:
            s.add(b)
s = list(s)
s.sort()

best_concentration = -1
best_a = -1
best_b = -1
for a in w:
    for b in s:
        if a + b > F:
            break
        if b > E * a // 100:
            break
        concentration = 100 * b / (a + b)
        if concentration > best_concentration:
            best_concentration = concentration
            best_a = a
            best_b = b
print(best_a + best_b, best_b)


Measured memory_bytes: 3316