akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	int n;
	cin>>n;
	v A(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>A[i];
	}
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i+1; j < n; ++j)
		{
			ans+=A[i]*A[j];
		}
	}
	cout<<ans;
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int mod = 1e9+7;
int n,k;
const int maxn = 4010;

int fexp(int x, int exp) {
	int ans = 1ll, base = x;
	while (exp) {
		if (exp & 1) ans *= base;
		base = (base*base)%mod;
		ans %= mod;
		exp >>= 1;
	}
	return ans;
}

int fac[maxn];
int choose(int n, int k) {
	if (k > n) return 0;
	if (k == 0 or n == k) return 1;
	return (fac[n] * fexp((fac[k]*fac[n-k])%mod,mod-2))%mod;
}

int32_t main() {
	FAST
	cin >> n >> k;
	fac[0] = fac[1] = 1;
	for (int i =2;i < maxn;i++) {
		fac[i] = (fac[i-1]*i)%mod;
	}
	for (int i = 1;i<=k;i++) {
		int n1 = n-k - (i-1); //n1 red balls
		int k1 = i + 1; //Split into k1 boxes.
		if (n1 < 0) {
			cout << "0\n";
			continue;
		}
		
		//cout << i << " " <<  n1 << " " << k1 << "\n";
		cout << (choose(n1+k1-1,n1) * choose(k-1,i-1))%mod << "\n";
	}
	
}




Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}



