akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

int n, m;
int a[1000];

void solve() {
    rep(i,n) cin >> a[i];
    int ans = -1;
    rep(i,n) for (int j = i+1; j < n; j++) {
        if (a[i] + a[j] > m) continue;
        ans = max(ans, a[i]+a[j]);
    }
    if (ans == -1) cout << "NONE" << endl;
    else cout << ans << endl;
}

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



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

typedef long long ll;
#define int         ll
typedef vector<int> vi;
#define test        int t; cin >> t; while(t--)
#define max(a,b)   (a>b?a:b)
#define min(a,b)   (a<b?a:b)
const int mod=1000000007;

vector<int> sv;
int cnt(int n,int x){
    int cn=0;
    while(n>1 && n%x==0){
        n/=x;
        cn++;
    }
    return cn;
}
int powr(int x,int n){
    if(n==0) return 1;
    int ret=powr(x,n/2);
    ret*=ret;
    ret%=mod;
    if(n%2) ret*=x;
    ret%=mod;
    return ret;
}
int32_t main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
        
    int n,k;
    cin>>n>>k;
    sv=vector<int>(k+1);
    
    for (int i = k; i >=1; --i){
            sv[i]=powr(k/i,n);
            for(int j=2*i;j<=k;j+=i){
                // (sv[i]+=mod-powr(k/j,n))%=mod;
                (sv[i]+=mod-sv[j])%=mod;
            }
    }
    // cout<<sv[2]<<endl;
    int ans=0;
    for (int i = k; i >=1; --i){
            ans+=(i*sv[i])%mod;
            ans%=mod;
    }
    cout<<ans;

  
    return 0;
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std ;
#define ll long long

int main(){
	double sum=0,n,ai;
	cin>>n;
	for(int i = 0;i<n;i++){
		cin>>ai;
		sum+=(1.0/ai);
	}
	cout<<(1.0/sum)<<'\n';
	return 0;
}


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

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        var lst = new List<int>();
        for (int i = 1; i <= 100; i++) {
            if (A % i == 0 && B % i == 0) {
                lst.Add(i);
            }
        }
        WriteLine(lst.OrderByDescending(i => i).ToArray()[K-1]);
    }
}


class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9+5;
int main()
{
	int n,k;scanf("%d%d",&n,&k);
	vector<int> v(n,0);
	for(int& i:v)
	scanf("%d",&i);
	int maxi=INF;
	vector<int> dp(n,INF);
	
	dp[0]=0;
	dp[1]=abs(v[1]-v[0]);
	
	for(int i=2;i<n;i++)
	{
		for(int j=i-1;j>=i-k && j>=0;j--)
		{
			dp[i]=min(dp[i],dp[j]+abs(v[i]-v[j]));
		}
	}
	
	
	
	//for(int i=0;i<n;i++)	cout<<dp[i]<<" ";cout<<endl;
	
	cout<<dp[n-1]<<endl;
			
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define N 1000000007
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,q,l,r,flag = 0,h,m,n,k;
    ld x,y,z;
    cin>>x>>y;
    z =  x*y;
    cout<<(ll)(z+0.0001);
}

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

using namespace std;

