akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n+1);
    rep(i, 1, n+1)
        cin >> h[i];
    vector<bool> v(n+1, true);
    rep(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        if (h[a] > h[b])
            v[b] = false;
        if (h[b] > h[a])
            v[a] = false;
        if (h[b] == h[a])
        {
            v[a] = false;
            v[b] = false;
        }
    }
    int res = 0;
    rep(i, 1, n+1)
        res += v[i];
        // if (v[i] == true)
        //     cout << i << endl;
    cout << res;
    return 0;
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
   
  if((s.find('a')!=string::npos)&&(s.find('b')!=string::npos)&&(s.find('c')!=string::npos))cout << "Yes";
  else cout << "No";


}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int MAXN = 10005;
char str[MAXN];
int main()
{
    int flag=0;
    scanf("%s", str);
    for(int i=0;i<strlen(str)-1;++i)
    {
        if(str[i]=='A'&&str[i+1]=='C')
        {
            flag=1;
            puts("Yes");
            break;
        }
    }
    if(!flag)
        puts("No");
    return 0;
}


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

const int N = 2e3 + 10, mod = 1e9 + 7;
typedef long long ll;
typedef pair <ll, ll> pii;

string grid[N];
int dp1[N][N], dp2[N][N], col[N][N], row[N][N];

int main() {
	int n, m, q;
	cin >> n >> m >> q;
	for (int i = 0; i < n; i++)
		cin >> grid[i];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			dp1[i + 1][j + 1] = dp1[i][j + 1] + dp1[i + 1][j] - dp1[i][j] + (grid[i][j] == '1');
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			dp2[i + 1][j + 1] = dp2[i][j + 1] + dp2[i + 1][j] - dp2[i][j];
			if(i && grid[i][j] == grid[i - 1][j] && grid[i][j] == '1')
				dp2[i + 1][j + 1]++;
			if(j && grid[i][j] == grid[i][j - 1] && grid[i][j] == '1')
				dp2[i + 1][j + 1]++;
		}
	}
	for (int i = 1; i < n; i++)
		for (int j = 0; j < m; j++)
			col[i + 1][j + 1] = col[i][j + 1] + (grid[i][j] == grid[i - 1][j] && grid[i][j] == '1');
	for (int i = 0; i < n; i++)
		for (int j = 1; j < m; j++)
			row[i + 1][j + 1] = row[i + 1][j] + (grid[i][j] == grid[i][j - 1] && grid[i][j] == '1');
	while (q--) {
		int x, y, xx, yy;
		cin >> x >> y >> xx >> yy;
		int v = dp1[xx][yy] - dp1[x - 1][yy] - dp1[xx][y - 1] + dp1[x - 1][y - 1];
		int e = dp2[xx][yy] - dp2[x][yy] - dp2[xx][y] + dp2[x][y] + row[x][yy] - row[x][y] + col[xx][y] - col[x][y];
		cout << v - e << "\n";
	}
}

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

