akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
#include <functional>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}
const int INF = 1e9;

int h, w;
char s[1200][1200];
queue<pair<int, int> > qu;
int dp[1200][1200];

int nm(int x, int y) {
    if (x < 0 || y < 0 || x >= h || y >= w)
        return 0;
    return 1;
}
int k;

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

int main() {
    scanf("%d%d%d", &h, &w, &k);
    for (int i = 0; i < h; ++i)
        scanf(" %s", s[i]);
    int sx = 0, sy = 0;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) {
            dp[i][j] = INF;
            if (s[i][j] == 'S')
                sx = i, sy = j;
        }
    dp[sx][sy] = 0;
    qu.push(make_pair(sx, sy));
    while (!qu.empty()) {
        int x = qu.front().first;
        int y = qu.front().second;
        qu.pop();
        if (dp[x][y] >= k)
            continue;
        for (int i = 0; i < 4; ++i) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nm(nx, ny) && s[nx][ny] != '#') {
                if (dp[nx][ny] > dp[x][y] + 1) {
                    dp[nx][ny] = dp[x][y] + 1;
                    qu.push(make_pair(nx, ny));
                }
            }
        }
    }
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            if (dp[i][j] < INF)
                dp[i][j] = 0, qu.push(make_pair(i, j));
    while (!qu.empty()) {
        int x = qu.front().first;
        int y = qu.front().second;
        qu.pop();
        for (int i = 0; i < 4; ++i) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nm(nx, ny)) {
                if (dp[nx][ny] > dp[x][y] + 1) {
                    dp[nx][ny] = dp[x][y] + 1;
                    qu.push(make_pair(nx, ny));
                }
            }
        }
    }
    int ans = INF;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) {
            if (i == 0 || j == 0 || i == h - 1 || j == w - 1) {
                ans = min(ans, dp[i][j]);
            }
        }
    cout << ((ans + k - 1) / k) + 1 << "\n";
    return 0;
}




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

import static java.lang.Math.*;

public class Main {

    void solve() throws IOException {
        int n = readInt();
        if (n < 1000) {
            System.out.println("ABC");
        } else {
            System.out.println("ABD");
        }
    }

    //-------------------------------------------------

    final boolean ONLINE_JUDGE = !new File("input.txt").exists();

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok;

    public void run() {
        Runnable run = () -> {
            try {
                long startTime = System.currentTimeMillis();
                Locale.setDefault(Locale.US);
                if (ONLINE_JUDGE) {
                    in = new BufferedReader(new InputStreamReader(System.in));
                    out = new PrintWriter(System.out);
                } else {
                    in = new BufferedReader(new FileReader("input.txt"));
                    out = new PrintWriter("output.txt");
                }
                tok = new StringTokenizer("");
                solve();
                in.close();
                out.close();
                long endTime = System.currentTimeMillis();
                long totalMemory = Runtime.getRuntime().totalMemory();
                long freeMemory = Runtime.getRuntime().freeMemory();
                System.err.println();
                System.err.println("Time = " + (endTime - startTime) + " ms");
                //System.err.println("Memory = " + ((totalMemory - freeMemory) / 1024) + " KB");
            } catch (Throwable e) {
                e.printStackTrace(System.err);
                System.exit(-1);
            }
        };
        new Thread(null, run, "run", 256 * 1024 * 1024).start();
        min(0, 0);
    }

