akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

struct mint {
	ll x;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
	bool operator==(const mint a) const {
		return x == a.x;
	}
	bool operator!=(const mint a) const {
		return x != a.x;
	}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }


int main() {
    ll n;
    cin >> n;
    vector<vector<vector<mint>>> dp(n+1, vector<vector<mint>>(2, vector<mint>(2, 0)));
    dp[0][0][0] = 1;
    rep(i, n){
        dp[i+1][0][0] = dp[i][0][0] * 8;
        dp[i+1][1][0] = dp[i][0][0] + dp[i][1][0] * 9;
        dp[i+1][0][1] = dp[i][0][0] + dp[i][0][1] * 9;
        dp[i+1][1][1] = dp[i][1][0] + dp[i][0][1] + dp[i][1][1] * 10;
    }
    cout << dp[n][1][1] << endl;
}

Measured memory_bytes: 151384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S, T; cin >> S >> T;
    // dp[i][j] : LCS of S[0..i) and T[0..j)
    vector<vector<int>> dp(S.size() + 1, vector<int>(T.size() + 1));
    for (int i = 0; i <= S.size(); i++) {
        dp[i][0] = 0;
    }
    for (int j = 0; j <= T.size(); j++) {
        dp[0][j] = 0;
    }
    for (int i = 1; i <= S.size(); i++) {
        for (int j = 1; j <= T.size(); j++) {
            dp[i][j] = max({ dp[i-1][j], dp[i][j-1], dp[i-1][j-1] + (S[i-1] == T[j-1]) });
        }
    }
    string ans;
    int cnt = dp[S.size()][T.size()];
    int i = S.size(), j = T.size();
    while (cnt > 0) {
        if (cnt == dp[i-1][j]) i--;
        else if (cnt == dp[i][j-1]) j--;
        else ans += S[i-1], i--, j--, cnt--;
    }
    reverse(begin(ans), end(ans));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  string s;
  cin >> s;
  int n = s.size();
  vi v(n);
  int rs = -1, re = -1, ls = -1, le = -1;
  fi(0, n) {
    if(i == n - 1) {
      le = i;
      if(s[i - 1] == 'R') {
        re = i - 1;
        ls = i;
      }
    }
    else if(s[i] == 'R' && rs == -1) {
      rs = i;
      continue;
    }
    else if(s[i] == 'L' && ls == -1) {
      ls = i;
      re = i - 1;
      continue;
    }
    else if(s[i] == 'R' && ls != -1) {
      le = i - 1;
    }
    else
      continue;
    int rsum = re - rs + 1;
    int lsum = le - ls + 1;
    v[re] = v[ls] = (rsum + lsum) / 2;
    if((rsum + lsum) % 2) {
      if(rsum > lsum)
        v[re]++;
      else
        v[ls]++;
      if((max(rsum, lsum) - 1) % 2)
        swap(v[re], v[ls]);
    }
    rs = i;
    re = ls = le = -1;
  }
  
  for(int x: v) {
    cout << x << " ";
  }
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace std;

int main() {
    int N; cin >> N;
    vector<tuple<string,int,int> > v(N);
    for (int i = 0; i < N; ++i) {
        string S; int P; cin >> S >> P;
        P *= -1;
        v[i] = make_tuple(S, P, i);
    }
    sort(v.begin(), v.end());
    for (auto e : v) cout << get<2>(e)+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }





int main() {
	mapci cup; cup['A'] = 1;
	char c, c1, c2;
	while (cin >> c1 >> c >> c2) {
		swap(cup[c1], cup[c2]);
	}
	mapci::iterator it;
	for (it=cup.begin(); it!=cup.end(); it++) if ((*it).second) cout << (*it).first << endl;
	return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;i++){
        if(i%d==0)++ans;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,m,a[101],sum=0,cnt;float len=0;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    len=float(float(sum)/float(4*m));
    cnt=0;
     for(i=0;i<n;i++)
    {
        if(a[i]>=len)
        {
            cnt++;
        }
    }
    if(cnt>=m)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int ret;
int A[11];
int B[11];
int C[11];
int n;
void solve(int a,int b,int c){
	if(a==n){
		int tmp=0;
		for(int i=10;i>=0;i--){
			tmp*=10;tmp+=C[i];
		}
		ret=max(ret,tmp);
		return;
	}
	int t=A[a]-B[a]-b;
	
	if(t<0){
		C[a]=t+10;
		if(c)solve(a+1,0,c-1);
		solve(a+1,1,c);
	}else{
		C[a]=t;
		solve(a+1,0,c);
	}
}
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int at=0;
	while(a){
		A[at]=a%10;
		a/=10;at++;
	}
	n=at;
	at=0;
	while(b){
		B[at]=b%10;b/=10;at++;
	}
	solve(0,0,c);
	printf("%d\n",ret);
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    ll a,b;
    cin>>a>>b;
    if(a+b==3)
    {
        cout<<"3"<<endl;
    }
    else if(a+b==4)
    {
        cout<<"2"<<endl;
    }
    else 
    {
        cout<<"1"<<endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  int d[N];
  int sum = 0;

  rep (i, N) cin >> d[i];

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      sum += d[i] * d[j];
    }
  }

  int ans = sum / 2;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;

