akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    ll H[N];
    REP(i, 0, N) {
        cin >> H[i];
    }
    V<bool> ok(N, true);
    REP(i, 0, M) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        if (H[a] <= H[b]) {
            ok[a] = false;
        }
        if (H[b] <= H[a]) {
            ok[b] = false;
        }
    }
    ll ans = 0;
    REP(i, 0, N) {
        if (ok[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4444
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
int dp[2010][2010],n,k;
int main(){
	dp[0][0]=1;
	for(int i=1;i<=2000;i++){
		dp[i][0]=1;
		for(int j=1;j<=i;j++){
			dp[i][j]=dp[i-1][j]+dp[i-1][j-1];
			dp[i][j]%=MOD;
		}
	}
	scanf("%d %d",&n,&k);
	n-=k;
	printf("%d\n",n+1);
	for(int i=2;i<=k;i++){
		long long res=0;
		if(i>n+1){
			puts("0");
			continue;
		}
		for(int j=i-1;j<=n;j++){//中间 
			long long tmp=1;
			tmp=(long long)dp[j-1][i-2]*(n-j+1);
			tmp%=MOD;
			tmp*=dp[k-1][i-1];
			tmp%=MOD;
			res+=tmp;
			res%=MOD;
		}
		printf("%lld\n",res);
	}
	return 0;
}

Measured memory_bytes: 15104
num = int(input())
li = [1]
for i in range(2,1001):
    for j in range(2,1001):
        if(i**j <= num):
            li.append(i**j)
        else:break
for i in sorted(list(set(li))):
    if(i <= num):
        temp = i
    else:
        break
print(temp)

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

const int pdx[12] = { -2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2 };
const int pdy[12] = { -1, 0, 1, -2, 2, -2, 2, -2, 2, -1, 0, 1 };
const int sdx[9] = { 0, 0, 0, 1, 1, 1, -1, -1, -1 };
const int sdy[9] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
bool memo[10][10][10];
int sx[10];
int sy[10];
int n;
bool flag;


void init()
{
	flag = false;
	for (int i = 0; i < 10; i++)
	{
		for (int j = 0; j < 10; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				memo[i][j][k] = false;
			}
		}
	}
}

bool isSafePos(int x, int y, int t)
{
	for (int i = 0; i < 9; i++)
	{
		if (x == sx[t] + sdx[i] && y == sy[t] + sdy[i]) return true;
	}
	return false;
}

bool check(int x, int y, int t)
{
	if (x < 0 || 9 < x || y < 0 || 9 < y) return false;
	if (memo[x][y][t]) return false;
	if (!(isSafePos(x, y, t))) return false;
	return true;
}


void calc(int x, int y, int t)
{
	memo[x][y][t] = true;
	if (t == n)
	{
		flag = true;
		return;
	}
	for (int i = 0; i < 12; i++)
	{
		int X = x + pdx[i];
		int Y = y + pdy[i];
		if (check(X, Y, t % n))	calc(X, Y, t + 1);
	}
}


int main()
{
	int px, py;
	while (cin >> px >> py, px + py)
	{
		cin >> n;
		for (int i = 0; i < n; i++) cin >> sx[i] >> sy[i];
		init();
		calc(px, py, 0);
		if (flag) cout << "OK" << endl;
		else cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)

int gcd(int x,int y){ return (!y ? x : gcd(y, x%y)); }
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const int base[] = {4001, 4001};
inline int mu(int x,int y){
	return 1LL * x * y % mod;
}
inline int ad(int x,int y){
	return (x + y) % mod;
}
int h[2][maxn], pw[2][maxn];
int gh(int l,int r, int k){
	return ad(h[k][r], mod - mu(h[k][l], pw[k][r - l]));
}
pii gh2(int l,int r){
	return {gh(l, r, 0), gh(l, r, 1)};
}
int32_t main(){
	//IOS;
	int n; string s;
	cin >> n >> s;
	for(int i=0; i<2; i++){
		pw[i][0] = 1;
		for(int j=1; j<maxn; j++)
			pw[i][j] = mu(pw[i][j - 1], base[i]);
		for(int j=1; j<=n; j++)
			h[i][j] = ad(mu(h[i][j - 1], base[i]), s[j - 1] + 33);
	}
	int lo = 0, hi = n;
	while(hi - lo > 1){
		int mid = hi + lo >> 1;
		map<pii,bool> mp;
		bool can = 0;
		for(int r=n; r-mid>=0; r--){
			mp[gh2(r - mid, r)] = 1;
			if(r >= 2* mid){
				auto val = gh2(r - 2 * mid, r - mid);
				if(mp[val])
					can = 1;
			}
		}
		if(can)
			lo = mid;
		else
			hi = mid;
	}
	cout << lo << endl;
}


Measured memory_bytes: 10752
#include <iostream>
#include <iomanip>
#include <deque>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
int ans=0;
int n,x;
int m[105];
const double eps=1e-9;
typedef vector<int> vi;
typedef long long ll;
int main(void)
{
  cin >> n >> x;
  int ans=n;
  for(int i=0;i<n;i++)
    {
      cin >> m[i];
      x-=m[i];
    }
  sort(m,m+n);
  ans+=x/m[0];
  cout << ans << endl;
  
  return 0;
}


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

const int N=15;

int n,mn,k;

int a[N],d,bin[N],ban[N];

inline int solve(int step=d,int flag=0){
  if(flag){
    int ret=0;
    for(int i=1;i<=step;i++)ret+=bin[i]*mn;
    return ret;
  }
  if(!step)return 0;
  for(int i=flag?0:a[step];i<10;i++)if(!ban[i]){
    int tmp=0;
    if(~(tmp=solve(step-1,i>a[step])))
      return tmp+bin[step]*i;
  }
  return -1;
}

inline bool chk(int x){
  while(x){if(ban[x%10])return 0;x/=10;}
  return 1;
}

int main(){
  scanf("%d%d",&n,&k);
  bin[1]=1;for(int i=2;i<=6;i++)bin[i]=bin[i-1]*10;
  while(k--){
    int x;
    scanf("%d",&x);ban[x]=1;
  }
  for(int i=n;;i++)if(chk(i))return printf("%d\n",i),0;
  while(ban[mn])mn++;
  while(n)a[++d]=n%10,n/=10;
  int ans=solve();
  if(!~ans){
    int x=mn;
    while(!x&&ban[x])x++;
    ans=bin[d+1]*x;
    for(int i=1;i<=d;i++)ans+=bin[i]*mn;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>

using namespace std;

int main(){
    int a,b,t;
    cin >> a >> b >> t;
    cout << (t/a)*b << endl;
    return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

// https://beta.atcoder.jp/contests/abc080/tasks/abc080_b

int main() {
    ll N; cin >> N;
    string strN = to_string(N);

    ll sum = 0;
    REP(i, strN.length()) {
        sum += strN[i] - '0';
    }

    if (N % sum == 0) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
import sys
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]

if K < 2:
    raise Exception('Error!')

sum = K
for i in range(N-1):
    sum = sum*(K-1)

if __name__ == '__main__':
    print(sum)

"""
def myfunc(n, k):
    if n <= 0:
        return k
    n = int(n-1)
    k = k*(k-1)
    return myfunc( n,k )

if __name__ == '__main__':
    print(int(myfunc(N, K)))
"""


Measured memory_bytes: 3060
N = int(input())
A = [int(input()) for _ in range(N)]
B = sorted(A)
bool = 1 if B[-1] == B[-2] else 0
for i in range(N):
  if bool:
    print(B[-1])
  else:
    if A[i] == B[-1]:
      print(B[-2])
    else:
      print(B[-1])

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

int c[3][3];
int a[3];
int b[3];

int main(){

    
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            cin >> c[i][j];
        }
    }
    a[0]= 0;
    b[0] = c[0][0]-a[0];
    b[1] = c[0][1]-a[0]; 
    b[2] = c[0][2]-a[0];
    a[1] = c[1][0]-b[0];
    a[2] = c[2][0]-b[0];

    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            if(a[i]+b[j] != c[i][j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    
    
    

    return 0;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define N 100005
using namespace std;

int n,m;
vector<int> G[N],ans;
bool used[N];

void dfs(int x){
  
  if(used[x])return;
  used[x]=1;
  ans.push_back(x);

  for(int i=0;i<G[x].size();i++){
    if(!used[G[x][i]]){
      dfs(G[x][i]);
      break;
    }
  }
  
}

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

  int a,b;
  for(int i=0;i<m;i++){
    scanf("%d%d",&a,&b);
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  
  dfs(0);
  reverse(ans.begin(),ans.end());
  
  int end=ans[ans.size()-1];
  for(int i=0;i<G[end].size();i++)
    if(!used[G[end][i]]){
      dfs(G[end][i]);
      break;
    }

  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    if(i)printf(" ");
    printf("%d",ans[i]+1);
  }

  cout<<endl;
  return 0;
}


Measured memory_bytes: 9720
// D - Islands War
#include <bits/stdc++.h>
using namespace std;

int in(){int x;scanf("%d",&x);return x;}

int main(){
	int N=in(), M=in();
	vector<pair<int,int>> V;
	while(M--){
		int l=in(), r=in();
		V.emplace_back(r,l);
	}
	sort(V.begin(), V.end());
	int ans = 0, R = 0;
	for(auto p:V) if(p.second >= R){ R = p.first; ans++; }
	cout<< ans <<endl;
}

Measured memory_bytes: 1400
def main():
    a, b = list(map(float, input().split()))
    round = lambda x: int((x * 2 + 1) // 2)
    a = round(a)
    b = round(100 * b)
    ans = str(a * b)
    if len(ans) >= 3:
        print(ans[:-2])
    else:
        print(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61932
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define VL vector < ll >
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
#define cu cout<<
#define en endl
#define sp " "
#include<cstdio>
#include<cstring>
void bug()
{
    cout << "here\n";
}
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
#define N 10000009
bool prime[N];
vector<ll> prm;
void seive ()
{
    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {

        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
bool isprime(ll n)
{
    if(n<2) return 0;
    if(n==2) return 1;
    else
    {
        for(int i=2; i*i<=n; i++)
            if(n%i==0) return 0;
    }
    return 1;

}

ll countSum(ll x)
{
    ll res = 0;
    while (x != 0)
    {
        res += (x % 10);
        x /= 10;
    }
    return res;
}
const int nx = 2e5+5;

int main()
{
    fast;
    string x;
    cin >> x;
    int c = 0;
    int mx = 0;
    //cout << x <<endl;
    for( char ch : x)
    {
        if(ch == 'R')c++;

        else
        {
            mx = max(mx,c);
            c=0;
        }
        //cout << c <<endl;
    }
    cout << max(mx,c) <<endl;

}






Measured memory_bytes: 3656
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int ans = (int)(n / 1.08);
			while (true) {
				int val = (int)(ans * 1.08);
				if (val == n) {
					Console.WriteLine(ans);
					return;
				}

				if (val < n) {
					++ans;
				} else {
					Console.WriteLine(":(");
					return;
				}
			}
		}
	}


	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 11092
#include <iostream>
using namespace std;
int main(){
    int H, W;
    while(1){
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3072
def reppref(s, n)
	s.bytes * ((s.size + n - 1) / s.size)
end

s = gets.chomp
t = gets.chomp

ptn = reppref(t, s.size + t.size)
mp = [-1]
j = -1
ptn.size.times{|i|
	j = mp[j] while j >= 0 && ptn[i] != ptn[j]
	j += 1
	mp.push(j)
}

j = 0
mx = 0
reppref(s, s.size * 2 + t.size).each{|x|
	j = mp[j] while j == ptn.size || (j >= 0 && ptn[j] != x)
	j += 1
	mx = j if mx < j
}
puts (mx >= s.size + t.size ? -1 : mx / t.size)


Measured memory_bytes: 48416
#include <iostream>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin >> n;
    
    bool p[60000];
    for (int i = 1; i <= 55555; i++) p[i] = true;
    
    p[1] = false;
    int x = 2, q1[10000], q = 0;
    while (1) {
        if (p[x]) {
            int y = 2 * x;
            while (y <= 55555) {
                p[y] = false;  y += x;
            }
        }
        x++;
        if (x > 55555) break;
    }
    
    for (int i = 1; i <= 55555; i++) {
        if (i % 5 == 1 && p[i]) {
            q1[q] = i;
            q++;
        }
    }
    
    for (int i = 0; i < n; i++) {
        cout << q1[i] << " ";
    }
    
    
}


Measured memory_bytes: 256
import fractions
def myegcd(a,b):
    x1 = 1
    y1 = 0
    z1 = a
    x2 = 0
    y2 = 1
    z2 = b
    while z2!=fractions.gcd(a,b):
        if z2==0:
            break
        q = (z1-(z1%z2))/z2
        x1 = x1 -(q*x2)
        y1 = y1 -(q*y2)
        z1 = z1 -(q*z2)

        t = x1
        x1 = x2
        x2 = t

        t = y1;
        y1 = y2;
        y2 = t;

        t = z1;
        z1 = z2;
        z2 = t;
    return x2,y2

p,q = map(int,raw_input().split())
ans1,ans2 = myegcd(p,q)
print ans1,ans2

Measured memory_bytes: 7936
from sys import stdin
#import heapq
K,T = [int(x) for x in stdin.readline().rstrip().split()]
data = [(int(b),a) for a,b in enumerate(stdin.readline().rstrip().split())]
#heapq.heapify(data)
ans = 0
cake_num = -1
flag = True
 
if T == 1:
    ans = K-1
else:
    while flag:
        data.sort()
        #print(data)
        c_c,c_n = data.pop()
        #print(c_c,c_n)
        if c_n == cake_num:
            c_c2,c_n2 = data.pop()
            if c_c2 == 0:
                ans = c_c
                flag = False
            else:
                data.append((c_c2-1,c_n2))
            data.append((c_c,c_n))
            cake_num = c_n2
            #flag = False
        else:
            data.append((c_c-1,c_n))
            cake_num = c_n
        if c_c == 0:
            ans = 0
            flag = False
        
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N;
    multiset<ll> a;
    rep(i,N) cin>>A, a.insert(A);
    ll ans = 0, two = (1LL<<31);
    while(!a.empty()){
        auto ite = a.end();
        --ite;
        ll comp = *ite;
        a.erase(ite);
        while(two > comp * 2) two /= 2;
        ite = a.find(two - comp);
        if(ite != a.end()){
            ++ans;
            a.erase(ite);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 9600
# -*- coding:utf-8 -*-
n, m = map(int, input().split())
d = []
for i in range(m):
    a, b = map(int, input().split())
    d.append([a, b])

d.sort(key=lambda x: (x[0], x[1]))

mn = 100000000
ans = 0
for a, b in d:
    if a >= mn:
        ans += 1
        mn = b
    mn = min(mn, b)

if mn != 100000000:
    ans += 1
print(ans)


Measured memory_bytes: 64788
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n-1); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define scout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int n,b; cin >> n >> b;
	vector<string> a(n);
	rep(i,n) cin >> a[i];
	sort(be(a));
	rep(i,n) cout << a[i];
	cout << endl;
}

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

using namespace std;

#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define INF 0x3f3f3f3f
#define f1(n) for(int i=0 ; i<n ; i++)
#define f2(m) for(int j=0 ; j<m ; j++)
#define ll long long
typedef pair<int, int> iPair;
const double epsilon = 1e-7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<int> v(5);
  int index;
  for (int i=0; i<5; ++i) {
    cin >> v[i];
    if (v[i] == 0)
      index = i;
  }
  cout << index + 1 << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };




signed main() {
	int n, k;
	string s;
	int l, r;
	vector<pair<bool, int>>list;
	vector<int>list2;


	cin >> n >> k;
	cin >> s;

	//左からi番目の人は、Sのi文字目が 0 のとき直立し、1 のとき逆立ちしています。
	
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}

	bool flag = false;// false=0, true=1
	string str = { s[0] };
	int cnt = 0;

	for (int i = 0; i < n; i++) {
		if (i == n - 1) {
			list.push_back(make_pair(str[0] - '0', str.length()));
			break;
		}

		if (s[i] != s[i + 1]) {
			list.push_back(make_pair(s[i] - '0', str.length()));
			str = s[i + 1];
		}
		else if (s[i] == s[i + 1]) {
			str += s[i + 1];
		}
	}

	int sum = 0, maxn = 0;

	for (int i = 0; i < list.size(); i++) {
		sum += list[i].second;
		list2.push_back(sum);
	}

	for (int i = 0; i < list.size(); i++) {
		if (list[i].first == 0) {
			//int num = ((i + (2 * k - 1)) < list.size() ? (list2[(i + (2 * k - 1))] - list2[i]) : (list2[list.size() - 1] - list2[i]));
			int num = ((i + (2 * k - 1)) < list.size() ? (list2[(i + (2 * k - 1))] - list2[i] + list[i].second)  : (list2[list.size() - 1] - list2[i]) + list[i].second);
			maxn = max(maxn, num);
		}
		else if (list[i].first == 1) {
			int num = ((i + (2 * k )) < list.size() ? (list2[(i + (2 * k ))] - list2[i] + list[i].second) : (list2[list.size() - 1] - list2[i] + list[i].second));
			maxn = max(maxn, num);
		}
	}

	cout << maxn << endl;

	return 0;
}

Measured memory_bytes: 2164
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import bisect
import sys
def sieve(n):
    prime = []
    isprime = [1] * n
    isprime[0] = isprime[1] = False
    for i in range(2, n):
        if(isprime[i] == False):continue
        prime.append(i)
        for j in range(2*i, n, i):
            isprime[j] = False
    return prime

prime = sieve(100000)
for n in sys.stdin:
    n = int(n)
    m = bisect.bisect_left(prime, n)
    if n == prime[m]:
        print prime[m - 1], prime[m + 1]
    else:
        print prime[m - 1], prime[m]

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

char T[2] = { '+', '-' };

int main() {
  string s;
  cin >> s;
  int A = s[0] - '0', B = s[1] - '0', C = s[2] - '0', D = s[3] - '0';
  rep(op1, 0, 2) {
    rep(op2, 0, 2) {
      rep(op3, 0, 2) {
        int ret = A;
        if (op1 == 0) {
          ret += B;
        } else if (op1 == 1) {
          ret -= B;
        }

        if (op2 == 0) {
          ret += C;
        } else if (op2 == 1) {
          ret -= C;
        }

        if (op3 == 0) {
          ret += D;
        } else if (op3 == 1) {
          ret -= D;
        }

        if (ret == 7) {
          cout << A << T[op1] << B << T[op2] << C << T[op3] << D << "=7" << endl;
          return 0;
        }
      }
    }
  }
};


Measured memory_bytes: 256
def analyze_map(data):
    S1 = []  # ?°´????????????????§?????????£?????¨
    S2 = []  # ?°´??????????????¢?????£?????¨

    area = 0
    for i, p in enumerate(data):
        if p == '\\':
            S1.append(i)  # '\'?????????????????????????¨???¶
        elif p == '/':
            if S1:
                pos = S1.pop()
                area = (i - pos)
                while S2 and S2[-1][0] > pos:
                    sub_pos, sub_area = S2.pop()
                    area += sub_area
                S2.append((pos, area))
    return S2


if __name__ == '__main__':
    # ??????????????\???
    #data = '\\\\///\\_/\\/\\\\\\\\/_/\\\\///__\\\\\\_\\\\/_\\/_/\\'
    #data = '\\\\///\\_/\\/'
    data = input()

    # ???????????????
    results = analyze_map(data)

    # ???????????¨???
    # print(results)
    total_area = sum([area for pos, area in results])
    if total_area:
        print(total_area)
        valid_areas = [area for start, area in results if area > 0]
        print('{0} {1}'.format(len(valid_areas), ' '.join(map(str, valid_areas))))
    else:
        print('0\n0')

Measured memory_bytes: 7944
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
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);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
string s;
int m[224514];
int cnt[2020];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> s;
	int n = s.size();
	for (int i = n - 1; i >= 0; i--)m[n - i] = (m[n - i - 1] + (s[i] - '0') * mod_pow(10, n - i - 1, 2019)) % 2019;
	for (int i = 0; i <= n; i++)cnt[m[i]]++;
	int ans = 0;
	for (int i = 0; i <= 2018; i++)ans += cnt[i] * (cnt[i] - 1) / 2;
	cout << ans << endl;
	ggr
}

Measured memory_bytes: 5292
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i<(int)n; ++i)
#define forr(i, t, n) for (int i = t; i<n; ++i)
#define rmod(x, y) (((x%y)+y)%y)
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int MAXN = 1e5;
const int MAXH = 1e4;

int n, k;
int h[MAXN];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	forn(i, n)	cin >> h[i];
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	forr(i, 2, n)
	{
		int mn = INT_MAX;
		forr(j, 1, k+1)
		{
			if (i-j<0) break;
			mn = min(dp[i-j] + abs(h[i]-h[i-j]), mn);
		}
		dp[i] = mn;
	}
	cout << dp[n-1];
	
	return 0;
}

Measured memory_bytes: 1024
s=input()
ls=len(s)
R=[1]+[0]*(ls-1)
L=[0]*(ls-1)+[1]
for i in range(1,ls):
    if s[i]=='R':
        R[i] = R[i-1]+1
    if s[-(i+1)]=='L':
        L[-(i+1)] = L[-i]+1
cnum=[0]*ls
for i in range(ls-1):
    if L[i]==0 and R[i+1]==0:
        cnum[i] = (R[i]+L[i+1])//2 + (R[i]%2==1 and L[i+1]%2==0)
        cnum[i+1] = (R[i]+L[i+1])//2 + (R[i]%2==0 and L[i+1]%2==1)
print(*cnum)

Measured memory_bytes: 11140
#include<iostream>
#include<vector>
#include<map>
#include<tuple>
#include<string>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV 1000000007
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m; x=x*x%m;n>>=1;}return r%m;}
using namespace std;
 
int main(){
  map<int,int> mii;
  int n;cin >> n;
  rep(i,n){
    int d; cin >> d;
    mii[d]++;
  }
  int m; cin >> m;
  int flag = 0;
  rep(i,m){
    int t; cin >> t;
    mii[t]--;
    if(mii[t] == -1)
      flag=1;
  }
  if(!flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 9600
n, a, b, c, d = gets.chomp.split.map(&:to_i)
s = gets.chomp
if s[b..d-2].include?("##")
  puts "No"
  exit
end
if s[a..c-2].include?("##")
  puts "No"
  exit
end
if c < d
  puts "Yes"
else
  if s[b-2..d].include?("...")
    puts "Yes"
    exit
  end
  puts "No"
end


Measured memory_bytes: 2428
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int D;

int main(){
    cin>>D;
    printf("Christmas ");
    rep(i,25-D){
        printf("Eve ");
    }
    out("");
}


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

ll n;
ll ans;

void dfs(ll x, int a, int b, int c){
	if(x > n) return;
	if(a*b*c) ans++;
	dfs(x*10+3, 1, b, c);
	dfs(x*10+5, a, 1, c);
	dfs(x*10+7, a, b, 1);
}



int main(){
	cin >> n;
	dfs(0, 0, 0, 0);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef vector<int> vi;

int N,M; Graph G;
void input()
{
    cin>>N>>M;
    G.resize(N+1);
    for(int i=0;i<M;++i){
        int a,b; cin>>a>>b;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
}

void solve()
{
    vi nroom(N+1,-1);
    queue<int> que;

    nroom[1]=0; que.push(1);
    while(!que.empty()){
        int v=que.front(); que.pop();
        for(auto nv:G[v]){
            if(nroom[nv]>=0) continue;
            nroom[nv]=v;
            que.push(nv);
        }
    }

    bool flag=true;
    for(int i=1;i<=N;++i){
        if(nroom[i]<0){
            flag=false; break;
        }
    }
    if(flag){
        cout<<"Yes\n";
        for(int i=2;i<=N;++i){
            cout<<nroom[i]<<endl;
        }
    }
    else cout<<"No"<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 10244
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

const int N = 2e6 + 7;

vector <int> edges[N];
int res[N];

int root = 0;
int cnt = 1;

void add(string &s) {
	int now = root;
	for (char c : s) {
		int k = c - 'a';
		if (edges[now][k] == -1) {
			edges[now][k] = cnt;
			edges[cnt++].resize(26, -1);
		}
		now = edges[now][k];
	}
	res[now]++;
}

int go(string s) {
	vector <int> path;
	int now = root;
	for (char c : s) {
		int k = c - 'a';
		path.pb(now);
		now = edges[now][k];
	}
	path.pb(now);
	vector <int> have(26, 0);
	reverse(s.begin(), s.end());
	reverse(path.begin(), path.end());
	have[s[0] - 'a'] = true;
	int ans = 0;

	for (int i = 2; i < path.size(); ++i) {
		have[s[i - 1] - 'a'] = true;
		for (int x = 0; x < 26; ++x) {
			int kek = edges[path[i]][x];
			if (kek != -1 && have[x]) {
				ans += res[kek];
			}
		}
	}
	//cout << s << " " << ans << endl;
	return ans;
}

int main(){
#ifdef LOCAL
	freopen("B_input.txt", "r", stdin);
	//freopen("B_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	edges[0].resize(26, -1);

	int n;
	cin >> n;
	vector <string> t;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		reverse(s.begin(), s.end());
		add(s);
		t.pb(s);
	}
	int ans = 0;
	for (string s : t) {
		ans += go(s);
	}
	cout << ans << endl;

}


Measured memory_bytes: 167288
N = int(input())
X = int(0)

if N == 10000:
    print(0)
elif N < 1000:
    X = 1000 - N
    print(X)
else:
    for i in range(11) :
        if N < i * 1000:
            X = i * 1000 - N
            if X == 1000:
                print(0)
            else:
                print(X)
            break

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

int main() {
  int H, W;
  cin >> H >> W;
  vector <vector<char>> p(H,vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++){
      cin >> p.at(i).at(j);
    }
  }
  for (int i = 0; i < H; i++) {
    for (int k = 0; k < 2; k++){
      for (int j = 0; j < W; j++){
        if (j == W-1) cout << p.at(i).at(j) << endl;
        else cout << p.at(i).at(j);
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <map>
#include <algorithm>
using namespace std;

using P = pair<int,int>; //x,y;
using T = tuple<int,int,int>; //x,y,b
int main(){
    map<P,int> overlap;//int??????????????°?????????
    map<P,int> Mov[15];
    int N;
    while(cin>>N,N){
        overlap.clear();
        for(int i=0;i<15;i++) Mov[i].clear();
        for(int i=0;i<N;i++){
            int x,y;
            cin>>x>>y;
            int l,r,f,b,d,u;
            cin>>l>>r>>f>>b>>d>>u;
            string rot;
            cin>>rot;
            overlap[P(x,y)]|=(1<<i);
            Mov[i][P(x,y)]=d;
            // cout<<d<<endl;
            for(auto c:rot){
                int temp=d;
                switch(c){
                    case 'L':
                        d=l;l=u;u=r;r=temp;
                        x--;
                        break;
                    case 'R':
                        d=r;r=u;u=l;l=temp;
                        x++;
                        break;
                    case 'B':
                        d=b;b=u;u=f;f=temp;
                        y++;
                        break;
                    case 'F':
                        d=f;f=u;u=b;b=temp;
                        y--;
                        break;
                    default:
                        break;
                }
                // cout<<d<<endl;
                overlap[P(x,y)]|=(1<<i);
                Mov[i][P(x,y)]=d;
            }
        }
        int dp[1<<N];
        fill(dp,dp+(1<<N),0);
        for(int b=0;b<(1<<N);b++){
            for(int i=0;i<N;i++){
                if(b&(1<<i)) continue;
                int bb=b|(1<<i);
                int diff=0;
                for(auto p:Mov[i]){
                    int x,y,d; tie(x,y)=p.first; d=p.second;
                    if(overlap[P(x,y)]&b) continue;
                    else diff+=d;
                }
                dp[bb]=max(dp[bb],dp[b]+diff);
            }
        }
        cout<<dp[(1<<N)-1]<<endl;
    }

    return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{   int a,b,c;
 	string answer;
 	cin >> a >> b>> c;
 	answer = "No";
    if((a+c) == b||(a+b)==c||(b+c)==a){
    	answer = "Yes";
    }
 	cout << answer;
  
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;

int main() {
  int N;
  double Ans = 0;
  cin >> N;
  
  vector< map<string, double> > mati(N);
  double x,y;
  for (int i = 0; i < N; i++) {
    cin >> x >> y;
    mati[i]["x"] = x;
    mati[i]["y"] = y;
  }


  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      Ans += sqrt( pow( (mati[i]["x"] - mati[j]["x"]), 2.0) +
                   pow( (mati[i]["y"] - mati[j]["y"]), 2.0) );
    }
  }



  cout << fixed << setprecision(10) << Ans/N << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	string S;
	cin >> S;

	string kotae;
	kotae = S[0];
	kotae += to_string(S.size() - 2);
	kotae += S[S.size() - 1];

	co(kotae);

	Would you please return 0;
}

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

int main(){
    std::string S;
    std::cin >> S;

    int max_length = 0;
    int now_length = 0;
    for(int i = 0; i < S.length(); i++){
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            now_length++;
        }else{
            max_length = std::max(max_length, now_length);
            now_length = 0;
        }
    }
    max_length = std::max(max_length, now_length);

    std::cout << max_length << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char c;
	scanf("%c",&c);
	if(c=='A')
		printf("T");
	else if(c=='T')
		printf("A");
	else if(c=='C')
		printf("G");
	else if(c=='G')
		printf("C");	 
	return 0;
}


Measured memory_bytes: 256
<?php
  //?の部分は全部aいれればいい
  //tの大きさが連続する?より小さい場合は?、tの末尾を?の末尾と合わせ、aで埋める
  //tの方が大きい場合は、?に末尾から入る分だけ入れて、tがsの中にあるか判別
fscanf(STDIN,"%s",$s);
fscanf(STDIN,"%s",$t);
$s_len = strlen($s);
$t_len = strlen($t);
$count = 0;
$res_start = -1;
for($i=0;$i<=$s_len-$t_len;$i++){
  for($j=$i;$j<$i+$t_len;$j++){
    //echo $s[$j]." ".$t[$j-$i]."\n";
    if($s[$j]==$t[$j-$i] || $s[$j]=='?'){
      $count++;
    }
  }
  if($count == $t_len){
    $res_start = $i;
  }
  //echo "-----------\n";
  $count = 0;
}

if($res_start<0){
  echo "UNRESTORABLE\n";
  exit;
}


for($i=$res_start;$i<$res_start+$t_len;$i++){
  $s[$i] = $t[$i-$res_start];
}
  
for($i=0;$i<$s_len;$i++){
  if($s[$i]=='?'){
    $s[$i] = 'a';
  }
}
//echo $res_start;

echo $s."\n";


Measured memory_bytes: 16312
def main():
    a = list(map(int, list(input())))
    b = list(map(int, list(input())))

    if len(a) > len(b):
        print('GREATER')
    elif len(a) < len(b):
        print('LESS')
    else:
        flg = 2
        for i in range(len(a)):
            if a[i] > b[i]:
                flg = 1
                break
            elif a[i] < b[i]:
                flg = 0
                break

        if flg == 2:
            print('EQUAL')
        elif flg == 1:
            print('GREATER')
        else:
            print('LESS')





if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<cstdio>
#define MAXN 2555
#define INF 0x3f3f3f3f
#define v first
#define b second
using namespace std;
const int N = 1000000;
bool prime[N];
int p[N],tot=0;
void init(){
    for(int i = 2; i < N; i ++) prime[i] = true;
    for(int i = 2; i < N; i++){
        if(prime[i]) p[tot ++] = i;
        for(int j = 0; j < tot && i * p[j] < N; j++){
            prime[i * p[j]] = false;
            if(i % p[j] == 0) break;
        }
    }
}

int main()
{
   init();
   int n;
   while(scanf("%d",&n)==1)
   {
      int sum=0;
      for(int i=0;i<tot;i++)
      {
         if(p[i]<=n)
            sum++;
         else break;
      }
      cout<<sum<<endl;
   }
   return 0;
}

Measured memory_bytes: 4408
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdbool.h>

#define lli long long int
lli g(lli a, lli b)
{
	lli tmp;
	lli x = a*b;
	if (a<b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}
	lli r = a%b;
	while (r!=0)
	{
		a = b;
		b = r;
		r = a%b;
	}
	return (x/b);
}

lli f(lli a, lli b, lli c)
{
	if (a == b)
	{
		if (a%c == 0)
			return (1);
		return (0);
	}

	lli small = a + (c - a%c)%c;
	lli big = (b/c)*c;
	if(small == big)
		return (1);
	return(1+((big - small)/c));
}
int main(void)
{
	lli a, b, c, d;
	scanf("%lld %lld %lld %lld",&a, &b, &c, &d);
	lli out = 0;
	lli by_c = f(a,b,c);
	lli by_d = f(a,b,d);
	//printf("debug:c:%lld\n",by_c);
	//printf("debug:d:%lld\n",by_d);

	lli e = g(c,d);
	//printf("debug:gcd:%lld\n",e);
	lli by_e = f(a,b,e);
	//printf("debug:e:%lld\n",by_e);

	out = b - a + 1;
	out = out - by_c - by_d + by_e;
	printf("%lld\n",out);
	return (0);
}


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


int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans;
  if((b-a)%2==0){
    ans = (b-a)/2;
  }
  else{
    ans = min(a, (n-b+1)) + (b-a-1)/2;
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fs first
#define sc second
#define mp make_pair
using namespace std;
typedef pair<pair<int,int>,int> pii;

bool l(const pii &a,const pii &b){
  int s1 = a.fs.sc*b.fs.fs, s2 = a.fs.fs*b.fs.sc;
  if(s1==s2)return a.sc<b.sc;
  if(a.fs.fs==0)return false;
  if(b.fs.fs==0)return true;
  return s1<s2;
}

int main(){
  int h,w;
  string f[999];
  cin.tie(0);
  std::ios::sync_with_stdio(0);
  cin >> h >> w;

  vector<pii> v;
  rep(i,h){
    cin >> f[i];
    rep(j,w){
      if( (i==0&&f[i][j]=='#') || (i!=0&&f[i][j]!=f[i-1][j]) ){
	v.push_back(mp(mp(j,h-i),-1));
	v.push_back(mp(mp(j+1,h-i),1));
      }
      if( (j==w-1&&f[i][j]=='#') || (j!=w-1&&f[i][j]!=f[i][j+1])){
	v.push_back(mp(mp(j+1,h-i),-1));
	v.push_back(mp(mp(j+1,h-i-1),1));
      }
    }
  }

  int res = 0, tmp = 0;
  sort(v.begin(),v.end(),l);
  rep(i,v.size()){
    tmp += v[i].sc;
    res = max(res,tmp);
  }
  cout << (res+3)/2 << endl;
}

Measured memory_bytes: 15100
object Main extends App {
  val _ = io.StdIn.readInt()
  val arr: Array[Int] = io.StdIn.readLine().split(" ").map(_.toInt)
  val min = arr.min

  def mkGroup(s: IndexedSeq[Int]): Seq[Seq[Int]] = {
    val sorted: Seq[Int] = s.sorted
    val m: collection.mutable.Map[Int, Int] = collection.mutable.Map.empty
    s.indices.foreach(i => m.update(i, sorted.indexOf(s(i))))
    def getCycle(n: Int): List[Int] = m.get(n) match {
      case None => List()
      case Some(x) => m.remove(n); n :: getCycle(x)
    }
    s.indices.map(i => getCycle(i)).filterNot(_.isEmpty)
  }

  def cost(inds: Seq[Int]): Int = {
    val s = inds.map(arr(_))
    ((s.length - 2) * s.min + s.sum).min((s.length+1) * min + s.min + s.sum)
  }

  val groups = mkGroup(arr)
  println((groups map cost).sum)
}

Measured memory_bytes: 53276
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    int n, m, c; cin >> n >> m >> c;
    vector<int> b(m);
    for (int &x : b) {
        cin >> x;
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        int sum = c;
        for (int j = 0; j < m; j++) {
            int x; cin >> x;
            sum += b[j] * x;
        }
        res += (sum > 0);
    }
    cout << res << "\n";
}


Measured memory_bytes: 256