akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define Task ""

using namespace std;
typedef long long ll;

const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;

struct point
{
    int x, y, t;
    int dist(const point & other) const
    {
        return abs(x - other.x) + abs(y - other.y);
    }
}p[maxn];
int N;

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen("A.INP", "r")){
        freopen("A.INP", "r", stdin);
        freopen("A.OUT", "w", stdout);
    }
    if (fopen(Task".INP", "r")){
        freopen(Task".INP", "r", stdin);
        freopen(Task".OUT", "w", stdout);
    }
    cin >> N;
    for (int i=1; i<=N; ++i){
        cin >> p[i].t >> p[i].x >> p[i].y;
        if (p[i].t - p[i-1].t < p[i].dist(p[i-1])){
            cout << "No\n";
            return 0;
        }
        if ((p[i].dist(p[i-1]) - (p[i].t - p[i-1].t)) % 2){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>

using namespace std;

#define MAX_RANGE 2000000

void Sol4()
{
	int N;
	cin >> N;
	vector<int> A;
	int numOfNonDivisibles=0;

	vector<int> hsh_map(MAX_RANGE+1);
	vector<int> isDivisible(MAX_RANGE+1);
	

	for (int i = 0; i < N; i++)
	{
		int num;
		cin >> num;
		hsh_map[num]++;		// sort of count sort. going in sequence will be in ascending order
	}

	

	for (int i = 0 ; i <= MAX_RANGE ; i++)
	{
		if (!hsh_map[i] || isDivisible[i])		// if number does not exists in the list (hshmap is 0) or if exists, then we are not checking divisble for the same number.
			continue;							// example 16 is in list, and divisible was made 1 due to second loop starting i = 8, then we skip
		if (hsh_map[i] == 1 && !isDivisible[i])		// if number existed and isdivisible is not set so far, then count.
			numOfNonDivisibles++;					// moreover if there are duplicates, say 5 appear 2 times, so hshmap = 2. should not  count as one 5 is divisble by another 
		for (int j = i; j <= MAX_RANGE; j += i)	// set all numtiple of i's to 1. say control reaches here for existed values only example 3.
			isDivisible[j] = 1;					// then 3 6 9  .. so on all indexes set to 1
	}
	
	cout << numOfNonDivisibles << endl;
}
int main()
{
    #define endl '\n'
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(0);
    {
        //freopen("handmade09", "r", stdin);
        //freopen("out.txt", "w", stdout);
        //Sol1();
        //Sol2();
        //Sol3();
        Sol4();
        //Sol5();
        //Sol6();
    }
    cin.get();
}

Measured memory_bytes: 18412
<?php
//??\?????°??¨?±±??????????????\???????????????
$count=0;
$mountList=array();
//?±±??????????????\?????????
while($count<10){
    $stdin=trim(fgets(STDIN));
    //??\??????????????????????????????????????????????????\???
    if(0<=$stdin&&$stdin<=10000){
        $mountList[]=$stdin;
        $count++;
    }
}
//??\??????????????°????????????????????????
//rsort($mountList);
for($i=0;$i<9;$i++){
    for($j=9;$j>$i;$j--){
        if($mountList[$j]>$mountList[$j-1]){
            $tmp=$mountList[$j];
            $mountList[$j]=$mountList[$j-1];
            $mountList[$j-1]=$tmp;
        }
    }
}

//????????????
for($i=0;$i<3;$i++){
    //????????????
    echo $mountList[$i]."\n";
}

Measured memory_bytes: 15484
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h, w = LI()
a = ['#' + input() + '#' for _ in range(h)]
a = ['#'*(w+2)] + a + ['#'*(w+2)]
for i in a:
    print(i)

Measured memory_bytes: 66020
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			ArrayList<Pos> ps = new ArrayList<Pos>();
			for (int i = 0; i < N; ++i) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				ps.add(new Pos(x, y));
			}
			Collections.sort(ps);
			HashSet<Pos> set = new HashSet<Pos>(ps);
			int ans = 0;
			for (int i = 0; i < N; ++i) {
				Pos p1 = ps.get(i);
				for (int j = i + 1; j < N; ++j) {
					Pos p2 = ps.get(j);
					if (p1.x == p2.x || p1.y > p2.y) continue;
					int sq = (p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y);
					if (sq <= ans) continue;
					Pos p3 = new Pos(p2.x - (p2.y - p1.y), p2.y + (p2.x - p1.x));
					if (!set.contains(p3)) continue;
					Pos p4 = new Pos(p1.x - (p2.y - p1.y), p1.y + (p2.x - p1.x));
					if (!set.contains(p4)) continue;
					ans = sq;
				}
			}
			System.out.println(ans);
		}
	}

	static class Pos implements Comparable<Pos> {
		int x, y;

		Pos(int x, int y) {
			this.x = x;
			this.y = y;
		}

		public int compareTo(Pos o) {
			if (this.x != o.x) return this.x - o.x;
			return this.y - o.y;
		}

		public int hashCode() {
			return (this.x << 16) ^ this.y;
		}

		public boolean equals(Object obj) {
			Pos o = (Pos) obj;
			return this.x == o.x && this.y == o.y;
		}

	}

}