int main() {
	int D, N;
	cin >> D >> N;
	if (N == 100) {
		N++;
	}

	for (int i = 1; i <= D; i++) {
		N *= 100;
	}

	cout << N << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1000000001;

struct edge{
  int to;
  int cost;
  edge(int to,int cost) : to(to) , cost(cost) {}
};



int main(){
  int V,E,r;
  cin>>V>>E>>r;
  vector< vector< edge > > G(V);
  for(int i=0;i<E;i++){
    int s,t,d;
    cin>>s>>t>>d;
    G[s].push_back( (edge){t,d} );
  }
  vector<int> d(V,INF);
  d[r]=0;
  typedef pair<int,int> Pair;
  priority_queue< Pair, vector<Pair> , greater<Pair> > Q;
  Q.push( Pair(0,r) );
  while(!Q.empty()){
    Pair p=Q.top();
    Q.pop();
    int pos=p.second;
    int cost=p.first;
    if( cost > d[pos] )continue;
    for(edge e:G[pos]){
      if(cost+e.cost<d[e.to]){
        d[e.to]=cost+e.cost;
        Q.push( Pair(d[e.to],e.to) );
      }
    }
  }
  for(int i=0;i<V;i++){
    if(d[i]==INF)cout<<"INF"<<endl;
    else cout<<d[i]<<endl;
  }
  return 0;
}



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


def solve(inp):
    import math
    (N, K) = map(int, inp.readline().strip().split(' '))
    H = list(map(int, inp.readline().strip().split(' ')))

    if K > len(H):
        return "0"

    H = sorted(H)
    H = H[:(N - K)]

    print(sum(H))


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25740
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<functional>

using ll = long long;
using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<ll> h(n);

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

    // for( int j = 0;j < n-1; ++j) {
    //     if (!(h[j]-1 <= h[j+1])) {
    //         cout << "No" << endl;
    //         return 0;
    //     }
    // }

    // cout << "Yes" << endl;

    for ( int check = n-1; check >= 1; check--) {
        if (h[check] >= h[check-1]) {

        } else if (h[check] >= h[check-1]-1) {
            h[check-1]-=1;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    

    return 0;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
info=[]
check=0
for i in range(m):
    s,c=map(int,input().split())
    info.append([s-1,c])
    if n<s:
        check=1
ans=-1
if check==0:
    s=10**(n-1)
    g=10**n
    if n==1:
        s=0
    #print(info)
    for i in range(s,g):
        num=list(str(i))
        #print(num)
        count=0
        for j in range(m):
            if num[info[j][0]]==str(info[j][1]):
                count+=1
        #print(count)
        if count==m:
            ans=i
            break
print(ans)

Measured memory_bytes: 39280
// 作者：杨成瑞先生
import java.io.*;
import java.util.*;

public class Main {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

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

        boolean one = false, two = false, three = false, four = false;
        for(int i=0;i<4;i++) {
            int a = sc.nextInt();
            if(a == 1) one = true;
            else if(a == 9) two = true;
            else if(a == 7) three = true;
            else if(a == 4) four = true;
        }

        pw.println(one && two && three && four ? "YES" : "NO");

        pw.close();
	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
     
#define int long long
#define hell 1000000007  
#define endl "\n"
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX_SIZE 1000001


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

    int a[n+1], b[n];

    for(int i=1;i<n;i++)
        cin>>b[i];

    a[1] = b[1];
    a[n] = b[n-1];

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

    for(int i=1;i<=n;i++)
        sum+=a[i];

    cout<<sum;


return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    vector<int> num;
    string str;
    int tmp;cin>>tmp;
    while(cin >> str) {
        if ('0' == str[0]) {
            int n;
            cin >> n;
            num.push_back(n);
        } 
        else if ('1' == str[0]) {
            int idx;
            cin >> idx;
            cout << num[idx] << endl;
        }
        else {
            num.pop_back();
        }
    }
    return 0;
}



Measured memory_bytes: 3900
#include<iostream>
#include<string>
#include<map>

using namespace std;

string str;
map<char, int> record;

int main() {
    cin >> str;
    for(auto s : str) {
        record[s]++;
    }
    for (map<char, int>::iterator it = record.begin(); it != record.end(); it++) {
        if((*it).second % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3644
n,k = map(int,input().split())
h = list(map(int,input().split()))

if(n==k):
    print(0)
    exit()

inf = 10**15 * (n+1)
dp = [[inf] * (n-k+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(1,n+1):
    for j in range(1, n-k+1):
        if(j==1):
            dp[i][j] = h[i-1]
        else:
            tmp = inf
            for l in range(1,i):
                tmp = min(tmp, dp[l][j-1] + max(0, h[i-1]- h[l-1])  )
            dp[i][j] = tmp

ans = inf
for i in range(n+1):
    ans = min(ans, dp[i][-1])

print(ans)

Measured memory_bytes: 42860
//Author : Ayush Jain

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

#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define fi first
#define se second
const int N=1e5 + 5;
const int M=1e5 + 5;

ull pw[67];
void pre()
{
  pw[0]=1;
  for(int i=1;i<64;i++) pw[i]=2*pw[i-1];
}

int main()
{
  ios_base::sync_with_stdio(false);
  pre();
  int n,i;
  ll s[N];
  cin>>n;
  ll c4=0,c2=0;
  for(i=0;i<n;i++){
    cin>>s[i];
    if(s[i]%4==0){
      c4++;
      continue;
    }
    if(s[i]%2==0){
      c2++;
      continue;
    }

  }  
  if(c4*2+1>=n){
    cout<<"Yes\n";
    return 0;
  }
  c4=c4*2;
  if(c4+c2>=n) cout<<"Yes\n";
  else cout<<"No\n";
  
    
  return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i]--;
  }

  int res = -1;
  int cur = 0;
  int cnt = 0;
  int loopCnt = 1'000'000;
  while (loopCnt > 0) {
    int tmp = a[cur];
    cnt++;
    if (tmp == 1) {
      res = cnt;
      break;
    }
    if (tmp == cur) {
      break;
    }
    cur = tmp;
    loopCnt--;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 640
def popcount(i): # i < 2^32
    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24



# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

#n,k,*a = map(int,read().split())
n, = map(int,readline().split())
x = input()

p = x.count("1")
p0 = p-1
p1 = p+1

if p0 != 0:
    r0 = int(x,2)%p0
else:
    r0 = 0
r1 = int(x,2)%p1


#print(f"r0={r0},r1={r1}","p",p0,p1)


for i in range(n):
    if x[i]=="0":
        v = (r1 + pow(2,n-i-1,p1))%p1
    else:
        if p0 == 0:
            print(0)
            continue
        v = (r0 - pow(2,n-i-1,p0))%p0
        
    ans = 1
    while v:
        #print(v,i)
        ans += 1
        v %= popcount(v)
    print(ans)
        
    
    
    
    
    







Measured memory_bytes: 80816
#define _USE_MA_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    vi a(5);
    int ans=0;
    int r=10;
    rep(i,5){
        cin>>a[i];
        ans+=(a[i]+9)/10*10;
        if(a[i]%10)r=min(r,a[i]%10);
    }
    ans-=10-r;
    cout<<ans<<endl;
}

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

#define reps(i,a,b) for(int i=a; i<b; i++)
#define rep(i,n) reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1e9)

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(all(a));
  int cnt = 0,ans=0;
  rep(i,n){
    cnt++;
    if(i==n-1){
      if(cnt > a[i]){
        ans += cnt-a[i];
      }
      if(cnt < a[i]){
        ans += cnt;
      }
      break;
    }
    if(a[i+1] != a[i]){
      if(cnt > a[i]){
        ans += cnt-a[i];
      }
      if(cnt < a[i]){
        ans += cnt;
      }
      cnt = 0;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<cstdlib>
#define N 100010
#define M 3010
#define ll long long
#define ld long double
#define top 1e12
using namespace std;

struct data{ll x; int sum;};
int n, flag[M], l, p[M], y, ans;
ll w[N], x, x1, W;
ld xx;
map<ll, int>mp;
vector<data>son[N];

inline void prev(){
	memset(flag, 0, sizeof(flag)); l=0;
	for(int i=2; i<=3000; i++){
		if(!flag[i])p[++l]=i;
		for(int j=1; j<=l&&i*p[j]<=3000; j++){
			flag[i*p[j]]=1;
			if(i%p[j]==0)break;
		}
	}
}

inline ll ABS(ll a){return max(a, -a);}
inline ll gcd(ll a, ll b){return b?gcd(b, a%b):a;}
inline ll mul(ll a, ll b, ll p){
	ll x=(ld)a/p*b+1e-3;
	return ((a*b-x*p)%p+p)%p;
}
inline ll pow(ll y, ll x, ll p){
	ll s=1, t=y;
	while(x){if(x&1)s=mul(s, t, p); t=mul(t, t, p); x>>=1;}
	return s;
}
inline int check_p(ll a, ll r, ll sum, ll n){
	ll x=pow(a, r, n), now=x;
	for(int i=1; i<=sum; i++){
		x=mul(x, x, n);
		if(x==1&&now!=1&&now!=n-1)return 1;
		now=x;
	}
	if(x!=1)return 1;
	return 0;
}
inline int miller_rabin(ll n){
	if(n==2)return 1; if(n%2==0)return 0;
	ll r=n-1, sum=0; while(r%2==0){sum++; r>>=1;}
	for(int i=1; i<=10; i++)if(check_p(rand()%(n-1)+1, r, sum, n))return 0;
	return 1;
}
inline ll pollard_rho(ll a, ll n){
	ll k=2, x=rand()%(n-1)+1, y=x, p=1;
	for(ll i=1; p==1; i++){
		x=(mul(x, x, n)+a)%n;
		p=gcd(ABS(x-y), n);
		if(i==k){y=x; k<<=1;}
	}
	return p;
}
inline ll find_fac(ll n){
	if(n==1)return 1;
	if(miller_rabin(n))return n;
	ll t=n;
	while(t==n)t=pollard_rho(rand()%(n-1)+1, n);
	return t;
}

int main(){
	srand(1999);
	prev();
	scanf("%d", &n); mp.clear();
	for(int i=1; i<=n; i++){
		scanf("%lld", &w[i]); son[i].clear();
		for(int j=1; j<=l; j++){x=(ll)p[j]*p[j]*p[j]; while(w[i]%x==0)w[i]/=x;}
		W=w[i];
		for(int j=1; j<=l; j++){
			y=0; while(W%p[j]==0){y++; W/=p[j];}
			if(y)son[i].push_back((data){p[j], y});
		}
		if(W==1)continue;
		x=find_fac(W);
		if(x==W)son[i].push_back((data){W, 1});
		else{
			x1=W/x;
			if(x1==x)son[i].push_back((data){x, 2});
			else{son[i].push_back((data){x, 1}); son[i].push_back((data){x1, 1});}
		}
	}
	for(int i=1; i<=n; i++)mp[w[i]]++;
	ans=0;
	for(int i=1; i<=n; i++)if(w[i]>=2&&mp[w[i]]){
		xx=1.0;
		for(int j=0; j<son[i].size(); j++)xx*=son[i][j].sum==1?son[i][j].x*son[i][j].x:son[i][j].x;
		if(xx>top){ans+=mp[w[i]]; mp[w[i]]=0; continue;}
		x=1;
		for(int j=0; j<son[i].size(); j++)x*=son[i][j].sum==1?son[i][j].x*son[i][j].x:son[i][j].x;
		ans+=max(mp[w[i]], mp[x]); mp[w[i]]=mp[x]=0;
	}
	if(mp[1])ans++;
	printf("%d", ans);
	return 0;
}

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

#define si(x) scanf("%d",&x)

using namespace std;

int main()
{
    int n;
    si(n);
    vector<int> arr(3*n);
    vector<long long> largest(n+1,0) , smallest(n+1,0);
    for(int i=0;i<3*n;i++){
        si(arr[i]);
    }
    priority_queue<int> pq1,pq2;
    for(int i=0;i<n;i++){
        pq1.push(arr[i]*-1);
        largest[0] += arr[i];
    }
    for(int i=n;i<2*n;i++){
        pq1.push(arr[i]*-1);
        largest[i-n+1] = largest[i-n] + pq1.top() + arr[i];
        pq1.pop();
    }

    for(int i=3*n-1;i>=2*n;i--){
        pq2.push(arr[i]);
        smallest[0] += arr[i];
    }
    for(int i=2*n - 1;i>=n;i--){
        pq2.push(arr[i]);
        smallest[3*n -i - n] = smallest[3*n -i - n - 1] - pq2.top() + arr[i];;
        pq2.pop();
    }
    long long maxx = -1e14;
    for(int i=0;i<=n;i++){
        maxx = max(maxx , largest[i] - smallest[n-i]);
    }
    cout << maxx;
    return 0;
}


Measured memory_bytes: 4088
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<string>

using namespace std;
int n, m;
string s, t, rez;
int nr;
int matrix[3005][3005] = {0};
int a, b;
void read()
{
    cin >> s >>t;
    n = s.size();
    m = t.size();

}
void create(int n, int m)
{
    for(int i = 0; i <  n; i++)
        for(int j = 0; j < m; j++) {
            if (s[i] == t[j]) {
                matrix[i][j] = 1;
                if (i > 0 &&j > 0) {
                     //if(j > 0)
                    {
                        matrix[i][j] = matrix[i - 1][j - 1] + 1;
                    }
                }
            }


                if (i > 0) {
                    if (matrix[i][j] < matrix[i - 1][j])
                        matrix[i][j] = matrix[i - 1][j];
                }
                if (j > 0) {
                    if (matrix[i][j] < matrix[i][j - 1])
                        matrix[i][j] = matrix[i][j - 1];
                }

        }
    a = 0;
    b = 0;
    int ok1 = 0;
    int ok2 = 0;
    /*for(int i = n -1; i >= 0 && ok1 == 0; i--)
        for(int j = m - 1; j >=0 && ok2==0; j--)*/
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
        {
            if(matrix[i][j] > matrix[a][b])
            {//ok1 = 1;
            //ok2 = 1;
            a = i;
            b = j;}
        }
}
void modify(int n, int m)
{
    while(a >= 0 && b >= 0 && matrix[a][b] > 0)
    {
        if(s[a] == t[b])
        {
            rez = rez + s[a];
            b--;
            a--;
        }
        else if(a > 0 &&(matrix[a][b] == matrix[a - 1][b]))
        {
            
                a--;
        }
        else if(b > 0 && (matrix[a][b - 1] == matrix[a][b]))
        {
                b--;
        }
        nr++;
    }

}
int main()
{
    ios_base::sync_with_stdio(false);
    read();
    create(n, m);
    modify(n, m);
    reverse(rez.begin(), rez.end());
    cout << rez;
    /*for(int i = nr - 1; i >= 0; i--)
        cout << rez[i];*/
}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int x, a; cin >> x >> a;
  if (x < a) {
    cout << 0 << endl;
  } else {
    cout << 10 << endl;
  }
}

Measured memory_bytes: 256
H, W = map(int, input().split())
lst_S = [list(input()) for i in range(H)]

# 周囲に"."を追加
lst_S = [["." for i in range(W)]] + lst_S

for i in range(H + 1):
    lst_S[i] = ["."] + lst_S[i] + ["."]

lst_S = lst_S + [["." for i in range(W + 2)]]

count = 0

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if lst_S[i][j] == "#" and lst_S[i][j - 1] == "." and lst_S[i][j + 1] == "." and lst_S[i - 1][j] == "." and lst_S[i + 1][j] == ".":
            print("No")
            count += 1
            break
    if count > 0:
        break

if count == 0:
    print("Yes")


Measured memory_bytes: 3064
#define LOCAL

#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

// From Errichto's Youtube stream
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////
int N, W;
int dp[101][101][303];
int w[101], v[101];

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

    cin >> N >> W;

    for (int i = 1; i <= N; i++) {
        cin >> w[i] >> v[i];
    }

    int X = w[1];

    for (int i = 1; i <= N; i++)
        w[i] -= X;

    memset(dp, -1, sizeof(dp));

    dp[0][0][0] = 0;

    int result = 0;

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= i; j++) {
            for (int delta = 0; delta <= 3 * j; delta++) {
                if ((int64)j * X + delta > W)
                    break;

                if (dp[i-1][j][delta] != -1)
                    dp[i][j][delta] = dp[i-1][j][delta];
                
                if (j && delta >= w[i] && dp[i-1][j-1][delta - w[i]] != -1) {
                    dp[i][j][delta] = max(dp[i][j][delta], v[i] + dp[i-1][j-1][delta - w[i]]);
                }

                result = max(result, dp[i][j][delta]);
            }
        }
    }

    cout << result << "\n";

    return 0;
}


Measured memory_bytes: 12288
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
#define ever ;;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 3e5 + 345;
const ll MOD = 998244353;
const ll INF = 1e15 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

#define int ll

main() {
	fre("");
	ACCELERATE;
	
	int n;
	cin >> n;
	
	int a[N];
	n *= 3;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n, greater<int>());
	
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		i++;
		n--;
		sum += a[i];
	}
	
	cout << sum;
	return 0;
}
/*
 
*/


Measured memory_bytes: 2560
# coding: utf-8
# Your code here!

n,m = [int(i) for i in input().split()]
g = [[] for _ in range(n)]

uv = [[int(i)-1 for i in input().split()] for _ in range(m)]
for u,v in uv: g[u].append(v)

s,t = [int(i)-1 for i in input().split()]

#print(g)


from collections import deque

#############################################################################
#   初期設定
#############################################################################
#memo: 負なら未確認、0以上なら最短距離
memo = [[-3]*3 for _ in range(n)] # used[i][mod]
q = deque()
#初期状態をキューに入れる-----------------------------------------------------
#キューに入れる時点で使用したかどうかのmemoを更新-----------------------------
q.append((s,0)) #初期状態をキューに入れる
memo[s][0] = 0 #初期状態を訪問済みにする
#############################################################################
#   BFS
#############################################################################
while q: #キューが空になるまで
    (v,d) = q.popleft() #キューから情報を取り出す
    #foreach (x,y)のお隣さん に対して処理-------------------------------------
    for cv in g[v]:
        #(nx,ny)が確認済みならスキップ----------------------------------------
        if memo[cv][(d+1)%3] >= 0: continue
        #(nx,ny)が未確認のとき、確認済みにしてキューに入れる------------------
        memo[cv][(d+1)%3] = d+1
        q.append((cv,d+1))
        #経路復元が必要なとき-------------------------------------------------
        # prev[nx][ny] = [x,y]    
    
#print(memo)
print(memo[t][0]//3)




Measured memory_bytes: 86688
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Main{
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}                                              
		return ans;
	} 
    public static void main(String[] args) throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        int n=cin();
        double ans=0;
        int f=1;
        for(int i=1;i<=n-1;i++)
        {
        	f=f*i;
        }
        f=f*2;
        int[][]cor=new int[n][2];
        for(int i=0;i<n;i++)
        {
        	int[]ar=split();
        	cor[i][0]=ar[0];
        	cor[i][1]=ar[1];
        }
        for(int i=0;i<n;i++)
        {
        	for(int j=i+1;j<n;j++)
        	{
        		double d=Math.sqrt((cor[i][0]-cor[j][0])*(cor[i][0]-cor[j][0])+(cor[i][1]-cor[j][1])*(cor[i][1]-cor[j][1]));
        		ans=ans+d*(double)(f);
        	}
        }
        f=(f/2)*n;
        ans=ans/f;
        System.out.println(ans);
    }
}

Measured memory_bytes: 33280
import sys
import bisect
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)
if N%2 == 0:
  if s.count("hi") == N//2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

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