int main()
{
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<int> > a(n, vector<int>(m));
    vector<vector<int> > b(m, vector<int>(l));
    vector<vector<long> > c(n, vector<long>(l, 0));
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < m; ++i)
    {
        for (int j = 0; j < l; ++j)
        {
            cin >> b[i][j];
        }
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < l; ++j)
        {
            for (int k = 0; k < m; ++k)
            {
                c[i][j] += a[i][k] * b[k][j];
            }
            cout << c[i][j];
            if (j != l - 1)
                cout << " ";
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3220
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 01:52:13 2020

@author: Kanaru Sato
"""

N,M = list(map(int, input().split()))
sc = []
[sc.append(list(map(int, input().split()))) for i in range(0, M)]

found_flag = 0

for i in range(10**(N-1),10**N): #N桁の整数をリストアップ
    str_num = str(i)
    flag_i = 0
    for j in range(0,M):
        if int(str_num[sc[j][0]-1]) == sc[j][1]:
            flag_i += 1
    if flag_i == M:
        found_flag = 1
        int_num = i
        break

if N == 1:
    str_num = "0"
    flag_i = 0
    for j in range(0,M):
        if int(str_num[sc[j][0]-1]) == sc[j][1]:
            flag_i += 1
    if flag_i == M:
        found_flag = 1
        int_num = 0

if found_flag == 0:
    print("-1")
elif found_flag == 1:
    print(int_num)

Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
char a[1001][1001];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			int ans=0;
			if(a[i][j]=='#')printf("#");
			else
			{
				if(a[i-1][j-1]=='#')ans++;
				if(a[i-1][j]=='#')ans++;
				if(a[i-1][j+1]=='#')ans++;
				if(a[i][j-1]=='#')ans++;
				if(a[i][j+1]=='#')ans++;
				if(a[i+1][j-1]=='#')ans++;
				if(a[i+1][j]=='#')ans++;
				if(a[i+1][j+1]=='#')ans++;
				printf("%d",ans);
			}
		}
		printf("\n");
	}
	printf("\n");
}

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

using namespace std;

int main(void){

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

    sort(a.begin(), a.end());
    
    if(n%2==0) {
        int expect = 1;
        for(int i=0; i<n; i+=2) {
            if(!((a[i] == expect) && (a[i+1] == expect))) {
                cout << 0 << endl;
                return 0;
            }
            expect += 2;
        }
    }
    else {
        if(a[0] != 0) {
            cout << 0 << endl;
            return 0;
        }
        else {
            int expect = 2;
            for(int i=1; i<n; i+=2) {
                if(!((a[i] == expect) && (a[i+1] == expect))) {
                    cout << 0 << endl;
                    return 0;
                }
                expect += 2;
            }
        }
    }
    
    long long limit = 1000000000+7;
    long long result = 1;
    for(int i=0; i<n/2; i++) {
        result *= 2;
        if(result>limit) result-=limit;
    }

    cout << result << endl;

    return 0;
    
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

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

    vvl v(m);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        if(a <= m) {
            v[a-1].pb(b);
        }
    }

    priority_queue<ll> prQ;
    ll ans = 0;
    rep(i, m) {
        for(auto x : v[i]) {
            prQ.push(x);
        }
        if(!prQ.empty()) {
            ans += prQ.top();  
            prQ.pop();
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 8444
from heapq import heappush, heappop
inf = float('inf')
# mod = 10**9 + 7

class dijkstra:
    def __init__(self, to, start):
        self.N = len(to)
        self.to = [s[:] for s in to]
        self.start = start
        self.dist = [inf] * self.N
        self.dist[start] = 0
        # self.cnt = [0] * self.N
        # self.cnt[start] = 1
        self.pq = [(self.dist[start], start)]

    def update(self) -> None:
        while self.pq:
            _, v = heappop(self.pq)
            for nv, w in self.to[v]:
                if self.dist[nv] > self.dist[v] + w:
                    self.dist[nv] = self.dist[v] + w
                    heappush(self.pq, (self.dist[nv], nv))
                # if self.dist[nv] == self.dist[v] + w:
                #     self.cnt[nv] += self.cnt[v]
                #     self.cnt[nv] %= mod

n, m, s, t = map(int,input().split())
s -= 1; t -= 1
jpy = [[] for _ in range(n)]
snuke = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = map(int,input().split())
    u -= 1; v -= 1
    jpy[u].append((v, a))
    jpy[v].append((u, a))
    snuke[u].append((v, b))
    snuke[v].append((u, b))

JPY = dijkstra(jpy, s)
JPY.update()
SNUKE = dijkstra(snuke, t)
SNUKE.update()

cost_list = []
cost = inf

for i in range(n)[::-1]:
    cost = min(cost, JPY.dist[i] + SNUKE.dist[i])
    cost_list.append(cost)

cost_list.reverse()
for cost in cost_list:
    ans = pow(10, 15) - cost
    print(ans)

Measured memory_bytes: 126708
//2018-1-25
//miaomiao
//
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)

#define N (2000+5)
#define M (4000000+5)

int Gcd(int a, int b){return !b? a: Gcd(b, a % b);}

struct node{
	int p, v;
	bool operator <(const node &rhs)const{return v < rhs.v;}
};

int a[N], in[N], vis[N];
vector<int> G[N], g[N];

priority_queue<node> q;

bool cmp(int i, int j){
	return a[i] < a[j];
}

#define v G[now][i]

void Dfs(int now, int F){
	vis[now] = vis[F] + 1;

	sort(G[now].begin(), G[now].end(), cmp);
	For(i, 0, G[now].size() - 1){
		if(v == F) continue;
		
		if(vis[v]){
			if(vis[v] > vis[now]) g[now].pb(v), ++in[v];
		}else{
			g[now].pb(v); ++in[v];
			Dfs(v, now);
		}
	}
}

#undef v

int main(){
	int n;

	scanf("%d", &n);
	For(i, 1, n) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);

	For(i, 1, n) For(j, i + 1, n)
		if(Gcd(a[i], a[j]) > 1) G[i].pb(j), G[j].pb(i);
		
	For(i, 1, n) if(!vis[i]) Dfs(i, 0);
	For(i, 1, n) if(!in[i]) q.push((node){i, a[i]});
	
	int now, v;
	while(!q.empty()){
		now = q.top().p; q.pop();
		printf("%d ", a[now]);

		For(i, 0, g[now].size() - 1){
			--in[v = g[now][i]];
			if(!in[v]) q.push((node){v, a[v]});
		}
	}
	puts("");

	return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    for(ll i=0;i<N;i++)
    {
        cin>>A[i];
    }
    ll res=A[0];
    for(ll i=0;i<N;i++)
    {
        res=GCD(A[i],res);
    }
    cout<<res; 
    return 0;
}

Measured memory_bytes: 4056
n=int(input())
a=list(map(int,input().split()))
u=0
s=1
x=0
y=0
for i in a:
    u+=i
    if s*u<=0:
      x+=1-s*u
      u=s
    s=s*(-1)
s=-1
u=0
for i in a:
    u+=i
    if s*u<=0:
      y+=1-s*u
      u=s
    s=-1*s
print(min(x,y))

Measured memory_bytes: 14332
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [int(input()) for i in range(m)]

c = [0] * n
for i in range(n):
    for j in range(m):
        c[i] += a[i][j] * b[j]

    print(c[i])


Measured memory_bytes: 6020
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e6+10;

struct rec {
	int x,y;
} a[N],b[N];
int la,lb;

bool cmp1(rec a,rec b) {return a.x<b.x;}
bool cmp2(rec a,rec b) {return a.y>b.y;}

int n,s0,s1,m;
char s[N];

int main() {
	scanf("%d",&n);
	for(int i=1,l,r;i<=n;i++) {
		scanf("%s",s+1); l=r=0;
		for(int j=1;s[j];j++)
			if(s[j]=='(') l++;
			else if(l) l--;
			else r++;
		//-r +l
		if(r<l) a[++la]=(rec){r,l};
		else b[++lb]=(rec){r,l};
		s0+=r; s1+=l;
	}
	if(s0^s1) return puts("No"),0;
	sort(a+1,a+la+1,cmp1);
	sort(b+1,b+lb+1,cmp2);
	for(int i=1;i<=la;i++) {
		if(m<a[i].x) return puts("No"),0;
		m-=a[i].x-a[i].y;
	}
	for(int i=1;i<=lb;i++) {
		if(m<b[i].x) return puts("No"),0;
		m-=b[i].x-b[i].y;
	}
	puts("Yes"); return 0;
}


Measured memory_bytes: 9400
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N + 1):
  tmp = 0
  for j in range(len(str(i))):
    #print(str(i)[j], end="")
    tmp += int(str(i)[j])
  if A <= tmp <= B:
    ans+=i
print(ans)
  

Measured memory_bytes: 2940
w, h, x, y = map(int, input().split())
sq = 0
nearX = x - (w / 2)
nearY = y - (h / 2)
flag = False
if (x == 0 and y == 0) or (x == w and y == h) or (x == 0 and y == h) or (x == w and y == 0):
    flag = True

if flag:
    sq = (w*h)/2
    print(str(sq) + ' ' + '0')
    # print('a')
elif nearY < nearX:
    sq = w * (h / 2)
    print(str(sq) + ' ' + '0')
elif nearX < nearY:
    sq = h * (w / 2)
    print(str(sq) + ' ' + '0')
else:
    sq = h * (w / 2)
    print(str(sq) + ' ' + '1')


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
long long int mod=1e9+7;

int main(){
  vector<int> a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(a.begin(),a.end());
  cout<<a[2]*10+a[1]+a[0]<<endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<chrono>
#include<ctime>  
#include<climits>
#include<functional>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
// #include<bits/stdc++.h>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
#define mini(a, b) a = min(a, b)
#define maxi(a, b) a = max(a, b)

typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

const int MAXN = 1e5 + 10;

int n;
long long a[MAXN];
long long INF = (1LL << 60);

int m;
struct edge{
	int l, r;
	long long c;
};
edge e[MAXN];
multimap<ll, pii> mp;

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

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

    sort(e, e + m, [](const edge & x, const edge & y) {
    	return x.l < y.l;
    });

    a[1] = 0;
    for(int i = 2; i <= n; i++)
    	a[i] = INF;
    int j = 0;
    for(int i = 1; i <= n; i++) {
    	while(mp.size() && mp.begin()->second.second < i)
    		mp.erase(mp.begin());
    	if(!mp.size() && a[i] == INF) break;
    	a[i] = mp.begin()->first;

    	while(j < m && e[j].l <= i) {
    		mp.insert({a[i] + e[j].c, {e[j].l, e[j].r}});
    		j++;
    	}
    }

    cout << (a[n] == INF ? -1 : a[n]) << endl;
    
    return 0;
 
}














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

int main(){
    int n;
    cin >> n;
    long long int ans = 0;

    for(int i=1; i<=n; i++){
        if(i%3 != 0 && i%5 != 0) ans += i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <sstream>
#include <cctype>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define ms(a, b) memset(a, b, sizeof a)
int num[100005];
int cnt1, cnt2;
int main(){

    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &num[i]);
        if(num[i] % 4 == 0) cnt1++;
        else if(num[i] % 2 == 0) cnt2++;
    }
    n -= cnt1;
    n -= cnt1;
    if(n == 1) cout << "Yes";
    else if(n <= cnt2) cout << "Yes";
    else cout << "No";
    return 0;
}


Measured memory_bytes: 640
def lcs(X, Y):
    dp = []
    for y in Y:
        bgn_idx = 0
        for i, cur_idx in enumerate(dp):
            chr_idx = X.find(y, bgn_idx) + 1
            
            if not chr_idx:
                break
            dp[i] = min(cur_idx, chr_idx)
            bgn_idx = cur_idx
        else:
            chr_idx = X.find(y, bgn_idx) + 1
            if chr_idx:
                dp.append(chr_idx)
    return len(dp)

q = int(input())
for i in range(q):
    X = input()
    Y = input()
    print(lcs(X, Y))



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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    printf("%d\n", d[N/2]-d[N/2-1]);
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();

   int[] B = new int[N];
   for(int i=0;i<N-1;i++ )
   {
     B[i]  = sc.nextInt();
   }

   int total = 0;
   for(int i =0; i<N;i++)
   {
     if(i==0) total +=B[i];
     else if(i == N-1) total += B[i-1];
     else
     {
      if(B[i]> B[i-1]) total += B[i-1];  
      else total += B[i];
     }
   }
   
System.out.println(total);   
   
 }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
template<typename T> using vec = std::vector<T>;
template<typename T> using withi = std::pair<T, int>;
using ll = long long;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=withi<T>)vec<U>zipi(const vec<T>&x,int s=0){int N=x.size();vec<U>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int sx = in(), sy = in();
  int tx = in(), ty = in();
  int H = ty - sy + 1;
  int W = tx - sx + 1;
  cout << "L";
  rep(i, H) cout << "U";
  rep(i, W) cout << "R";
  cout << "D";
  rep(i, W - 1) cout << "L";
  rep(i, H - 1) cout << "D";
  cout << "D";
  rep(i, W) cout << "R";
  rep(i, H) cout << "U";
  cout << "L";
  rep(i, H - 1) cout << "D";
  rep(i, W - 1) cout << "L";
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int N;
  cin>>N;
  int A[N],B[N+1]={0};
  int i;
  
  for(i=1;i<N;i++)
  {
  	cin>>A[i];
    B[A[i]]++;
  }
  for(i=1;i<=N;i++)
  {
  	cout<<B[i]<<endl;
  }
  
return 0;

}

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);

	int n, k;
	cin >> n >> k;

	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (i + 1 == k) {
			cout << char(tolower(s[i]));
		} else {
			cout << s[i];
		}
	}

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
cnt = [0] * ((10**6)+1)

for elem in a:
    cnt[elem] += 1

unique = []

for i in range((10**6)+1):
    if cnt[i] == 1:
        unique.append(i)

cnt = [0] * ((10**6)+1)

a = list(set(a))

for elem in a:
    for m in range(elem*2, (10**6)+1, elem):
        cnt[m] = 1

ans = 0

for elem in unique:
    if cnt[elem] == 0:
        ans+=1

print(ans)


Measured memory_bytes: 47416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
 
int main(){
	ld a, b, x; scanf("%Lf%Lf%Lf", &a, &b, &x);
	ld v = a*a*b;
	ld ans;
	if(x * 2 >= v){
		ld h = (v - x) * 2 / a / a;
		ans = atan(h / a) / M_PI * 180;
	} else {
		ld h = x * 2	/ a / b ;
		ans = 90 - atan(h / b) / M_PI * 180;
	}
	printf("%.30Lf\n", ans);
}

Measured memory_bytes: 256
use std::io;
use std::io::{Read, BufReader};
use std::cmp;

fn next_token<R: Read>(reader: &mut R) -> Vec<u8> {
    let mut buf: [u8; 1] = [0];
    let mut read_chars = false;
    let mut ret: Vec<u8> = vec![];

    loop {
        if reader.read(&mut buf).unwrap() == 0 {
            break;
        } else {
            if buf[0] == '\r' as u8 || buf[0] == '\n' as u8 || buf[0] == ' ' as u8 {
                if read_chars {
                    break;
                }
            } else {
                read_chars = true;
                ret.push(buf[0]);
            }
        }
    };
    ret
}
fn next_i64<R: Read>(reader: &mut R) -> i64 {
    let token = next_token(reader);
    let mut ret: i64 = 0;
    let mut sgn = false;

    for c in token {
        if '0' as u8 <= c && c <= '9' as u8 {
            ret = ret * 10 + (c - ('0' as u8)) as i64;
        } else if '-' as u8 == c {
            sgn = true;
        }
    };
    ret * if sgn { -1 } else { 1 }
}
fn next_i32<R: Read>(reader: &mut R) -> i32 {
    next_i64(reader) as i32
}

fn check(lim: usize, a: &Vec<Vec<usize>>) -> bool {
    let n = a.len();
    let m = a[0].len();
    let mut forbid = vec![false; m];
    let mut cnt = vec![0 as usize; m];
    let mut ptr = vec![0 as usize; n];
    for i in 0..n {
        cnt[a[i][0]] += 1;
    }
    loop {
        let mut invalid = None;
        for j in 0..m {
            if cnt[j] > lim {
                invalid = Some(j);
                break;
            }
        }
        if invalid == None {
            return true;
        }
        let invalid = invalid.unwrap();
        forbid[invalid] = true;
        for i in 0..n {
            while forbid[a[i][ptr[i]]] {
                cnt[a[i][ptr[i]]] -= 1;
                ptr[i] += 1;
                if ptr[i] == m {
                    return false;
                }
                cnt[a[i][ptr[i]]] += 1;
            }
        }
    }
    false
}
fn main() {
    let buf = &mut BufReader::new(io::stdin());

    let n = next_i32(buf) as usize;
    let m = next_i32(buf) as usize;
    let mut a = vec![vec![]; n];
    for i in 0..n {
        let row = &mut a[i];
        for _ in 0..m {
            row.push((next_i32(buf) - 1) as usize);
        }
    }

    let mut left = 1;
    let mut right = n;
    while left < right {
        let mid = (left + right) / 2;
        if check(mid, &a) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    println!("{}", left);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

string s;
int main(void){
    cin >> s;
    ll res = 0;
    for (int i=0;i<s.length();i++){
        res += (int)(s[i]-'0');
    }
    if(res%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int N, K; cin >> N >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }

    vector<ll> csum(N);
    csum[0] = A[0];
    for (int i = 1; i < N; i++) {
        csum[i] = csum[i - 1] + A[i];
    }

    for (int i = 0; i < N - K; i++) {
        if (i == 0) {
            if (csum[K - 1] < csum[K] - csum[0]) {
                printf("Yes\n");
            } else {
                printf("No\n");
            }
        } else {
            if (csum[K + i - 1] - csum[i - 1] < csum[K + i] - csum[i]) {
                printf("Yes\n");
            } else {
                printf("No\n");
            }
        }
    }

    return 0;
}

Measured memory_bytes: 6484
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}
 
 
	public void run() {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
        
        int F=0;
        int T=0;
        
        F=X*4;
        T=X*2;
        
        if(T<=Y && F>=Y){
            if(Y%2==0){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }else{
            System.out.println("No");
        }
		
		
		
	}
		
}


Measured memory_bytes: 35816
n,c=[int(i) for i in input().split()]
s0=[]
t0=[]
for _ in range(n):
  a=[int(i) for i in input().split()]
  s0.append((a[0],a[2]))
  t0.append((a[1],a[2]))
s1=set(s0)
t1=set(t0)
s2=list(s1.difference(t0))
t2=list(t1.difference(s0))
s=[i[0]-0.5 for i in s2]
t=[i[0] for i in t2]

s.sort()
t.sort()
x=0
m=0
si=0
ti=0
while si != len(s):
  if s[si] < t[ti]:
    x+=1
    si+=1
  else:
    x-=1
    ti+=1
  m = max(m,x)
print(m)

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

int main(){
  int n, a;
  cin >> n >> a;
  if(n%500==0){
    cout << "Yes";
  }
  else if(n%500<=a){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
H,W,K=map(int,input().split())
A=[list(input())for _ in range(H)]
for i, a in enumerate(A):
	if"S"in a:y,x=(i,a.index("S"))
d=1e9
Q=deque([(0,y,x)])
while Q:
	c,i,j=Q.popleft()
	d=min(d,i,j,H-i-1,W-j-1)
	if d<1:break
	if c>=K:continue
	for ni,nj in((i+1,j),(i,j+1),(i-1,j),(i,j-1)):
		if 0<=ni<H and 0<=nj<W and A[ni][nj]==".":
			A[ni][nj]="#"
			Q+=[(c+1,ni,nj)]
print(-(-d//K)+1)

Measured memory_bytes: 68204
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int edges[4];

  int total_triangles = 0;

  int right_angle_num = 0;
  int acute_angle_num = 0;
  int obtuse_angle_num = 0;

  while(~scanf("%d %d %d",edges+0,edges+1,edges+2)){
    sort(edges,edges+3);
    if(edges[2] >= edges[0] + edges[1]){
      printf("%d %d %d %d\n",
             total_triangles,
             right_angle_num,
             acute_angle_num,
             obtuse_angle_num);
      break;
    }

    if(edges[2] * edges[2] == edges[0] * edges[0] + edges[1] * edges[1]){
      right_angle_num++;
    }
    else if(edges[2] * edges[2] < edges[0] * edges[0] + edges[1] * edges[1]){
      acute_angle_num++;
    }
    else if(edges[2] * edges[2] > edges[0] * edges[0] + edges[1] * edges[1]){
      obtuse_angle_num++;
    }
    
    total_triangles++;
  }
}

Measured memory_bytes: 1204
/*
    NO 
        TIME 
            TO 
                DIE
                    --007
                            */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <complex>
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
// define x, y as real(), imag()


template<class T>
istream& operator>> (istream& is, complex<T>& p) {
  T value;
  is >> value;
  p.real(value);
  is >> value;
  p.imag(value);
  return is;
}
#define M_PI 3.14159265358979323846
typedef long long int lli;
lli mod=1e9+9ll;
#define OS //single input use oeis
lli INF=9223372036854775807;
lli eps=1e-8;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y-x)>>(31))&(x^y))^y; }
int fmi(int x, int y) { return (((y-x)>>(31))&(x^y))^x; }
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,z,k,x,m,d,y,q,b,c;
const double pi=3.14159265358979323846;
lli me(lli a,lli b)
{
    // cout<<mod<<"\n";
    lli res=1;
    while(b)
    {
        if(b&1)
        res=(res%mod*a%mod)%mod;
        a=a*a;
        a%=mod;
        b=b>>1;
    }
    return res;
}
lli mI(lli a)
{
    return (me(a,mod-2)%mod+mod)%mod;
}

int main()
{
 #ifndef ONLINE_JUDGE
 freopen("input.txt", "r", stdin);
 freopen("output.txt", "w", stdout);
 #endif
 IO;
 OS;
 cin>>k;
 lli l,r;
 cin>>l>>r;
 for(int j=l;j<=r;j++)
 {
    if(j%k==0)
        return cout<<"OK",0;
 }

 cout<<"NG";

}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
   int N, M, X; cin >> N >> M >> X;
   vector<int> C(N);
   vector<vector<int>> A(N, vector<int>(M));

   rep(i, 0, N) {
     cin >> C.at(i);
     rep(j, 0, M) {
       cin >> A.at(i).at(j);
     }
   }

   int ans = 10000000;

   for (int i = 0; i < (1 << N); i++) { //bit全探索
     vector<int> sumA(M, 0); //能力の合計、初期値0
     int sum_tmp = 0;
     for (int j = 0; j < N; j++) { //各桁が買うかどうかに対応
       if (i & (1 << j)) {
         sum_tmp += C.at(j);
         rep(k, 0, M) {
           sumA.at(k) += A.at(j).at(k);
         }
       }
     }
     bool tmp = true;
     for (int l = 0; l < M; l++) {
       if (sumA.at(l) < X) {
         tmp = false;
       }
     }
     if (tmp) ans = min(ans, sum_tmp);
   }

   if (ans == 10000000) cout << -1 << endl;
   else cout << ans << endl;
 }


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool so[10000001];

int main() {

  so[0] = so[1] = 1;
  for(int i=2;i*i<=10000000;i++){
    if(so[i] == 0) {
      for(int j=2;j<=10000000/i;j++) so[i*j] = 1;
    }
  }

  while(1) {
    int n,p;
    cin >> n >> p;
    if(n == -1 && p ==-1) break;

    int cnt = 0;

    int a[101] = {};
    for(int i=n+1;cnt<=p;i++) if(so[i] == 0) a[cnt] = i,cnt++;
    


    int c =0;
    bool flg[101][101];
    for(int i=0;i<=p;i++)
      for(int j=0;j<=p;j++) flg[i][j] = 0;
    vector <int> b;
    for(int i=0;i<=p;i++)
      for(int j=0;j<=p;j++) {
	if(flg[i][j] == 1) continue;
	flg[i][j] = 1;
	flg[j][i] = 1;
	int sum = a[i]+a[j];
	b.push_back(sum);
	c++;
      }

    sort(b.begin(),b.end());

    // for(int i=0;i<p;i++) cout << b[i] <<endl;
    cout << b[p-1] <<endl;
  }
  return 0;
}
       

Measured memory_bytes: 11048
import sys
n, c, k = [int(i) for i in sys.stdin.readline().split()]
t_ls = []
for i in range(n):
    t = int(sys.stdin.readline().strip())
    t_ls.append(t)
t_ls.sort()
last = t_ls[0]
cnt = 1
ans = 1
for t in t_ls[1:]:
    if t <= last + k and cnt < c:
        cnt += 1
        continue
    last = t
    cnt = 1
    ans += 1
print(ans)

Measured memory_bytes: 7884
X,Y=map(int,input().split())
if X%Y==0:
  print(-1)
  exit()
  
i = 2
while True:
  if X*i % Y != 0 and X*i <= 10**18:
    print(X*i)
    exit()
  i += 1
  if X*i > 10**18:
    print(-1)
    exit()

Measured memory_bytes: 8880
#!/usr/bin/env python3
import sys
from itertools import *

def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word
tokens = iterate_tokens()
n=int(next(tokens))
m=int(next(tokens))
x=int(next(tokens))
c=[0]*n
a=[[0]*m for _ in range(n)]
for i in range(n):
    c[i]=int(next(tokens))
    for j in range(m):
        a[i][j]=int(next(tokens))

b=[]
def sumb(b):
    ret=0
    for i in range(n):
        if b[i]==1:
            ret+=c[i]
    return ret

def chk_mok(b):
    gak=[0]*m
    for i in range(n):
        if b[i]==1:
            for j in range(m):
                gak[j]+=a[i][j]
    ret=True
    for j in range(m):
        if gak[j]<x:
            ret=False
    return ret

if not chk_mok([1]*n):
    print(-1)
    exit()

ans=sum(c)

def buy(b, i):
    global ans
    if i==n:
        if chk_mok(b):
            ans=min(ans, sumb(b))
    else:
        buy(b+[0], i+1)
        buy(b+[1], i+1)

buy([0], 1)
buy([1], 1)

print(ans)


Measured memory_bytes: 9304
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String[] S = sc.nextLine().split(" ");
        int N = Integer.parseInt(S[0]);
        long T = Integer.parseInt(S[1]);

        long[] TN = new long[N];
        for (int i = 0; i < N; i++) {
            TN[i] = Long.parseLong(sc.next());
        }

        long ans = T;
        for (int i = 0; i < N; i++) {
            if (i + 1 >= N) {
                break;
            }
            long next = TN[i + 1] - TN[i];
            ans += Math.min(T, next);
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 50136
#include<iostream>
#include<iomanip>
#include<set>
#include<vector>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main(void)
{
  int n;
	string l;
	int k;
	cin >> n >> l >> k;
	char m = l[k-1];
	rep(i,n){
		if(l[i] != m) l[i] = '*';
	}
	cout << l << endl;

  return 0;
}


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

int main(){
    string S,T,a,b;
    cin>>S>>T;
    int cS,cT;
    cS=S.size();
    cT=T.size();
    cT--;
    a=S.assign(S,0,cS);
    b=T.assign(T,0,cT);
    if(a==b||T.size()==S.size()-1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0; 
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

bool jud(string s){
	string tmp=s;
	reverse(ALL(tmp));
	return s==tmp;
}

int main(){
	string s;
	cin>>s;
	
	bool ans=true;
	int n=s.size();
	if(jud(s) and jud(s.substr(0,(n-1)/2)) and jud(s.substr((n+3)/2-1,n-(n+3)/2+1))){}
	else ans=false;
	
	cout<<(ans?"Yes":"No")<<endl;
}

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

int main() {
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    cout << (s == u ? a - 1 : a) << " " << (t == u ? b - 1 : b) << endl;
}

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

signed main(){
  int A[3];
  cin>>A[0]>>A[1]>>A[2];
  int K;
  cin>>K;
  sort(begin(A),end(A));
  rep(i,K)A[2]*=2;
  int Msum=A[0]+A[1]+A[2];
  cout<<Msum<<endl;
}

Measured memory_bytes: 256
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_dedges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define in_wedges(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C), v[B].pb(A, C);}
#define in_dwedges(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C);}
#define endl "\n"

const ll MOD = 1000000007;
const ll INF = 1e18;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    string s, t;
    cin >> s >> t;

    int ss = s.size(), st = t.size();

    int mn = 1e8;

    repp(i, 0, ss - st){
        int cnt = 0;
        rep(j, i, t.size() + i) cnt += s[j] != t[j - i];
        mn = min(cnt, mn);
    }

    cout << mn;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 3580
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        String s=sc.next();
        int a=s.length();

        for(int i=0; i<a; i++){
            System.out.print('x');
        }
        sc.close();
    }
}

Measured memory_bytes: 21716
#import<cstdio>

template<typename ...> static inline int gc(void) { return getchar(); }
static inline void read(int &x){int k,m(0);x=0;for(;;){k=gc();if(48<=k&&k<=57){x=k-48;break;}}for(;;){k=gc();if(k<48||k>57)break;x=(x<<3)+(x<<1)+k-48;}}

int N, d[262144], p, x, i;

main(){
    read(N);
    i = N;
    for(; i; d[x] = --i)read(x);
    i = N;
    for(; --i;)p ? d[N] > d[i] ^ d[i] > d[i + 1] ^ d[i + 1] > d[N] ? ++p, N = i + 1 : 0 : d[i] > d[i + 1] ? --N : ++p;
    printf("%d", p);
}


Measured memory_bytes: 896