Measured memory_bytes: 13000
#include<iostream>
#include<map>
#include<string>

using namespace std;

int main(){
    int n;
    map<int, string> mp;
    cin >> n;
    string in;
    cout << 0 << endl;
    cin >> in;
    mp[0] = in;
    if(in == "Male"){
        mp[1] = "Female";
    }else{
        mp[1] = "Male";
    }
    int l = 0, r = n - 1;
    while(in != "Vacant"){
        int h = (l + r) / 2;
        cout << h << endl;
        cin >> in;
        if(mp[h % 2] == in){
            l = h + 1;
        }else{
            r = h - 1;
        }
    }
    return 0;
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

ll mod=1000000007;

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() {
  ll n,m,k;cin>>n>>m>>k;
  vector<ll> a(n+1);
  vector<ll> b(m+1);
  a[0]=b[0]=0;
  reps(i,n){ll x;cin>>x;a[i]=a[i-1]+x;}
  reps(i,m){ll x;cin>>x;b[i]=b[i-1]+x;}
  ll ans=0;
  rep(i,n+1){
    ll rem=k-a[i];
    if(rem<0)continue;
    auto itr=upper_bound(ALL(b),rem);
    int j=itr-b.begin();
    ans=max(ans,ll(j+i-1));
  }
  cout<<ans;
}

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

int main(){
  int A,B,K;
  cin >>A>>B>>K;
  
  rep(i,A,min(A+K,B+1)) cout <<i<< endl;
  rep(i,max(A+K,B-K+1),B+1) cout <<i<< endl;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int dp[1<<12];
int t[1100];
int c[1100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		scanf("%d",c+i);
		int d;scanf("%d",&d);
		for(int j=0;j<d;j++){
			int e;scanf("%d",&e);e--;
			t[i]|=1<<e;
		}
	}
	for(int i=0;i<(1<<a);i++)dp[i]=mod;
	dp[0]=0;
	for(int i=0;i<b;i++){
		for(int j=0;j<(1<<a);j++){
			dp[j|t[i]]=min(dp[j|t[i]],dp[j]+c[i]);
		}
	}
	if(dp[(1<<a)-1]==mod)dp[(1<<a)-1]=-1;
	printf("%d\n",dp[(1<<a)-1]);
}

Measured memory_bytes: 128
using System;
using System.Linq;

class Program
{
	static void Main()
	{
		long[] N = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        long ans;
      	long ansnew = N[0]%N[1];
      
      	do{
          ans = ansnew;
          ansnew = ans - N[1];
          ansnew = Math.Abs(ansnew);
        }
        while (ansnew <= ans);
      
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11348
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		String str = stdIn.nextLine();
		char[] a = str.toCharArray();
		for(int i = 0; i < a.length; ++i)
		{
			if('a' <= a[i] && a[i] <= 'z')
			{
				a[i] += 'A' - 'a';
			}
		}
		System.out.println(a);
	}
}

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

class TSort{
public:
  int V;
  vector<unordered_set<int> > in,out;
  vector<int> tp;
  TSort():V(0){}
  TSort(int V):V(V),in(V),out(V){}
  
  void add_edge(int from,int to){
    assert(from >= 0 && to >= 0);
    assert(from < V && to < V);
    out[from].insert(to);
    in[to].insert(from);
  }

  vector<int> dfs(){
    vector<int> visited(V,0);
    
    function<void(int)> dfs = [&](int pos){
      if(visited[pos]++) return;
      for(int nx:out[pos]) dfs(nx);
      tp.push_back(pos);
    };
    
    tp.clear();
    for(int i=0;i<V;i++) dfs(i);
    reverse(tp.begin(),tp.end());
    return tp;
  }

  vector<int> bfs(){
    auto tmp = in;
    tp.clear();
    queue<int> Q;
    for(int i=0;i<V;i++)if(in[i].empty()) Q.push(i);
    
    while(!Q.empty()){
      int v = Q.front();Q.pop();
      tp.push_back(v);
      for(int nx:out[v]){
        if(in[nx].size() == 1) Q.push(nx);
        in[nx].erase(v);
      }     
    }
    for(int i=0;i<V;i++) if(!in.empty()) tp.clear(); // exist loop
    tmp = in;
    return tp;
  }
};


int main(){
  int n,m;
  cin>>n>>m;
  TSort A(n);
  
  for(int i=0,a,b;i<m;i++)cin>>a>>b,A.add_edge(a,b);
  
  A.dfs();
  for(int i=0;i<n;i++)cout<<A.tp[i]<<endl;
  return 0;
}



Measured memory_bytes: 8296
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int a, b;
  cin >>a >> b;
  if(a+b==15){
    
    cout << "+\n";
  }else if(a*b==15){
    cout << "*\n";
  }else{
    cout <<"x\n";
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 1;
const long long mod = 998244353;


long long cnk[N], r[N];


int main() {
    long long i, j, n, A, B, K;
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> A >> B >> K;
    long long ans = 0;
    r[1] = 1;
    for (int i = 2; i <= n; ++i)
        r[i] = (mod - (mod / i) * r[mod % i] % mod) % mod;
    cnk[0] = 1;
    for (i = 1; i <= n; ++i)
        cnk[i] = (((cnk[i - 1]  * r[i]) % mod) * (n - i + 1)) % mod;
    for (i = 0; i <= n; ++i)
    if (i * A <= K && (K - i * A) % B == 0 && (K - i * A) / B <= n)
        ans = (ans + cnk[i] * cnk[(K - i * A) / B]) % mod;
    cout << ans;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;

	ll MX = 1000000000000000000LL;
	int n;
	cin >> n;
	ll cur = 1;
	V<ll> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
		if(v[i] == 0) return cout << 0 << endl, 0;
	}
	for(int i = 0; i < n; i++)	 {
		ll x = v[i];
		if(cur > (MX + x - 1) / x) {
			cout << -1 << endl;
			return 0;
		}
		cur *= x;
		if(cur > MX) return cout << -1 << endl, 0;
	}
	cout << cur << endl;
	
}





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

#define int long long
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; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    int n,k; cin >> n >> k;
    vector<int> a(n);
    rep(i,n){cin>>a[i]; a[i]--;}
    vector<int> dist(n,-1);
    dist[0]=0;
    int pos=0;
    int t=0;
    int start=0;

    //距離を計算し，ループを見つけたら終了
    rep(i,n){
        if(dist[a[pos]]!=-1){
            t=dist[pos]-dist[a[pos]]+1;
            start=a[pos];
            break;
        }
        dist[a[pos]]=dist[pos]+1;
        pos=a[pos];
    }
    
    
    if(dist[start]>k){
        pos=0;
        rep(i,k){
            pos=a[pos];
        }
        cout<<pos+1<<endl;
    }else{
        //k-=dist[start];
        //k%=t;
        pos=start;
        k=(k-dist[start])%t;
        rep(i,k){
            pos=a[pos];
        }
        cout<<pos+1<<endl;
    }
    //cout<<"k="<<k<<endl;
    //cout<<"dist[1]="<<dist[1]<<endl;
    //cout<<"t="<<t<<endl;
    //cout<<"start="<<start<<endl;
}

