akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

void dfs(int n, char m, string str) {
  if (n == str.size()) {
    cout << str << "\n";
    return;
  } else {
    for (char ch = 'a'; ch <= m; ++ch) {
      dfs(n, (ch == m) ? m+1 : m, str + ch);
    }
  }
}

int main() {
  int n;
  cin >> n;
  dfs(n, 'a', "");
}


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

struct stack{
public:
    int top;
    int stk[10000];

    void reset(){
        top = 0;
    }
    void push(int x){
        top++;
        stk[top] = x;
    }
    int pop(){
        top--;
        return stk[top + 1];
    } 
};

int main(){
    string in;
    stack stack;
    stack.reset();
    while(true){
            cin >> in;
            if(cin.eof())
                break;
            else if(in == "+"){
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a + b);
            }
            else if(in == "*"){
                int a = stack.pop();
                int b = stack.pop();
                stack.push(a * b);
            }
            else if(in == "-"){
                int a = stack.pop();
                int b = stack.pop();
                stack.push(b - a);
            }
            else{
                stack.push(atoi(in.c_str()));
            }
    }
    cout << stack.pop() << endl;
}


Measured memory_bytes: 3196
#include<iostream>
#include<queue>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#include<string>// 加法 S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
#include<cmath>//三角関数,rad
#include<algorithm>//__gcd()　lower_bound(a+l,a+r,x)-a でindex
// vector -> min/max({vector}) 
// 配列   -> *min_element(a+l,a+r)  *忘れず lとrで[l,r) 
//reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(S.begin(),S.end())
//sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
//vectorならv.begin(),v.end()
#include<ctime>//"clock()/CLOCKS_PER_SEC で秒数
#include<vector>//v.push_back(x),v.pop_back()
#include<queue>//q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
#include<functional>//vector,queueと併用でpriority_queue
//宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
// pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに
using namespace std;
typedef pair<int,int> P;
const int inf = 10e7;
#define Maxw 1000
#define Maxh 1000
int h,w;


bool flag=0;
int dx[2]={0,1};
int dy[2]={1,0};

int main(){
  int step[Maxh][Maxw];char maze[Maxh][Maxw];
  cin>>h>>w;
  string s;
for (int i=0;i<h+2;i++){
    for (int j=0;j<w+2;j++){
    step[i][j]=inf;}
  }step[1][1]=0;
  for (int i=0;i<w+2;i++){maze[0][i]='!';maze[h+1][i]='!';}
  for (int i=0;i<h+2;i++){maze[i][0]='!';maze[i][w+1]='!';}
  for (int H=1;H<h+1;H++){cin>>s;rep(j,w){maze[H][j+1]=s[j];}maze[H][0]='!';maze[H][w+1]='!';}
rep(i,h){
  rep(j,w){
    rep(k,2){if (maze[i+1+dx[k]][j+1+dy[k]]!='!'){
      step[i+1+dx[k]][j+1+dy[k]]=min(step[i+1+dx[k]][j+1+dy[k]],step[i+1][j+1]+(maze[i+1+dx[k]][j+1+dy[k]]=='#'&&maze[i+1][j+1]=='.'? 1:0));}}}}
int ans=0;if (maze[1][1]=='#')ans++;

  cout<<step[h][w]+ans<<endl;
}


Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;



set<P>st;
int x[55], y[55];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	REP(i, N) {
		cin >> x[i] >> y[i];
		st.insert({ x[i],y[i] });
	}
	//一個目
	int cnt = 0;
	REP(i, N) {
		//二個目
		REP(j, N) {
			if (i == j)continue;
			int res = 0;
			int p = x[j] - x[i];
			int q = y[j] - y[i];
			REP(k, N-1) {
				FOR(l, k + 1, N) {
					int dx = x[l] - x[k], dy = y[l] - y[k];
					if ((dx == p && dy == q) || (dx == -p && dy == -q))res++;
				}
			}
			cnt = max(cnt, res);
		}
	}
	print(N - cnt);
}


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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

#define dodebug(i, n, arr)	for(int i=0;i<n;++i)	cout<<arr[i]<<" ("<<i<<")\n";

ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

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

	int n, k;
	cin>>n>>k;
	vector<bool> dp(k+1, false);//true if the person whose chance it is can win.
	vector<int> stones(n, 0);
	for(auto &i:stones)	cin>>i;

	for(int i=0;i<=k;++i){
		for(auto x:stones){
			if(i >= x && !dp[i-x]){
				//if dp[i-x] is false that means if i play a chance and pass it to the other person
				//he loses and i win, therefore dp[i] is true, and vice versa
				dp[i] = true;
			}
		}
	}
	
	cout<<(dp[k]?"First":"Second")<<"\n";

	return 0;
}

