akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }


    void calc(int u)
    {
        bool ta = false;
        bool tb = false;
        foreach (var v in G[u])
        {
            if (S[v] == 'A' && B[v] >= 0)
            {
                ta = true;
            }
            else if (S[v] == 'B' && B[v] >= 0)
            {
                tb = true;
            }
            if (ta && tb)
            {
                B[u] = 1;
                return;
            }
        }
        B[u] = -1;
        foreach (var v in G[u])
        {
            if (B[v] >= 0)
            {
                calc(v);
            }
        }
    }

    int N, M;
    string S;
    int[] B;
    List<int>[] G;
    void solve()
    {
        N = cin.nextint;
        M = cin.nextint;
        S = ReadLine();
        G = Enumerable.Range(0, N).Select(i => new List<int>()).ToArray();
        B = new int[N];
        for (int i = 0; i < M; i++)
        {
            int a = cin.nextint - 1;
            int b = cin.nextint - 1;
            G[a].Add(b);
            G[b].Add(a);
        }

        for (int i = 0; i < N; i++)
        {
            if (B[i] == 0)
            {
                calc(i);
            }
        }

        for (int i = 0; i < N; i++)
        {
            if (B[i] == 1)
            {
                WriteLine("Yes");
                return;
            }
        }
        WriteLine("No");
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

int n,a[200005];

inline bool check(const int &k){
    if((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))return 1;
    if((a[n-1]> k&&a[n]> k)||(a[n]> k&&a[n+1]> k))return 0;
    for(int i=1;i<n-1;i++){
        if((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))return 1;
        if((a[n+i]> k&&a[n+i+1]> k)||(a[n-i]> k&&a[n-i-1]> k))return 0;
    }
    return a[1]<=k;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<n<<1;i++)scanf("%d",a+i);
    int l=1,r=(n<<1)-1;
    while(l<r){
        int mid=l+r>>1;
        if(check(mid))r=mid;
        else l=mid+1;
    }
    printf("%d",l);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int x,y;cin>>x>>y;

    for(int i=0;i<=x;i++){
        int z=y-2*i;
        if(z<0) continue;
        if(z%4==0 and i+z/4==x){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int a[]={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 main()
{
    ios::sync_with_stdio(0);
    int x; cin>>x;
    cout<<a[x-1];
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int dp[11][1<<10][331];
int ans(int n, int x, int s);
int main(){
  int n,m;
  memset(dp,-1,sizeof(dp));
  while(cin >>n>>m){
    if(n>10 || 330<m){cout <<"0"<<endl;}
    else{cout <<ans(n,0,m)<<endl;}
  }
  return 0;
}
int ans(int n, int x, int s){
  int y = 0;
  if(dp[n][x][s]>=0){return dp[n][x][s];}
  if(s<0){return 0;}
  if(n == 1){
    if(s<10){
      if(!(x&(1<<s))){y = 1;}
    }
  }
  else{
    for(int i=0; i<10; i++){
      if(!(x&(1<<i))){
	y+=ans(n-1,x|(1<<i),s-i*n);
      }
    }
  }
  dp[n][x][s] = y;
  return y;
}

Measured memory_bytes: 15732
#include <stdio.h>

int main(void)
{
	char s[50][50];
	int h, w, i, j, f = 0;
	scanf("%d%d", &h, &w);
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			scanf("%c", &s[i][j]);
			while (s[i][j] == 10) scanf("%c", &s[i][j]);
		}
	}
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (s[i][j] == 35) {
				if (i == 0 && j == 0) {
					s[0][1] == 46 && s[1][0] == 46 ? f = 1 : 0;
				}
				else if (i == 0 && j == w - 1) {
					s[0][w - 2] == 46 && s[1][w - 1] == 46 ? f = 1 : 0;
				}
				else if (i == h - 1 && j == 0) {
					s[h - 2][0] == 46 && s[h - 1][1] == 46 ? f = 1 : 0;
				}
				else if (i == h - 1 && j == w - 1) {
					s[w - 2][h - 1] == 46 && s[h - 2][w - 1] == 46 ? f = 1 : 0;
				}
				else if (i == 0) {
					s[i][j - 1] == 46 && s[i][j + 1] == 46 && s[i + 1][j] == 46 ? f = 1 : 0;
				}
				else if (i == h - 1) {
					s[i][j - 1] == 46 && s[i][j + 1] == 46 && s[i - 1][j] == 46 ? f = 1 : 0;
				}
				else if (j == 0) {
					s[i - 1][j] == 46 && s[i + 1][j] == 46 && s[i][j + 1] == 46 ? f = 1 : 0;
				}
				else if (j == w - 1) {
					s[i - 1][j] == 46 && s[i + 1][j] == 46 && s[i][j - 1] == 46 ? f = 1 : 0;
				}
				else {
					s[i + 1][j] == 46 && s[i - 1][j] == 46 && s[i][j + 1] == 46 && s[i][j - 1] == 46 ? f = 1 : 0;
				}
			}
		}
	}
	printf("%s", f ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 128
a = []
a = gets.split.map(&:to_i)
b = []
b = gets.split.map(&:to_i)
c = []
while s = gets
  c.push(s.split.map(&:to_i))
end
cnt=0
for i in 0..a[0]-1
t=0
    for j in 0..a[1]-1
    t+=b[j]*c[i][j]
    end
    t+=a[-1]
    if t>0
        cnt+=1
    end
end
puts cnt


Measured memory_bytes: 1788
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
S = input()

cnt = 1
for i in range(N-1):
    if S[i] != S[i+1]:
        cnt += 1
print(cnt)


Measured memory_bytes: 3316
n = int(input())

dic = {}
count = 0
for i in range(n):
    s = list(input().strip())
    s.sort()
    s = "".join(s)
    if s not in dic:
        dic[s] = 0
    else:
        dic[s] += 1
        count += dic[s]

print(count)


Measured memory_bytes: 17804
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

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


void solve(){
    ll k; string s;
    cin >> s >> k;
    ll n = s.size(), p =  -1;
    rep(i, n){
         if(s[i] == '1') p = i;
         else break;
    }
    if(p == -1)
    {
        ANS(s[0]);
    }
    else if(k-1 <= p)
    {
        ANS(s[k-1]);
    }
    else ANS(s[p+1]);

}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    ll n, m, c;
    ll a[50][50], b[50];
    cin >> n >> m >> c;
    rep(i, m) cin >> b[i];
    rep(i, n) rep(j, m) cin >> a[i][j];
    ll sum, ret;
    ret = 0;
    rep(i, n) {
        sum = 0;
        rep(j, m) sum += a[i][j] * b[j];
        sum += c;
        if (sum > 0)
            ret++;
    }
    cout << ret;
    /* ====================================== */
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;


int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll a, b, c; cin >> a >> b >> c;
  bool ok;
  if (a+b>=c) ok = false;
  else {
    if (4*a*b<(c-a-b)*(c-a-b)) ok = true;
    else ok = false;
  }
  cout << (ok? "Yes" : "No") << endl;










	return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int a[101];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		a[i]+=a[i-1];
	}
	int small=100000;
	for(int i=1;i<=n;i++)
		small=min(small,abs((a[n]-a[i])-a[i]));
	cout<<small<<endl;
	return 0;
}

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

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

  int a[n] = {0};
  int b[n] = {0};

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

  double p_1 = 0, p_2 = 0, p_3 = 0, p_i = 0;
  for (int i = 0; i < n; i++) {
    int d = a[i] - b[i];

    p_1 += fabs(d);
    p_2 += fabs(pow(d, 2));
    p_3 += fabs(pow(d, 3));
    p_i = max(p_i, fabs(d));
  }

  printf("%.8f\n", p_1);
  printf("%.8f\n", sqrt(p_2));
  printf("%.8f\n", pow(p_3, 1.0/3.0));
  printf("%.8f\n", p_i);

  return 0;
}



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