def main():
  input()
  values = list(map(int, input().split()))

  if len(values) == 0:
    print(0)
    return

  if len(values) == 1:
    print(values[0])
    return

  r = sum(values)

  for i in range(1, len(values)):
    d = abs(sum(values[:i]) - sum(values[i:]))
    r = min(d, r)

  print(r)


if __name__ == '__main__':
  main()



Measured memory_bytes: 3064
#include<stdio.h>
int main(){
    int k[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    scanf("%d",&K);
    printf("%d\n",k[K-1]);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include <sstream>
#include <vector>
#include <queue>
#include <utility>  
#include <set>
#include<unordered_set>
#include <map>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L
#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;
   
int sum(int l, int r) {

	return (l + r)*(r - l + 1) / 2;

}

int gcd(int a, int b) {

	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a%b);
	}

}

 
int f[100001];
 

int Find(int x) {

	if (x == f[x])
		return x;

	return f[x] = Find(f[x]); 

}
const int Mod = 1e9 + 7;

long long fastPower(long long base, long long power) {
	long long result = 1;
	while (power > 0) {
		if (power & 1) { 
			result = result * base % Mod;
		}
		power >>= 1; 
		base = (base * base) % Mod;
	}
	return result;
}
 
int Inv(int x) {
	return fastPower(x, Mod - 2);
}