Measured memory_bytes: 3628
def f(x):
    return 10 ** (ord(x) - ord('a') + 1)


import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


from collections import Counter

N = int(input())
counter = Counter()
for i in range(N):
    counter[sum([f(i) for i in input()])] += 1
res = 0
for v in counter.values():
    if v > 1:
        res += combinations_count(v, 2)
print(res)

Measured memory_bytes: 74200
#include <iostream>

using namespace std;

int main() {
    long long int W, H, x, y;
    cin >> W >> H >> x >> y;
    
    if((double)x==(double)W/2 && (double)y==(double)H/2) {
        cout << (double)W*H/2 << " " << '1' << endl;
    } else {
        cout << (double)W*H/2 << " " << '0' << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	int sol = n * (n+1) / 2;
	cout << sol << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(ll i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
}
const int mxN=int(1e7)+1;
int spf[mxN]; 
void sieve() 
{ 
    spf[1]=1; 
    loop(i,2,mxN)
    {
        spf[i]=i; 
    }
    for(int i=4; i<mxN; i+=2) 
    {
        spf[i]=2; 
    }
    for(int i=3; (i*i)<mxN; i++) 
    { 
        if(spf[i]==i) 
        {  
            for(int j=i*i; j<mxN; j+=i) 
            {
                if(spf[j]==j)
                { 
                    spf[j]=i; 
                }
            }
        } 
    } 
} 
ll divs(int x)
{
    ll res=1LL;
    unordered_map<int,int> countt;
    while(x!=1) 
    { 
        countt[spf[x]]++;
        x/=spf[x]; 
    } 
    for(auto y:countt)
    {
        res*=((ll)y.second+1LL);
    }
    return res;
}
int main()
{
    vok();
    sieve();
    int n;
    IN n;
    ll ans=0LL;
    loop(i,1,n+1)
    {
      	ll temp=divs(i);
        ll add=(ll)(i)*temp;
        ans+=add;
    }
    OUT ans<<endl
    return 0;
}

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

int main(){
    ll n,a,b,ans=0;
    cin>>n>>a>>b;
    ans+=n/(a+b)*a;
    n=n%(a+b);
    if(n<=a) ans+=n;
    else ans+=a;
    cout<<ans;
}

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

int main(void)
{
  int n,s;
  string str;

  cin >> n;

  getline(cin, str);

  for(int i = 0 ; i < n ; i++)
    {
      getline(cin, str);
      s = str.size();
      
      for(int i = 0 ; i < s ; i++)
	{
	  if(str[i] == 'H' && str[i+1] == 'o' && str[i+2] == 's' &&
	     str[i+3] == 'h' && str[i+4] == 'i' && str[i+5] == 'n' &&
	     str[i+6] == 'o')
	    {
	      str[i+6]='a';
	    }
        }
      cout << str << endl;
    }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	static class Engine {
		int x, y;

		public Engine(int x, int y) {
			this.x = x;
			this.y = y;
		}
		
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		Engine[] engine = new Engine[N];
		for(int i=0; i<N; i++) {
			engine[i] = new Engine(sc.nextInt(), sc.nextInt());
		}
		
		Arrays.sort(engine, new Comparator<Engine>() {
			public int compare(Engine e1, Engine e2) {
				if(e1.x==0) {
					if(e1.y>=0) {
						return -1;
					} else {
						return (e2.x==0 && e2.y>=0)||e2.x<0 ? 1 : -1;
					}
				}
				if(e2.x==0) {
					if(e2.y>=0) {
						return 1;
					} else {
						return (e1.x==0 && e1.y>=0)||e1.x<0 ? -1 : 1;
					}
				}
				if(e1.x<0 && e2.x>0) {
					return -1;
				}
				if(e1.x>0 && e2.x<0) {
					return 1;
				}
				return Long.compare((long)e2.x*e1.y, (long)e1.x*e2.y);
			}
		});
		
		double max = 0;
		for(int i=0; i<N; i++) {
			long x = 0;
			long y = 0;
			for(int j=0; j<N; j++) {
				x += engine[(i+j)%N].x;
				y += engine[(i+j)%N].y;
				max = Math.max(max, Math.sqrt(x*x+y*y));
			}
		}
		
		System.out.println(max);
		sc.close();
	}
	
}

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

int main()
{
    int a[5],n,i,j,p,ma=-1;
    for(i=0;i<3;i++)
        scanf("%d",&a[i]);
    scanf("%d",&n);

    for(i=0;i<3;i++)
    {
        p=n;
        int sum=0,b[5];
        while(p)
        {
            for(j=0;j<3;j++)
            {
                if(i==j && p==n)
                    b[j]=a[j]*2;
                else if(i==j && p!=n)
                    b[j]=b[j]*2;
                else
                    b[j]=a[j];
            }
            p--;
        }
        for(j=0;j<3;j++)
            sum+=b[j];
        if(sum>ma)
            ma=sum;
    }
    printf("%d\n",ma);
}


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

int main()
{
    int W, a, b;
    cin >> W >> a >> b;
    int dist;
    if (a < b)
    {
        dist = b - (a + W);
        if (dist > -W && dist < 0)
        {
            cout << 0 << endl;
        }
        else
        {
            cout << dist << endl;
        }
    }
    else if (a == b)
        cout << 0 << endl;
    else
    {
        dist = a - (b + W);
        if (dist > -W && dist < 0)
        {
            cout << 0 << endl;
        }
        else
        {
            cout << dist << endl;
        }
    }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
  int n,k;cin >> n >> k;
  vector<int>a(n);for(int i=0;i<n;i++)cin >> a[i];
  sort(a.begin(),a.end());
  vector<int> b;
  b.push_back(0);
  for(int i=0;i<a.size()-1;i++)if(a[i]!=a[i+1])b.push_back(i+1);
  b.push_back(n);
  vector<int>c;
  for(int i=0;i<b.size()-1;i++)c.push_back(b[i+1]-b[i]);
  sort(c.begin(),c.end());
  int ans=0,cnt=0,i=0;
  while(c.size()-i-1>=k){
    ans+=c[i];i++;}
  cout << ans;
}


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

using namespace std;

int main()
{
    int n, l; cin>>n>>l;
    vector<string> v(n);
    for(int i=0; i<n; i++) cin>>v[i];
    sort(v.begin(), v.end());
    for(auto x:v) cout<<x;
    cout<<"\n";

    return 0;
}

Measured memory_bytes: 256
def resolve():
    n=int(input())
    A=list(map(int,input().split()))

    ans=0
    r=0
    xor=0
    sum=0

    for l in range(n):
        while(r<n and xor^A[r]==sum+A[r]):
            xor^=A[r]
            sum+=A[r]
            r+=1
        if l==r: r+=1 # 起こり得ない
        else:
            ans+=r-l
            xor^=A[l]
            sum-=A[l]
    print(ans)
resolve()

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

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	if (n >= m) {
		cout << 0 << endl;
		return 0;
	}

	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	vector<pair<int, int>> b(m - 1);
	for (int i = 0; i < m - 1; i++) {
		b[i].first = a[i + 1] - a[i];
		b[i].second = i;
	}
	sort(b.rbegin(), b.rend());
	
	vector<int> p;
	for (int i = 0; i < n - 1; i++) {
		p.emplace_back(b[i].second);
	}

	int it = 0;
	int ans = 0;
	for (int i = 0; i < p.size(); i++) {
		ans += a[p[i]] - a[it];
		it = p[i] + 1;
	}
	ans += a[m - 1] - a[it];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#define ll long long

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N-1);

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

    ll ans = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> B[i];
        ans += B[i];
    }
    for (int i = 0; i < N-1; i++)
    {
        cin >> C[i];
    }

    for(int i = 0;i < N;i++){
        if(i > 0 && A[i-1] + 1 == A[i]){
            ans += C[A[i-1] - 1];
        }
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main()　{
	int n;
  	int a[110];
  	cin >> n;
  	for(int i=0; i < n; i++) cin >> a[i];
  	set<int> values;
  	for(int i = 0; i < n; i++) {
		values.insert(a[i]);
    }
  
  	cout << values.size() << endl;
  
}


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

using namespace std;

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<ll>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define pll pair<ll,ll>
#define pii pair<int,int>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

int main(){
    string s;
    cin>>s;
    int n=s.size(),ans=0,scount=0,tcount=0;
    stack<char> stk;
    pan(i,n){
        if(s[i]=='S'){
            stk.push(s[i]);
        }
        else if(s[i]=='T'){
            if(!stk.empty()){
                if(stk.top()=='S') stk.pop();
                else if(stk.top()=='T') stk.push(s[i]);
            }
            else stk.push(s[i]);
        }
    }
    cout<<stk.size();
}


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

using namespace std;

static const int INF = 1e9 + 7;

void hawawa()
{
  int n;
  cin >> n;
  vector<long long> a(n);
  for (auto&& i : a) {
    cin >> i;
  }
  sort(begin(a), end(a));
  long long now = 0;
  int ans = 0;
  for (int i = 0; i + 1 < n; i++) {
    now += a[i];
    if (now * 2 < a[i + 1]) ans = 0;
    else ans++;
  }
  ans++;
  cout << ans << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
}

Measured memory_bytes: 1024
import java.lang.Math.max

data class Node(var parentNodeNum: Int = -1, var sibling: Int = -1, var degree: Int = 0, var depth: Int = 0, var height: Int = 0,
                var nodeType: NodeType = NodeType.ROOT, var left: Pair<Int, Node>? = null, var right: Pair<Int, Node>? = null)
enum class NodeType {
    ROOT {
        override fun toString() = "root"
    },
    INTERNAL_NODE {
        override fun toString() = "internal node"
    },
    LEAF {
        override fun toString() = "leaf"
    }
}

fun main(args: Array<String>) {
    val inputList = List(readLine()?.toInt() ?: return) {
        readLine()?.split(" ".toRegex())?.map(String::toInt) ?: listOf()
    }
    val nodeMap = mutableMapOf<Int, Node>()
    inputList.forEach { input ->
        val nodeNum = input[0]
        nodeMap.putIfAbsent(nodeNum, Node())
        nodeMap[nodeNum]?.let { node ->
            if (input[1] != -1) {
                val leftNum = input[1]
                nodeMap.putIfAbsent(leftNum, Node())
                node.left = leftNum to nodeMap[leftNum]!!
                nodeMap[leftNum]?.parentNodeNum = nodeNum
                node.degree++
            }
            if (input[2] != -1) {
                val rightNum = input[2]
                nodeMap.putIfAbsent(rightNum, Node())
                node.right = rightNum to nodeMap[rightNum]!!
                nodeMap[rightNum]?.parentNodeNum = nodeNum
                node.degree++
            }
            node.left?.second?.sibling = node.right?.first ?: -1
            node.right?.second?.sibling = node.left?.first ?: -1
        }
    }
    recDepth(nodeMap.values.first { it.parentNodeNum == -1 }, 0)
    val stringBuilder = StringBuilder()
    for (i in inputList.indices) {
        nodeMap[i]?.let { node ->
            stringBuilder.append("node $i: parent = ${node.parentNodeNum}, sibling = ${node.sibling}, degree = ${node.degree}, depth = ${node.depth}, height = ${node.height}, ${node.nodeType}\n")
        }
    }
    print(stringBuilder.toString())
}

fun recDepth(node: Node, depth: Int): Int {
    node.depth = depth
    when {
        node.parentNodeNum == -1 -> node.nodeType = NodeType.ROOT
        node.right == null && node.left == null -> node.nodeType = NodeType.LEAF
        else -> node.nodeType = NodeType.INTERNAL_NODE
    }
    val leftHeight = if (node.left != null) {
        recDepth(node.left!!.second, depth + 1)
    } else {
        0
    }
    val rightHeight = if (node.right != null) {
        recDepth(node.right!!.second, depth + 1)
    } else {
        0
    }
    node.height = max(leftHeight, rightHeight)
    return node.height + 1
}


Measured memory_bytes: 29776
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 1000000;
ll mod = INF;


int main(){
    string s;
    cin >> s;
    
    int cnt=0;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]=='R'){
            cnt++;ans=max(ans,cnt);
        }else {cnt=0;}
    }

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