    String readString() {
        while (!tok.hasMoreTokens()) {
            String line;
            try {
                line = in.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            if (line == null) return null;
            tok = new StringTokenizer(line);
        }
        return tok.nextToken();
    }

    int readInt() {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    void debug(Object... o) {
        if (!ONLINE_JUDGE) {
            System.err.println(Arrays.deepToString(o));
        }
    }

    long binpow(int a, int n) {
        long r = 1;
        while (n > 0) {
            if ((n & 1) > 0) {
                r *= a;
            }
            a *= a;
            n /= 2;
        }
        return r;
    }

    static long gcd(long x, long y) {
        return y == 0 ? x : gcd(y, x % y);
    }

    private long[] readLongArray(int n) throws IOException {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = readLong();
        }
        return a;
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 28500
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, A);
    CIN(int, B);

    int ans = 0;
    if ( A >= 13) {
        ans = B;
    } else if ( A >= 6 ) {
        ans = B / 2;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    string s;
    cin>>s;
    ll q;
    cin>>q;
    bool t=true;
    vector<char>s1,s2;
    rep(0,i,q){
        ll q0;
        cin>>q0;
        if(q0==1)t=!t;
        if(q0==2){
            ll f;
            char c;
            cin>>f>>c;
            if(t){
                if(f==1)s1.pb(c);
                if(f==2)s2.pb(c);
            }else{
                if(f==1)s2.pb(c);
                else s1.pb(c);
            }
        }
    }
    ll n1=s1.size(),n2=s2.size();
    if(t){
        rep(0,i,n1)cout<<s1[n1-1-i];
        cout<<s;
        rep(0,i,n2)cout<<s2[i];
    }else{
        rep(0,i,n2)cout<<s2[n2-1-i];
        rep(0,i,s.size())cout<<s[s.size()-1-i];
        rep(0,i,n1)cout<<s1[i];
    }
}

Measured memory_bytes: 3888
#include <iostream>
using namespace std;
int main()
{
    long n,m;
    cin>>n>>m;
    long sum=0;
    if(n*2<=m){
        sum+=n;
        m-=n*2;
        sum+=m/4;
    }
    else
        sum+=m/2;
    cout<<sum;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int read()
{
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=100010;

int n,a[maxn],t0,t1,t2;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]%2!=0)t0++;
		if(a[i]%2==0){
			if(a[i]%4==0)t2++;
			else t1++;
		}
	}
    if(t2>=t0||(t2+1==t0&&t1==0))printf("Yes");else printf("No");
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	ll k; cin>>k;
	const int n = 50;
	VL a(50);
	rep(i,n) a[i]=i+k/50;
	rep(i,k%n){
		a[i]+=n+1; rep(j,50) a[j]--;
	}
	cout<<n<<endl;
	rep(i,n) cout<<a[i]<<' ';
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

ll fac[100005];
ll in[100005];
ll md = 1000000007;

ll po(ll x, ll y) 
{ 
	ll p = md;
    ll res = 1;
	x = x % p;  // Update x if it is more than or  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p;
		y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res % md; 
}

void fact()
{
	ll i;
	fac[0] = 1;
	fac[1] = 1;
	fr(i,2,100005)
		fac[i] = (fac[i-1] * i)%md;
}

void inff()
{
	ll i;
	in[0] = 1;
	in[1] = 1;
	fr(i,2,100005)
		in[i] = po(fac[i], md - 2);
}

ll ncr(ll n, ll r)
{
	if(n < r)
		return 0;
	ll tmp = (fac[n]*(in[r]))%md;
	tmp *= in[n-r];
	tmp %= md;
	return tmp;
}

int main()
{
	FAST;
	fact();
	inff();
	ll n, k, i, j;
	cin >> n >> k;
	ll a[n];
	fr(i, 0, n)	
		cin >> a[i];
	sort(a, a+n);
	ll pre[n];
	pre[0] = a[0]%md;
	fr(i,1,n)
		pre[i] = (pre[i-1] + a[i])%md;
	ll ans = 0;
	fr(i, k-2, n-1)
	{
		ll t1 = pre[n-1];
		t1 -= pre[i];
		t1 += md;
		t1 %= md;
		ll t2 = pre[n-1-i-1];
//		trace3(i, t1, t2);
		ll tmp = t1 - t2 + md;
		tmp %= md;
//		trace1(tmp);
		tmp *= ncr(i, k-2);
//		trace1(tmp);
		tmp %= md;
		ans += tmp;
		ans %= md;
//		trace1(ans);
	}
	cout << ans;
}


Measured memory_bytes: 3328
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		char[] s = stdIn.next().toCharArray();
		int cnt = 0;
		for(int i = 0; i < s.length-2; i++) {
			if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') {
				cnt++;
			}
		}
		System.out.println(cnt);
		
		
		
		
		
	}

}


Measured memory_bytes: 22228
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                String S = sc.next();
                int n = sc.nextInt(), ans = 0;
                for (int i = 0; i < n; i++) {
                        String Input = sc.next();
                        Input += Input;
                        if (Input.indexOf(S) != -1) {
                                ans++;
                        }
                }
                System.out.println(ans);
        }
}

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