using namespace std;
int main(){
    int n,x,cnt=1,sam=0,a;
    cin >> n >>x;

    REP(i,n){
        cin >> a;
        sam += a;
        cnt ++;
        if(sam > x){
            cout << cnt -1 <<endl;
            return 0;
        }
    }

    cout << cnt <<endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

hidari = 0
d = 0
d_max = 0

for i in range(N-1):
    if H[i] - H[i+1] < 0:
        d = i - hidari
        hidari = i + 1
        if d > d_max:
            d_max = d

d = N - hidari - 1

print(max(d_max, d))


Measured memory_bytes: 15020
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int ctoi(const char c)
{
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}

int main()
{
    string N; cin >> N;
    int result = 0;
    for (auto c : N) result += ctoi(c);
    if (stoi(N) % result == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100005

int parent[MAX], left[MAX], right[MAX];
int n, D[MAX];

int getDepth(int u){
  int d = 0;
  while(parent[u] != -1){
    u = parent[u];
    d++;
  }
  return d;
}
void setDepth(int u, int p){
  D[u] = p;
  if(right[u] != -1){
    setDepth(right[u], p);
  }
  if(left[u] != -1){
    setDepth(left[u], p+1 );
  }
}

void printChildren(int u){

  int i, c;

  printf("node %d: ", u);
  printf("parent = %d, ", parent[u]);
  printf("depth = %d, ", getDepth(u));

  if(parent[u] == -1 ) printf("root, ");
  else if(left[u] == -1 ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for( i = 0, c = left[u] ; c != -1 ; i++, c = right[c]){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

int main(){
  int i, j, d, v, c, l, r;
  scanf("%d", &n);
  for(i = 0 ; i < n ; i++)  parent[i] = left[i] = right[i] = -1;

  for( i = 0 ; i < n ; i++){
    scanf("%d", &v);
    scanf("%d", &d);
    for( j = 0 ; j < d ; j++){
      scanf("%d", &c);
      if( j == 0 ) left[v] = c;
      else right[l] = c;
      l = c;
      parent[c] = v;
    }
  }
  for( i = 0 ; i < n ; i++){
    if( parent[i] == -1 ) r = i;
  }

  setDepth(r, 0);

  for( i = 0 ; i < n ; i++) printChildren(i);

  return 0;
}



Measured memory_bytes: 6368
A,B,C,D=map(int,input().split())
mod=998244353
dp=[[0 for y in range(D-B+1)]for x in range(C-A+1)]
dp[0][0]=1
for x in range(C-A):
    dp[x+1][0]=(dp[x][0]*B)%mod
for y in range(D-B):
    dp[0][y+1]=(dp[0][y]*A)%mod
for x in range(C-A):
    for y in range(D-B):
        dp[x+1][y+1]=(dp[x+1][y]*(A+x+1)+dp[x][y+1]*(B+y+1)-dp[x][y]*(A+x)*(B+y))%mod
print(dp[C-A][D-B])


Measured memory_bytes: 146692
n = gets.chomp.to_i
z = n.times.map { temp = gets.chomp.split(' ').map(&:to_i); temp[0] == temp[1] }
if (0..(n - 3)).any? { |i| z[i] && z[i + 1] && z[i + 2]}
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 14436
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length == 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function slove() {
    const sc = new Scanner();
    const [n, m] = (await sc.getLine()).split(' ').map((x) => +x);
    const list = [];
    const cnt = Array(m).fill(0);
    for (let i = 0; i < n; i++) {
      const t = (await sc.getLine()).split(' ').map((x) => +x);
      t.shift();
      for (let v of t) {
        cnt[v - 1]++;
      }
    }
    console.log(cnt.filter((x) => x === n).length);
    sc.close();
  }

  slove();
}


Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  char c;
  cin >> a >> c >> b;
  
  if (c == '+') {
    cout << a + b;
  }
  
  if (c == '-') {
    cout << a - b;
  }
  
}


Measured memory_bytes: 256
//void __(){
//    ll n,a,b;
//    cin >> n >> a >> b;
//    if(a%2 == b%2)
//        print (b-a)/2;
//    else
//        print (b-a)/2 + min(n+1-b,a-0);
//
//}
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
struct _print {
    string sep,end;
    bool space;
    ostream &stream;
    _print(string _sep=" ",string _end="\n",
            ostream &_stream = cout)
        : sep(_sep),end(_end),space(false),
            stream(_stream) {}
    ~_print() { stream << end; }
    template <typename T>
        _print &operator , (const T &t) {
            if (space) stream << sep;
            space = true;
            stream << t;
            return *this;
        }
};
#define print _print(),
void __(){
    ll n,a,b;
    cin >> n >> a >> b;
    if(a%2 == b%2)
        print (b-a)/2;
    else
        print (b-a)/2 + min(n+1-b,a-0);
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        __();
}


Measured memory_bytes: 256
#include<stdio.h>

long fac(int n){
    if(n == 1) return 1;
    
    return (n * fac(n -1));
}

int main(void){
    int n; 
    long res;
    
    scanf("%d", &n);
    
    res = fac(n);
    
    printf("%ld\n", res);
    
    return 0;
}

Measured memory_bytes: 588
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int main(){
  int p,q,r;
  cin>>p>>q>>r;
  int ab=min(p,q+r);
  int bc=min(q,p+r);
  int ac=min(r,p+q);
  cout<<ab+bc+ac-max({ab,bc,ac})<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long X = sc.nextLong();
    long Y = sc.nextLong();
    String ans = "Alice";
    if(Math.abs(X - Y) <= 1) ans = "Brown";
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[] = new int[3];
    for(int i = 0;i<3;i++){
      a[i] = sc.nextInt();
    }
    int ans = 0;
    if(a[0] == a[1] && !(a[0] == a[2])){
      ans = 1;
    }
    if(a[1] == a[2] && !(a[1] == a[0])){
      ans = 1;
    }
    if(a[2] == a[0] && !(a[2] == a[1])){
      ans = 1;
    }
    if(ans == 1){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23124
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Control.Monad ( replicateM )
import qualified Data.List as L ( sort )


getParm :: IO [Int]
getParm = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,_] <- getParm
  ss    <- replicateM n C.getLine
  putStrLn . C.unpack $ minimumCombination ss 

minimumCombination 
 :: [C.ByteString] -> C.ByteString
minimumCombination = C.concat . L.sort

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,N) for(int i=0;i<N;i++)

int main()
{
    string s; cin>>s;
    bool ans = count(all(s), s[0])==2 && count(all(s), s[1])==2 && count(all(s), s[2])==2 && count(all(s), s[3])==2;
    cout<< (ans?"Yes":"No")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
using ll = long long;
using vll = vector<long long>;

#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)


int main() {
	const ll x = pow(10, 9) + 7;

	ll n, k, cntB = 0, cntS = 0, cntR = 0, y, z = 0, cntRS;
	in(n);
	in(k);
	vll a(n);
	vector<pair<ll, ll>> b;
	rep(i, 0, n) {
		in(a[i]);
	}
	rep(i, 0, n - 1) {
		for (int j = i + 1; j < n; j++) {
			if (a[i] > a[j]) {
				cntB++;
				if (cntB > x) {
					cntB -= x;
				}
			}
			else if (a[i] < a[j]) {
				cntS++;
				if (cntS > x) {
					cntS -= x;
				}
			}
		}
	}

	y = k-1;
	cntRS = (1 + y);
	if (y % 2 == 1) {
		z = (y + 1) / 2;
		y -= 1;
	}
	cntRS = (cntRS * (y / 2) % x + z)%x;
	cntR = (cntRS + k) % x;

	outn((cntB* cntR% x + cntS * cntRS) % x);

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    ll s = 0, t = 0;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s += a[i];
    }

    ll r = 1LL << 60;
    for (int i = 0; i < n - 1; i++) {
        s -= a[i];
        t += a[i];
        r = min(r, abs(s - t));
    }

    cout << r << endl;


    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 100001;
ll dp[100005];

int main() {
    ll n, k, v, w, mx;
    scanf("%d%d", &n, &k);
    memset(dp, 0x3f, sizeof dp);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        scanf("%lld%lld", &w, &v);
        for (int j = MAXN-1; j >= v; j--)
            dp[j] = min(dp[j], dp[j-v]+w);
    }
    for (int i = 0; i < MAXN; i++)
        if (dp[i] <= k) mx = i;
    printf("%d\n", mx);
    return 0;
}

Measured memory_bytes: 1024
#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 vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long, long> > vllll;
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(), 0)
#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 * b / gcd(a, 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
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  ll x;
  cin >> x;
  ans = x;
  fi(0, n - 1) {
    cin >> x;
    ans = gcd(ans, x);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int q[21000],tail;
ll com(ll n,ll m){
	if(n<m) return 0;
	ll ret = 1;
	for(int i=0,j=1;i<m;i++){
		ret*=n-i;
		while(j<=m && ret%j==0){
			ret/=j;
			j++;
		}
	}
	return ret;
}
ll f[30];
int g[30];
int a[100];
int main(){
	ll n;
	cin>>n;
	int now  = 0;
	while(n){
		for(int i = 63;i>1;i--) if((1ll<<i-1)-1<=n){
			n -= (1ll<<i-1)-1;
			//now++;
			//cout<<i<<endl;
			int num = 0;
			memset(a,0,sizeof(a));
			bool flag = true;
			while(n>0 && flag){
				flag =false;
				ll mx =0;
				int p= 0;
				for(int j = 0;j*2<=i;j++){
					ll tmp = 0;
					for(int k = 0;k<=j;k++) tmp+=com(j,k)*com(i-j,k);
					if(tmp>mx && tmp<=n) {
						mx = tmp;
						p = j;
					}
				}
				if(p>0){
					flag = true;
					a[++num] = p;
					n-= mx;
				}
			}
			if(num){
				sort(a+1,a+num+1);
				reverse(a+1,a+num+1);
				for(int j =0;j<i-a[1];j++) q[tail++] = now+1;
				for(int k = 1;k<=num;k++){
				 	q[tail++] = now+k+1;
					for(int j = 0;j<a[k]-a[k+1];j++) q[tail++] = now+1;
				}
				for(int k = num;k>0;k--) q[tail++] = now+k+1;
				now+=num+1;
			} else{
				for(int j = 0;j<i;j++) q[tail++] = now+1;
				now++;
			}
			
			break;
		}
	}
	cout<<tail<<endl;
	for(int i =0;i<tail;i++) cout<<q[i]<<' ';
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int k;cin>>k;
  int res=0;
  rep1(i,k){
    rep1(j,k){
      if((i+j)%2==1)res++;
    }
  }
  cout<<res/2<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define Test int t;cin>>t;while(t--)
#define PI acos(-1)
#define endl "\n"
#define fx(x) fixed<<setprecision(x)
#define sz(s) (int)s.size()
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define mem(a,n) memset((a),n,sizeof (a))
const double eps=1e-9;
const int mod=1e9+7;
int dx[]={-1,-1,-1,0,0,1,1,1};
int dy[]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll x,ll y) {return(!y)?x:gcd(y,x%y);}
ll lcm(ll x,ll y) {return((x/gcd(x,y))*y);}
using namespace std;
void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int n,w;
vector<pair<int,int> >v;
int dp[101][100002];
int solve(int idx,int va){
    if(va<0)return w+1;
    if(idx==n){
        if(va==0)return 0;
        return w+1;
    }
    int &ret=dp[idx][va];
    if(~ret)return ret;
    ret=min(v[idx].first+solve(idx+1,va-v[idx].second),solve(idx+1,va));
    return ret;
}
int main()
{
    fast();
    mem(dp,-1);
    cin>>n>>w;
    v.resize(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
    }
    int ans;
    for(int i=100000;i>=0;i--){
        if(solve(0,i)<=w){
            ans=i;
            break;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 43112
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
//#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


const ll MOD=1e9+7;
const int N=500000;

ll gcd(ll x,ll y){
    if(x) return gcd(y%x,x);
    else return y;
}

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

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

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

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

  operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

main(){
    int k=in();
    WeightedGraph<int> G(k);
    vec used(k);
    int now=1;
    rep(i,k){
        G[i].emplace_back((i+1)%k,1);
    }
    rep(i,k){
        G[i].emplace_back(i*10%k,0);
    }
    auto v=dijkstra(G,1);
    cout<<v[0]+1;
}

Measured memory_bytes: 7164
L, R = map(int, input().split())

if R * (R - 1) < 2019:
    print(L * (L + 1))
    exit()

ans = 2019
for i in range(L , R):
    for j in range(i + 1, R + 1):
        ans = min(i * j % 2019, ans)
        if ans == 0:
            print(ans)
            exit()

print(ans)


Measured memory_bytes: 3316
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    numbers=[]
    a,b = map(int,input().split())
    numbers=list(range(a,b+1))
    count=0

    for number in numbers:
        if str(number)[0]==str(number)[-1] and str(number)[1]== str(number)[3]:
            count+=1
    print(count)

if __name__=="__main__":
    main()

Measured memory_bytes: 12336
def t(l_2d):
  return list(zip(*l_2d))
	
	
n = int(input())
a = [list(input().split()) for i in range(n)]
x,u = t(a)
x=map(float,x)



ret=0
for xi,ui in zip(x,u):
	if ui=="JPY":
		ret+=xi
	else:
		ret+=xi*380000
print(ret)

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

int main(){
  int x;
  cin >> x;
  if(x < 1200)  cout << "ABC" << endl;
  else cout << "ARC" << endl;
}

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

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


void solve(long long X, long long N, std::vector<long long> p){
    ll ans = 0;
    ll score = 999999999999999;
    vector<ll> a(200);
    rep(i,200) a[i] = 0;
    rep(i,N) a[p[i]] = 1;
    if(N == 0){
        cout << X << endl;
        return;
    }

    for(int i = 0; i<200; i++){
        if(a[i]) continue;
        ll now = abs(i-X);
        if(now < score){
            score = now;
            ans = i;
        }
    }
    cout << ans << endl;

}

int main(){
    long long X;
    scanf("%lld",&X);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(X, N, std::move(p));
    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    string s;
    ll k;

    cin >> s >> k;

    ll n = s.size();

    char f = s.front();
    char b = s.back();

    if (count(s.begin(), s.end(), f) == n) {
        cout << n * k / 2 << endl;
        ret();
    }

    ll sa = [&]() -> ll {
        string t = s;
        ll ans = 0;
        rep(i, n - 1) {
            if (t[i] == t[i + 1]) {
                ans++;
                t[i + 1] = '*';
            }
        }
        return ans;
    }();

    if (f != b) {
        cout << sa * k << endl;
        ret();
    }

    ll pre = [&]() -> ll {
        rep(i, n) {
            if (s[i] != f) return i;
        }
        __throw_runtime_error("konaide");
    }();

    ll suf = [&]() -> ll {
        for (int i = n - 1; i >= 0; i--) {
            if (s[i] != b) return n - i - 1;
        }
        __throw_runtime_error("konaide");
    }();


    cout << sa * k - ((pre / 2 + suf / 2 - (pre + suf) / 2) * (k - 1)) << endl;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int r;
    cin >> r;
    cout << fixed << setprecision(10);
    cout << 2 * M_PI * r << endl;
}


Measured memory_bytes: 3784
time=[]
n=list(map(int,input().split()))
for i in range(n[0]):
    keep=str(n[i*2+1]).zfill(2)+":"+str(n[i*2+2]).zfill(2)
    if not(keep in time):
        time.append(keep)
n=list(map(int,input().split()))
for i in range(n[0]):
    keep=str(n[i*2+1]).zfill(2)+":"+str(n[i*2+2]).zfill(2)
    if not(keep in time):
        time.append(keep)
time.sort()
for i,j in enumerate(time):
    if j[0]=="0":
        time[i]=j[1:]
    else:break
print(" ".join(time))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
 int N;cin>>N;
  vector<vvi> F;
  vvl P(N,vector<ll>(11));
  vector<bitset<10>> bs(N);
  rep(i,N){
    string s;
    rep(j,10){
      char c;cin>>c;
      s +=c;
    }
    bitset<10> a(s);
    bs[i]=a;
    
  }
  
  rep(i,N){
    rep(j,11){
      cin>>P[i][j];
    }
  }
  ll ans=-1000000000;
  for (int tmp = 0; tmp < (1 << 10); tmp++) {
    ll cnt=0;
    bitset<10> xx(tmp);
    // ビット列を出力
    if(xx==0000000000)continue;
    
    rep(i,N){
   
      cnt +=P[i][(bs[i]&xx).count()];
    }
    ans =max(ans,cnt);
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;
int main() {
	int x, y, z;
	cin >> x >> y >> z;
	int ans = 0,d=0;
	d = x - z;
	ans = d / (y + z);

	cout << ans << endl;

	return 0;
}

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

int main(){
    std::string S;
    std::cin >> S;
    std::size_t n = S.size();
    for(int mojisu = n - 1; mojisu > 0; mojisu--){
        if(mojisu % 2 != 0) continue;
        int i;
        for(i = 0; i < mojisu / 2; i++){
            if(S[i] != S[mojisu / 2 + i]) break;
        }
        if(i == mojisu / 2){
            std::cout << mojisu << std::endl;
            return 0;
        }
    }
    return 0;
}


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

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

using ll = long long;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n)cin >> a.at(i);
  int sum = 0;
  rep(i,n)sum += (a.at(i)-1);
  cout<<sum <<endl;
}


Measured memory_bytes: 256
H, W = list(map(int, input().split()))

if H == 1 or W == 1:
    print(1)
else:
    H2 = H // 2
    W2 = W // 2
    H3 = H - H2
    W3 = W - W2
    print(H2 * W2 + H3 * W3)


Measured memory_bytes: 38256
import math
n, d = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(n)]
cnt = 0
for i in range(n-1):
    for j in range(i+1, n):
        dis = 0
        for k in range(d):
            dis += (lst[i][k] - lst[j][k]) ** 2
        if math.sqrt(dis).is_integer():
            cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const double EPS = 1e-12;

int main(void) {
    i64 n;
    cin >> n;
    vector<vector<pair<i64, i64>>> t(n);
    vector<i64> b(n, 0);
    for (i64 i = 0; i < n - 1; i++) {
        i64 u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        t[u].push_back({v, w});
        t[v].push_back({u, w});
    }
    
    b[0] = 1;
    
    queue<pair<i64, i64>> que;
    que.push({0, 0});
    
    while (!que.empty()) {
        auto p = que.front(); que.pop();
        i64 now = p.first, nol = p.second;
        
        for (i64 i = 0; i < t[now].size(); i++) {
            i64 next = t[now][i].first, nel = nol + t[now][i].second;
            if (b[next] == 0) {
                b[next] = nel % 2 + 1;
                que.push({next, nel});
            }
        }
    }
    
    for (i64 i = 0; i < n; i++) {
        cout << b[i] - 1 << endl;
    }
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,k,x,y;
cin>>n>>k>>x>>y;
int ans;
if(n<=k){
    ans=x*n;
}
else{
    ans=x*k+(n-k)*y;
}
cout<<ans<<endl;
//system("pause");
return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

// clang-format off
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

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

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

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

    int a, b;
    cin >> a >> b;
    vec v;
    v.pb(a + b);
    v.pb(a - b);
    v.pb(a * b);
    print(*max_element(all(v)));
    return 0;
}


Measured memory_bytes: 764
import sys
s=input()
t=input()

dic={}
for i in range(len(s)):
    if not s[i] in dic and t[i] in dic.values():
        print("No")
        sys.exit()
    dic.setdefault(s[i],t[i])
    if dic[s[i]]!=t[i]:
        print("No")
        sys.exit()


print("Yes")

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
  int i, j, n, p, count=0;
  int A[100];

  scanf("%d",&n);

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

  for(i=0 ; i<n ; i++){
    for(j=n-1 ; j>i ; j--){
      if(A[j] < A[j-1]){
	p = A[j];
	A[j] = A[j-1];
	A[j-1] = p;
	count++;
      }
    }
  }
  for(i=0 ; i<n-1 ; i++) printf("%d ",A[i]);
  printf("%d\n%d\n",A[i],count);

  return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> a, std::vector<long long> b) {
  ll cnt = 0;
  ll sumA = 0;
  ll sumB = 0;
  rep(n, N) {
    ll tmp = ceil(max(b[n] - a[n], 0LL) / 2.0);
    cnt += tmp;
    a[n] += tmp * 2;
    sumA += a[n];
    sumB += b[n];
  }

  if (sumA - sumB <= cnt) {
    print(YES);
  } else {
    print(NO);
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  std::vector<long long> b(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &b[i]);
  }
  solve(N, std::move(a), std::move(b));
  return 0;
}


Measured memory_bytes: 384
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] a) {
        Scanner scan = new Scanner(System.in);
        scan.nextLine();
        List<Integer> list = Arrays.stream(scan.nextLine().split("\\s")).map(Integer::valueOf).collect(Collectors.toList());
        System.out.println(
                IntStream.rangeClosed(0, 100).map(i -> list.stream().mapToInt(p -> (p - i) * (p - i)).sum()).min().getAsInt()
        );
    }
}


Measured memory_bytes: 29008
#include<bits/stdc++.h>
#define PI 2*acos(0)
#define ll long long
#define pii pair<int,int>
#define mx 100005
using namespace std;
ll int dp[101][mx];
ll int w[mx],v[mx];
ll int n,W;
ll int f(ll int pos,ll int c)
{
    if(c<0) return LONG_LONG_MIN;
    if(c==0) return 0;
    if(pos>n) return 0;
    if(dp[pos][c]!=-1) return dp[pos][c];
    ll int val1=f(pos+1,c-w[pos])+v[pos];
    ll int val2=f(pos+1,c);
    ll int ans=max(val1,val2);
    dp[pos][c]=ans;
    return dp[pos][c];
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll int i,j,k;
    cin>>n>>W;
    for(i=1;i<=n;i++){
        cin>>w[i]>>v[i];
    }
    memset(dp,-1,sizeof(dp));
    ll int ans=f(1,W);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 82560
import itertools
N, K = list(map(int, input().split()))
d = []
A = []
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))
#print(A) 
s = list(set((list(itertools.chain.from_iterable(A)))))
print(N - len(s))