int main() {
  int n, m, k;
  cin>>n>>m>>k;
  if (k % n == 0 || k % m == 0) {
    cout<<"Yes"<<endl;
    return 0;
  }
  for (int i=0; i<=n; i++) {
    for (int j=0; j<=m; j++) {
      if (i*m + j*n - 2*i*j == k) {
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

	int w = sc.nextInt();
	int a = sc.nextInt();
	int b = sc.nextInt();

	System.out.println(a + w < b ? b - a - w : b + w < a ? a - b - w : 0);

	sc.close();
	}

}


Measured memory_bytes: 21844
#include <stdio.h>

int main(int argc, char const *argv[])
{
	int n,l[10];
	int sum = 0,max = 0;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
	{
		scanf(" %d",&l[i]);
		sum += l[i];
		if(l[i] > max){
			max = l[i];
		}
	}
	if(max < sum - max)	printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main()
{
    string W, T;
  	int count = 0;
    cin >> W;
  	for(int i = 0; i < W.size(); i++)
    {
      if(W[i] >= 'A' && W[i] <= 'Z')
        W[i] += 32;
    }
    while(cin >> T)
    {
      if(W == "END_OF_TEXT")
        break;
      for(int i = 0; i < T.size(); i++)
      {
        if(T[i] >= 'A' && T[i] <= 'Z')
          T[i] += 32;
      }
      if(W == T)
        count++;
    }
  	cout << count << endl;
}


Measured memory_bytes: 3164
H, W = map(int, input().split())
L, R = 0, 0
if H % 2 == 0:
  L = H // 2
  R = H // 2
else:
  L = H // 2 + 1
  R = H // 2
S = 0
if W % 2 == 0:
  S = (L + R) * (W // 2)
else:
  S = (L + R) * (W // 2) + L
if W != 1 and H != 1:
  print(S)
else:
  print(1)

Measured memory_bytes: 3060
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
typedef long long int ll;
using namespace std;

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

    vector<int> a(n);
    REP(i, n) cin >> a[i];

    SORT(a);

    int ans = a[n - 1] - a[0];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import defaultdict


class PrimeFactor():

    def __init__(self, n):                  # エラトステネス　O(N loglog N)
        self.n = n
        self.table = list(range(n+1))
        self.table[2::2] = [2]*(n//2)
        for p in range(3, int(n**0.5) + 2, 2):
            if self.table[p] == p:
                self.table[p * p::2 * p] = [p] * ((n - p * p - 1) // (2 * p) + 1)

    def is_prime(self, x):  # 素数判定　O(1)
        if x < 2:
            return False
        return self.table[x] == x

    def prime_factors(self, x):             # 素因数分解 O(logN)
        res = []
        if x < 2:
            return res
        while self.table[x] != 1:
            res.append(self.table[x])
            x //= self.table[x]
        return res

    def prime_counter(self, x):             # 素因数分解（個数のリスト）
        res = defaultdict(int)
        if x < 2:
            return res
        while self.table[x] != 1:
            res[self.table[x]] += 1
            x //= self.table[x]
        return res

    def prime_gcd(self, X):                 # n個の最大公約数　X:n個のリスト
        exponents = self.prime_counter(X[0])
        for x in X[1:]:
            Y = self.prime_counter(x)
            for prime, exp in exponents.items():
                if Y[prime] < exp:
                    exponents[prime] = Y[prime]
        res = 1
        for prime, exp in exponents.items():
            res *= pow(prime, exp)
        return res

    def prime_lcm(self, X, mod=None):       # n個の最小公倍数　X:n個のリスト
        exponents = defaultdict(int)
        for x in X:
            for prime, exp in self.prime_counter(x).items():
                if exp > exponents[prime]:
                    exponents[prime] = exp
        res = 1
        for prime, exp in exponents.items():
            res *= pow(prime, exp, mod)
        if mod == None:
            return res
        else:
            return res % mod

mod = 10 ** 9 + 7

N = int(input())
A = list(map(int, input().split()))
B = set(A)
B = list(A)
table = PrimeFactor(10**6)
num = table.prime_lcm(B,mod)

res = 0
for a in A:
    res += num * pow(a, mod - 2, mod)

print(res % mod)

Measured memory_bytes: 90244
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int A = 0, a, b;
  vector<vector<long>> data(N, vector<long> (N, -1));
  for(int i = 0; i < N; i++){
    cin >> A;
    for(int j = 0; j < A; j++){
      cin >> a >> b;
      data.at(i).at(a - 1) = b;
    }
  }
  string B;
  int baf;
  int flag, count, ans = 0;
  for(int i = 0; i < pow(2, N); i++){
    baf = i;
    B = "";
    flag = 1;
    count = 0;
    for(int j = 0; j < N; j++){
      B += to_string(baf % 2);
      baf /= 2;
    }
    for(int j = 0; j < N; j++){
      if(B.at(j) == '0')continue;
      for(int k = 0; k < N; k++){
        if(data.at(j).at(k) == -1 || j == k)continue;
        if((data.at(j).at(k) + '0') != B.at(k)){
          flag = 0;
          break;
        }
      }
      if(flag == 0)break;
    }
    if(flag == 1){
      for(int j = 0; j < N; j++){
        if(B.at(j) == '1')count++;
      }
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
n,m = map(int,input().split())
pref = [[] for i in range(n)]    
ans = [[] for i in range(m)]        
for i in range(m):
        p,y = map(int,input().split())
        pref[p-1].append([y,i])
for i in range(n):
        pref[i].sort()

for i in range(len(pref)):
        for j in range(len(pref[i])):
                ans[pref[i][j][1]] = [i+1,j+1]

for i in range(len(ans)):
        print("%06d%06d"%(ans[i][0],ans[i][1]))

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    vector<int> v(5);
    rep(i, 5){
        cin >> v[i];
    }
    SORT(v);
    int k;
    cin >> k;
    if(v[4] - v[0] <= k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]

T = [0]*N
M = [0]*N
for i in range(N):
    res = 0
    idx = 0
    s = S[i]
    l = len(s)
    m = 0
    while idx<l:
        if s[idx]==')':
            res -= 1
            m = min(res,m)
        else:
            res += 1
        idx += 1
    
    M[i] = m
    T[i] = res

Tp = []
Tn = []
for i in range(N):
    if T[i]>=0:
        Tp.append([M[i], T[i]])
    else:
        Tn.append([M[i]-T[i], -T[i]])

Tp.sort(reverse = True)
Tn.sort(reverse = True)
res = 0
for m,t in Tp:
    if res<-m:
        print('No')
        exit()
    res += t

resn = 0
for m,t in Tn:
    if resn<-m:
        print('No')
        exit()
    resn += t
if res==resn:
    print('Yes')
else:
    print('No')

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

const ll INF = (1LL << 31) - 1;
struct SegmentTree {
    vector<ll> ar;
    ll size = 1;
    SegmentTree(int n) {
        ar.resize(4 * n - 1, 0);
        while (size < n) {
            size *= 2;
        }
    }
    void update(ll idx, ll x) {
        ll k = size + idx;
        ar[k] += x;
        while (k != 1) {
            k /= 2;
            ar[k] = ar[k * 2] + ar[k * 2 + 1];
        }
    }
    ll findinner(ll s, ll t, ll idx, ll be, ll en) {
        ll mid = (be + en) / 2;
        if (be == s && t == en) {
            return ar[idx];
        }
        ll two = 0;
        ll one = 0;
        if (s < mid) {
            two = findinner(s, min(t, mid), 2 * idx, be, mid);
        }
        if (t > mid) {
            one = findinner(max(s, mid), t, 2 * idx + 1, mid, en);
        }
        return one + two;
    }
    ll find(ll s, ll t) { return findinner(s, t, 1, 0, size); }
};
int main() {
    ll n, q;
    cin >> n >> q;
    SegmentTree st(n);
    REP(i, q) {
        ll com, x, y;
        cin >> com >> x >> y;
        if (com == 0) {
            st.update(x - 1, y);
        } else {
            cout << st.find(x - 1, y) << endl;
        }
    }
}


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

int s[105][105];
int a[10005];
int b[10005];

int main()
{
	int H,W;
	int N,i,j,t;
	while(cin>>H>>W)
	{
		cin>>N;
		for(i=1;i<=N;i++)
		cin>>a[i];
		t=0;
		for(i=1;i<=N;i++)
		    for(j=0;j<a[i];j++)
		    b[t++]=i;
		t=0;
		for(i=0;i<H;i++)
		{
			if(i%2==0)
			{
				for(j=0;j<W;j++)
				s[i][j]=b[t++];
			}
			else
			{
				for(j=W-1;j>=0;j--)
				s[i][j]=b[t++];
			}
		}
		for(i=0;i<H;i++)
		{
			for(j=0;j<W-1;j++)
			cout<<s[i][j]<<" ";
			cout<<s[i][W-1]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <utility>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    Int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
    return 0;
}



Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct data{
    int x,y;
    data(int _x,int _y):x(_x),y(_y){}
    data(){}
    bool operator<(const data &d)const{
        return x==d.x?y<d.y:x<d.x;
    }
};

int main(){
    int n,m;
    while(cin>>n,n){
        vector<data>latte(n);
        for(int i=0;i<n;i++){
            int a,b;
            cin>>a>>b;
            latte[i]=data(a,b);
        }
        cin>>m;
        vector<data>field(m);
        for(int i=0;i<m;i++){
            int a,b;
            cin>>a>>b;
            field[i]=data(a,b);
        }

        sort(latte.begin(),latte.end());
        sort(field.begin(),field.end());

        for(int i=0;i<m;i++){
            int dx=field[i].x-latte[0].x;
            int dy=field[i].y-latte[0].y;

            int lp=1,fp=1;
            while(lp<n&&fp<m){
                while(true){
                    if(latte[lp].x+dx==field[fp].x&&latte[lp].y+dy==field[fp].y)break;
                    if(fp>=m){
                        lp=0;
                        break;
                    }
                    fp++;
                }
                lp++;fp++;
            }
            if(lp==n){
                cout<<dx<<" "<<dy<<endl;
                break;
            }
        }

    }
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
string str;
string ans;
vector<int>pos,a,b;
int A,B;
bool ok[6005];
string dp[3005];
void rec(){
	string ans = "";
	for(int i=0;i<=pos.size();i++){
	    if(i == pos.size() && !pos.empty()) break;
		vector<int>in;
		for(int j=i;j<pos.size();j++){
			in.pb(a[pos[j]]);
			in.pb(b[pos[j]]);
			assert(a[pos[j]]>b[pos[j]]);
		}
		SORT(in);
		string cur = "";
		for(int ii=0;ii<in.size();ii++){
			cur.pb(str[in[ii]]);
		}
		int nxt = 0;
		if(in.size()) nxt = in[in.size()-1]+1;
		while(nxt<2*n){
			int p = POSL(a,nxt);
			if(p == a.size()) break;
			assert(a[p]<b[p]);
			cur.pb('a'); cur.pb('b');
			nxt = b[p]+1;
		}
		if(ans<cur) ans = cur;
	}
	cout<<ans<<endl;
}
int main(){
	cin>>n;
	cin>>str;
	for(int i=0;i<2*n;i++){
		if(str[i] == 'a') a.pb(i);
		else b.pb(i);
	}
	assert(a.size()==b.size());
	for(int i=0;i<n;i++){
		if(a[i]>b[i]){
			pos.pb(i);
		}
		ok[i] = 1;
	}
//string ans = "";
	if(pos.empty()){
		rec(); return 0;
	}
	vector<int>vec;
	for(int i=0;i<pos.size();i++){
		vector<int>in;
		int pre = INF;
		int en = pos.size();
		en--;
		for(int j=i;j<pos.size();j++){
			if(pre < b[pos[j]]){
				en = j-1;
				break;
			}
			in.pb(a[pos[j]]);
			in.pb(b[pos[j]]);
			pre = a[pos[j]];
		}
		SORT(in);
		string cur = "";
		for(int ii=0;ii<in.size();ii++){
			cur.pb(str[in[ii]]);
		}
		if(dp[en] < cur)	{
			dp[en] = cur;
			vec.pb(en);
		}
	}
	ERASE(vec);
	vector<string>vs;
	for(int i=0;i<vec.size();i++){
		string str = dp[vec[i]];
		if(i == vec.size()-1){
		    assert(vec[i] == pos.size()-1);
			int nxt = a[pos[vec[i]]]+1;
			while(nxt<2*n){
				int p = POSL(a,nxt);
				if(p == a.size()) break;
				assert(a[p]<b[p]);
				str.pb('a'); str.pb('b');
				nxt = b[p]+1;
			}
		}
		vs.pb(str);
	}
	vector<string>dp;
	for(int i=0;i<vs.size();i++){
		string hoge = vs[i];
		for(int j=0;j<i;j++){
			hoge = max(hoge,dp[j]+vs[i]);
		}
		dp.pb(hoge);
	}
	cout<<dp[dp.size()-1]<<endl;
}

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


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

    // vector<string> gifts;
    set<string> gifts;

    for(int i = 0; i < N; i++)
    {
        cin >> s;
        auto ite = gifts.find(s);

        if(ite == gifts.end())
        {
            gifts.insert(s);
        }
    }

    std::cout << gifts.size();

    return 0;
}


Measured memory_bytes: 19040
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
int main()
{
    int n,k;
    cin>>n>>k;
    int a[100005]={0};
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    //sort(a,a+n);
    }
    sort(a,a+n);
    int diff=1e9;
    if(n==1)
        diff=a[0];
    for(int i=0;i<n-1;i++)
    {
        if(a[i+1]!=a[i])
            diff=min(diff,a[i+1]-a[i]);
    }
    for(int i=n-1;a[i]>=k&&i>=0;i--)
    {
        if((a[i]-k)%diff==0)
        {
            cout<<"POSSIBLE\n";
            return 0;
        }
    }
    cout<<"IMPOSSIBLE\n";
    return 0;
}



Measured memory_bytes: 640
import java.util.Scanner;

class Main{
  public static void main(String args[]){
	  Scanner s = new Scanner(System.in);
	  int a = s.nextInt();
	  int b = s.nextInt();

	  if (a < b) 
		  System.out.println("a < b");
	  else if (a > b)
		  System.out.println("a > b");
	  else
		  System.out.println("a == b");
	  
	  s.close();
  }
}


Measured memory_bytes: 26064
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){

    int N,H,W;
    
    cin>>N>>H>>W;
    
    cout<<(N-H+1)*(N-W+1)<<endl;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chkmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chkmax(T &a, T b) { return a < b ? (a = b, true) : false; }

typedef long long ll;

int nextInt() {int x; scanf("%d", &x); return x;}
ll nextLong() {ll x; scanf("%lld", &x); return x;}

vector<ll> v;

struct P {
  ll S, K, num;
};

ll choose(int n, int m) {
  ll res = 1;
  for (int i = 1; i <= m; i++, n--) {
    res *= n;
    res /= i;
  }
  return res;
}

P f(const int K) {
  ll S = 0;
  ll last = v[v.size() - K];
  int n = 0;
  int m = 0;
  for (int i = 0; i < K; i++) {
    S += v[v.size() - 1 - i];
    if (v[v.size()-1-i] == last) m++;
  }
  REP(i, v.size()) {
    if (v[i] == last) n++;
  }
  return {S, K, choose(n, m)};
}

int main2() {
  v.clear();
  int N = nextInt();
  int A = nextInt();
  int B = nextInt();
  REP(i, N) v.push_back(nextLong());
  sort(v.begin(),v.end());

  ll bestS = -1;
  ll bestK = -1;
  ll ans = -1;

  for (int K = A; K <= B; K++) {
    P p = f(K);
    if (ans == -1 || (bestS * p.K) < (p.S * bestK) ) {
      bestK = p.K;
      bestS = p.S;
      ans = p.num;
    } else if ((bestS * p.K) == (p.S * bestK)) {
      ans += p.num;
    }
  }

  printf("%.10f\n", (double)bestS/(double)bestK);
  printf("%lld\n", ans);

  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Measured memory_bytes: 256
Q = int( input())
def matching(A,B):
    #最大となる組み合わせは、1,2,...,xと1,2,...,xという頂点を逆順で組み合わせることで得られることが分かる
    #このとき、これらの積の最大値は(x+1)//2*(x+1-(x+1)//2)である
    #ここで、B = A + nであるとき、最大はA*(A+(n-1))以上になることが分かる。
    #n >= 1であれば、積の最大値はA.Bを飛ばしても実現されることが分かる。
    if A == B:
        return 2*A - 2
    S = A*B
    L, H = 0, A*B
    while H - L != 1:
        M = (L+H)//2
        if ((M+1)//2)*(M + 1 - (M+1)//2) < S:
            L = M
        else:
            H = M
    return L-1 #L-1なのは、A,Bを飛ばすため
for _ in range(Q):
    A, B = map( int, input().split())
    print( matching(A,B))

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

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)


void func(std::string S, std::string T, long long A, long long B, std::string U){
    if (S==U) A -= 1;
    if (T==U) B -= 1;
    cout << A << ' ' << B << endl;
}

int main(){
    // cout << fixed << setprecision(5);

    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::string U;
    std::cin >> U;
    func(S, T, A, B, U);
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
constexpr int INF = 1 << 29;
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

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

struct Line {
	double a, b, c;
};

struct BIT {
	int N;
	vector<int> bit;
	BIT(int n) : N(n), bit(N + 1){}
	void add(int a, int w) {
		for(int x = a; x < N; x |= x + 1) {
			bit[x] += w;
		}
	}
	int sum(int a) {
		int ret = 0;
		for(int x = a - 1; x >= 0; x = (x & (x + 1)) - 1) {
			ret += bit[x];
		}
		return ret;
	}
};

ll getTransNum(vector<int> &r) {
	BIT bit(r.size());
	ll ret = 0;
	for(int i = 0; i < r.size(); i++) {
		ret += i - bit.sum(r[i]);
		bit.add(r[i], 1);
	}
	return ret;
}

bool ok(vector<Line> &L, double c, bool vertical) {
	vector<pair<double, int>> L_c;
	if (vertical) {
		for (int i = 0; i < L.size(); i++) {
			// Ax+By=C
			// By=C-Ax
			// y=(C-Ax)/B
			double y = (L[i].c - L[i].a * c) / L[i].b;
			L_c.push_back(mp(y, i));
		}
	} else {
		for (int i = 0; i < L.size(); i++) {
			// Ax+By=C
			// Ax=C-By
			// x=(C-By)/A
			double x = (L[i].c - L[i].b * c) / L[i].a;
			L_c.push_back(mp(x, i));
		}
	}

	sort(L_c.begin(), L_c.end());
	vector<int> r;
	for (int i = 0; i < L_c.size(); i++) {
		r.push_back(L_c[i].second);
	}

	ll n = getTransNum(r);
	int minn = L.size() * (L.size() - 1) / 2;
	if (minn % 2 == 0) {
		minn = minn / 2;
	} else {
		minn = minn / 2 + 1;
	}
	return n >= minn;
}

int main() {
	int N;
	cin >> N;
	vector<Line> L;
	for (int i = 0; i < N; i++) {
		double a, b, c;
		cin >> a >> b >> c;
		L.push_back((Line){a, b, c});
	}
	vector<Line> L_x = L;
	vector<Line> L_y = L;
	sort(L_x.begin(), L_x.end(), [](Line &lhs, Line &rhs){return lhs.a / lhs.b < rhs.a / rhs.b;});
	sort(L_y.begin(), L_y.end(), [](Line &lhs, Line &rhs){return lhs.b / lhs.a < rhs.b / rhs.a;});

	double ans_x, ans_y;
	double a = -1e30;
	double b = 1e30;
	for (int i = 0; i < 200; i++) {
		double c = (a + b) / 2;
		if (ok(L_x, c, true)) {
			b = c;
		} else {
			a = c;
		}
	}
	ans_x = b;
	
	a = -1e30, b = 1e30;
	for (int i = 0; i < 200; i++) {
		double c = (a + b) / 2;
		if (ok(L_y, c, false)) {
			b = c;
		} else {
			a = c;
		}
	}
	ans_y = b;

	printf("%.15f %.15f\n", ans_x, ans_y);
	return 0;
}



Measured memory_bytes: 4776
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int n, h, m, s;

int main(){
	cin >> n;
	h = n / 3600;
	m = (n - h * 3600) / 60;
	s = (n - h * 3600 - m * 60);
	cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  ll n;
  cin >> n;
  ll ans=0;
  vector<ll> a(n),b(n+1,0);
  rep(i,n) cin >> a[i];
  rep(i,n){
    ans+=b[a[i]];
    b[a[i]]++;
  }
  rep(i,n){
    cout << ans-b[a[i]]+1 << endl;
  }

}


Measured memory_bytes: 5760
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------

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

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

	map<int ,int> backet;

	for(int i = 0; i < n; i++){
		backet[a[i]]++;
	}

	int ans = 0;
	for(auto i : backet){
		if(i.second == 0)continue;
		if(i.second > i.first){
			ans += i.second - i.first;
		} else if(i.second < i.first){
			ans += i.second;
		}
	}

	cout << ans << endl;

	
}

Measured memory_bytes: 5120
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n;
	
	while(cin >> n,n)
	{
		iiv v;
		iv ans;
		REP(i,n)
		{
			iv vtmp;
			int m;
			cin >> m;
			REP(j,m)
			{
				int tt;
				cin >> tt;
				vtmp.PB(tt);
				
			}
			v.PB(vtmp);
		}
		
		int k;
		cin >> k;
		
		iv _list;
		REP(i,k)
		{
			int tmp;
			cin >> tmp;
			_list.PB(tmp);
		}
		
		REP(i,n)
		{
			bool flag = true;
			REP(j,k)
			{
				if(find(ALL(v[i]),_list[j]) == v[i].end())
				{
					flag = false;
					break;
				}
			}
			if(flag)
			{
				ans.PB(i+1);
			}
		}
		
		if(ans.size() == 1)
		{
			cout << ans[0] << endl;
		}
		else
		{
			cout << -1 << endl;
		}
		
	}
		
	
	return 0;
}

Measured memory_bytes: 3224
#include "bits/stdc++.h"
#include "iostream"
using namespace std;

int main()
{
	long long N,K;
	cin>>N>>K;
	long long ans = 1;
	for(long long i=0;i<N;i++){
	if (2*ans>=ans+K){
	ans = ans + K;
	}
	else{
	ans = 2*ans;
	}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

a, b, c, k = map(int, input().split())

ans = None
if k % 2 == 0:
    ans = a - b
else:
    ans = b - a

if abs(ans) > 10 ** 18:
    print('Unfair')
else:
    print(ans)


Measured memory_bytes: 61252
use std::io;


fn main() {
    let s = read_one::<String>();
    let s = s.replace("2017", "2018");
    println!("{}", s);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    stack<int> S;
    string Command;
    cin >> Command;
    for (int i = 0; i < Command.size(); i++) {
        char c = Command[i];
        if (c == '0') S.push(0);
        else if (c == '1') S.push(1);
        else {
            if (!S.empty()) S.pop();
        }
    }
    string ans = "";
    while (!S.empty()) {
        ans += to_string(S.top());
        S.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';
}


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

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if(a<b){
		if(b<c){
			cout << "Yes";
			cout << "\n";
			return 0;
		}
	}
	cout << "No";
	cout << "\n";
	
}


Measured memory_bytes: 3080
# coding: utf-8
# ?????????????????¨????????????
class Dice(object):
	def __init__(self):
		# ???????????????????????°
		# ????????¶???
		self.dice = (2, 5), (3, 4), (1, 6) # x, y, z
		self.ax = [[0, False], [1, False], [2, False]]
		self.axmap = [0, 1, 2]
		self.mm = {"N": (0, 2), "S": (2, 0), "E": (1, 2), "W": (2, 1), "R": (0, 1), "L": (1, 0)}

	def rotate(self, dir):
		def rot(k, r):
			# k?????????????????????????????????????????§?§????
			# r?????????????????¢???????§????
			t = self.axmap[r]
			self.axmap[k], self.axmap[r] = t, self.axmap[k]
			self.ax[t][1] = not self.ax[t][1]

		rot(*self.mm[dir])

	def top(self):
		z = self.ax[self.axmap[2]]
		return self.dice[z[0]][z[1]]
	
	def right(self):
		y = self.ax[self.axmap[1]]
		return self.dice[y[0]][y[1]]

	def front(self):
		x = self.ax[self.axmap[0]]
		return self.dice[x[0]][x[1]]

if __name__=="__main__":
	dice = Dice()
	labels = input().split()
	q = int(input())
	for _ in range(q):
		a, b = input().split()
		p = labels.index(a) + 1
		for _ in range(4):
			if p==dice.top():
				break
			dice.rotate("N")
		for _ in range(4):
			if p==dice.top():
				break
			dice.rotate("E")
		
		p = labels.index(b) + 1
		for _ in range(4):
			if p==dice.front():
				break;
			dice.rotate("R")

		print(labels[dice.right()-1])

Measured memory_bytes: 7780
#include <iostream>
using namespace std;
int main(void){
    int n, mn = 1e9, ans = 0;
    cin >> n;
    for(int i=0;i<n;i++){
        int p;
        cin >> p;
        if(mn >= p){
            ans++;
            mn = p;
        }
    }
    cout << ans << endl;
}


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

ll n,a[500],dp[502][502],sum[502];

ll f(ll i,ll j)
{
	if(dp[i][j]!=-1)
	return dp[i][j];
	if(i==j)
	{
		dp[i][j]=0;
		return 0;
	}
	for(int k=i;k<j;k++)
	{
		f(i,k);f(k+1,j);
		if(dp[i][j]==-1)
		dp[i][j] = dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1];
		else
		dp[i][j]=  min(dp[i][j],dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1]);
		
	}
}

main()
{ 
	cin>>n;
	
	for(int i=1;i<=500;i++)
	for(int j=1;j<=500;j++)
	dp[i][j]=-1;
	sum[0]=0;
	
	for(int i=1;i<=n;i++)
	{
	cin>>a[i];
	sum[i]=sum[i-1]+a[i];
}

f(1,n);
/*for(int i=1;i<=n;i++)
cout<<sum[i]<<" ";
cout<<endl;
cout<<endl;

	
for(int i=1;i<=n;i++)
{
	for(int j=1;j<=n;j++)
	cout<<dp[i][j]<<" ";
	cout<<endl;
	}*/

cout<<dp[1][n];
}
	
	


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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    string c1;

    cin >> c1;

    string c2;

    cin >> c2;

    long long cc1;

    cin >> cc1;

    long long cc2;

    cin >> cc2;

    string mop;

    cin >> mop;

    if(mop==c1) {

        cc1--;

    } else {

        cc2--;

    }

    cout << cc1 << ' ' << cc2 << '\n';

    return 0;

}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

void numeration_add(int N, vector<int> &pattern, int i) { //N進法
    if (pattern[i] != N - 1) pattern[i]++;
    else {
        pattern[i] = 0;
        numeration_add(N, pattern, i + 1);
    }
}

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

    int n;
    cin >> n;
    int arr[4] = {0, 3, 5, 7};
    int cnt = 0;
    vector<int> pattern(11, 0);

    while (pattern[10] == 0) {
        ll num = 0;
        bool used[4] = {};
        bool valid = true, zero_appeared = false;

        rep(i, 11) {
            if (zero_appeared && pattern[i] != 0) {
                valid = false;
                break;
            } else if (pattern[i] == 0) {
                zero_appeared = true;
            } else {
                num += arr[pattern[i]] * (ll) pow(10, i);
                used[pattern[i]] = true;
            }
        }
        
        if (num <= n && used[1] && used[2] && used[3] && valid) cnt++;
        numeration_add(4, pattern, 0);
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] points = br.readLine().split(" ");
        double x1 = Double.parseDouble(points[0]);
        double y1 = Double.parseDouble(points[1]);
        double x2 = Double.parseDouble(points[2]);
        double y2 = Double.parseDouble(points[3]);
        double distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
        System.out.println(distance);
    }
}

Measured memory_bytes: 24488
using System;

namespace ABC132
{
    class Program
    {
        static int Main(string[] args)
        {
            problemB();
            return 0;
        }

        static void problemB()
        {
            string n = Console.ReadLine();
            string[] p = Console.ReadLine().Split(' ');

            int ans = 0;

            for (int index = 1; index < int.Parse(n) - 1; index++)
            {
                if(int.Parse(p[index]) < int.Parse(p[index+1])&& int.Parse(p[index-1]) < int.Parse(p[index]))
                {
                    ans = ans + 1;
                }
                else if (int.Parse(p[index]) > int.Parse(p[index + 1]) && int.Parse(p[index - 1]) > int.Parse(p[index]))
                {
                    ans = ans + 1;
                }
            }

            Console.WriteLine(ans);
        }
    }
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==1)cout<<"YES"<<endl;
    else{
        if(a%b==c) cout<<"YES"<<endl;
        else {
            int tmp=((a%b)+a)%b,first=a%b;
            bool flag=false;
            while(tmp!=first){
                if(tmp==c) flag=true;
                tmp=(tmp+a)%b;
            }
            if(flag)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <string>
#include  <cstdlib>


int main(void)
{
	std::string s;
	std::cin >> s;

	for(int i = 0; i < 3; i++)
		std::cout << s[i];
	std::cout << std::endl;

	return EXIT_SUCCESS;
}


Measured memory_bytes: 3596
import Data.Foldable (maximumBy)
import Data.Maybe (catMaybes, fromJust)
import Data.Array (listArray, (!))

type StrL = (String, Int)
tailL ((x:xs), n) = (xs, n-1)
cons x (xs,n) = (x:xs, n+1)

cmp :: StrL -> StrL -> Ordering
cmp (s1,l1) (s2,l2)
  | l1 > l2 = GT
  | l1 < l2 = LT
  | otherwise = cmp' s1 s2
  where
    cmp' [] [] = EQ
    cmp' (x:xs) (y:ys)
      | x > y = GT
      | x < y = LT
      | otherwise = cmp' xs ys

match = listArray ('1','9') [2,5,5,4,5,6,3,7,6]

main :: IO ()
main = do
  n <- read . head . words <$> getLine
  as <- map head . words <$> getLine
  let result = listArray (0,n) $ map nth [0..] where
      nth 0 = Just ("",0)
      nth n =
        case catMaybes [(cons a)<$>result!(n-m)|a<-as, let m=match!a, n-m>=0] of
          [] -> Nothing
          xs -> Just $ maximumBy cmp xs
  putStrLn $ fst $ fromJust $ result!n


Measured memory_bytes: 7548
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

ll n, a, b, cnk[190][190], ct = 2;
bool p;

int main(){


cin >> n >> p;

cnk[1][1] = cnk[1][2] = 1ll;


for(ll i = 2; i <= n + 1; i++) {
    ct++;
    for(ll j = 1; j <= ct; ++j) {

        cnk[i][j] = cnk[i - 1][j] + cnk[i - 1][j - 1];

    }
}

for(ll i = 1; i <= n; ++i) {
    ll ai;
    cin >> ai;
    if(ai % 2 == 0) {a++;}
    else {b++;}
}

ll ans = 0;

if(!p) {

    ll all = 0;

    for(ll k = 1; k <= a; ++k) {

        ans += cnk[a][k + 1];

    }

    for(ll i = 2; i <= b; i += 2) {
        all += cnk[b][i + 1];
    }

    cout << ans * all + all + ans + 1;

}

else {

    ll all = 0;

    for(ll k = 1; k <= a; k++) {

        all += cnk[a][k + 1];

    }

    for(ll i = 1; i <= b; i += 2) {
        ans += cnk[b][i + 1];
    }

    ll all_ans = ans * all + ans;

    cout << all_ans;

}

return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

vll c, d;

// Dijkstra
// O(Elog(V))
struct Dijkstra {
  struct Edge {
    int to;
    ll cost;
    long long time;
  };

  vector<vector<Edge>> G;
  int num_v;
  vector<priority_queue<P, vector<P>, greater<P>>> vinfo;

 public:
  Dijkstra(int max_v) : G(max_v), num_v(max_v), vinfo(max_v) {
  }

  void add_edge(int from, int to, long long cost, long long time) {
    G[from].push_back((Edge){to, cost, time});
  }

  void solve(int s, ll initial_silver) {
    // P.first : time
    // P.second: index
    // P.third: money
    using T = tuple<ll, ll, ll>;
    priority_queue<T, vector<T>, greater<T>> que;

#define MAX_SILVER ((ll)2500)

    chmin(initial_silver, MAX_SILVER);

    // memo[v][num_silver]: vにいて銀貨をnum_silver枚持っている状態の最小時間
    vvll memo(num_v + 1, vll(MAX_SILVER + 1, INF));

    que.emplace(0, s, initial_silver);

    while (!que.empty()) {
      T p = que.top();
      que.pop();

      ll t = get<0>(p);
      int v = get<1>(p);
      ll sil = get<2>(p);
      chmin(sil, (ll)MAX_SILVER);

      // より少ないコストでの経路が見つかっている場合
      if (memo[v][sil] <= t) {
        continue;
      }
      rep(i, sil + 1) {
        chmin(memo[v][i], t);
      }

      // vの各辺に対しよりコストの低い経路があるかを確認
      for (auto& e : G[v]) {
        ll silver = sil - e.cost;
        if (silver >= 0) {
          if (memo[e.to][silver] > t) {
            que.emplace(t + e.time, e.to, silver);
          }
        }
      }

      // 換金
      ll new_c = min(sil + c[v], MAX_SILVER);
      if (memo[v][new_c] > t) {
        que.emplace(t + d[v], v, new_c);
      }
    }

    FOR(i, 2, num_v) {
      cout << *min_element(all(memo[i])) << endl;
    }
  }

  vector<int> get_path(const vector<int>& prev, int t) {
    vector<int> path;

    for (int v = t; v != -1; v = prev[v]) {
      path.push_back(v);
    }

    reverse(path.begin(), path.end());
    return path;
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, m, s;
  cin >> n >> m >> s;

  Dijkstra graph(n + 1);

  rep(i, m) {
    int u, v;
    ll a, b;
    cin >> u >> v >> a >> b;
    graph.add_edge(u, v, a, b);
    graph.add_edge(v, u, a, b);
  }

  c = vll(n + 1);
  d = vll(n + 1);

  REP(i, n + 1) {
    cin >> c[i] >> d[i];
  }

  graph.solve(1, s);

  return 0;
}


Measured memory_bytes: 4496
X = list(input())
#print(X)
ans=0
anss=[]
for i in X:
  if i in ['A','C','G','T']:
    ans+=1
#    print(i)
  else:
    ans = 0
  anss.append(ans)

if anss:
  print(max(anss))
else:    
  print(0)    


Measured memory_bytes: 2940
#include <iostream>
#include <sstream>
#include <set>
#include <vector>
using namespace std;

constexpr int MAX_N = 10;

int N, K;
int cards[MAX_N];

vector<int> vec;
set<int> numbers;
bool used[MAX_N];

void dfs(int n) {
  if (n == K) {
    ostringstream oss;
    for (int i : vec) {
      oss << i;
    }
    numbers.insert(stoi(oss.str()));
    return;
  }

  ++n;
  for (int i{}; i < N; ++i) {
    if (used[i])
      continue;
    used[i] = true;
    vec.push_back(cards[i]);
    dfs(n);
    vec.pop_back();
    used[i] = false;
  }
}

int main() {
  while (true) {
    cin >> N >> K;
    if (N == 0 && K == 0)
      break;
    for (int n{}; n < N; ++n) {
      cin >> cards[n];
    }

    vec.clear();
    numbers.clear();
    dfs(0);
    cout << numbers.size() << endl;
  }
  return 0;
}



Measured memory_bytes: 3120
#include<iostream>
#include<string>
std::string str;
inline bool check()
{
    bool b=false;
    for(std::string::iterator iter=str.begin();iter!=str.end();++iter)
    {
        if(*iter=='C') b=true;
        if(b&&*iter=='F') return true;
    }
    return false;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::cin>>str;
    std::cout<<(check()?"Yes\n":"No\n");
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long mod = 1000000007;

long long mypow(long long a, long long b)
{
	long long res = 1;
	while (b)
	{
		if (b & 1)
			res = res * a % mod;
		a = (a* a) % mod;
		b >>= 1;
	}
	return res % mod;
}
long long inv(long long a)
{
	return mypow(a, mod - 2) % mod;
}
long long myc(long long n, long long k)
{
	vector<long long> fact(n + 1);
	fact[0] = 1; fact[1] = 1;
	for (int i = 2; i <= n; i++)
		fact[i] = fact[i - 1] * i % mod;
	return fact[n] * inv(fact[k]) % mod * inv(fact[n - k]) % mod;

}
int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	long long x, y;
	cin >> x >> y;
	if (x > y)
		swap(x, y);
	if ((x + y) % 3 != 0 || 2 * x - y < 0)
		cout << 0;
	else
	{
		cout << myc((x + y) / 3, (2 * x - y) / 3);
	}

		
	return 0;
}

Measured memory_bytes: 5504
n, m = map(int, input().split())
AB = [[] for _ in range(n)]
for i in range(n):
  AB[i] = list(map(int, input().split()))
  
AB.sort(key=lambda x: x[0])

c = 0
ans = 0
for i,j in AB:
  c += j
  if c < m:
    ans += i*j
  else:
    ans += i*(m-(c-j))
    break

print(ans)


Measured memory_bytes: 29000
#include <bits/stdc++.h>
using namespace std;
//SET PRECIOSION   cout << fixed ;  cout << setprecision(n) << ans << endl;
#define ll long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector <ll> v;
ll x,y,z,a,b,c,sum,ans,total,t,cnt,n,m,k,p,kase;
string s,s2;
map<ll,ll> mp;

map<ll,ll> :: iterator itr1, ptr1;
set<ll> :: iterator itr, ptr;
int main()
{
	FAST;
	cin>>s;
	if(s[1]==s[0]|| s[2]==s[1]|| s[3]==s[2])
        cout<<"Bad"<<endl;
    else
        cout<<"Good"<<endl;
	//clear vectors and maps you idiot
	// check array size dumb
	// use long long instead of int too
	return 0;
}


Measured memory_bytes: 3628
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <bitset>
#include <array>
#include <set>
#include <string>

#include <iterator>
#include <algorithm>
#include <numeric>

#include <ios>
#include <sstream>
#include <iostream>
#include <fstream>

#include <climits>
#include <cmath>

using namespace std;

#define EPS (1e-7)
#define MOD ((int)1e9+7)
#define PI (atan(1.0)*4)

using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;

void OUT(bool isTrue, string t="YES", string f="NO"){
    cout<<(isTrue?t:f)<<endl;
}
void out(bool isTrue, string t="yes", string f="yes"){
    cout<<(isTrue?t:f)<<endl;
}

template <typename T>
string printItr(T b, T e, string delim=" ")
{
    stringstream ss;
    ostream_iterator<decltype(*b)> out_it(ss, delim.c_str());
    copy(b,e - 1, out_it);
    ss<<*(e-1);
    return ss.str();
}

void bulk(){}
template <class Head, class... Tail>
void bulk(Head& head, Tail&... tail){
    cin>>head;
    bulk(tail...);
}

ll inv_pow(ll x, ll n, ll mod) {
  ll res = 1;
  for(;n>0;n>>=1){
    if(n&1) res=res*x%mod;
    x=x*x%mod;
  }
  return res;
}

void factMod(ll x, ll n, ll mod, vll& v) {
    v.resize(n+1);
    v[0]=1;
    for(int i=1;i<=n;i++){
        v[i]=v[i-1]*(i%mod)%mod;
    }
}

void factInv(ll x, ll n, ll mod, vll& v){
    v.resize(n+1);
    v[x]=inv_pow(x,mod-2,mod);
    for(int i=n;i>=0;i--){
        v[i-1]=v[i]*(x%mod)%mod;
    }
}

#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(i,m,n) for(int i=m; i<n;i++)
#define each(i,n) for(auto i:n)
#define all(i) i.begin(),i.end()
#define cint(...) int __VA_ARGS__;bulk(__VA_ARGS__);


int main(void){
    cint(n);
    vi a(n);
    vi b(n,0);
    each(&i,a)cin>>i;
    int  ans=1;
    rep(i,n){
        ans*=(2-a[i]%2);
    }
    cout<<pow(3,n)-ans;
}

Measured memory_bytes: 256