int nChoosek(int n, int k) {
 
	int ans = 1;

	for (int i = 1; i <= k; ++i) 
		ans = ans * Inv(i) % Mod *(n - i + 1) % Mod;

	return ans % Mod;

}


int arr[200001];

int digit(int n) {

	int cnt = 0;
	
	while (n) {

		n /= 10;
		cnt++;

	}

	return cnt;
}

int binarySearchLessThanOrEqual(int des) {

	int l = 0;
	int r = 1000000000;

	while (l <= r) {

		int mid = (l + r) / 2;

		if (mid > des) {

			r = mid - 1;

		}
		else {
			l = mid + 1;
		}
	}

	return r;

}


double dis(double x, double y, double x2, double y2) {

	return sqrt( (x - x2)*(x - x2) +  (y - y2) * (y - y2) );

}


int x[10];
int y[10];

int a[10];
int32_t main() {

	IOS;

	for (int i = 0; i < 10; i++) {

		a[i] = i + 1;

	}

	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {

		cin >> x[i] >> y[i];

	}

	double sum = 0;

	int prevX = 0;
	int prevY = 0;

	bool flag = true;
	int cnt = 0;
	do {



		for (int i = 1; i < n; i++) {
			
			sum += dis(x[a[i-1]], y[a[i-1]], x[a[i]], y[a[i]]);

		}

		cnt++;
	} while (next_permutation(a, a + n));
 
	//cout << n << endl;
	double result = sum / cnt;

	
	 cout << fixed << setprecision(10) << result << endl;
 
	 
 


}