Measured memory_bytes: 9220
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.nextLine());
        String[] tmp = scanner.nextLine().split(" ");
        int[] A = new int[N];
        int count=0;
        for (int i = 0; i < N; i++) {
            A[i]=Integer.parseInt(tmp[i]);
        }
        boolean isAllEven=true;
        label:while(isAllEven){
            for (int v:A){
                if(v%2==1){
                    isAllEven=false;
                    break label;
                }
            }
            for (int i = 0; i < N; i++) {
                A[i]=A[i]/2;
            }
            count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21716
def resolve():
    (n, m) = list(map(int, input().split(" ")))
    
    for i in range(m):
        o = list(map(int, input().split(" ")))
        if i == 0:
            lmax = o[0]
            rmin = o[1]
        else:
            lmax = max(lmax, o[0])
            rmin = min(rmin, o[1])

    print(rmin-lmax+1 if lmax <= rmin else 0)


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int p[410][410];
int c = 1;
vector<string> s;
int h,w;
void bfs(int i,int j){
    if(p[i][j]==0){
        p[i][j] = c;
        if(i!=0){
            if(s[i][j]!=s[i-1][j]){
                bfs(i-1,j);
            }
        }
        if(i!=h-1){
            if(s[i][j]!=s[i+1][j]){
                bfs(i+1,j);
            }
        }
        if(j!=0){
            if(s[i][j-1]!=s[i][j]){
                bfs(i,j-1);
            }
        }
        if(j!=w-1){
            if(s[i][j]!=s[i][j+1]){
                bfs(i,j+1);
            }
        }
    }
}

int main(){
    cin >> h >> w;
    s.resize(h);
    rep(i,h)cin >> s[i];
    rep(i,h){
        rep(j,w){
            bfs(i,j);
            c++;
        }
    }
    ll q[200000][2]={};
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.'){
                q[p[i][j]][0]++;
            }else{
                q[p[i][j]][1]++;
            }
        }
    }
    ll ans = 0;
    rep(i,200000){
        ans += q[i][0]*q[i][1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 24320
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();//文字数
        String s = sc.next();//文字列
        int k = sc.nextInt();//指定文字番
        
        String[] array = s.split("");
        String ss = array[k-1];
        
        for(int i = 0; i<n; i++){
            if(!array[i].equals(ss)){
                array[i] = "*";
            }
        }
        
        for(String sss : array){
            System.out.print(sss);
        }
    }
}

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

