akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

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

int dp[100005][2];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	int n = s.size();
	dp[0][0] = (s[0] == '1');
	dp[0][1] = (s[0] == '0');
	repn(i, 1, n){
		dp[i][0] = dp[i - 1][1] + (s[i] == '1');
		dp[i][1] = dp[i - 1][0] + (s[i] == '0');
	}
	cout << min(dp[n - 1][0], dp[n - 1][1]) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string s;
    cin>>s;
    REP(i,s.length()){
        cout<<"x";
    }
    cout<<endl;
    return 0;
}

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

using namespace std;

int main(void){
    int n; cin >> n;
    if(n%10==9 || n/10==9){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  string s;
  cin >> s;
  ll N = s.length();
  if (N == 2) {
    if (s[0] == s[1]) {
      cout << 1 << " " << 2;
      return 0;

    } else {
      cout << -1 << " " << -1;
      return 0;
    }
  }

  REP(i, N - 2) {
    ll index = i + 1;
    if (s[i] == s[i + 1]) {
      cout << index << " " << index + 2;
      return 0;
    }
    if (s[i + 1] == s[i + 2]) {
      cout << index << " " << index + 2;
      return 0;
    }
    if (s[i] == s[i + 2]) {
      cout << index << " " << index + 2;
      return 0;
    }
  }
  cout << -1 << " " << -1;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
  i64 x;
  cin >> x;
  i64 ans = x / 11 * 2;
  if (x % 11 > 0) ans++;
  if (x % 11 > 6) ans++;
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

int main(){
    int A, B, K;
    int i, j;
    scanf("%d %d %d", &A, &B, &K);
    // printf("%d %d %d", A, B, K);
    
    int small = 0, big = 0;
    small = A + K - 1;
    big = B - K + 1;
    //printf("%d %d", small, big);

    if (small > big){
        for(i=A;i<B+1;i++){
            printf("%d\n", i);
        }
    }else if (small == big){
        for(i=A; i<B+1; i++){
            printf("%d\n", i);
        }
    }
    
    else // if (small < big)
    {
        for(i=A; i<small+1; i++){
            printf("%d\n", i);
        }
        for(i=big; i<B+1; i++){
            printf("%d\n", i);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<vector>

using namespace std;

int solve(int,int,int);

int n,k,cnt;
int d[102];
int memo[102][4][4];

int main(){
	cin >> n >> k;
	
	for(int i=0;i<k;i++){
		int tmp;
		cin >> tmp;
		cin >> d[tmp];
	}
	cout << solve(1,0,0) << endl;
	return 0;
}

int solve(int day,int old_type,int type){
	int rec = 0;
	if(memo[day][old_type][type] != 0)return memo[day][old_type][type];
	
	if(day == n+1){
		rec = 1;
	}
	else if(d[day] != 0){
		if(old_type == type && type == d[day])rec = 0;
		else rec = solve(day+1,type,d[day]);
	}
	else{
		for(int i=1;i<=3;i++){
			if(old_type == type && type == i)continue;
			rec += solve(day+1,type,i);
		}
	}
	return memo[day][old_type][type] = rec%10000;
}

Measured memory_bytes: 1168
import java.util.*;
public class Main{
	public static void main(String[] args){
	Scanner sc= new Scanner (System.in);
	while(sc.hasNext()){
	long a = sc.nextLong();
		long b = sc.nextLong();
		long r = 0;
		long temp = 0;
		long LCM = 0;
		LCM = a * b;
		if ( a < b){
			temp = a;
			a = b;
			b = temp;	
		}
	for( r = a % b; r!=0;){
		temp = r;
		r = b % r;
		b = temp;
	}
	LCM = LCM / b; 
	System.out.println(b +" "+ LCM);
	}
}
}

Measured memory_bytes: 17216
N = gets.to_i

queue = []
N.times do
	a = gets.to_i
	if queue.empty?
		queue.push(a)
		next
	end
	if queue[0] >= a
		queue.unshift(a)
	elsif queue[-1] < a
		queue[-1] = a
	else
		len = queue.size
		s = 0
		t = len - 1
		while true
			if queue[s] < a && queue[s + 1] >= a
				queue[s] = a
				break
			end
			n = (s + t) / 2
			if queue[n] < a
				s, t = n, t
			else
				s, t = s, n
			end
		end
	end
end

puts queue.size

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#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--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi v(n), c(n);
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    int ans = 0;
    rep(i, n) ans += max(v[i]-c[i], 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define sz(x) ((int)(x).size())
#define pii pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;



int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int x; cin >> x;
    if (x >= 30) cout << "Yes";
    else cout << "No";


    return 0;
}

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

int a[10005];

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	
	long long mx=1145141919;
	for(int i=0;i<n;i++){
		if(mx>a[i]){
			mx=a[i];
			}
		}
		
	long long tu=-1111111111;
	for(int i=0;i<n;i++){
		if(tu<a[i]){
			tu=a[i];
		}
	}
	long long h=0;
	for(int i=0;i<n;i++){
		h+=a[i];
	}
	cout<<mx<<" "<<tu<<" "<<h<<endl;
		
		
		return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
const int INF = 1e9 + 5;

int main(){
int n;
  scanf("%d",&n);
  vector<int> ans(3,0);
  for(int i=n-1;i>=0;i--){
  	int t[3];
    scanf("%d%d%d",&t[0],&t[1],&t[2]);
    t[1]+=ans[1];
    t[0]+=ans[0];
    t[2]+=ans[2];
    ans[0]=max(t[1],t[2]);
    ans[1]=max(t[0],t[2]);
    ans[2]=max(t[1],t[0]);
  }
  printf("%d",max(max(ans[0],ans[1]),ans[2]));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,ans=2;
    cin>>n>>x;
    int l[n];
    int m[n];

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

    for(int i=1; i<n; i++)
    {
        m[i]=m[i-1]+l[i];

        if(m[i]<=x)
            ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int n = s.size();
	int res = 0;
	for(int i = 0; i < n; ++i){
		if(s[i]=='+')res++;
		if(s[i]=='-')res--;
	}
	cout<<res<<endl;
	return 0;
}


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

int main(){
  int n;
  while(cin>>n,n){
    vector<char> c(n);
    for(int i=0;i<n;i++)cin>>c[i];
    vector<int> box('Z'-'A'+1,0);
    for(int i=0;i<n;i++){
      box[c[i]-'A']++;
      int fir_b=-1;
      int index=-1;
      int sec_b=-1;
      for(int j=0;j<='Z'-'A';j++){
	int tmp=box[j];
	if(fir_b<box[j]){
	  tmp=fir_b;
	  fir_b=box[j];
	  index=j;
	}
	if(sec_b<tmp){
	  sec_b=tmp;
	}
      }
      if(fir_b>sec_b+(n-1-i)){
	cout<<char('A'+index)<<" "<<i+1<<endl;
	break;
      }
      if(i==n-1){
	cout<<"TIE"<<endl;
      }

    }

				 


  }

  return 0;
}

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

const string str[4] = {"AC", "WA", "TLE", "RE"};

int main(void) 
{
   int n;
   cin >> n;
    map<string, int> mp;
   rep(i,n){
       string s;
       cin >> s;
       mp[s]++;
   }
   rep(i,4) printf("%s x %d \n",str[i].c_str(), mp[str[i]]);
}

Measured memory_bytes: 3728
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    xor = 0
    for a in A:
        xor ^= a
    ans = [a ^ xor for a in A]
    print(*ans)
resolve()

Measured memory_bytes: 114080
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp15
{
    class Class404
    {
        static void Main()
        {
            var AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = AB[0], B = AB[1];
            int count = 0;
            for (int i = A; i <= B; i++)
            {
                string n1 = i.ToString();
                string n2 = string.Join("", n1.Reverse());
                if (n1 == n2) count++;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 46668
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void){
	int A[3];
	int max = 1;
	int min = 100;
	for (int i = 0; i < 3; i++) {
		scanf("%d", &A[i]);
		if (A[i] > max) {
			max = A[i];
		}

		if (A[i] < min) {
			min = A[i];
		}
	}
	printf("%d", max - min);


		return 0;
}



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

using namespace std;

struct Shop {
  string name;
  int price;
  int number;
};

bool cmp(const Shop &a, const Shop &b)
{
    if (a.name == b.name)
    {
        return a.price > b.price;
    }
    
    return a.name < b.name;
}

bool cmp2(const Shop &a, const Shop &b)
{
    return a.price > b.price;
}

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

    vector<Shop> shop;

    string name[n];
    int point[n];
    for (int i = 1; i <= n; i++)
    {
        Shop s;

        cin >> s.name >> s.price;
        s.number = i;

        shop.push_back(s);
    }

    sort(shop.begin(), shop.end(), cmp);

    for (int i = 0; i < n; i++)
    {
        cout << shop[i].number << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
//#include <cmath>
#include <cstdlib>

using namespace std;

long long kaijo(long long x){
  	//cout << x << endl;
    if(x == 1) return 1;
    return x*kaijo(x-1)%1000000007;
}

int main(){

    long long n,m;
    cin >> n >> m;

    if(llabs(n-m) > 1LL){
        cout << "0";
        return 0;
    }
  
  	//cout << n << " " << m << " " << kaijo(n) << " " << kaijo(m) << endl;

    if(n == m) cout << (kaijo(n)*kaijo(m)*2)%1000000007;
    else cout << (kaijo(n)*kaijo(m))%1000000007;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <strings.h>
#include <queue>
using namespace std;

int main()
{
    char C[6];
    cin>>C;
    if((C[2]==C[3]) and (C[4]==C[5])){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

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

using namespace std;

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

#define F first
#define S second

const int MAXN = 1e5 + 10;

int n, a[MAXN];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)	cin >> a[i];
	sort(a, a + n);
	if (a[n-1] - a[0] > 1){
		cout << "No\n";
		return 0;
	}
	if (a[n-1] == a[0]){
		int x = a[0];
		if (x == n-1 || x <= n/2)
			cout << "Yes\n";
		else
			cout << "No\n";
	}
	else{
		int x = a[0], y = a[n-1];
		int cx = 0, cy = 0;
		for (int i = 0; i < n; i++)
			if (a[i] == x)
				cx++;
			else
				cy++;

		int rem = y - cx;
		if (rem <= 0){
			cout << "No\n";
			return 0;
		}

		int cc = n - cx;
		if (rem <= cc/2)
			cout << "Yes\n";
		else
			cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class T> inline std::istream& operator >> (std::istream& is, std::vector<T>& v) { for (T& x : v) { is >> x; }return is; }
	template<class T> inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v) {
		for (auto itr = v.begin(); itr != v.end();) { os << (*itr) << ((++itr != v.end()) ? " " : ""); }
		return os;
	}
	template<class V, typename T>inline void fill(V& v, const T& val) { v = val; }
	template<class V, typename T>inline void fill(std::vector<V>& v, const T& val) { for (V& x : v) { fill(x, val); } }
	template<class V, typename H>inline void resize(std::vector<V>& v, const H h) { v.resize(h); }
	template<class V, typename H, typename... T>inline void resize(std::vector<V>& v, const H& h, const T& ... t) { v.resize(h); for (auto& x : v) { resize(x, t...); } }
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }

	ll a, b;
	ll f(ll x) {
		ll t1 = a * x / b;
		ll t2 = a * (x / b);
		return t1 - t2;
	}


	void solve() {
		IOS;
		ll n;
		cin >> a >> b >> n;
		ll res = 0;
		ll t = n / b * b;
		chmax(res, f(n));
		if (b - 1 <= n) {
			chmax(res, f(b - 1));
		}
		put(res);
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}


Measured memory_bytes: 3640
def pow2(n):
	v = 1
	for i in range(0, n):
		v *= 2
	return v

def switchlist(x, n):
	m = x
	lst = []
	while m != 0:
		lst.append(m%2)
		m = int(m/2)
	for i in range(len(lst), n):
		lst.append(0)
	return lst

N, M = map(int, input().split())
bulb = []
for i in range(0, M):
	inpt = list(map(int, input().split()))
	bulb.append(inpt[1:])
rule = list(map(int, input().split()))
cnt = pow2(N)
for i in range(0, pow2(N)):
	switches = switchlist(i, N)
	for j in range(0, M):
		oncount = 0
		for k in range(0, len(bulb[j])):
			if switches[bulb[j][k]-1] == 1: oncount += 1
		if oncount % 2 != rule[j]:
			cnt -= 1
			break
print(cnt)

Measured memory_bytes: 42604
import java.util.Scanner;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    void run() {
        for (;;) {
            String in = sc.next();
            if (in.equals("#END")) {
                return;
            }
            String ans = "";
            for (int i = 1; i < in.length(); i++) {
                String lcs = lcs(in.substring(0, i), in.substring(i, in.length()));
                if (lcs.length() > ans.length()) {
                    ans = lcs;
                }
            }
            System.out.println(ans);
        }
    }
 
    String lcs(String s, String t) {
        int n = s.length();
        int m = t.length();
        int[][] dp = new int[n + 1][m + 1];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (s.charAt(i) == t.charAt(j)) {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                } else {
                    dp[i + 1][j + 1] = Math.max(dp[i + 1][j], dp[i][j + 1]);
                }
            }
        }
        char[] res = new char[dp[n][m]];
        while (n > 0 && m > 0) {
            if (dp[n][m] == dp[n - 1][m]) {
                n--;
            } else if (dp[n][m] == dp[n][m - 1]) {
                m--;
            } else {
                res[dp[n - 1][m - 1]] = s.charAt(n - 1);
                n--;
                m--;
            }
        }
        return String.valueOf(res);
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 285764
n = int(input())
S = sorted([sorted(input()) for _ in range(n)])

memo = {}
ans = 0

for i in range(n):
    si = ('').join(S[i])
    if si not in memo:
        memo[si] = 1
    else:
        memo[si] += 1
        ans += memo[si] - 1

print(ans)


Measured memory_bytes: 39092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, k;
  cin >> n >> k;
  vl x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];

  ll ans = 1LL << 62;
  rep(xi, n) rep(yi, n) rep(xj, n) rep(yj, n) {
    ll min_x = min(x[xi], x[xj]);
    ll min_y = min(y[yi], y[yj]);
    ll max_x = max(x[xi], x[xj]);
    ll max_y = max(y[yi], y[yj]);
    ll cnt = 0;
    rep(i, n) {
      if (min_x <= x[i] and x[i] <= max_x and min_y <= y[i] and y[i] <= max_y) {
        cnt++;
      }
    }
    if (cnt >= k) {
      cmin(ans, (max_x-min_x)*(max_y-min_y));
    }
  }
  cout << ans << endl;
}


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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	int x,y;
	cin >> x >> y;
	if(x < y) swap(x, y);
	if(x == 2 && y == 2)
		cout << "Yes\n";
	else if(x == 2 || y == 2)
		cout << "No\n";
	else if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
	{
		x = y;
		if(x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
			cout << "Yes\n";
		else cout << "No\n";
	}
	else
	{
		x = y;
		if(x == 4 || x == 6 || x == 9 || x == 11)
			cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S, T;
	int A, B;
	string U;
	map<string, int> smap;
	cin >> S >> T;
	cin >> A >> B >> U;
	smap[S] = A;
	smap[T] = B;
	smap[U]--;

	cout << smap[S] << " " << smap[T] << endl;

	return 0;
}

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

const int INF=1e8;

int main(){
    int k;
    cin>>k;
    vector<int> dist(k,INF);
    vector<int> used(k,0);
    dist[1]=1;
    deque<int> que;
    que.push_front(1);
    while(!que.empty()){
        int v=que.front();
        que.pop_front();
        if(used[v]) continue;
        used[v]=true;
        int forward=(v+1)%k;
        if(dist[forward]>dist[v]+1){
            dist[forward]=dist[v]+1;
            que.push_back(forward);
        }
        int jump=(v*10)%k;
        if(dist[jump]>dist[v]){
            dist[jump]=dist[v];
            que.push_front(jump);
        }
    }
    cout<<dist[0]<<endl;
    return 0;
}

Measured memory_bytes: 1280
def divisor_listout(n,m):
    max_n = max(n,m)
    out = [1]
    for i in range(2,max_n+1):
        if n % i == 0 and m % i == 0:
              out.append(i)
    return out

n1, n2, result = map(int,input().split())
ans = divisor_listout(n1,n2)[::-1]
print(ans[result-1])


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

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

int main() {
        int a, b;
        scanf("%d%d", &a, &b);
        printf("%d\n", 2 * b - a);
        return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <string.h>
#include <cassert>

#ifdef _DEBUG
#define typeof(X) std::identity<decltype(X)>::type //C++0x (for vs2010)
#else
#define typeof(X) __typeof__(X) // for gcc
#endif

#define sz(a)  int((a).size())
#define FOREACH(it, c) for (typeof((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define FOR(i,count) for (int i = 0; i < (count); i++)
#define V_CIN(v) do{for(int i = 0; i < sz(v); i++) cin >> (v)[i];}while(0)
#define all(c) (c).begin(),(c).end()

using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
const int MODULO = 1000000007;

typedef pair<int,int> Pii;

template<int size>
class UnionFind{
	int par[size];
	int rank[size];
public:
	UnionFind(){ reset(); }

	void reset(){
		FOR(i,size) par[i] = i,rank[i] = 0;
	}

	int find(int x){
		if(par[x] == x) return x;
		return par[x] = find(par[x]);
	}

	void unite(int x,int y){
		x = find(x),y = find(y);
		if(x == y) return ;
		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x,int y){return find(x) == find(y);}
};

// begin

char t[10][10];
int h,w,c;
int dh[] = {0,1,0,-1},dw[] = {1,0,-1,0};

void unit(UnionFind<64>& u,char col)
{
	FOR(j,h)FOR(k,w){
		FOR(i,4){
			int nh = dh[i] + j,nw = dw[i] + k;
			if(nh >= h || nw >= w) continue;
			if(u.same(0,j * w + k) && col == t[nh][nw])
				u.unite(j * w + k,nh * w + nw);
		}
	}
}

int color(char last_c,int count,UnionFind<64>& sor){

	if(count == 1){
		if(last_c != c) return 0;
		UnionFind<64> u(sor);
		unit(u,c);
		int ans = 0;
		FOR(j,h*w) ans += u.same(0,j);
		return ans;
	} else {
		int ans = 0;
		for(char i = '1'; i <= '6'; i++){
			if(last_c == i) continue;
			UnionFind<64> u(sor);
			unit(u,i);
			ans = max(ans,color(i,count - 1,u));
		}
		return ans;
	}
}

int main()
{
	while(cin>>h>>w>>c,h||w||c){
		c += '0';
		FOR(i,h) FOR(j,w) cin>>t[i][j];

		UnionFind<64> u;
		FOR(j,h)FOR(k,w){
			FOR(i,4){
				int nh = dh[i] + j,nw = dw[i] + k;
				if(nh >= h || nw >= w) continue;
				if(t[j][k] == t[nh][nw])
					u.unite(j * w + k,nh * w + nw);
			}
		}

		int ans = 0;
		ans = max(ans,color(t[0][0],6,u));
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 872
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define debug(x) cerr<<#x<<":"<<(x)<<endl;

signed main() {
  int n;cin>>n;
  string s; cin>>s;
  int x=0,y=0;
  for(int i=0;i<s.size();++i){
    if ('a' <= s[i] && s[i] <= 'm') ++x;
    if ('n' <= s[i] && s[i] <= 'z') --x;
    if ('A' <= s[i] && s[i] <= 'M') ++y;
    if ('N' <= s[i] && s[i] <= 'Z') --y;
  }

  string ans = "";
  
  if (x<0) ans += string(abs(x),'n');
  else if(x>0) ans += string(x, 'a');
  if (y<0) ans += string(abs(y),'N');
  else if(y>0) ans += string(y, 'A');
  
  cout<<ans.size()<<endl;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

ll GetDays(ll y, ll m, ll d){
    // 1・2月 → 前年の13・14月
    if (m <= 2){
        --y;
        m += 12;
    }
    ll dy = 365 * (y - 1); // 経過年数×365日
    ll c = y / 100;
    ll dl = (y >> 2) - c + (c >> 2); // うるう年分
    ll dm = (m * 979 - 1033) >> 5; // 1月1日から m 月1日までの日数
    return dy + dl + dm + d - 1;
}

ll solve(ll y, ll m, ll d) {
    return GetDays(y, m, d) - GetDays(2012, 12, 21);
}

bool uru(int y) {
    if (y % 400 == 0)return true;
    if (y % 100 == 0)return false;
    if (y % 4 == 0)return true;
    return false;
}
int month[2][13] = {
    {0,31,28,31,30,31,30,31,31,30,31,30,31}
    ,{0,31,29,31,30,31,30,31,31,30,31,30,31}
};
void nextday(int& y, int& m, int& d) {
    if (d == month[uru(y)][m]) {
        m++;
        d = 1;
    }
    else d++;
    if (m == 13) {
        y++;
        m = 1;
    }
}

int main() {
    init();

    string in;
    while (1) {
        cin >> in;
        if (in == "#")break;
        VI a;
        int f = 0;
        FOR(i, 0, in.length()) {
            if (in[i] == '.') {
                a.push_back(stoi(in.substr(f, i - f)));
                f = i + 1;
            }
        }
        a.push_back(stoi(in.substr(f)));

        if (a.size() == 3) {
            int w = 20, t = w * 18, k = t * 20, b = k * 20;
            ll date = solve(a[0], a[1], a[2]) % 1872000;
            cout << date / b << ".";
            date %= b;
            cout << date / k << ".";
            date %= k;
            cout << date / t << ".";
            date %= t;
            cout << date / w << ".";
            date %= w;
            cout << date << "\n";
        }
        else {
            int dif[4] = { 20,20,18,20 };
            FOR(i, 0, 4)a[i + 1] += a[i] * dif[i];
            int date = a[4];

            int y = 2012, m = 12, d = 21;
            FOR(i, 0, date)nextday(y, m, d);
            cout << y << "." << m << "." << d << "\n";
        }
    }
}


Measured memory_bytes: 3172
N = gets.to_i
L = gets.split.map(&:to_i).sort
dp1 = Array.new(1 << 10, 0)
dp2 = Array.new(1 << 11, 0)

ans = L.inject(0) do |count, l|
  dp2.each_with_index do |n, ab|
    count += n if ab > l
  end
  dp1.each_with_index do |n, a|
    dp2[a + l] += n
  end
  dp1[l] += 1
  count
end
puts ans


Measured memory_bytes: 1912
//ABC151-D
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

vector<vector<int>> gridBFS(vector<string> & s, int sy, int sx, char wall = '#'){
    const int dy[] = {0, 1, 0, -1}, dx[] = {1, 0, -1, 0};
    int h = s.size(), w = s[0].size();
    vector<vector<int>> dist(h, vector<int>(w, -1));
    queue<pair<int, int>> que;
    que.emplace(sy, sx);
    dist[sy][sx] = 0;
    while(!que.empty()){
        pair<int, int> p = que.front();
        que.pop();
        for(int i = 0; i < 4; i++){
            int ny = p.first + dy[i], nx = p.second + dx[i];
            if(0 <= ny && ny < h && 0 <= nx && nx < w && s[ny][nx] != wall && dist[ny][nx] == -1){
                que.emplace(ny, nx);
                dist[ny][nx] = dist[p.first][p.second] + 1;
            }
        }
    }
    return dist;
}

signed main(){
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i,h){
        cin >> s[i];
    }
    int ans = 0;
    for(int y = 0; y < h; y++){
        for(int x = 0; x < w; x++){
            if(s[y][x] == '.'){
                vector<vector<int>> dist = gridBFS(s, y, x);
                for(int i = 0; i < h; i++){
                    for(int j = 0; j < w; j++){
                        ans = max(ans, dist[i][j]);
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def input():
    import sys
    return sys.stdin.readline().rstrip()


def factorial(n, DIVISOR):
    import functools
    return functools.reduce(lambda x, y: (x % DIVISOR) * y, range(1, n + 1)) % DIVISOR


def main():
    import math
    import collections
    import itertools
    import functools

    DIVISOR = 10 ** 9 + 7
    n, m = map(int, input().split())
    if abs(n - m) > 1:
        print(0)
    elif abs(n - m) == 0:
        print((factorial(n, DIVISOR) ** 2 * 2) % DIVISOR)
    elif abs(n - m) == 1:
        print(factorial(min(n, m), DIVISOR) ** 2 * max(n, m) % DIVISOR)


if __name__ == '__main__':
    main()

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, k;
	cin>>n>>k;
	vector<int> p(n);
	for(auto &x : p){
		cin>>x;
	}
	int sum = 0;
	for(int i = 0; i < k; i++){
		sum += p[i];
	}
	int ans = sum;
	for(int i = k; i < n; i++){
		sum += p[i] - p[i - k];
		ans = max(ans, sum);
	}
	cout<<ld(ans + k)/2<<endl;

	return 0;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.ArrayList;

public class Main
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s;
		while((s=br.readLine())!=null && !s.isEmpty())
		{
			int n = Integer.parseInt(s.split(" ")[0]);
			int sum = Integer.parseInt(s.split(" ")[1]);
			if(n==0 && sum==0) break;
			ArrayList<Integer> a = new ArrayList<Integer>();
			if(sum<10)
				for(int i=0; i<=sum; i++) a.add(i);
			else
				for(int i=0; i<10; i++) a.add(i);
			System.out.println(combination(a,0,sum,n));
		}
	}

	private static int combination(ArrayList<Integer> num, int index, int sum, int n)
	{
		if(n==0 || index == num.size()) 		 return 0; //answer not found 
		int rest=0;
		if((rest=sum-num.get(index))==0 && n==1) return 1; //answer found
		return combination(num, index+1, rest, n-1) + combination(num, index+1, sum, n);
	}	
}

Measured memory_bytes: 9688
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll factmemo[SIZE];
ll factmemoMod = -1;
void initFactorial(int n, int M){
  factmemoMod = M;
  factmemo[0] = 1;
  for(int i=1;i<=n;i++) factmemo[i] = (factmemo[i-1] * i)%M;
}

ll factorial(int n,int M){
  if(factmemoMod == M) return factmemo[n];
  
  ll ret=1;
  if(n<=1) return 1;
  
  for(int i=1;i<=n;i++) ret = (ret*i)%M;
  
  return ret;
}

ll power(int k,int n,int M){
  if(n==0) return 1;
  if(n==1) return (ll)k;
  
  ll ret = power(k,n/2,M);
  
  ret=(ret*ret)%M;
  
  if(n%2==1) ret=(ret*k)%M;
  
  return ret;
}


//nCm nPm nHm (mod M)

/*Combination*/
int C(int n,int m,int M){
  if(n<m) return 0;
  if(m==0 || n==m) return 1;
  
  ll chi = factorial(n,M);
  ll mot = (factorial(m,M) * factorial(n-m,M))%M;
  
  mot = power((int)mot,M-2,M);
  
  ll ret = (chi*mot)%M;
  
  return (int)ret;
}

/*Permutation*/
int P(int n,int m,int M){
  if(n<m) return 0;
  if(m==0) return 1;
  
  ll chi = factorial(n,M);
  ll mot = factorial(n-m,M);
  
  mot = power((int)mot, M-2,M);
  
  ll ret = (chi*mot)%M;
  
  return (int)ret;
}

/*Combination with Repetitions*/
int H(int n,int m,int M){
  if(n==0 && m==0) return 1;
  return C(n+m-1,m,M);
}


int main(){
  int n, m;

  cin >> n >> m;

  ll ans = 1;

  initFactorial(SIZE-1, mod);
  
  for(int i=2;i*i<=m;i++){
    int cnt = 0;

    while(m%i==0){
      cnt++;
      m/=i;
    }

    ans *= C(cnt+n-1, n-1, mod);
    ans %= mod;
  }

  if(m != 1){
    ans *= C(n, 1, mod);    
    ans %= mod;
  }

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



Measured memory_bytes: 1792
#include <stdio.h>

int main(){
	int time,h,m,s,c;
	scanf("%d",&time);
	h=time/3600;
	c=time-h*3600;
	m=c/60;
	s=c-m*60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

template <typename T>
struct edge
{
    int src, to;
    T cost;

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    edge &operator=(const int &x)
    {
        to = x;
        return *this;
    }

    operator int() const { return to; }
};

//Weighted edge set
template <typename T>
using Edges = vector<edge<T>>;
//Weighted graph
template <typename T>
using WeightedGraph = vector<Edges<T>>;
//Unweighted graph (adjacency matrix)
using UnweightedGraph = vector<vector<int>>;
//distance matrix
template <typename T>
using Matrix = vector<vector<T>>;

int main()
{
    int N;
    cin >> N;
    UnweightedGraph G = vector<vector<int>>(N, vector<int>(N, 0));
    for (int i = 0; i < N; i++)
    {
        int a, c;
        cin >> a >> c;
        a--;
        for (int j = 0; j < c; j++)
        {
            int b;
            cin >> b;
            b--;
            G[a][b]++;
        }
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cout << G[i][j] << (j == N - 1 ? "\n" : " ");
        }
    }
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int main() {
    vector<int> k;
    int r, D , x;
    cin  >> r >> D >> x;
    for(int i = 0; i < 10; i++){
        x = r*x - D;
        cout << x << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int[] len = new int[N];
		long cnt = 0;
		for (int i = 0; i < N; i++) {
			len[i] = input.nextInt();
		} 
		Arrays.sort(len);
		for (int S = 0; S < N; S++) {
			for (int M = S+1; M < N; M++) {
				for (int L = M+1; L < N; L++) {
					if (len[L]<len[M]+len[S]) cnt++;
					else break;
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 31556
import math



H,N = map(int,input().split())
Damage = []
Cost = []


DP = [0] + [pow(10,9)] * (H+1)



for i in range(N):
    a,b = map(int,input().split())
    Damage.append(a)
    Cost.append(b)
    
#print(DP)


# DP[i] = min magic points to do i damage

for i in range(1,len(DP)):
    for spell in range(N):
        DP[i] = min(DP[i],DP[max(0,i-Damage[spell])]+Cost[spell])




print (DP[H])


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


int main() {
    string S;
    cin >> S;
    int n = S.length();
    int ans;
    //bool flag=false;
    for(int i=n-2; i; i-=2){
        if(S.substr(0,i/2)==S.substr(i/2,i/2)){
            ans=i;
            break;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    N = int(input())
    order_list = list(map(int, input().split()))
    present_list = list(range(1, N+1))
    temp = zip(order_list, present_list)
    temp = sorted(temp)
    order_list, present_list = zip(*temp)
    print(' '.join(map(str,present_list)))


Measured memory_bytes: 27236
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int mod=1e9+7;
int add(int x,int y){return x+y<mod?x+y:x+y-mod;}
void ade(int& x,int y){x+=y;if(x>=mod)x-=mod;}
int qpow(int x,int k)
{
	int r=1;
	while(k)
	{
		if(k&1)r=1ll*r*x%mod;
		k>>=1;x=1ll*x*x%mod;
	}
	return r;
}
int T;
int n,m;
int f[660][660];
int ed[660];
int pre[660];
int g[660];
bool check(int l,int r)
{
	for(int i=l;i<=r;++i) if(ed[i]&&(ed[i]<l||ed[i]>r))return 0;
	return 1;
}
int getr(int l,int r){return r>=l?pre[r]-pre[l-1]:0;}
int calc(int l,int r)
{
	int res=g[getr(l,r)];
	for(int i=l+1;i<r;i+=2)
		ade(res,mod-1ll*f[l][i]*g[getr(i+1,r)]%mod);
	return res;
}
int main()
{
	g[0]=1;
	for(int i=2;i<=600;i+=2)g[i]=1ll*g[i-2]*(i-1)%mod;
	memset(f,0,sizeof(f));
	memset(ed,0,sizeof(ed));
	memset(pre,0,sizeof(pre));
	scanf("%d%d",&n,&m);
	int x,y;
	for(int i=1;i<=m;++i)
	{
		scanf("%d%d",&x,&y);
		ed[x]=y;
		ed[y]=x;
	}
	for(int i=1;i<=n*2;++i) pre[i]=pre[i-1]+(!ed[i]);
	int ans=0;
	for(int l=1;l<=n*2;++l)
		for(int r=l+1;r<=n*2;r+=2)
			if(check(l,r))
			{
				f[l][r]=calc(l,r);
//				cout<<"l: "<<l<<" r: "<<r<<" f: "<<f[l][r]<<" re: "<<getr(1,l-1)+getr(r+1,n*2)<<endl;
				ade(ans,1ll*f[l][r]*g[getr(1,l-1)+getr(r+1,n*2)]%mod);
			}
	printf("%d\n",ans);
	return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int maxn = 200000+10;
int N,K,A[maxn];

int get(int act,int x){
	//if(act <= x)return 0;
	//return 1+get(act-x,x);
	return act/x;
}
int can(int x){
	int cnt = 0;
	forn(i,0,N){
		if(A[i] <= x)continue;
		cnt += get(A[i],x);
	}
	if(cnt > K)return 0;
	return 1;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> K;
	forn(i,0,N)cin >> A[i];
	int ini = 1,fin = 1e9+1;
	while(ini < fin){
		int mit = (ini+fin)>>1;
		if(can(mit))fin = mit;
		else ini = mit+1;
	}
	cout << ini << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
int i,j,n,a[50],c;
int main(){
  for(cin>>n;i<n;i++)cin>>a[i];
  for(i=0;i<n-1;i++)for(j=i+1;j<n;j++)c+=a[i]*a[j];
  cout<<c;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		for(int i=0; i<N; i++) {
			int temp = sc.nextInt();
			if(m.containsKey(temp)) {
				m.put(temp, m.get(temp) + 1);
			} else {
				m.put(temp, 1);
			}
		}
		sc.close();
		int ans = 0;
		for(Map.Entry<Integer, Integer> entry : m.entrySet()) {
			int minusone = 0;
			int plusone = 0;
			if(m.containsKey(entry.getKey()-1)) {
				minusone = m.get(entry.getKey()-1);
			}
			if(m.containsKey(entry.getKey()+1)) {
				plusone = m.get(entry.getKey()+1);
			}
			if(ans < minusone + plusone + entry.getValue()) {
				ans = minusone + plusone + entry.getValue();
			}
		}
		System.out.println(ans);
	}

}


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int R = nextInt();

		String ans ;
		if(R<1200){
			ans="ABC";
		}else if(R<2800){
			ans="ARC";
		}else{
			ans="AGC";
		}




		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21332
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
#include <fstream>
#include <cassert>
#include <cmath>
#include <sstream>
#include <time.h>
#include <complex>

#include <unordered_map>
#include <unordered_set>
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define DFOR(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define rep(i,n) FOR(i,0,n)
#define repn(i,n) FORN(i,1,n)
#define drep(i,n) DFOR(i,n-1,0)
#define drepn(i,n) DFOR(i,n,1)
#define MAX(a,b) a = Max(a,b)
#define MIN(a,b) a = Min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define Reset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(all(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)
#define forever for(;;)
#define PINF 1000000000000
#define newline '\n'

#define test if(1)if(0)cerr
using namespace std;

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;
const double pi = acos(-1.0);

vector<string> v;

int main()
{
    v.resize(3);
    rep(i, 3)
    {
        cin >> v[i];
    }
    SORT(v); bool ans = false;
    do
    {
        bool tmp = true;
        for (int i = 0; i < 2; ++i)
        {
            if (v[i].back() != v[i+1].front())
            {
                tmp = false;
                break;
            }
        }
        if (tmp)
        {
            ans = true;
            break;
        }
    } while (next_permutation(v.begin(), v.end()));
    cout << (ans?"YES":"NO") << newline;
}

Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long int
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
int n,w;
ll a[105],b[105];
ll dp[105][100005];

ll recurse(int weight,int ind)
{
    if(ind>=n)
        return 0;
    if(dp[ind][weight]!=-1)
        return dp[ind][weight];
    dp[ind][weight]=max(dp[ind][weight],recurse(weight,ind+1));
    if(weight+a[ind]<=w)
        dp[ind][weight]=max(dp[ind][weight],recurse(weight+a[ind],ind+1)+b[ind]);
    return dp[ind][weight];

}

int main()
{ quick;

    memset(dp,-1,sizeof(dp));
    cin>>n>>w;
    fab(0,n,i)
    cin>>a[i]>>b[i];
    
    cout<<recurse(0,0)<<endl; 
    

 cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}

Measured memory_bytes: 85828