Measured memory_bytes: 6384
import java.util.*;
import java.lang.*;
import java.math.*;

class Main {

	Scanner sc = new Scanner(System.in);

	void run() {
		
		int x;
		
		while ( sc.hasNextInt() ) {
			x = sc.nextInt() + sc.nextInt();
			
			
			
			int count = 0;
			
			do{
				x /= 10;
				count++;
			} while ( x != 0);
			
			
			System.out.println(count);
			
		}
		return;

	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)
const ll INF = (1LL << 50);
typedef pair<int, ll>P;

bool cmp(const P&a, const P&b) {
	return a.second > b.second;
}

int main() {

	int n, m;
	cin >> n >> m;
	vector<ll>A(n);
	REP(i, n) cin >> A[i];

	SORT(A);

	vector<P> num(m);
	REP(i, m) cin >> num[i].first >> num[i].second;

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

	ll sum = 0;
	int j = 0;
	for (int i = 0; i < n; i++) {
		if (j < num.size()){
			if (A[i] >= num[j].second) sum += A[i];
			else {
				sum += num[j].second;
				num[j].first--;
			}
			if (num[j].first == 0) j++;
		}
		else {
			sum += A[i];
		}
	}

	cout << sum << endl;

	return 0;

}

Measured memory_bytes: 2560
# s+s になる文字列を末尾を削ることで作る。
# 長さが限られているのでループを回す
s = input()
l = len(s)
for i in range(l // 2 - 1, 0, -1):
    if s[:i] == s[i : 2 * i]:
        print(2 * i)
        exit()


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

int main(){
 long long n,d;
  cin >> n >> d;
  int ans=0;
  
  for(int i=0;i<n;i++){
    long long x,y;
    cin >> x >> y;
    if(sqrt(x*x+y*y)<=d) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(){
    int N, count = 0, flag = 1;
    scanf("%d", &N);

    int A[N];
    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }

    do{
        for(int i = 0; i < N; i++){
            if(A[i] % 2 != 0){
                flag = 0;
                break;
            }
        }
        if(flag != 0){
            for(int i = 0; i < N; i++){
                A[i] /= 2;
            }
            count++;
        }
    }while(flag != 0);

    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL X;
  cin>>X;
  LL ans = X/500*1000;
  X-=X/500 * 500;
  ans+=X/5*5;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main() {
  int N, A, B;
  scanf("%d %d %d", &N, &A, &B);

  char S[131072]={};
  scanf("%s", S);

  int domestic=0, foreign=0;
  for (int i=0; S[i]; ++i) {
    switch (S[i]) {
    case 'a':
      if (domestic + foreign < A + B) {
        ++domestic;
        printf("Yes\n");
      } else {
        printf("No\n");
      }
      break;
    case 'b':
      if (domestic + foreign < A + B && foreign < B) {
        ++foreign;
        printf("Yes\n");
        break;
      }
    case 'c':
      printf("No\n");
    }
  }

  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define regsiter register
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
int ab(int x)
{
	return x>0?x:-x;
}
int main()
{
	int n=io::F();
	int cx=0,cy=0,ct=0;
	while(n--)
	{
		int t=io::F(),x=io::F(),y=io::F();
		int d=ab(x-cx)+ab(y-cy);
		if((t-ct+d)&1)
		{
			puts("No");
			return 0;
		}
		if(t-ct<d)
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}




Measured memory_bytes: 256
import sys
from operator import itemgetter

n = int(input())
robots = []
for line in sys.stdin:
    X, L = map(int, line.split())
    l, r = X - L, X + L
    robots.append((l, r))
robots.sort(key=itemgetter(1))

curr = -(10 ** 10)
ans = 0
for l, r in robots:
    if curr > l:
        continue
    ans += 1
    curr = r
print(ans)


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

using namespace std;

int main(void) {
	int n, m, i, j, x, y;
	bool match = false;
	cin >> n >> m;
	vector<string> a(n), b(m);
	for (i = 0; i < n; i++)
		cin >> a[i];
	for (i = 0; i < m; i++)
		cin >> b[i];
	for (y = 0; match == false && y <= n - m; y++) {
		for (x = 0; match == false && x <= n - m; x++) {
			if (a[y][x] == b[0][0]) {
				for (i = 0; i < m; i++) {
					for (j = 0; j < m; j++) {
						if (a[i + y][j + x] != b[i][j])
							break;
					}
					if (j != m)
						break;
				}
				if (i == m)
					match = true;
			}
		}
	}
	if (match)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
n,m,c = gets.chomp.split.map(&:to_i)
bs = gets.chomp.split.map(&:to_i)
as = n.times.map{gets.chomp.split.map(&:to_i)}
count = 0
as.each do |a|
  sum = c
  (0..m-1).each do |i|
    sum += a[i]*bs[i]
  end
  count += 1 if sum > 0
end
puts count


Measured memory_bytes: 1788
#include <iostream>
using namespace std;
#define MAX_N 200000
#define rep(i, n) for (int i = 0; i < (n); i++)

int main(void) {
  int N;
  cin >> N;
  int A[MAX_N];
  int64_t SUM0 = 0;
  rep(i, N) {
    cin >> A[i];
    SUM0 += A[i];
  }

  int64_t MIN = INT64_MAX;
  int64_t SUM1 = 0;
  for (int i = 0; i < N-1; i++) {
    SUM1 += A[i];
    SUM0 -= A[i];
    int64_t DIFF = abs(SUM0 - SUM1);
    MIN = min(MIN, DIFF);
  }
  cout << MIN << endl;
  return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i ++)
#define pb push_back
#define mp make_pair

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>


using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
const ll mod = 1e9 + 7;
const ll power = 49999;

ll a, b;
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
/*
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
*/
	cin >> a >> b;
	if (a == 2 || b == 2)
		cout << "No";
	else
		cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)

x_s = Y[N // 2 - 1]
x_l = Y[N // 2]
for i in range(1, N + 1):
	if X[i - 1] <= x_s:
		print(x_l)
	else:
		print(x_s)

Measured memory_bytes: 93780
import java.util.Scanner;

class Solver {

    private final int N;

    Solver(Scanner in){
        N = in.nextInt();
    }

    void solve() {
        System.out.println(1. * (N - (N / 2)) / N);
    }
}

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

        new Solver(in).solve();

        in.close();
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
typedef long long LL;
#define lowbit(x) (x&(-x))
LL n;
LL a[N], b[N], bit[4 * N];

void add(LL x, LL val) {
	x += n + 1;
	for (; x <= 2 * n + 1; x += lowbit(x)) {
		bit[x] += val;
	}
}

LL sum(LL x) {
	LL val = 0;
	x += n + 1;
	for (; x > 0; x -= lowbit(x)) {
		val += bit[x];
	}
	return val;
}

LL sol(LL x) {
	LL tmp = 0, ans = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] <= x) {
			tmp++;
		} else {
			tmp--;
		}
		ans += sum(tmp - 1);
		add(tmp, 1);
	}
	tmp = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] <= x) {
			tmp++;
		} else {
			tmp--;
		}
		add(tmp, -1);
	}
	return ans;
}

int main(int argc, char const *argv[]) {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	memset(bit, 0, sizeof(bit));
	sort(b, b + n);
	LL nn = unique(b + 1, b + 1 + n) - b - 1;
	LL L = 1, R = nn, M, ans;
	LL tar = (n * (n + 1) / 2) / 2 + 1;
	add(0, 1);
	while (L <= R) {
		M = (L + R) >> 1;
		LL res = sol(b[M]);
		if (res >= tar) {
			ans = b[M];
			R = M - 1;
		} else {
			L = M + 1;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
    int n;
    cin >> n;
    n++;
    vector<int> a(n), b(n - 1);
    for (auto &i : a)
        cin >> i;
    for (auto &i : b)
        cin >> i;
    int ans=0;
    for (int i = 0; i < n - 1; i++)
    {
        if(a[i]<=b[i])
        {
            ans+=a[i];
            b[i]-=a[i];
            a[i]=0;
        }
        else
        {
            ans+=b[i];
            a[i]-=b[i];
            b[i]=0;
        }
        if(a[i+1]<=b[i])
        {
            ans+=a[i+1];
            a[i+1]=0;
        }
        else
        {
            ans+=b[i];
            a[i+1]-=b[i];
        }
    }
    
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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



int main(){
    int a,b,c;
    cin >> a >> b >> c;
    
    int ans = 0;
    ans = c-(a-b);
    if(ans<=0) ans = 0;
    cout << ans << endl;
    
    


}



Measured memory_bytes: 256
import math

N, A, B, C = map(int,input().split())
mod = 10**9+7

def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1]
g2 = [1, 1]
inv = [0, 1] 
for i in range(2, 2*10**5+1):
    g1.append((g1[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inv[-1]) % mod)

def g(a):
    b, u, v = mod, 1,0
    while b:
        t = a//b
        a -= t * b
        u -= t * v
        a,b,u,v = b,a,v,u
        u %= mod
    return u if u > 0 else u + mod

p1,p2 = A * g(A + B) % mod, B * g(A + B) % mod
p3 = (100 - C) * g(100) % mod

ans = 0
for i in range(N):
    ans += (N+i)*cmb(N+i-1,i,mod)% mod*(pow(p1,N,mod) * pow(p2,i,mod) % mod + pow(p1,i,mod) * pow(p2,N,mod) % mod)% mod
    ans %= mod
ans = ans * g(p3) % mod
print(ans)

Measured memory_bytes: 26912
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,ma6=0,ma9=0,tmp;
  cin >> n;
  int a[n+10];
  a[0] = 0;
  a[1] = 1;
  for(int i=2; i<=n; i++){
    for(int j=0; pow(6,j)<=i; j++){
      tmp = pow(6,j);
      ma6 = max(ma6,tmp);
    }
    for(int j=0; pow(9,j)<=i; j++){
      tmp = pow(9,j);
      ma9 = max(ma9,tmp);
    }
    a[i] = min(a[i-ma6],a[i-ma9])+1;
    ma6=0;
    ma9=0;
  }
  cout << a[n] << endl;
}

Measured memory_bytes: 640
import sys

read = sys.stdin.read
INF = 1 << 60


def main():
    N, W, *WV = map(int, read().split())
    weight = WV[::2]
    value = WV[1::2]

    V = sum(value)
    dp = [[INF] * (V + 1) for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(N):
        for v in range(V + 1):
            if v - value[i] >= 0:
                dp[i + 1][v] = dp[i][v - value[i]] + weight[i]
            if dp[i + 1][v] > dp[i][v]:
                dp[i + 1][v] = dp[i][v]

    ans = 0
    for v in range(V, 0, -1):
        if dp[N][v] <= W:
            ans = v
            break

    print(ans)
    return


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  int n; cin >> n;
  map <string, int> cnt1, cnt2;
  while(n--) {
    string s; cin >> s;
    cnt1[s]++;
    cnt2[s] = 0;
  }
  int m; cin >> m;
  while(m--) {
    string s; cin >> s;
    cnt2[s]++;
  }
  int mx = 0;
  for(auto x : cnt1) {
    mx = max(mx, cnt1[x.first] - cnt2[x.first]);
  }
  print(mx);
}

Measured memory_bytes: 256
<?php


fscanf(STDIN, "%d %d", $H, $W);
fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));
array_unshift($a, 0);

$x = 0;
$y = 0;
$dx = 1;
$dy = 0;
$ans = array(array());
$cursor = 1;

while(true) {
    $a[$cursor]--;
    $color = $cursor;
    if ($a[$cursor] == 0) {
        $cursor++;
    }
    $ans[$x][$y] = $color;
    if ($cursor > $N) {
        break;
    }
    $x += $dx;
    $y += $dy;
    if ($x == $W) {
        $x--;
        $y++;
        $dx = 0;
        $dy = 1;
    }
    if ($y == $H) {
        $y--;
        $x--;
        $dx = -1;
        $dy = 0;
    }
    if ($x < 0) {
        $x++;
        $y--;
        $dx = 0;
        $dy = -1;
    }
    if ($y < 0) {
        $x++;
        $y++;
        $dx = 1;
        $dy = 0;
    }
    if (isset($ans[$x][$y])) {
        if ($dx == 1 && $dy == 0) {
            $x--;
            $y++;
            $dx = 0;
            $dy = 1;
        } elseif ($dx == -1 && $dy == 0) {
            $x++;
            $y--;
            $dx = 0;
            $dy = -1;
        } elseif ($dx == 0 && $dy == 1) {
            $y--;
            $x--;
            $dx = -1;
            $dy = 0;
        } elseif ($dx == 0 && $dy == -1) {
            $x++;
            $y++;
            $dx = 1;
            $dy = 0;
        }
    }
}

for ($y = 0; $y < $H; $y++) {
    $arrTmp = array();
    for ($x = 0; $x < $W; $x++) {
        $arrTmp[] = $ans[$x][$y];
    }
    echo implode(" ", $arrTmp) . PHP_EOL;
}


Measured memory_bytes: 6776
#include<iostream>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>//min,max,swap,rand,reverse,sort,lower_bound
#include<functional>
#include<vector>
#include<list>
#include<map>
#include<tuple>
#include<cmath>//abs, sin, cos
#include<bitset>
using namespace std;


#include<math.h>
int main()
{
	unsigned long long int A, P;
	long double B, J;
	long double O;
	cin >> A >> B;;
	//O = B * 100;
	//P = (A * O)/100;
	O = (A*B)+0.0001;
	P = O;
	cout << P << endl;

	return 0;
}

Measured memory_bytes: 3204
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <queue>

#define INF 214748364000

using namespace std;

/*union-find*/
int par[10000],ranks[10000];

void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i;
		ranks[i] = 0;
	}
}

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

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

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