int main(){
    long long n, x;
    long long temp;
    long long temp2;
    long long count=0;
    vector<long long> v;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> x;
        v.push_back(x);
    }
    for(int i=0; i<n-1; i++){
        temp = i;
        for(int j=i+1;j<n;j++){
            if(v[temp]>v[j]){
                temp = j;
            }
        }
        if(i!=temp){
            count = count + 1;
        }
        temp2 = v[temp];
        v[temp] = v[i];
        v[i] = temp2;

    }

    for(int i=0; i<v.size()-1; i++){
        cout << v[i] << " ";
    }
    cout << v[v.size()-1] << endl;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ll long long 

int main () {
	ll i,j,k,n,m,su=0,ar[200005];
	map<ll,ll> ma;
	map<ll,bool> done;
	cin>>n;
	for(i=0;i<n;i++) {
		cin>>ar[i];
		ma[ar[i]]++;
	}
	for(i=0;i<n;i++) {
		j = ma[ar[i]];
		if(!done[ar[i]]) {
			su += (j*(j-1))/2;
			done[ar[i]] = 1;
		}
	}
	for(i=0;i<n;i++) {
		j = ma[ar[i]];
		su -= (j*(j-1))/2;
		j--;
		su += (j*(j-1))/2;
		cout<<su<<endl;
		su -= (j*(j-1))/2;
		j++;
		su += (j*(j-1))/2;
	}
	return 0;
}