int main(){
  int N, X[8], Y[8];
  cin >> N;

  for(int i=0; i<N; ++i){
    cin >> X[i] >> Y[i];
  }
  vector<int> ord;
  for(int i=0; i<N; ++i) ord.push_back(i);
  
  long double sm = 0;
  do{
    for(int i=0; i<N-1; ++i){
      int a = ord[i];
      int b = ord[i+1];

      long double dx = X[a] - X[b];
      long double dy = Y[a] - Y[b];

      sm += sqrt(dx*dx + dy*dy);
    }
  }while(next_permutation(ord.begin(), ord.end()));

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

  cout << setprecision(10) << sm / cnt << endl;

  return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

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

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W;
  cin >> H >> W;
  vector<vector<int>> c(10, vector<int>(10));
  for (int i = 0; i < 10; i++)
  {
    for (int j = 0; j < 10; j++)
      cin >> c[i][j];
  }

  for (int k = 0; k < 10; k++)
  {
    for (int i = 0; i < 10; i++)
    {
      for (int j = 0; j < 10; j++)
      {
        chmin(c[i][j], c[i][k] + c[k][j]);
      }
    }
  }

  ll res = 0;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      int A;
      cin >> A;
      if (A == -1)
        continue;
      res += c[A][1];
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	string s;
	cin >> s;
	for (int i = 0; i < (int)s.size() - 1; i++) {
		string t = "";
		t += s[i];
		t += s[i + 1];
		if (t == "AC") {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define MAX 105000
#define fr(i,x) for(int i=0;i<x;i++)
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}
ll ar[MAX];
void divisor(){
    for (int i = 1; i <= MAX; i++)
    {
        for (int j = i; j <= MAX;j+=i)
        {
            ar[j]++;
            
        }
        
        
    }
    
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll d,ns,nt,r = INT_MAX;
    string s,t;
    
    cin >> s >> t;
    ns = s.length();
    nt = t.length();
    for (int i = 0; i < ns-nt+1; i++)
    {
        ll c = 0;
        for (int j = 0; j < nt; j++)
        {
            
            //cout << s[j+i] << " ";
            if(s[j+i]!=t[j]) c++;
        }
        //cout << c << endl;
        r = min(r,c);
    }
    
    cout << r << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
    lli a, b, c, d;
    cin >> a >> b >> c >> d;
    lli lcm_of_cd = max(c, d) / __gcd(c, d) * min(c, d);
    // cout << "lcm_of_cd = " << lcm_of_cd << endl;
    
    lli lb_c = a / c + (a % c > 0);
    // cout << "lb_c = " << lb_c << endl;
    lli ub_c = b / c;
    // cout << "ub_c = " << ub_c << endl;
    lli num_c = ub_c - lb_c + 1;
    // cout << "num_c = " << num_c << endl;

    lli lb_d = a / d + (a % d > 0);
    // cout << "lb_d = " << lb_d << endl;
    lli ub_d = b / d;
    // cout << "ub_d = " << ub_d << endl;
    lli num_d = ub_d - lb_d + 1;
    // cout << "num_d = " << num_d << endl;

    lli lb_lcm_of_cd = a / lcm_of_cd + (a % lcm_of_cd > 0);
    // cout << "lb_lcm_of_cd = " << lb_lcm_of_cd << endl;
    lli ub_lcm_of_cd = b / lcm_of_cd;
    // cout << "ub_lcm_of_cd = " << ub_lcm_of_cd << endl;
    lli num_lcm_of_cd = ub_lcm_of_cd - lb_lcm_of_cd + 1;
    // cout << "num_lcm_of_cd = " << num_lcm_of_cd << endl;

    lli ans = (b - a + 1) - (num_c + num_d - num_lcm_of_cd);
    cout << ans << endl;
    return 0;
}

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

///////////////////////////////////////////////////////////////////////////
// code credit : https://github.com/niklasb/contest-algos/
// blob/master/convex_hull/dynamic.cpp
const ll is_query = -(1LL<<62);
struct Line {
    ll m, b;
    mutable function<const Line*()> succ;
    bool operator<(const Line& rhs) const {
        if (rhs.b != is_query) return m < rhs.m;
        const Line* s = succ();
        if (!s) return 0;
        ll x = rhs.m;
        return b - s->b < (s->m - m) * x;
    }
};
struct HullDynamic : public multiset<Line> { // will maintain upper hull for maximum
    bool bad(iterator y) {
        auto z = next(y);
        if (y == begin()) {
            if (z == end()) return 0;
            return y->m == z->m && y->b <= z->b;
        }
        auto x = prev(y);
        if (z == end()) return y->m == x->m && y->b <= x->b;
        return (x->b - y->b) * (long double)(z->m - y->m) >= (y->b - z->b) * (long double)(y->m - x->m);
    }
    void insert_line(ll m, ll b) {
        auto y = insert({ m, b });
        y->succ = [=] { return next(y) == end() ? 0 : &*next(y); };
        if (bad(y)) { erase(y); return; }
        while (next(y) != end() && bad(next(y))) erase(next(y));
        while (y != begin() && bad(prev(y))) erase(prev(y));
    }
    ll getVal(ll x) {
        auto l = *lower_bound((Line) { x, is_query });
        return l.m * x + l.b;
    }
};
///////////////////////////////////////////////////////////////////////////

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,c;
    cin >> n >> c;
    const int inf = 1e17;
    int height;
    cin >> height;
    HullDynamic hd;
    hd.insert_line(2*height, -height*height);
    int memo;
    for(int i = 0; i < n; ++i) {
        cin >> height;
        memo = c + height*height - hd.getVal(height);
        hd.insert_line(2*height, -height*height-memo);
    }
    cout << memo << '\n';
    return 0;
}


























Measured memory_bytes: 19072
#include <iostream>

using namespace std;

int main()
{
    long long a, b, c;

    cin >> a >> b >> c;

    if (a + b > c)
    {
        cout << "No" << endl;
        return 0;
    }

    if (4 * a * b < (c - a - b) * (c - a - b))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, S;
  cin >> K >> S;
  int count = 0;

  for (int X =0; X <=K; X++){
    for (int Y =0; Y <=K; Y++){
        int t = X+Y;
          if(t <= S && t+K >= S){
            count++;}
    }
  }
  
  cout << count << endl;
  
}

 

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 110, M = 110, mod = 1e9 + 7;

int n, a, b;

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = (LL)res * a % mod;
		a = (LL)a * a % mod;
		b >>= 1;
	}
	return res;
}