struct edge { int from,to,cost;};

bool comp(const edge& e1, const edge& e2){
	return e1.cost < e2.cost;
}

int main(){
	int V,E,
	    s,t,d,sum=0;
	edge G[100000];
	
	scanf("%d %d",&V,&E);
	for(int i=0;i<E;i++){
		scanf("%d %d %d",&s,&t,&d);
		G[i] = {s,t,d};
	}
	
	sort(G,G+E,comp);
	init(V);
	for(int i=0;i<E;i++){
		edge e= G[i];
		if(!same(e.to,e.from)){
			unite(e.to,e.from);
			sum += e.cost;
		}
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 4468
#include<stdio.h>

#define N 100000

int binary(int *,int,int);

int main(){
  int pre,nex,i,cnt=0;
  int a[N],b[N];

  scanf("%d",&pre);
  for(i=0;i<pre;i++) scanf("%d",&a[i]);

  scanf("%d",&nex);
  for(i=0;i<nex;i++){
    scanf("%d",&b[i]);
    cnt += binary(a,b[i],pre);
  }

  printf("%d\n",cnt);

  return 0;
}

int binary(int *a,int b,int cut){
    int left = 0,p=0,right=cut,mid;

    while(left <= right) {
        mid = (left + right) / 2; /* calc of middle key */
        if (a[mid] == b) {
            p++;
            break;
        } else if (a[mid] < b) {
            left = mid + 1; /* adjustment of left(start) key */
        } else {
            right = mid - 1; /* adjustment of right(end) key */
        }
    }
    return p;
}

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

typedef unsigned long long int ll;

const ll pmax = 1000001;
const ll nmax = (pmax - 1)*(pmax - 1);
const ll powmax = 65;

bool prime[pmax];
ll countsum[powmax];

void countcalc(){
    countsum[0] = 0;
    ll base = 1;
    ll nextsum = 3;
    for(ll i = 1; i < powmax; i++){
        if(i >= nextsum){
            base++;
            nextsum += base + 1;
        } 
        countsum[i] = base;
        // cout << i << " " << countsum[i] << endl;
    }
}

void sieve(){
    for(ll i = 0; i < pmax; i++) prime[i] = true;
    for(ll i = 2; i < ceil(sqrt(pmax)); i++){
        if(!prime[i]) continue;
        for(ll j = i+i; j < pmax; j += i) prime[j] = false;
    }
}

int main(){
    countcalc();
    sieve();

    ll n; cin >> n;
    ll ans = 0;
    for(ll i = 2; i < pmax; i++){
        if(!prime[i]) continue;
        ll cnt = 0;
        while(n%i == 0){
            n = n/i;
            cnt++;
        }
        //if(cnt != 0) cout << i << " : " << cnt << endl;
        ans += countsum[cnt];
    }
    if(n != 1) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4608
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MAXN = 2e5 + 5;
const int mod = 998244353; 
LL tr[MAXN] , dp[MAXN];
int n , k , L[15] , R[15];
void update(int x , LL y) {
	for (; x <= n; x += (x & (-x))) tr[x] = (tr[x] + y) % mod;
}
LL find(int x) {
	if(!x) return 0;
	LL res = 0;
	for (; x; x -= (x & (-x))) res = (res + tr[x]) % mod;
	return res;
}

int main() {
	scanf("%d %d" , &n , &k);
	for (int i = 1; i <= k; ++i) {
		scanf("%d %d" , &L[i] , &R[i]);
	}
	dp[1] = 1;update(1 , 1);
	for (int i = 2; i <= n; ++i) {
		for (int j = 1; j <= k; ++j) {
			if(i <= L[j]) continue;
			dp[i] = (dp[i] + find(i - L[j]) - find(max(i - R[j] - 1 , 0))) % mod;
			dp[i] = (dp[i] + mod) % mod; 
		}
		update(i , dp[i]);
	}
	printf("%lld" , dp[n]);
	return 0;
}

Measured memory_bytes: 6364
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
vector<int> numberOfDivisors(int n) {
    vector<int> num(n + 1);
    for (int i = 1; i <= n; i++)
        for (int j = i; j <= n; j += i) num[j]++;
    return num;
}
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;

    auto v = numberOfDivisors(N);
    int ans = 0;
    rep(i, 1, N + 1) {
        if (i % 2) {
            if (v[i] == 8) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> P;
    for (int i = 0; i < m; ++i) {
        int l, r;
        cin >> l >> r;
        P.emplace_back(l, r);
    }
    sort(P.begin(), P.end());

    int res = 0;
    for (int i = 0; i < m; ++i) {
        int r = P[i].second;

        while (i + 1 < m && P[i + 1].first < r) {
            r = min(P[i + 1].second, r);
            ++i;
        }
        // cout << i << " ::  " << r << endl;
        ++res;
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 1400
def myAnswer(N:int,x:int,A:list) -> int:
   if(sum(A)==x): return N
   A.sort()
   counter = 0
   hantei = True
   for n,a in enumerate(A):
      if(a > x):
         hantei = False
         break
      elif(a == x):
         counter += 1
         return counter
      elif(a < x):
         x -= a
         counter += 1

   if(x != 0 and counter != 0 and hantei ):
      counter -=1
   return counter

def modelAnswer():
   tmp=1
def main():
   N,x = map(int,input().split())
   A = list(map(int,input().split()))
   print(myAnswer(N,x,A[:]))


if __name__ == '__main__':
   main()


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

string s[110];
int N,L; 


int main(void){
    cin >> N >> L; 
    for(int i=0; i<N; ++i){
        cin >> s[i];
    }
    sort(s,s+N);
    for(int i=0; i<N; ++i){
        cout << s[i];
    }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------
string s;
signed main() {
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			if (s[i] == 'L') {
				cout << "No\n";
				return 0;
			}
		}
		else {
			if (s[i] == 'R') {
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from itertools import combinations_with_replacement as combi
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n, m, q = MII()
    query = [MII() for _ in range(q)]
    l = [i for i in range(1,m+1)]
    maxv = 0
    for v in combi(l,n):
        sumv = 0
        for a,b,c,d in query:
            if v[b-1]-v[a-1] == c:
                sumv += d
        maxv = max(maxv, sumv)
    print(maxv)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9512
#include <bits/stdc++.h>
using namespace std;
int main() {

    #define ll long long
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n == 1 or n == 2){
       cout << 0 << endl;
       return 0;
   }
   
    ll a[3]={0};
   
    for(int i=0;i<n;i++){
       if(s[i]=='R')
        a[0]++;
       else if(s[i]=='G')
        a[1]++;
       else
        a[2]++;
   }
   
   ll s1=0;
   s1=a[0]*a[1]*a[2];
   for(int i=0;i<n;i++)
   {
       for(int j=1;j<=min(i,n-i-1);j++)
       {
           if(s[i]!=s[i-j] && s[i]!=s[i+j] && s[i-j]!=s[i+j])
           {
               s1--;
           }
       }
   }
   cout<<s1<<endl;
}

Measured memory_bytes: 3608
/*B - Bite Eating*/
#include <bits/stdc++.h>
using namespace std;

using Long = long long;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int minimo = INT_MAX;
	int suma = 0;
	int tam;
	int aux;
	int ans;
	int dif;
	int L;

	cin >> tam >> L;


	vector <int> nums(tam);

	for (int i = 0; i < tam ; ++i)
	{
		nums[i] = i + L;
		suma += nums[i];
	}

	for (int i = 0; i < tam; ++i)
	{
		aux = suma - nums[i];
		dif = abs(aux - suma);

		if(dif < minimo){
			minimo = min(dif, minimo);
			ans = aux;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
def examA():
    N, L = LI()
    V, D = LI()
    X = [LI()for _ in range(N)]

    ans = 0
    print(ans)
    return

def examB():
    N, K = LI()
    H = 11; W = 7
    S = [[0]*(W+1) for _ in range(H+3)]
    for h in range(H+2):
        for w in range(W):
            S[h+1][w+1] = (S[h][w+1] + S[h+1][w] - S[h][w] + (7*h+w+1))
    #print(S)
    base = 0
    for h in range(H):
        for w in range(W-2):
            cur = S[h+3][w+3] - S[h+3][w] - S[h][w+3] + S[h][w]
            if cur%11==K:
                base += 1
                #print(h,w)
    ans = base * ((N-2)//11)
    #print(ans)
    rest = (N-2)%11
    for h in range(rest):
        for w in range(W-2):
            cur = S[h+3][w+3] - S[h+3][w] - S[h][w+3] + S[h][w]
            if cur%11==K:
                ans += 1
                #print(h,w)
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examB()

"""

"""

Measured memory_bytes: 3956
import itertools


N = int(input())

P = [list(map(int,input().split())) for i in range(N)]

S = 0


route = list(itertools.combinations(P, 2))

for i in route:
   
   S += ((i[0][0] - i[1][0])**2 + (i[0][1] - i[1][1])**2)**0.5
   
print(S*2/N)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int main()
{
	int n; cin >> n;
	vector <vector<int>> v(n);
	rep(i,n)
	{
		int hoge;
		cin >> hoge;
		int k;
		cin >> k;
		rep(j,k)
		{
			int foo;
			cin >> foo;
			v[i].push_back(foo-1);
		}
	} 
	vector<int> color(n);
	rep(i,n)color[i]=0;
	queue<int> Q;
	vector <int> d(n);
	rep(i,n)d[i]=-1;

	color[0] = 1;
	d[0]=0;
	Q.push(0);
	while(!Q.empty())
	{
		int u = Q.front();
		Q.pop();
		rep(i,v[u].size())
		{
			if(color[v[u][i]]==0)
			{
				color[v[u][i]]=1;
				d[v[u][i]]=d[u]+1;
				Q.push(v[u][i]);
			}
		}
	}

	rep(i,n)cout<<i+1<<' '<<d[i]<<endl;
	return 0;
}


Measured memory_bytes: 3132
#include <algorithm>
#include <cmath>
#include <chrono>
#include <cstdio>
#include <ctime>
#include <iostream>
#include <random>
#include <string>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
/*---------------------------------------*/

const int MAX = 100000;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

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

  vector<int> odd(MAX+1, 0); // 1-based
  vector<int> even(MAX+1, 0); // 1-based
  REP(i, n) {
    if (i % 2 == 0) ++even[v[i]];
    else ++odd[v[i]];
  }
  vector<int> copy_odd(MAX+1);
  vector<int> copy_even(MAX+1);
  REP(i, MAX+1) {
    copy_odd[i] = odd[i];
    copy_even[i] = even[i];
  }
  sort(ALL(odd), greater<int>());
  sort(ALL(even), greater<int>());
  size_t max_odd = distance(copy_odd.begin(), find(ALL(copy_odd), odd[0]));
  size_t max_even = distance(copy_even.begin(), find(ALL(copy_even), even[0]));
  int ans = n;
  if (max_odd != max_even) {
    ans -= odd[0] + even[0];
  } else if (odd[0] != even[0]) {
    if (odd[0] > even[0]) {
      ans -= odd[0] + even[1];
    } else {
      ans -= odd[1] + even[0];
    }
  } else if (odd[1] > even[1]) {
    ans -= odd[1] + even[0];
  } else {
    ans -= odd[0] + even[1];
  }
  cout << ans << "\n";
}


Measured memory_bytes: 2176