Measured memory_bytes: 18944
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll X, Y; cin >> X >> Y;
    rep(i, X + 1){
        if(i * 2 + (X - i) * 4 == Y){
            pt("Yes");
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repr(i,n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    string s;
    cin >> s;
    if ((s[2] == s[3]) && (s[4] == s[5])) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if (abs(a - b) % 2 != 0)
    {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int ans = min(a, b) + abs(a - b) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n,m = list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(n)]
ab.sort()


from collections import deque

ab = deque(ab)
from heapq import heappush, heappop, heapify
hq = []
# heappush(hq,(1,33))
# heappush(hq,(5,43))
#
# for i in range(len(hq)):
#     print(heappop(hq))

jobs = []
#m-1日後に何をするかから考える
ret = 0
for mi in range(1,m+1):
    while len(ab)>0 and ab[0][0]<=mi:
        a,b = ab.popleft()
        heappush(jobs,[-b,a])
    if len(jobs)>0:
        ret+=heappop(jobs)[0]
print(-ret)

Measured memory_bytes: 28476
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n,m,l=0;
  cin>>n>>m;
  if(n>m){cout<<0<<endl;return 0;}
  vector<int>x(m);
  for(int i=0;i<m;i++)cin>>x[i];
  sort(x.begin(),x.end());
  vector<int>g(m-1);
  for(int i=0;i<m-1;i++)g[i]=x[i+1]-x[i];
  sort(g.begin(),g.end());
  for(int i=0;i<n-1;i++)l+=g[g.size()-i-1];
  cout<<x.back()-x.front()-l<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	string A, B;
	cin >> A >> B;
	if (A.size() < B.size()) {
		cout << "LESS" << endl;
	}
	else if (A.size() > B.size()) {
		cout << "GREATER" << endl;
	}
	else if (A < B) {
		cout << "LESS" << endl;
	}
	else if (A > B) {
		cout << "GREATER" << endl;
	}
	else {
		cout << "EQUAL" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    long long n, a, b, ans;
    cin >> n >> a >> b;
    if(a%2==1&&b%2==1){
        ans = (b-a) / 2;
        cout << ans << endl;
    }else if(a%2==0&&b%2==0){
        ans = (b-a) / 2;
        cout << ans << endl;
    }else{
        ans = min(n-b,a-1) + 1 + (b - a -1) / 2;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        if (a > b) {
            System.out.println(0);
        } else if (a == b) {
            System.out.println(1);
        } else if (n == 1) {
            System.out.println(0);
        } else if (n == 2) {
            System.out.println(1);
        } else {
            System.out.println((b-a)*(n-2)+1);
        }
    }

}


Measured memory_bytes: 21712
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

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

    int k;
    cin >> n >> k;
    int pattern;
    pattern = k * pow(k - 1, n - 1);
    cout << pattern << endl;
    return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
# define int long long

using namespace std;

const int N = 1e5 + 7;

vector < int > fr[N], en[N];
int used[N], comp[N], cntBlock[N], cntCmp[N], cnt;

void dfs( int v ) {
    used[v] = 1;
    comp[v] = cnt;
    cntCmp[cnt]++;

    for ( auto u: fr[v] ) {
        if ( !used[u] ) {
            dfs( u ); 
        }
    }
}

int32_t main() {
    speed;
    int n , m , k;
    cin >> n >> m >> k;

    for ( int i = 0; i < m; i++ ) {
        int a, b;
        cin >> a >> b;

        fr[a].push_back(b);
        fr[b].push_back(a);
    } 
    for ( int i = 0; i < k; i++ ) {
        int a, b;
        cin >> a >> b;

        en[a].push_back(b);
        en[b].push_back(a);
    }
    for ( int i = 1; i <= n; i++ ) {

        if ( used[i] ) {
            continue;
        }
        cnt++;
        dfs( i );
    }
    for ( int i = 1; i <= n; i++ ) {

        for ( auto v: en[i] ) {

            if ( comp[v] == comp[i] ) {
                cntBlock[i]++;
            }
        }
    }
    for ( int i = 1; i <= n; i++ ) {

        cout << cntCmp[ comp[i] ] - fr[i].size() - 1 - cntBlock[i] << ' ';
    }
}   
  

Measured memory_bytes: 15616
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	reverse(all(t));
	if(s == t)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}


Measured memory_bytes: 256
def f(books, sw)
	d = 1
	rest = sw
	books.each do |bw|
		return Float::INFINITY if bw > sw
		if rest < bw
			d += 1
			rest = sw - bw
		else
			rest -= bw
		end
	end
	d
end

loop do
	m, n = gets.split.map &:to_i
	break if m == 0
	books = (1..n).map {gets.to_i}
	l = 0
	r = books.inject(:+)

	min = Float::INFINITY	
	loop do
		if r < l
			p min
			break
		end
		c = (l + r) / 2
		if f(books, c) <= m
			min = c
			r = c - 1
		else 
			l = c + 1
		end
	end
end

Measured memory_bytes: 8680
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

b = a.index(1) 
ans = 0
b -= (k-1)
if b < 0:
    b = a.index(1) + abs(b)
if b > n-1 -(k-1):
    b -= b- (k-1)
c,d = divmod(b,k-1)
ans += c
if d != 0:
    ans +=1
e,f = divmod(n-1 - b,k-1)
ans += e
if f != 0:
    ans +=1
if d != 0 and f != 0 and d + f <= k-1:
    ans -=1
print(ans)

Measured memory_bytes: 20504
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int x, a, b, ans;
    cin >> x >> a >> b;
    ans = (x-a)-((x-a)/b)*b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ 0056: Goldbach's Conjecture
// 2017.10.28 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MAX  50000
#define HALF 2761		// prime[2760]=24989, prime[2761]=25013
char table[MAX+1];			// zero: if prime 
int sz, prime[5200] = {   	// prime[46] = 223, max sz = 5132
  3,  5,  7, 11, 13, 17, 19, 23, 29, 
 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 
 73, 79, 83, 89, 97,101,103,107,109,113, 
127,131,137,139,149,151,157,163,167,173, 
179,181,191,193,197,199,211,223 };
int ans[MAX+MAX] = {0,0,0,0,1,0};
char buf[10], *p;

int main()
{
	int i, j, k;

	for (i = 0; i < 47; i++) {
		k = prime[i];
		for (j = k<<1; j < MAX; j += k) table[j] = 1;
	}
	for (sz = 0, i = 3; i <= MAX; i += 2) if (!table[i]) prime[sz++] = i;
	for (i = 0; i < HALF; i++) {
		k = prime[i];
		for (j = i; j < sz; j++) ans[k + prime[j]]++;
	}

	while (fgets(p=buf, 10, stdin) && *buf != '0') {
		i = 0; while (*p >= '0') i = (i<<3) + (i<<1) + (*p++ & 0xf);
		if (i & 1) putchar('1'-table[i-2]), putchar('\n');
		else printf("%d\n", ans[i]);
	}
	return 0;
}

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

signed main() {
  int n; cin >>n;
  map<string, int> m;
  rep(i,n) {
    string s; cin >> s;
    m[s]++;
  }
  cout << "AC x "  << m["AC"] << endl;
  cout << "WA x "  << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x "  << m["RE"] << endl;
}


Measured memory_bytes: 3628
r, c = map(int, input().split())
tbl = [[] for _ in range(r)]
cSum = [0 for _ in range(c+1)]

for i in range(r):
  tblS = input()
  tbl[i] = list(map(int, tblS.split()))
  print(tblS, end = '')
  print(' ', sum(tbl[i]), sep = '')

  for j in range(c):
    cSum[j] += tbl[i][j]
  cSum[c] += sum(tbl[i])

print(' '.join(map(str, cSum)))


Measured memory_bytes: 5676
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

a, b = iInM()

if a * b % 2 == 0:
    print('Even')
else:
    print('Odd')

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

namespace AtCoderAGC033
{
    class Program
    {
        static void Main(string[] args)
        {
            var HWN = Console.ReadLine().Split().Select(int.Parse).ToList();
            var Src = Console.ReadLine().Split().Select(int.Parse).ToList();
            var S = Console.ReadLine();
            var T = Console.ReadLine();

            var begin = new long[] { 1, 1 };
            var end = new long[] { HWN[0], HWN[1] };

            var UL = "UL";
            var DR = "DR";
            for (int i = HWN[2] - 1; 0 <= i; --i)
            {
                for (int j = 0; j < 2; ++j)
                {
                    if (UL[j] == T[i] & end[j] < HWN[j])
                    { ++end[j]; }
                    else if (DR[j] == T[i] & 1 < begin[j])
                    { --begin[j]; }
                    if (UL[j] == S[i])
                    { ++begin[j]; }
                    else if (DR[j] == S[i])
                    { --end[j]; }

                    if (end[j] < begin[j] | end[j] < begin[j])
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                }
            }
            if (
                begin[0] <= Src[0] & Src[0] <= end[0] & 
                begin[1] <= Src[1] & Src[1] <= end[1]
                )
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
            return;
        }

   }
}



Measured memory_bytes: 12640
#include<bits/stdc++.h>
using namespace std;
const int N = 4e5+10;
const int st = 2e5+5;
const int mod = 998244353;
long long dp[N];
pair<int,int> rang[10];
long long sum[10];

int main()
{
    int n,i,k,j,l;
    dp[st] = 1;
    cin>>n>>k;
    for(j=0;j<k;j++)
    {
        int l,r;
        cin>>l>>r;
        rang[j] = {l,r};
    }
    for(i=st;i<st+n;i++)
    {
        for(j=0;j<k;j++)
        {
            dp[i]+=sum[j];
            dp[i]%=mod;
        }
        for(j=0;j<k;j++)
        {
            sum[j]-=dp[i-rang[j].second];
            sum[j]+=dp[i-rang[j].first+1];
            sum[j] %=mod;
            sum[j]+=mod;
            sum[j]%=mod;
        }
    }
    cout<<dp[st+n-1];
}



Measured memory_bytes: 5160
#include<bits/stdc++.h>
using namespace std;
int main() {
  int a, b ;
  cin >> a >> b;
  if (a==b) cout << "Draw" << endl;
  else if (a==1) cout << "Alice" << endl;
  else if (b==1) cout << "Bob" << endl;
  else if (a>b) cout << "Alice" << endl;
  else if (b>a) cout << "Bob" << endl;
  return 0;
}

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

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<pii> vpi;

// ---------------------------  TEMPLATE ENDS  -------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9+7;
const int inf = 2e18;
const ld eps = 1e-9;
const int NN = 3e7;


int dp[NN][3];
int a[4], b[4];


void solve(){
      int i = 0, j = 0, k = 0, n = 0, m = 0;
      cin >> n;
      fr(i, 0, 3)  {
            cin >> a[i];
      }
      fr(i, 0, 3)  {
            cin >> b[i];
      }
      
      for(j = 0; j < 3; j++)  {
            for(i = 0; i <= n; i++)  {
                  int &v = dp[i][j];
                  if(j > 0)  {
                        v = dp[i][j-1];
                  } else  {
                        v = i;
                  }
                  
                  if(b[j] - a[j] > 0 and i >= a[j])  {
                        remax(v, dp[i-a[j]][j] + b[j]);
                  }
            }
      }
      int now = dp[n][2];
      memset(dp, 0, sizeof dp);
      for(j = 0; j < 3; j++)  {
            for(i = 0; i <= now; i++)  {
                  int &v = dp[i][j];
                  if(j > 0)  {
                        v = dp[i][j-1];
                  } else  {
                        v = i;
                  }
                  
                  if(a[j] - b[j] > 0 and i >= b[j])  {
                        remax(v, dp[i-b[j]][j] + a[j]);
                  }
            }
      }
      cout << dp[now][2] << endl;      
}

int32_t main(){
#ifndef TRACE
      ios::sync_with_stdio(false); cin.tie(0); 
#endif
      int T = 1, tc;
      for(tc = 1; tc <= T; tc++){
            solve();
      }
      return 0;
}













Measured memory_bytes: 703488
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<set>
#include<map>
#include<ctime>
#include<iostream>
using namespace std;
typedef long long LL;
char A[3];
int main()
{
	while( ~scanf(" %s",A) ){
		map< char , int > Q;
		for( int i = 0 ; i < 3 ; i++ ){
			Q[A[i]]++;
		}
		int flag = 0;
		for( char i = 'a' ; i <= 'c' ; i++ ){
			if( Q[i] == 1 )
				flag += 1;
		}
		if( flag == 3)
			printf("Yes\n");
			else
				printf("No\n");
			Q.clear();
	}
}

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

typedef long long int ll;
typedef pair<ll,ll> P;
//cout<<fixed<<setprecision(15);

int main(){
    string s,t;
    cin>>s>>t;
    int count=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    int n, x, y;
    cin >> n >> x >> y;
    --x;
    --y;
    vector<int> ans(n);
    repi(sv, n, 0)
    {
        vector<int> dist(n, INF);
        queue<int> q;
        auto push = [&](int v, int d) {
            if (dist[v] != INF)
                return;
            dist[v] = d;
            q.push(v);
        };
        push(sv, 0);//最初の頂点
        while (!q.empty())
        {
            int v = q.front();
            q.pop();
            int d = dist[v];
            if (v - 1 >= 0)//隣の頂点
                push(v - 1, d + 1);
            if (v + 1 < n)//隣の頂点
                push(v + 1, d + 1);
            if (v == x)//特別な頂点
                push(y, d + 1);
            if (v == y)
                push(x, d + 1);
        }
        repi(i, n, 0) ans[dist[i]]++;
    }
    repi(i, n, 0) ans[i] /= 2;
    repi(i, n, 1)
    {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#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;

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

	int a, b;
	cin >> a >> b;
	if (a >= 13) cout << b << endl;
	else if (a >= 6) cout << b / 2 << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n=0,y=0;
  int i=0,j=0;
  int a=-1,b=-1,c=-1;
  int sen=0,gosen=0,man=0;
  scanf("%d %d",&n,&y);
  for(man=0;man<=n;man++){
    for(gosen=0;man+gosen<=n;gosen++){
      sen=n-gosen-man;
      if(man*10000+gosen*5000+sen*1000==y)
      {
        a=man;
        b=gosen;
        c=sen;
      }
    }
  }
  printf("%d %d %d",a,b,c);
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; 
const int N = 1e5+10, mod = 2e9+10;

void solve() {
    int a, b, c, k; cin >> a >> b >> c >> k;
    
    if (a > k) {
        cout << k << endl;
    } else if (a + b >= k) {
        cout << a << endl;
    } else {
        cout << a - (k - a - b) << endl;
    }

}

int main(void) {
    int t = 1; 
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 3632
x, y = map(int, input().split())
ans = 0
m = [0, 300000, 200000, 100000]
if 1 <= x <= 3:
  ans += m[x]
if 1 <= y <= 3:
  ans += m[y]
if x == y == 1:
  ans += 400000
print(ans)

Measured memory_bytes: 9008
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1000000009;
const int N = (int)100002;
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int weight[105],value[105],dp[105][N],n,w;
int solve(int idx , int v){
    if(idx==n&&v==0)return 0;
    
    if(idx==n||v<0)return OO;
    
    int &ret = dp[idx][v];
    if(~ret)return ret;
    ret = solve(idx + 1 , v);
    ret = min(ret , solve(idx + 1 , v - value[idx]) + weight[idx]);
    return ret;
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int sum =0;
    scanf("%d %d",&n,&w);
    for(int i=0; i<n; ++i)
        scanf("%d %d", &weight[i], &value[i]),sum+=value[i];
    memset(dp,-1,sizeof(dp));
    for(int i=sum;i>=1;i--){
        if(solve(0,i)<=w){
            printf("%d",i);
            return 0;
        }
    }
    
    return 0;
}


Measured memory_bytes: 41216
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int[] a) {
    auto n = a.length;
    int ans = 0;
    for (int i = 2; i < n; i++) {
        auto p = [a[i-2], a[i-1], a[i]];
        p.sort();
        if (p[1] == a[i-1]) ans++;
    }
    return ans;
}

void main() {
    readint;
    auto a = readints;
    writeln(calc(a));
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

const int limit = 60 * 24 * 7;  // 開始時は0〜limit分の決め方がある
int s, n, t, p, m;
string weekday, my_time;
const string week[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};

bool InLenge(int time)
{
    int w = time % (7 * 24 * 60);
    int h = time % (24 * 60);
    bool res = false;

    if (weekday == "All")
        res = true;
    else {
        for (int i = 0; i < 7; ++i)
            if (weekday == week[i]) {
                if (i * 24 * 60 <= w && w < (i + 1) * 24 * 60)
                    res = true;
                break;
            }
    }
    if (!res)
        return false;

    res = false;
    if (my_time == "All")
        res = true;
    else if (my_time == "Day" && 6 * 60 <= h && h < 18 * 60)
        res = true;
    if (my_time == "Night" && ((0 <= h && h < 6 * 60) || (18 * 60 <= h && h < 24 * 60)))
        res = true;

    return res;
}

int Count(int st)
{
    int res = 0;
    for (int i = 0; i < m; ++i) {
        if (InLenge(st) && InLenge(st + s)) {
            ++res;
        }
        st += t;
    }
    return res;
}

int main()
{
    while (true) {
        // Input
        cin >> s >> n >> t >> weekday >> my_time >> p >> m;
        if (s == 0 && n == 0 && t == 0 && p == 0 && m == 0 &&
            weekday == "None" && my_time == "None")
            break;

        int max_cnt = 0;
        for (int i = 0; i < limit; ++i)
            max_cnt = max(max_cnt, Count(i));

        printf("%.10f\n", 1.0 - pow(1.0 - 1.0 / p, n * max_cnt));
    }

    return 0;
}

Measured memory_bytes: 1308
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define REP(i,n) for (int (i); i < (n); i++)

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = min(a, b); i; i--) {
		if (a % i == 0 && b % i == 0) {
			k--;
			if (k == 0) {
				cout << i << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
void dfs(ll in, ll x, ll a, ll b, ll c, ll &ans)
{
    if (x > in)
    {
        return;
    }
    if (a && b && c)
    {
        ans++;
    }
    dfs(in, 10 * x + 3, 1, b, c, ans);
    dfs(in, 10 * x + 5, a, 1, c, ans);
    dfs(in, 10 * x + 7, a, b, 1, ans);
}
int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    dfs(n, 0, 0, 0, 0, ans);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long llint;
#define inf 1e18

llint n,i;
void solve(){
	cin >> n >> i;
	cout << n-i+1 << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int k,x;
  cin>>k>>x;
  for(int i=0;i<2*k-1;i++){
    if(i)cout<<" ";
    cout<<i+x-k+1;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){

  int L,A,B,C,D,c;
  c = 0;
  scanf("%d%d%d%d%d",&L,&A,&B,&C,&D);

 while(A > 0 || B > 0){
   A -= C;
   B -= D;
   c ++;
   }

 printf("%d\n",L - c);
 return 0;
}






Measured memory_bytes: 2036
using System;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Text;

namespace Fish.aizu
{
	public static class AizuOnlineJudge
	{
		public static int[] SplitToInts(string line)
		{
			return line.Split(' ').Select(x => int.Parse(x)).ToArray();
		}
		public static double[] SplitToDoubles(string line)
		{
			return line.Split(' ').Select(x => double.Parse(x)).ToArray();
		}
		public static long[] SplitToLongs(string line)
		{
			return line.Split(' ').Select(x => long.Parse(x)).ToArray();
		}
		public static int Main()
		{
			Compute(Console.In, Console.Out);
			return 0;
		}
		
		public static void Compute(TextReader reader, TextWriter writer)
		{
			// 複数の行にまたがる１つの英文が与えられます。 
			string line = null;
			var table = new int[26];
			while (null != (line = reader.ReadLine()))
			{
				foreach (var c in line.ToLower())
				{
					var index = c - 'a';
					if (index >= 0 && index < 26)
					{
						table[c - 'a']++;
					}
				}
			}
			for (int i = 0; i < table.Length; i++)
			{
				writer.Write((char)(i + 'a'));
				writer.Write(" : ");
				writer.WriteLine(table[i]);
			}
		}
	}
}

Measured memory_bytes: 5656
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::collections::HashMap;

fn main() {
    let n = get!(usize);
    let mut map = HashMap::new();
    for _ in 0..n {
        let a = get!(i32);
        let e = map.entry(a).or_insert(0);
        *e += 1;
    }
    let mut r = 0;
    for n in map.values() {
        if n%2 == 1 { r += 1; }
    }
    println!("{}", r);
}

Measured memory_bytes: 3836
#!usr/bin/env python3
from collections import defaultdict

def main():
    fl = input().split(" ")
    V = int(fl[0])
    E = int(fl[1])
    R = int(fl[2])
    #Adjacency list
    G = defaultdict(dict)
    for i in range(int(E)):
        s, t, w = [int(x) for x in input().split(" ")]
        G[s][t] = w
    #initialized
    d = {}
    INF = float('inf')
    #INF = 10001
    for i in range(V):
        d[i] = INF
    d[R] = 0
    q = [R]
    while q:
        u = q.pop(0)
        for v in G[u].keys():
            if d[v] > d[u] + G[u][v]:
                d[v] = d[u] + G[u][v]
                q.append(v)

    for k in range(V):
        if d[k] == float('inf'):
            
            print("INF")
        else:
            print(d[k])



if __name__ == '__main__':
    main()

Measured memory_bytes: 98980
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main()
{
	int n, x = 0, y = 0, t = 0;
	cin >> n;
	bool flag = true;
	for(int i = 0; i < n; i++)
	{
		int ti, xi, yi;
		cin >> ti >> xi >> yi;
		int dt = ti - t;
		int dx = abs(xi - x);
		int dy = abs(yi - y);
		if (dx + dy > dt)
		flag = false;
		else if (dx > dy)
		{
			int r = dt - dx;
			if((r - dy) % 2 == 1)
				flag = false;
		}
		else
		{
			int r = dt - dy;
			if((r - dx) % 2 == 1)
				flag = false;
		}
		t = ti;
		x = xi;
		y = yi;
	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n, t, a, b, ans = 1010;
  cin >> n >> t;
  rep(i,n)
  {
    cin >> a >> b;
    if (b <= t)
      ans = min(ans, a);
  }
  if (ans > 1000) {
    cout << "TLE";
  } else {
    cout << ans;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int w,n;
int a[31];
int x,y;
int k;

int main(){
	for(int i=1;i<31;i++){
		a[i]=i;
	}
	scanf("%d %d",&w,&n);
	for(int i=1;i<=n;i++){
		scanf("%d,%d",&x,&y);
		k=a[x];
		a[x]=a[y];
		a[y]=k;
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 2724