int main(){
  int n,m; cin >> n >> m;
  if(n>=m){cout << 0;}
  else{
  	int X[m]; 
  	for(int i=0; i<m; i++){
      cin >> X[i];
  	}
  	sort(X, X+m);
  
  	int Y[m-1];
  	for(int i=0; i<m-1; i++){
      Y[i] = X[i+1]-X[i];
    }
  	sort(Y, Y+m-1);
  	
    int sum=0;
    for(int i=0; i<m-n; i++){sum = sum + Y[i];}
    cout << sum;
  }
    
  return 0;
}

Measured memory_bytes: 1024
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    ll n;
    cin >> n;
    string s;
    while (n > 0) {
        n--;
        s += 'a' + (n % 26);
        n /= 26;
    }
    reverse(all(s));
    cout << s << endl;
}


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

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

int main() {
  int n;
  cin >> n;
  string ans = "";
  while (n != 0) {
    if (n % 2 != 0) {
      n--;
      ans = "1" + ans;
    } else
      ans = "0" + ans;
    n /= -2;
  }

  if (ans == "") ans = "0";

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


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    ll N;
    cin >> N;
    vector<ll> p(N);
    vector<ll> psorted(N);

    for (ll i = 0; i < N; i++)
    {
        cin >> p.at(i);
        psorted.at(i) = p.at(i);
    }

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

    ll count = 0;
    for (ll i = 0; i < N; i++)
    {
        if (p.at(i) != psorted.at(i))
        {
            count++;
        }
    }

    if (count <= 2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return;
}

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


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


void solve(long long N, std::vector<long long> d){
    if(N % 2 != 0){
        cout << 0 << endl;
        return;
    }
    sort(d.begin(),d.end());
    long long ans = d[N/2] - d[N/2 - 1];
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int>v(26);
    for(auto c:s)
        v[c-'a']++;
    int ans=1;
    for(auto c:v)
        ans=(ans*(c+1))%mod;
    cout<<(ans-1+mod)%mod<<endl;
    return 0;
}

Measured memory_bytes: 3756