Measured memory_bytes: 3224
import java.util.*;
import java.io.*;
public class Main{
 public static void main(String agrs[])
 {
   Scanner in = new Scanner(System.in);
   PrintWriter out = new PrintWriter(System.out);
   int n = in.nextInt();
   if(n % 1000 == 0)
   {
     out.println(0);
   }
   else
   {
     out.println((n / 1000 + 1) * 1000 - n);
   }
   out.close();
 }
}

Measured memory_bytes: 35776
#include<bits/stdc++.h>
#define ll long long 
#define F first 
#define S second 
#define pb push_back 
#define mp make_pair 
#define f(i,n) for(int i=0;i<n;i++) 
#define fr(i,a,b) for(int i=a;i<b;i++) 
using namespace std; 

void test(){
	ll a,b,c;
	cin>>a>>b>>c;
	if(a==b and a!=c)
		cout<<"Yes\n";
	else if(a==c and a!=b)
		cout<<"Yes\n";
	else if(b==c and b!=a)
		cout<<"Yes\n";
	else cout<<"No\n";
}

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

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  COMinit();
  ll n,k;
  cin >> n >> k;
  REP(i, k)
    cout << COM(n-k+1, i+1)*COM(k-1, i-1+1)%MOD << endl;  
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
	~debug(){cerr<<endl;}
	template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
	template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
	template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
	template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
	template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;


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

    ll n;
    cin >> n;
    vector<ll> f;
    for(ll i = 1; i*i <= n; i++) {
        if(n % i == 0) {
            f.push_back(i);
            f.push_back(n/i);
        }
    }
    
    auto ok = [&](ll x, ll y) {
        return (x-y)*(x*x*x*x + x*x*x*y + x*x*y*y + x*y*y*y + y*y*y*y) == n;
    };
    
    for(ll factor : f) {
        for(ll x = -500; x <= 500; x++) {
            ll y = x - factor;
            if(ok(x, y)) {
                cout << x << ' ' << y << endl;
                exit(0);
            }
        }
    }
    
    assert(false);
    
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  ll n;
  string s;
  cin>>n>>s;
  int ans = 0;
  int cnt_r = 0;
  REP(i, n) {
    if(s[i] == 'R') cnt_r++;
  }
  REP(i, n) {
    if(cnt_r == 0) break;
    if(s[i] == 'W') {
      ans++;
    }
    cnt_r--;
  }
  cout << ans << endl;
  // int l = 0, r = n-1;
  // while(1) {
  //   FOR(i, l, n) {
  //     if (s[i] == 'W') {
  //       l = i;
  //       s[i] == 'R';
  //       break;
  //     }
  //     if(i == n-1) {
  //       l = n;
  //       break;
  //     }
  //   }
  //   rFORe(i, 0, r) {
  //     if (s[i] == 'R') {
  //       r = i;
  //       s[i] == 'W';
  //       break;
  //     }
  //     if(i == 0) {
  //       r = -1;
  //       break;
  //     }
  //   }
  //   if (l > r) {
  //     break;
  //   }
  //   if (l >= n && r < 0) break;
  //   // cout << l << r << endl;
  //   ans++;
  //   if (l > r) break;
  //   // l++; r--;
  // }
  // cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3768
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
lis = [V[i] - C[i] for i in range(N)]
ans = 0
for i in range(N):
  if lis[i] > 0:
    ans += lis[i]