Measured memory_bytes: 3620
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	cout << "Christmas";
	for(int i=0; i<25-n; i++){
		cout << " Eve";
	}
	cout << endl;
	return 0;
}

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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

const int Nmax=310;
char buf[Nmax][Nmax];

signed main(){
	int n=read();
	REP(i,n)
		scanf("%s",buf[i]);
	int ans=0;
	REP(k,n){
		bool ok=true;
		REP(i,n)REP(j,n)
			if(buf[i][(j+k)%n]!=buf[j][(i+k)%n])
				ok=false;
		if(ok)ans+=n;
	}
	print(ans);
}


Measured memory_bytes: 384
def A():
    HW = input().split()
    H = int(HW[0])
    W = int(HW[1])
    hw = input().split()
    h = int(hw[0])
    w = int(hw[1])
    print( (H-h) * (W-w) )
    return 

if __name__ == '__main__':
    A()

Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
	int a, b, c,sum=0;
	char s[4];
	scanf("%s", &s);


	
		if (s[1]=='B') {
			printf("ARC");
			return 0;
	}
		else
	printf("ABC");

	return 0;
}

Measured memory_bytes: 1732
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    RA = readInts()
    ans = 0
    for i in range(n):
        if RA[RA[i]-1] == i+1:
            ans += 1
    print(ans//2)
if __name__ == '__main__':
  main()


Measured memory_bytes: 17564
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    if(n%2==0) {
        cout << 0.5000000 << endl;
    }
    else {
        double a = n-n/2;
        cout << setprecision(12) << a/n << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import Control.Monad

main :: IO ()
main = do
  _ <- getLine
  a <- reverse . map read . words <$> getLine
  let ans = foldl po (Just (2, 2)) a
  putStrLn $ case ans of
    Nothing       -> "-1"
    Just (mi, ma) -> unwords $ map show [mi, ma]

po :: Maybe (Int, Int) -> Int -> Maybe (Int, Int)
po range x = do
  (mi, ma) <- range
  guard $ ma >= x
  guard $ mi <= ((ma `div` x) * x)
  return ((mi - 1) `div` x * x + x, ma `div` x * x + x - 1)

Measured memory_bytes: 62844
from collections import deque, Counter


def bfs():
    dist = [[float("inf")] * W for i in range(H)]
    dist[Sy][Sx] = 0

    dx = [0, 1, 0, -1]
    dy = [1, 0, -1, 0]

    que = deque([])
    que.append((Sy, Sx))

    while que:
        p = que.popleft()
        y = p[0]
        x = p[1]

        if y == Gy and x == Gx:
            break

        for i in range(4):
            ny = y + dy[i]
            nx = x + dx[i]

            if 0 <= ny < H and 0 <= nx < W and Map[ny][nx] != "#" and dist[ny][nx] == float("inf"):
                dist[ny][nx] = dist[y][x] + 1
                que.append((ny, nx))

    return dist


# Input params and answer
H, W = map(int, input().split())
Map = [list(input()) for i in range(H)]

# Start and Goal
Sy, Sx = 0, 0
Gy, Gx = H - 1, W - 1

# Count #
sharp = 0
for l in Map:
    for s in l:
        if s == "#":
            sharp += 1

# BFS
dist = bfs()

# Can't reach goal
if dist[Gy][Gx] == float("inf"):
    print(-1)
    exit()

# 1 dim array
c = []
for l in dist:
    c += l

ans = H * W - (sharp + dist[Gy][Gx] + 1)

print(ans)


Measured memory_bytes: 3436
import math
import itertools

n = int(input())
route = list(range(n))

town = []
for _ in range(n):
    x, y = map(int, input().split())
    town.append([x, y])

distance = 0
for r in itertools.permutations(route):
    for i in range(n-1):
        distance += math.sqrt((town[r[i]][0] - town[r[i+1]][0])
                              ** 2 + (town[r[i]][1] - town[r[i+1]][1])**2)

print(distance/math.factorial(n))

Measured memory_bytes: 3188
let print str a b =
  String.sub str a (b-a+1) |> print_endline;;
let replace str a b p=
  String.mapi (fun i x -> if a <= i && b >= i then p.[i-a] else x ) str;;
let reverse str a b =
  String.mapi (fun i x -> if a <= i && b >= i then str.[a+b-i] else x) str;;

let split = Str.split (Str.regexp_string " ");;
let () =
  let s = read_line () and
      n = read_int () in
  let rec loop str = function
      0 -> ()
    | i -> let c = read_line () |> split |> Array.of_list in
           let (a,b) = (int_of_string c.(1),int_of_string c.(2)) in
           let result =
             if c.(0) = "replace" then
               replace str a b c.(3)
             else if c.(0) = "reverse" then
               reverse str a b
             else begin
                 print str a b; str
               end
           in loop result (i-1)
  in loop s n;;

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

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

int main(void)
{
    ll n,m; cin>>n>>m;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    rep(i,m){
        if(4*m * a[i]<sum){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3608
fun main(args: Array<String>) {
    var (n, x, y)= readLine()!!.split(' ').map{ it.toInt()}
    var dist=Array(n){0}.toMutableList()
    for(i in 1..n){
        for (j in 1 until i){
            dist[Math.min(Math.abs(j-i), Math.min(Math.abs(x-i) +1+ Math.abs(y-j), Math.abs(y-i) +1+ Math.abs(x-j)))]++
        }
    }
    for(i in 1 until n){
        println(dist[i])
    }
}

Measured memory_bytes: 43252
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set> 

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    multiset<int> st;
    vint a(n);
    REP(i,n){
        cin >> a[i];
    }
    st.insert(a[0]);
    for(int i=1;i<n;i++){
        auto itr1 = st.lower_bound(a[i]);
        if(itr1==st.end()){
            auto itr2 = st.end();
            itr2--;
            st.erase(itr2);
            st.insert(a[i]);
        }else if(itr1==st.begin()){
            st.insert(a[i]);
        }else{
            itr1--;
            st.erase(itr1);
            st.insert(a[i]);
        }
    }
    
    cout << st.size() << endl;

    return 0;
}

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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N / 1000;
  b = N % 1000 / 100;
  d = N % 10;
  c = N % 100 / 10;
  if ((a == b && b == c) || (b == c && c == d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
typedef long long ll;
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n;
	ll c, k;
	cin >> n >> c >> k;
	vector<ll> t(n);
	for (int i = 0; i < n; i++)
	{
		cin >> t[i];
	}
	sort(t.begin(), t.end());
	ll bus = 1;
	ll member = 1;
	ll startTime = 0;
	for (int i = 1; i < n; i++)
	{
		if (t[i] - startTime > k) {
			bus++;
			member = 0;
		}
		if (member == c) {
			bus++;
			member = 0;
		}
		if (member == 0) {
			startTime = t[i];
		}
		member++;
	}
	cout << bus << endl;
}

Measured memory_bytes: 1024
// copied
#include <cstdio>
#include <algorithm>
#include <cstdlib>

using namespace std;

const int maxn=2e5+1e2;
#define LL long long

int a[maxn];

int getint()
{
	char ch;int b=1;
	for(ch=getchar();ch>'9'||ch<'0';ch=getchar())if(ch=='-')b=-1;
	int num=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar())num=num*10+ch-'0';
	return num*b;
}

int main()
{
	int n=getint();
	LL sum=0;
	for(int i=1;i<=n;i++){a[i]=getint();sum+=a[i];}
	LL re=0,ans=1e17;
	for(int i=1;i<n;i++)
	{
		re+=a[i];
		ans=min(ans,abs(sum-re-re));
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2380
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
int n, top, a[N];
struct node {int v, c;} sta[N];
void insert(int v, int x) {
	while(sta[top].v > v) top --;
	if(sta[top].v == v) sta[top].c ++;
	else sta[++ top] = (node){v, 1};
	if(top > 1 && sta[top].c == x) top --, insert(v - 1, x);
}
int check(int x) {
	sta[top = 1] = (node){0, 0};
	for(int i = 2; i <= n; ++ i) if(a[i] <= a[i - 1]) insert(a[i], x);
	return sta[1].c == 0;
}
signed main() {
	n = read();
	for(int i = 1; i <= n; ++ i) a[i] = read();
	int cnt = 0;
	for(int i = 2; i <= n; ++ i) cnt += a[i] > a[i - 1];
	if(cnt == n - 1) return puts("1"), 0;
	int l = 2, r = n, mid, ans;
	while(l <= r) {
		mid = (l + r) >> 1;
		if(check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	printf("%lld\n", ans);
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)
  
  ll H, W;
  IN(H,W);
  vvll a(H,vll(W,0));
  REP(i,H) REP(j,W) IN(a[i][j]);

  vll y, x, y_, x_;
  REP(i,H){
    if(i%2==0){
      REP(j,W-1){
        if(a[i][j]%2==0) continue;
        y.pb(i);
        x.pb(j);
        y_.pb(i);
        x_.pb(j+1);
        a[i][j]--;
        a[i][j+1]++;
      }
      if(a[i][W-1]%2==0) continue;
      if(i>=H-1) continue;
      y.pb(i);
      x.pb(W-1);
      y_.pb(i+1);
      x_.pb(W-1);
      a[i][W-1]--;
      a[i+1][W-1]++;
    }else{
      for(ll j=W-1; j>0; --j){
        if(a[i][j]%2==0) continue;
        y.pb(i);
        x.pb(j);
        y_.pb(i);
        x_.pb(j-1);
        a[i][j]--;
        a[i][j-1]++;
      }
      if(a[i][0]%2==0) continue;
      if(i>=H-1) continue;
      y.pb(i);
      x.pb(0);
      y_.pb(i+1);
      x_.pb(0);
      a[i][0]--;
      a[i+1][0]++;
    }
  }

  printf("%lu\n", y.size());
  REP(i,y.size()){
    printf("%lld %lld %lld %lld\n", y[i]+1, x[i]+1, y_[i]+1, x_[i]+1);
  }

  return 0;
}

Measured memory_bytes: 8148
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>

typedef struct {
    uint64_t *a;
} Heap;

Heap *heap_init(uint64_t size)
{
    Heap *h = malloc(sizeof(Heap));
    h->a = malloc(sizeof(uint64_t) * (size+1));
    h->a[0] = 1;
    return h;
}

void heap_term(Heap *h)
{
    free(h->a);
    free(h);
}

void mheap_add(Heap *h, uint64_t x)
{
    h->a[h->a[0]] = x;

    for(uint64_t i=h->a[0]; i!=1; i=i>>1){
        if(h->a[i] <= h->a[i>>1]){
            break;
        }
        uint64_t tmp = h->a[i>>1];
        h->a[i>>1] = h->a[i];
        h->a[i] = tmp;
    }

    h->a[0] += 1;
}

uint64_t mheap_pop(Heap *h)
{
    uint64_t res = h->a[1];

    if(h->a[0]!=1){
        h->a[1] = h->a[h->a[0]-1];
        h->a[0] -= 1;
        uint64_t ci;
        for(uint64_t i=1;;){
            if((i<<1) + 1 < h->a[0]){
                uint64_t mc = h->a[i<<1] > h->a[(i<<1)+1] ? h->a[i<<1] : h->a[(i<<1)+1];
                uint64_t mi = h->a[i<<1] > h->a[(i<<1)+1] ? i<<1 : (i<<1)+1;
                if(mc <= h->a[i]){
                    break;
                } else {
                    ci = mi;
                }
            } else if((i<<1)+1 == h->a[0]){
                if(h->a[i<<1] <= h->a[i]){
                    break;
                } else {
                    ci = i<<1;
                }
            } else {
                break;
            }
            uint64_t tmp = h->a[ci];
            h->a[ci] = h->a[i];
            h->a[i] = tmp;
            i = ci;
        }
    }
    return res;
}

typedef Heap PQueue;
PQueue *pqueue_init(uint64_t size)
{
    return heap_init(size);
}

void pqueue_term(PQueue *pq)
{
    heap_term(pq);
}

void pqueue_add(PQueue *pq, uint64_t x)
{
    mheap_add(pq, x);
}

uint64_t pqueue_pop(PQueue *pq)
{
    return mheap_pop(pq);
}

int main()
{
    int N, M;
    scanf("%d%d\n", &N, &M);
    PQueue *pq = pqueue_init(N);
    for(int ni=0; ni<N; ni++){
        uint64_t A;
        scanf("%"PRIu64, &A);
        pqueue_add(pq, A);
    }
    for(int mi=0; mi<M; mi++){
        uint64_t mp = pqueue_pop(pq);
        pqueue_add(pq, mp/2);
    }

    uint64_t res = 0;
    for(int ni=0; ni<N; ni++){
        res += pqueue_pop(pq);
    }
    printf("%"PRIu64"\n", res);

    return 0;
}


Measured memory_bytes: 896
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, i;
	int a[100001];
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", a+i);
	}
	a[n]=0;
	qsort(a, n, 4, comp);
	int ans=0, now=1;
	for(i=0; i<n; i++){
		if(a[i]==a[i+1]){
			now++;
		}else{
			if(now>=a[i]){
				ans+=now-a[i];
			}else{
				ans+=now;
			}
			now=1;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

void solve()
{
	string s;
	cin>>s;
	rep(i,0,s.size())
	cout<<'x';	
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"
#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"

ll min(ll x,ll y){return (x<y ? x:y);}
ll max(ll x,ll y){return (x>y ? x:y);}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}


int main(){
  ll N,M; cin>>N>>M;
  ll k[M];
  ll p[M];
  vector<ll> v[M];
  
  REP(i,M){
    cin >> k[i];
    REP(j,k[i]){
      ll s;
      cin >> s;
      --s;
      v[i].push_back(s);
    }
  }
  REP(i,M){
    cin >> p[i];
  }
  
  ll count = 0;
  for(ll tane=0;tane<pow(2,N);tane++){
    ll temp = tane;
    ll sw[N];
    REP(i,N){
      sw[i] = temp%2;
      temp /= 2;
    }
    
    ll denkyu[M];
    INIT(denkyu,M,0);
    REP(i,M){
      for(ll x:v[i]){
        denkyu[i] += sw[x];
      }
    }
    ll on_count = 0;
    REP(i,M){
      on_count += (denkyu[i]%2==p[i]);
    }
    if(on_count==M) count++;
  }
  cout << count;
}

Measured memory_bytes: 256
(* O(n log(max a_s)) *)
let n = Scanf.scanf " %d" @@ (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let gcds = Array.make_matrix 2 (n + 1) 0
let rec gcd a b = if b = 0 then a else gcd b (a mod b)
let ans = ref 0
let _ =
  Array.iteri (fun i a -> gcds.(0).(i + 1) <- gcd gcds.(0).(i) a) a_s;
  Array.iteri (fun i a -> gcds.(1).(n - i - 1) <- gcd gcds.(1).(n - i) a_s.(n - i - 1)) a_s;
  for i = 0 to n - 1 do
    ans := max !ans @@ gcd gcds.(0).(i) gcds.(1).(i + 1)
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 6144
#include <stdio.h>
int main(){
  int a[200000],n,i,j,r,min,max;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  min = a[0];
  max = a[1] - a[0];
  for(i=1;i<n;i++){
    if(max<a[i]-min) max = a[i] - min;
    if(a[i]<min) min = a[i];
  }
      printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 2636
D, G = map(int, input().split())
pi = []
ci = []
for _ in range(D):
    p, c = map(int, input().split())
    pi.append(p)
    ci.append(c)

ans =  float('inf')


for bit in range(1 << D ):
    sum = 0
    count = 0
    nokori = set(range(1, D + 1))

    for i in range(D):
        # if bit & (1 << D)で、bitにiが含まれているか（フラグが立っているか）を判定してくれるらしい
        #今回は、i×100点の問題を全て解く場合の処理を書く
        if bit & (1 << i):
            sum +=  100 * (i + 1) * pi[i] + ci[i]
            count += pi[i]
            nokori.discard(i + 1)

    if (sum < G ):
        use = max(nokori)
        n = min(pi[use-1], (G- sum )// (use * 100) )
        if n < 1:
            n = 1
        count += n
        sum   += n * 100 * use 

    if  (sum >= G):
        ans = min(count, ans)

print(ans)



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

const double pi = acos(-1);

int main() {
	int n, m;
	cin >> n >> m;
	long long sum = 0;
	for (int i = 0; i < m; i++) {
	 	int x;
	 	cin >> x;
	 	sum += x;
	}
	if (n - sum >= 0) {
	 	cout << n - sum << '\n';
	}
	else {
	 	cout << "-1\n";
	}
  return 0;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  vi a(n);
  REP(i,n)cin>>a[i];
  int ans = 0;
  REP(i,n)REP(j,i)CHMAX(ans,abs(a[i]-a[j]));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np

a = input().split(" ")

L = int(a[0])
R = int(a[1])

if int(L/2019) < int(R/2019):
    print(0)
else:
    flag = 0
    min = 2018
    max = 0
    for i in range(L,R+1):
        if max < i%2019:
            max = i%2019
        if min > i%2019:
            min = i%2019
        if i%2019 == 0:
            print(0)
            flag = 1
            break
    if flag == 0:
        flag2 = 0
        ans = 2018
        for i in range(min,max):
            for j in range(i+1,max+1):
                if ans > (i*j)%2019:
                    ans = (i*j)%2019
                if ans == 0:
                    print(0)
                    flag2 = 1
                    break
            if flag2 == 1:
                break
        if flag2 == 0:
            print(ans)


Measured memory_bytes: 12504
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if (a==5 && b==5 && c==7) {
		printf("YES\n");
	}
	else if(a==5 && b==7 && c==5){
		printf("YES\n");
	}
	else if(a==7 && b==5&& c==5){
		printf("YES\n");
	}
	else{
		printf("NO\n");

	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define P pair<int, int>
int main(){
  int n;
  int a, b, mx = -1, mp;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    if(mx < a){
      mx = a;
      mp = b;
    }
  }
  cout << mx+mp << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, M, X = map(int, input().split())

As = list(map(int, input().split()))
A_set = set(As)

def count(f, t, A_set):
    ret = 0
    for i in range(f, t + 1):
        ret += i in A_set
    return ret

ans1 = count(0, X, A_set)
ans2 = count(X, N, A_set)
print(min(ans1, ans2))






Measured memory_bytes: 6192
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

double eps = 1e-9;

int n;
int x[24], y[24], r[24], c[24];
bool hit[24][24];
map<int,int> dp;

int dfs(int S){
    if(dp.count(S)) return dp[S];
    int & res = dp[S];
    res = 0;
    rep(i,n){
        if(S>>i & 1){
            rep(j,i){
                if(S>>j & 1){
                    if(hit[i][j] || c[i]!=c[j]) continue;
                    bool ok = true;
                    rep(k,i) if(hit[i][k] && (S>>k & 1)) ok = false;
                    rep(k,j) if(hit[j][k] && (S>>k & 1)) ok = false;
                    if(!ok) continue;
                    S ^= 1<<i;
                    S ^= 1<<j;
                    res = max(dfs(S)+2, res);
                    S ^= 1<<i;
                    S ^= 1<<j;
                }
            }
        }
    }
    return res;
}

int main(){
    while(cin>>n && n){
        dp.clear();
        rep(i,n) cin >> x[i] >> y[i] >> r[i] >> c[i];
        rep(i,n)rep(j,i){
            int dx=x[i]-x[j], dy=y[i]-y[j];
            int d = dx*dx+dy*dy;
            hit[i][j] = hit[j][i] = d < (r[i]+r[j])*(r[i]+r[j]);
        }
        int S = 0;
        rep(i,n) S |= 1<<i;
        cout << dfs(S) << endl;
    }
}

Measured memory_bytes: 50352