int C(int a, int b)
{
	int res = 1;
	for (int i = a; i > a - b; i -- ) res = (LL)res * i % mod;
	for (int i = 1; i <= b; i ++ ) res = (LL)res * qp(i, mod - 2) % mod;
	return res;
}

int main()
{
	cin >> n >> a >> b;
	int res = qp(2, n) - C(n, a) - C(n, b) - 1;
	res = (res % mod + mod) % mod;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e4+5;
const ll INF=999999999999;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
ll dp[MAXN];
int main()
{
    ll h,n;
    cin>>h>>n;
    int cnt=0;
    for(int i=0;i<=h;i++)dp[i]=INF;
    dp[0]=0;
    for(int i=1;i<=n;i++)
    {
        int w,v;cin>>w>>v;
        for(int j=1;j<=h;j++)
        {
            dp[j]=min(dp[j],dp[max(j-w,0)]+v);
        }
    }
    cout<<dp[h]<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()


int main() {
    int n, m;
    while(cin >> n, n){
        vector<P> v;
        for(int i=0;i<n;i++){
            int h, r;
            cin >> h >> r;
            v.push_back({h,r});
        }
        cin >> m;
        for(int i=0;i<m;i++){
            int h, r;
            cin >> h >> r;
            v.push_back({h,r});
        }
        sort(v.begin(), v.end());

        v.push_back({IINF,IINF});
        int N = v.size();
        vector<int> dp(N, 0);
        for(int i=0;i<N;i++){
            for(int j=0;j<i;j++){
                if(v[j].first < v[i].first && v[j].second < v[i].second){
                    dp[i] = max(dp[i], dp[j]+1);
                }
            }
        }
        cout << dp[N-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

array<ll, 51> A, P;

ll f(int n, ll x) {
    if (n == 0) {
        if (x <= 0)
            return 0;
        else
            return 1;
    }
    else if (x == 1LL) {
        return 0;
    }
    else if (x <= 1LL + A[n - 1]) {
        return f(n - 1, x - 1LL);
    }
    else {
        return P[n - 1] + 1LL + f(n - 1, x - 2LL - A[n - 1]);
    }
}

signed main() {
    ll N, X;
    cin >> N >> X;

    A[0] = 1;
    P[0] = 1;
    FOR(i, 1, 51) {
        A[i] = A[i-1] * 2 + 3;
        P[i] = P[i-1] * 2 + 1;
    }

    cout << f(N, X) << LF;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    map<string, int> mp;

    int n; cin >> n;
    REP(i, n) {
        string s; cin >> s;
        mp[s]++;
    }

    int m; cin >> m;
    REP(i, m) {
        string s; cin >> s;
        mp[s]--;
    }

    int ans = 0;
    for (auto it : mp) {
        ans = max(ans, it.second);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc087/tasks/arc090_a

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int16_t> v(n), w(n);
    int sum = 0, now1 = 0, now2 = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        sum += w[i];
    }
    // x軸がiのときに下へ移動
    for (int i = 0; i < n; i++) {
        now1 += v[i];
        ans = max(ans, now1 + sum - now2);
        now2 += w[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    ll n = 0;
    cin >> n;
    cout << n*(n-1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long double a, b, c; cin >> a >> b >> c;
  long long d = c - a - b;
  if(d > 0 && d * d > 4 * a * b){
    cout << "Yes" << endl;
   } else {
	cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
 using namespace std ;
 int main()
{
 int A, B, C, D, x, y, z, k;
 cin>>A;
 cin>>B;
 cin>>C;
 cin>>D;
x=(A+C);
y=(A+D);
z=(B+C);
k=(B+D);
if (x<=y&&x<=z&&x<=k)
{
  cout<<x<<endl;
}
if  (y<=k&&y<x&&y<=z)
{
  cout<<y<<endl;
}
if (z<y&&z<x&&z<=k)
{
  cout<<z<<endl;
}
if (k<y&&k<z&&k<x)
{
  cout<<k<<endl;
}
}

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

typedef long long ll;

int main(void)
{
    long long int a , b , c , counter;

    while(cin >> a){

        b=600;
        c=0;

        while(true){

            b-=a;

            if(b==0)break;

            c+= b*b;

            //b-=a;
        }

        cout << c*a << endl;
    }

    return 0;
}

Measured memory_bytes: 3044
#include <iostream>
#include <iomanip>

int main()
{
    double a, b, c, d, e, f, x, y;
    while (std::cin >> a >> b >> c >> d >> e >> f) {
        x = (c * e - b * f) / (a * e - b * d);
        y = (-c * d + a * f) / (a * e - b * d);
        if (x == -0.0) {
            x = 0;
        }
        if (y == -0.0) {
            y = 0;
        }
        std::cout << std::fixed << std::setprecision(3) << x << " " << y << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3120
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <ios>
#include <iomanip>


using namespace std;

int main(){
    int N,M;
    int K;
    cin >> N >> M;
    int food[N][M];

    REP(i, N){
        REP(j, M){
            food[i][j] = 0;
        }
    }

    cin >> K;
    REP(i, K){
        int m;
        cin >> m;
        food[0][m-1] = 1;
    }

    FOR(i, 1, N){
        cin >> K;
        REP(j, K){
            int m;
            cin >> m;
            food[i][m-1] = 1;
        }
    }

    int tmp=1;
    int ans=0;
    REP(i, M){
        REP(j, N){
            tmp *= food[j][i];
        }
        if(tmp==1){
            ans+=1;
        }
        tmp=1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ss second 
#define ff first 
#define ed "\n"


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll q,x,a;
	string key;
	cin >>q;
   map<string,ll>  p1;
    map<string,ll> ::iterator it=p1.begin();
	while(q--)
	{
		cin>>a;
		if(!a)
		{
			cin>>key>>x;
			p1[key] = x;
		}
		if(a==1)
		{
			cin>>key;
			if(!p1.empty())
			{
				cout<<p1[key]<<ed;
			}
			else
			cout<<"0"<<ed;
		}
		if(a==2){
			cin>>key;
			p1.erase(key);
		
		}
	
	}
	return 0;
}
	



Measured memory_bytes: 25904
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 1e5 + 7;

namespace Fenw {
	int f[N];

	void set(int pos, int val) {
		for (int i = pos; i < N; i = (i | (i + 1))) {
			f[i] = max(f[i], val);
		}
	}

	int get(int r) {
		int ans = 0;
		for (int i = r; i >= 0; i = (i & (i + 1)) - 1) {
			ans = max(ans, f[i]);
		}
		return ans;
	}
}

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

	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	auto sn = a;
	sort(sn.begin(), sn.end());
	sn.resize(unique(sn.begin(), sn.end()) - sn.begin());
	for (auto &t : a) {
		t = lower_bound(sn.begin(), sn.end(), t) - sn.begin();
	}
	reverse(a.begin(), a.end());
	for (auto x : a) {
		Fenw::set(x, Fenw::get(x) + 1);
	}
	int ans = *max_element(Fenw::f, Fenw::f + N);
	cout << ans << endl;

}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979311599796346854418516159057617187500
const ll N=1e5+5,mod=1000000007;
signed main()
{
    fast;
    ll pro=1,temp,t,n,m,k,i,j,l,r,mid,x,y,z,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,sum=0,flag=1,i1=-1,i2=-1;
    cin>>x>>y>>z;
    cout<<z-min(x-y,z)<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b,c,t;
    
    scanf("%d%d%d",&a,&b,&c);
    
    int array[3] = { a,b,c };

	for (int i = 0; i<2; i++) {
		for (int m = i + 1; m<3; m++)
			if (array[i]>array[m]) {
				t= array[i];
				array[i] = array[m];
				array[m] = t;
			}
	}
	printf("%d %d %d\n", array[0], array[1], array[2]);

    
    
    return 0;
}


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


int IsPrime(int num)
{
    if (num < 2) return -1;
    else if (num == 2) return 0;
    else if (num % 2 == 0) return -1; 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return -1;
        }
    }
    return 1;
}

int main(){
  long long n;
  int a=-1;
  cin>>n;
  while(a==-1){
  a=IsPrime(n);
  n+=1;
  }
  n-=1;
  cout<<n;
  return 0;
}

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

using namespace std;

using int64 = long long;

int main(void) {
    int64 n,m;
    cin >> n >> m;
    vector<int64> s(m, 0);

    for (int64 i=0; i<m; i++) {
        int64 k;
        cin >> k;
        for (int64 j=0; j<k; j++) {
            int64 si; cin>>si;
            s[i] |= (1LL<<(si-1));
        }
    }

    vector<int64> p(m);
    for (int64 i=0; i<m; i++) cin >> p[i];
    
    int64 ans = 0;
    for (int64 i=0; i<(1LL<<n); i++) {
        bool f = true;
        for (int64 j=0; j<m; j++) {
            int64 tmp = s[j] & i;
            if (__builtin_popcount(tmp)%2 != p[j]) f = false;
        }
        if (f) {
            ans++;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 632
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scan(&N)
	x := make([]float64, N)
	y := make([]float64, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&x[i], &y[i])
	}
	sum := 0.
	for i := 0; i < N-1; i++ {
		for j := i + 1; j < N; j++ {
			dx := x[i] - x[j]
			dy := y[i] - y[j]
			sum += math.Sqrt(dx*dx + dy*dy)
		}
	}
	fmt.Println(sum / float64(N) * 2.0)
}


Measured memory_bytes: 1864
#include<iostream>
using namespace std;
int main(void)
{
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(W >= x+r  && H >= y+r && 0 <= x-r && 0 <= y-r){
      cout<< "Yes" << endl;
    }
    else{
      cout<< "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>  
        using namespace std;
        long long a[200050],ai[200050];
        int main(){
            long long n;
            cin >> n;
            for(int i=0;i<n;i++){
                cin >> a[i];
                ai[i] = a[i];
            }   
           sort(a,a+n,greater<long long>());
            for(int i=0;i<n;i++){
                if(a[0]==ai[i]) cout << a[1] << '\n';
                else cout << a[0] << '\n';
            }   
          return 0;
        }

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
signed main(){
    io();
    int n; cin >> n;
    vector<ll> v, pos;
    v.push_back(0);
    for(int i = 0, x; i < n; ++i){
        cin >> x;
        v.push_back(x);
    }
    v.push_back(0);
    bool ok = 1;
    for(int i = 1; i < n; ++i){
        if(v[i] >= v[i - 1] && v[i] >= v[i + 1]){
            pos.push_back(i);
        }
    }
    for(int i = 0; i < pos.size(); ++i){
        if(v[pos[i]] > v[pos[i] - 1]){
            --v[pos[i]];
        }
    }
    for(int i = 1; i < n; ++i){
        if(v[i] > v[i + 1]){
            ok &= 0;
            break;
        }
    }
    /*
    4 3 3 2 2 Yes
    4 3 3 3 2 Yes
    7 1 2 3 2 2 2 2 Yes
    */
    puts(ok ? "Yes" : "No");
    return 0; 
}

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

int main() {
	double a,b,e;
	int c, d;
	cin >> a >> b;
	e = a / b;
	int f = a;
	int g = b;
	c = a / b;
	d = f % g;
	cout<< c<<" " << d << " " <<fixed<< setprecision(8) << e << "\n";
	return 0;
}


Measured memory_bytes: 3288
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int N;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N;
	cin >> N;
	long long ans = 0;
	for(int i=1; i<N; i++){
		ans += i;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
#define rev(s) (string((s).rbegin(), (s).rend()))

ll ans=0;

void func(int n,string s,ll sum,ll cont) {
    if (n==s.size()-1) {
        ans+=sum+cont*10+int(s[n]-'0');
        return;
    }
    func(n+1,s,sum+cont*10+int(s[n]-'0'),0);
    func(n+1,s,sum,cont*10+int(s[n]-'0'));
}

int main(){

    string s;
    cin>>s;

    func(0,s,0,0);

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <iostream>
    using namespace std;
     
    int main() {
    	int x, y;
    	char op;
    	while(1){
    	cin >> x >> op >> y;
    	if(op == '+')cout << x+y << endl;
    	else if(op == '-')cout << x-y << endl;
    	else if(op == '*')cout << x*y << endl;
    	else if(op == '/')cout << x/y << endl;
    	else if(op == '?')break;
    	}
    	return 0;
    }

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


public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);

        int n = in.nextInt();
        int m = in.nextInt();
        int x = in.nextInt();
        int y = in.nextInt();
        int [] a = new int[n];
        int [] b = new int[m];
        for (int i = 0; i < a.length; i++) {
            a[i] = in.nextInt();
        }
        for (int i = 0; i < b.length; i++) {
            b[i] = in.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        int min = a[n-1] + 1;
        int max = b[0];
        int ans = Integer.MIN_VALUE;
        for (int i = min; i <=max; i++) {
            if(i>x && i<=y) {
                ans = i;
                break;
            }
        }
        if(ans == Integer.MIN_VALUE) {
            out.println("War");
        }
        else {
            out.println("No War");
        }
        out.flush();

    }
}
class Envelope {
    private int width;
    private int height;

    public int getHeight() {
        return height;
    }

    public int getWidth() {
        return width;
    }

    public Envelope(int width,int height) {
        this.width = width;
        this.height = height;
    }

    @Override
    public String toString() {
        return width + " " + height;
    }
}

class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return tokenizer.nextToken();
    }

    public Integer nextInt() {
        return Integer.valueOf(next());
    }
    public Long nextLong() {return  Long.valueOf(next());}

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

ll f(ll x){
  return x * (x+1) / 2;
}

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

  ll l = 0, r = n;
  while(r - l > 1){
    ll m = (l + r) / 2;
    if(f(m) >= n){
      r = m;
    }
    else{
      l = m;
    }
  }

  for(int i=1; i<=r; i++){
    if(i == f(r)-n) continue;
    cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdarg.h>
#include <stdio.h>

long long min(int len, ...) {
    long long i, _min, num;
    va_list ap;
    va_start(ap, len);

    _min = va_arg(ap, long long);
    for (i = 1; i < len; i++) {
        num = va_arg(ap, long long);
        if (num < _min)
            _min = num;
    }
    va_end(ap);
    return _min;
}


int main(void) {
    long long N, A, B, C, D, E, m, X;
    scanf("%lld%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D, &E);
    m = min(5, A, B, C, D, E);
    X = N/m;
    if (N%m == 0) X--;
    X += 5LL;
    printf("%lld\n", X);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
          int h,w,i=1,j,k,arr1[1000],arr2[1000],count=-1;
          do
          {
                    scanf("%d%d",&h,&w);
                    arr1[i]=h;
                    arr2[i]=w;
                    i++;
                    count++;

          }while((h!=0)&&(w!=0));
          for(i=1;i<=count;i++)
          {
                    k=1;
                    while(k<=arr1[i])
                    {
                              if(k%2!=0){
                              for(j=1;j<=arr2[i];j++)
                              {
                                        if(j%2!=0)
                                                  printf("#");
                                        else if(j%2==0)
                                                  printf(".");
                              }}
                              if(k%2==0){
                              for(j=1;j<=arr2[i];j++)
                              {
                                        if(j%2==0)
                                                  printf("#");
                                        else if(j%2!=0)
                                                  printf(".");
                              }}
                              printf("\n");
                              k++;
                    }
                    printf("\n");
          }
}



Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;
struct UnionFind{
    vector<int> par;
    UnionFind(int n):par(n,-1){}
    int find(int x){
        if(par[x]<0)return x;
        return par[x]=find(par[x]);
    }
    bool unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y)return false;
            par[x]+=par[y];
            par[y]=x;
        return true;
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }
};
int main(){
    int n,q;
    cin>>n>>q;
    UnionFind uf(n);
    rep(i,q){
        int c,x,y;
        cin>>c>>x>>y;
        if(c)cout<<uf.same(x, y)<<endl;
        else uf.unite(x,y);
    }
   return 0;
}


Measured memory_bytes: 3140
n,m=map(int,input().split())
lmax=0
rmin=float('inf')
for i in range(m):
  l,r=map(int,input().split())
  lmax=max(l,lmax)
  rmin=min(r,rmin)
if lmax>rmin:
  x=0
else:
  x=rmin-lmax+1
print(x)

Measured memory_bytes: 3060
#include <stdio.h>
#include<math.h>
int s[1000]; 

void reset(void);

main()
{
	int n,i;
	double a=0,m=0;
	
	while(1){
		reset();
		a=0,m=0;
		scanf("%d",&n);
		if(n==0){break;}
		for(i=0;i<n;i++){
			scanf("%d",&s[i]);
		}
		
		for(i=0;i<n;i++){
			m+=s[i];
		}
		m/=(double)n;
		
		for(i=0;i<n;i++){
			a+=(((double)s[i]-m)*((double)s[i]-m));
		}
		a/=(double)n;
		
		a=sqrt(a);
		
		printf("%.8f\n",a);
	}
	return 0;
}

void reset(void){
	int a;
	for(a=0;a<1000;a++){
		s[a]=0;
	}
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var N, r int
	str := "MARCH"
	fmt.Scan(&N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	m := map[string]int{}
	var s string
	for i := 0; i < N; i++ {
		fmt.Scan(&s)
		m[s[:1]]++
	}
	for i := 0; i < 5; i++ {
		for j := i + 1; j < 5; j++ {
			for k := j + 1; k < 5; k++ {
				r += m[str[i:i+1]] * m[str[j:j+1]] * m[str[k:k+1]]
			}
		}
	}
	fmt.Println(r)
}

Measured memory_bytes: 5504
import sys
import numpy as np
from numba import jit, njit
input = lambda: sys.stdin.buffer.readline().rstrip()

@njit
def main(n,m,k,a,b):
  sa = np.cumsum(a)
  sb = np.cumsum(b)
  rx = 0
  rb = m
  for ra in range(0,n+1): 
    while (sb[rb] + sa[ra]) > k and rb>0 :
      rb-=1
    if (sb[rb] + sa[ra]) <= k:
      rx = max(rx,ra+rb)
  return(rx)

n,m,k = map(int, input().split())
a = np.array([0]+list(map(int, input().split())))
b = np.array([0]+list(map(int, input().split())))
print(main(n,m,k,a,b))

Measured memory_bytes: 118428
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
int main()
{
  int s,w;cin >> s >> w;
  if(s <= w) cout << "unsafe" << "\n";
  else cout << "safe" << "\n";
  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long t,n,i,ans,cnt,j,k,x,p=0,q=0;
       cin>>x>>n;
       int a[n];
       for(i=0;i<n;i++)
       {
           cin>>a[i];
       }
       i=x;
       j=x;
       while(i<101,j>=0)
        {
            p=0;
            q=0;
       for(k=0;k<n;k++)
       {

           if(a[k]!=j){
            p++;
       }

           if(a[k]!=i){
            q++;
           }
       }
        if(p==n)
       {
           cout<<j<<endl;
           break;
       }
       if(q==n)
           {
               cout<<i<<endl;
               break;
           }
       i++;
       j--;
        }

}


Measured memory_bytes: 3556
def r(i):
    indr = s.find('<', i)
    return indr - i if indr != -1 else n - i - 1
def l(i):
    indl = s.rfind('>', 0, i)
    return i - indl -1 if indl != -1 else i 

s = input()
n = len(s) + 1
print(sum([max(r(i), l(i)) for i in range(n)]))


Measured memory_bytes: 29764
n = int(input())
t, a = map(int, input().split())
ondo = float('inf')
h = [int(x) for x in input().split()]
for i in range(n):
    if ondo > abs(a - (t - h[i]*0.006)):
        ans = i + 1
    else:
        continue
    ondo = min(ondo, abs(a - (t - h[i]*0.006)))
print(ans)

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

int main() {
	
	int n, m;
	cin >> n >> m;
	vector<tuple<int, int, int>> t(m);
	vector<pair<int, string>> ans(m);
	
	rep(i, m){
		int p, y;
		cin >> p >> y;
		t.at(i) = make_tuple(p, y, i);
	}
	sort(t.begin(), t.end());
	int cnt = 1;
	get<1>(t.at(0)) = cnt;
	for(int i = 1; i < m; i++){
		if(get<0>(t.at(i)) == get<0>(t.at(i-1))){
			cnt++;
		}else{
			cnt = 1;
		}
		get<1>(t.at(i)) = cnt;
	}
	
	rep(i, m){
		char tmp[13];
		sprintf(tmp, "%06d%06d", get<0>(t.at(i)), get<1>(t.at(i)));
		ans.at(i) = make_pair(get<2>(t.at(i)), tmp);
	}
	sort(ans.begin(), ans.end());
	
	rep(i, m){
		cout << ans.at(i).second << endl;
	}
	
	return 0;
}

Measured memory_bytes: 8960