print(ans)

Measured memory_bytes: 3060
#line 2 "solve.cpp"
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
#define int long long
const int INF = 1e18;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (int i = (int)((b)-1); i >= (int)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T>
inline void chmax(T &a, const T &b) {
    if ((a) < (b)) (a) = (b);
}
template <class T>
inline void chmin(T &a, const T &b) {
    if ((a) > (b)) (a) = (b);
}

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x)    \
    sort(all(x)); \
    x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int, int> pii;
typedef tuple<int, int, int> iii;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
void check_input(){
    assert(cin.eof() == 0);
    int tmp; cin >> tmp; 
    assert(cin.eof() == 1);
}

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H *//*}}}*/

signed main() {
    //input
    int s,w;cin>>s>>w;
    check_input();

    //solve
    cout << (w>=s ? "unsafe" : "safe") << endl;

    return 0; 
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
 int main(){
    int n, a,index;
    cin>>n;
    vector<int> v(n);
   for( int i=0; i<n; i++){
      cin>>v[i];
   }
   for( int i=0; i<n; i++){
      a=v[i];
      for(int j=i+1; j<n; j++){
            if(a>v[j]){
               a=v[j];
            index=j;
             }
         
        }
       if(v[i]!=a){
          swap(v[index],v[i]);
          break;
       }
   }

   for( int i=0; i<(n-1); i++){
   
      if(v[i]>v[i+1]){
         cout<<"NO"<<endl;
         return 0;
      }
   }
   cout<<"YES"<<endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <math.h>
using namespace std;

int gx,gy,p,x,z,y,w,a[16][16],sw=0,n;

int main(){
	cin>>n;for(int k=0;k<n;k++){
	while(cin>>gx>>gy>>p){
		int h[16][16]={0},v[16][16]={0};
		for(int i=0;i<p;i++){
			cin>>x>>y>>z>>w;
			if(x==z){int M=max(y,w); v[x][M]=1;}
			else {int M=max(x,z); h[M][y]=1;}
		}
		for(int i=0;i<=max(gx,gy);i++){v[i][0]=1;h[0][i]=1;}
		for(int i=0;i<=gx;i++){
			for(int j=0;j<=gy;j++){
				if(v[i][j]==0&&h[i][j]==0)a[i][j]=a[i-1][j]+a[i][j-1];
				else if(v[i][j]==0)a[i][j]=a[i][j-1];
				else if(h[i][j]==0)a[i][j]=a[i-1][j];
				else {
					if(i==0&&j==0)a[i][j]=1;
					else a[i][j]=0;
				}
			}
		}
		if(a[gx][gy]>0)cout<<a[gx][gy]<<endl;
		else cout<<"Miserable Hokusai!"<<endl;
		sw=1;
	}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
typedef long long ll;

using namespace std;

int N, Q;
ll A[200010], B[200010]; //[0, 2 * N) !!
multiset<ll> S;

void solve() {
	cin >> N >> Q;
	rep(i, 0, 2 * N) cin >> A[i];
	rep(i, 0, 2 * N) cin >> B[i];

	ll ans = 0; bool odd = false;
	ans += A[0] + A[2 * N - 1];
	rep(i, 1, 2 * N - 1) {
		ans += max(A[i], B[i]);
		odd ^= (A[i] > B[i]);
		S.insert(abs(A[i] - B[i]));
	}
	while(Q--) {
		ll a, x, y;
		cin >> a >> x >> y; a--;
		if(a == 0 || a == 2 * N - 1) {
			ans += x - A[a];
			A[a] = x;
		}
		else {
			odd ^= (A[a] > B[a]);
			odd ^= (x > y);
			ans += max(x, y) - max(A[a], B[a]);
			S.erase(S.lower_bound(abs(A[a] - B[a])));
			S.insert(abs(x - y));
			A[a] = x; B[a] = y;
		}
		cout << (!odd ? ans : ans - (*S.begin())) << "\n";
	}
}

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



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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k;
    string s;
    cin >> k >> s;
    if (s.size() > k) {
        for (int i = 0; i < k; i++) {
            cout << s[i];
            if (i == k - 1) cout << "..." << '\n';
        }
    } else {
        cout << s << '\n';
    }
    return 0;
}

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

using ll = long long;
using namespace std;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define YES(f) if((f)){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(f) if((f)){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)

#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);

#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}


void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	int A, B, C;
	cin >> A >> B >> C;
	int res = 0;
	while (B >= A) {
		B -= A;
		res++;
	}
	cout << min(res, C) << endl;
}

void solve()
{
}




Measured memory_bytes: 256
program main_c
   implicit none
   integer(8) :: a, b, c, d

   read(*,*) a, b, c

   d = c - a - b

   if (d > 0 .and. d**2 > 4*a*b ) then
      print *, 'Yes'
   else
      print *, 'No'
   end if
end program main_c


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

#define PI 3.14159265358979

int main(){
	double R;
	cin >> R;
	cout << 2 * R * PI << endl;
}


Measured memory_bytes: 3772