akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int N;
string S;
vector<vector<int>> E;
vector<int> cnt;
pair<int,int> dfs(int now,int p){
	pair<int,int> ret(0,0);
	int M = 0;
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i];
		if(to==p)continue;
		
		pair<int,int> t = dfs(to,now);
		ret.first+=t.first;
		ret.second+=t.second;
		M = max(M,t.first);
	}
	
	ret.first -= min(ret.first/2,ret.first-M)*2;
	if(S[now]=='1')ret.second++;
	ret.first += ret.second;
	
	return ret;
}

int dfs2(int now,int p,int depth){
	int ret= 0;
	if(S[now]=='1')ret+=depth;
	for(int i=0;i<E[now].size();i++){
		int to = E[now][i];
		if(to==p)continue;
		ret += dfs2(to,now,depth+1);
	}
	
	return ret;
}

int main(){

	cin>>N>>S;
	
	E.resize(N,vector<int>());
	for(int i=0;i<N-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	int ans = Inf;
	for(int i=0;i<N;i++){
		vector<int> x(E[i].size());
		int sum = 0;
		int m = 0;
		for(int j=0;j<E[i].size();j++){
			x[j] = dfs2(E[i][j],i,1);
			sum += x[j];
			m = max(m,x[j]);
		}
		int k = sum/2;
		if(sum%2==1)continue;
		for(int j=0;j<x.size();j++){
			if(m==x[j]){
				sum -= m;
				m = dfs(E[i][j],i).first;
				sum += m;
				break;
			}
		}
		if(sum/2<m)continue;
		ans = min(ans,k);
	}
	
	if(ans==Inf)cout<<-1<<endl;
	else cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3856
package main
import . "fmt"
import "sort"
func main() {
  var n,l int
  var s []string
  var x string
  Scan(&n,&l)
  s = make([]string,n)
  for i:=0;i<n;i++ {
    Scan(&s[i])
  }
  sort.Strings(s)
  x = ""
  for i:=0;i<n;i++ {
    x += s[i]
  }
  Println(x)
}

Measured memory_bytes: 1280
import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;

void main()
{
	int n = to!int(chomp(readln()));
	int k = to!int(chomp(readln()));
	int x = to!int(chomp(readln()));
	int y = to!int(chomp(readln()));
	int cost = 0;
	if(n > k)
	{
		cost = k*x+(n-k)*y;
	}
	else
	{
		cost = n * x;
	}
	writeln(to!string(cost));
}

int[] stringText2IntArray(string text)
{
	return map!(to!int)(split(readln())).array;
}


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

int main() {
	int H, W;
	cin >> H >> W;

	int i, j;
	vector<vector<char>> data(H, vector<char>(W));

	for(i = 0; i < H; ++i) {
		for(j = 0; j < W; ++j) {
			cin >> data.at(i).at(j);
		}
	}

	for(i = 0; i < H + 2; ++i) {
		for(j = 0; j < W + 2; ++j) {
			if (i == 0 || i == H + 1 || j == 0 || j == W + 1) {
				cout << '#';
			} else {
				cout << data.at(i - 1).at(j - 1);
			}
		}
		cout << endl;
	}
}

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

int sumOfDigits(int n)
{
	int sum = 0;
	while (n > 0) {
		sum += n % 10;
		n /= 10;
	}
	return sum;
}

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	int res = 0;

	for (int i = 1; i <= N; ++i) {
		int x = sumOfDigits(i);
		if (x >= A && x <= B) res += i;
	}

	cout << res << endl;
}
		


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
#include <limits>
using namespace std;

int main() {
	long long l, r;
	int ans = 2018;
	cin >> l >> r;
		for (long long i = l; i < r; i++) {
			for (int j = i + 1; j <= r; j++) {
				if ((i * j) % 2019 < ans) {
					ans = (i * j) % 2019;
				}
				if (i % 2019 == 0 or j % 22019 == 0) {
					cout << 0;
					return 0;
				}
			}
		}
	
	cout << ans;
}



Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>

using namespace std;

/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;
    }
    return sum;
}
/// 最小公倍数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
  int N, M;
  cin >> N >> M;
  int count = 0;
  for(int i = 1; i < 101; i = i + 2){
  if(i <= N)count++;
  }
if(count >= M)cout << "YES" << endl;
else cout << "NO" << endl;
   }
 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <sstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  int k,x;
  cin>>k>>x;
  int l = max(-1000000, x-k+1);
  int r = min(1000000, x + k - 1);
  for(int i = l; i <= r; i++) {
    cout << i << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] w = new Integer[n];
        for (int i = 0; i < n; i++) {
            w[i] = Integer.parseInt(sc.next());
        }

        int result = 100;
        for (int i = 1; i < n; i++) {
            int s1 = 0;
            for (int j = 0; j < i; j++) {
                s1 += w[j];
            }
            int s2 = 0;
            for (int j = i; j < n; j++) {
                s2 += w[j];
            }
            result = Math.min(result, Math.abs(s1 - s2));
        }
        System.out.println(result);
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,x;
    cin>>k>>x;
    string ans="";
    if (k*500 >= x) {
        ans = "Yes";
    } else {
        ans = "No";
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int sum=1;
    for(int i=1; i<n; i++)
    {
        if(s[i]!=s[i-1])
            sum++;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3712
let inf = 10101010101010
let n = Scanf.scanf "%d" (fun x -> x)
let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) |> Array.to_list
let sum = List.fold_left (+) 0 a
let f (v, s) (i, a) = if i = n-1 then v, s else min v (abs @@ sum - 2*(s+a)), s+a
let () =
  a |> List.mapi (fun i e -> i, e)
  |> List.fold_left f (inf, 0)
  |> fst |> Printf.printf "%d\n"

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

using namespace std;

int main() {
    int n,d;
    cin>>n>>d;
    int a[n][d];
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<d;j++)
        {
            cin>>a[i][j];
        }
    }
    int c=0;
    for(int i=0;i<n-1;i++)
    {
        for(int g=i+1;g<n;g++)
        {
        double sum=0;
        for(int j=0;j<d;j++)
        {
            sum+=(a[i][j]-a[g][j])*(a[i][j]-a[g][j]);
        }
        int sq=(int)sqrt(sum);
        if(sq*sq==sum)
        c++;
    }
    }
    
    
    cout<<c;
    return 0;
}

Measured memory_bytes: 256
N,M,K=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=[0]
B=[0]
ans=0
j=M
for i in range(N):
  A.append(A[i]+a[i])
for i in range(M):
  B.append(B[i]+b[i])
for i in range(N+1):
  if A[i]>K:
    break
  while A[i]+B[j]>K:
    j-=1
  ans=max(ans,i+j)
print(ans)


Measured memory_bytes: 47368
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

using Graph = vector<vector<int>>;

int main() {
   int N, M;
   cin >> N >> M;

   Graph G(N * 3);
   for (int i = 0; i < M; ++i) {
      int a, b;
      cin >> a >> b;
      a--;
      b--;
      G[a * 3].push_back(b * 3 + 1);
      G[a * 3 + 1].push_back(b * 3 + 2);
      G[a * 3 + 2].push_back(b * 3 );
   }
   int s, t;
   cin >> s >> t;
   s--;
   t--;
   vector<int> dist(N * 3, -1);
   queue<int> que;
   dist[s * 3] = 0;
   que.push(s * 3);
   while (!que.empty()) {
      int v = que.front();
      que.pop();
      for (int nv : G[v]) {
         if (dist[nv] != -1) continue;
         dist[nv] = dist[v] + 1;
         que.push(nv);
      }
    }
   
   // for (int v = 0; v < N; v++) cout << v << " : " << dist[v] << endl;
   if (dist[t * 3] == -1) cout << dist[t * 3] << endl;
   else cout << dist[t * 3] / 3 << endl;
   return 0;
}


Measured memory_bytes: 17792
MAXA = 10 ** 5

n = int(input())
lista = [int(i) for i in input().split()]
q = int(input())
query = [map(int, input().split()) for _ in range(q)]

num = [0 for _ in range(MAXA + 1)]
for a in lista:
    num[a] += 1

s = sum(i * a for i, a in enumerate(num))

for b, c in query:
    n = num[b]

    num[b] = 0
    num[c] += n
    s += n * (c - b)

    print(s)


Measured memory_bytes: 58428
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long



int main() {
	int a,t; cin >> a>>t;

	
	int count = 0;
	if (t == 1) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; ; i++) {
		
		if (a*i-(i-1)>=t) {

			cout << i << endl;
			return 0;
		}
		else {

		}
		
	}
	
}

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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long X;
	scanf("%lld",&X);

	ll x = 100;

	ll count = 0;
	while (x < X)
	{
		x *= 1.01;
		++count;
	}

	cout << count << endl;

	return 0;
}


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

typedef long long lint;
typedef long double louble;

#define so(a) ((int)((a).size()))

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 200007 , inf = 0x3f3f3f3f;

int n,val[_]={0};

vector<pair<int,int>> make(int la,int lb,int now,int bas)
{
	vector<pair<int,int>> ret;
	if(max(la,now-lb)<=now)ret.emplace_back(bas,max(la,now-lb));
	ret.emplace_back(bas+1,max(0,min(la,now-lb)));
	ret.emplace_back(bas+2,0);

	return ret;
}

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty();
	for(int i=1;i<=n;i++)val[i]=ty();

	pair<int,int> f[3],sf[3];
	for(int i=0;i<3;i++)f[i]=make_pair(0,0);

	for(int i=1;i<=n+1;i++)
	{
		vector<pair<int,int>> now;
		for(int j=0;j<3;j++)
		{
			auto temp=make(f[j].second,val[i-1]-f[j].second,val[i],f[j].first);
			now.insert(now.end(),temp.begin(),temp.end());
		}
		sort(now.begin(),now.end());

		int nowmi=now[0].first;

		for(int j=0;j<3;j++)sf[j]=make_pair(inf,0);
		for(auto j:now)if(j.first<=nowmi+2)sf[j.first-nowmi]=min(sf[j.first-nowmi],j);
		for(int j=0;j<3;j++)f[j]=sf[j];
	}

	cout<<f[0].first<<lf;
	
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
string s;
int dx[7]={0,1,-1,0,1,-1,0},dy[7]={-1,0,-1,0,1,0,1};
int mx[19]={2,3,1,2,3,1,2,4,3,2,1,0,0,0,1,2,3,4,4};
int my[19]={1,2,1,2,3,2,3,2,1,0,0,0,1,2,3,4,4,4,3};
bool check(int bit)
{
	int a[5][5]={};
	for(int i=0;i<19;i++)
	{
		a[mx[i]][my[i]]=bit%2;
		bit>>=1;
	}
	int ord=a[2][2];
	int next=0;
	for(int i=7;i--;)
	{
		int now=0;
		int x=mx[i],y=my[i];
		for(int r=7;r--;)
		{
			now=now*2+a[x+dx[r]][y+dy[r]];
		}
		next=next*2+s[now]-'0';
	}
	for(int i=0;i<7;i++)
	{
		a[mx[i]][my[i]]=next%2;
		next>>=1;
	}
	int now=0;
	for(int r=7;r--;)
	{
		now=now*2+a[2+dx[r]][2+dy[r]];
	}
	return s[now]-'0'==a[2][2];
}
main()
{
	while(cin>>s,s!="#")
	{
		bool flag=1;
		for(int i=0;i<1<<19;i++)
		{
			flag&=check(i);
		}
		cout<<(flag?"yes":"no")<<endl;
	}
}



Measured memory_bytes: 3008
#include<stdio.h>

int num_a, num_b, num_c;

condition() {
	if (num_a < num_b && num_b < num_c)
		return printf("Yes\n");
	else
		return printf("No\n");
}

int main() {
	scanf("%d %d %d", &num_a, &num_b, &num_c);
	condition();
	return 0;
}


Measured memory_bytes: 2124
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	string s;
	cin >> n>>s;
	vector<int>l(n);//左からi人の中で西を向いている人の数
	vector<int>r(n);//右からn-1-iの中で東を向いている人の数
	l[0] = 0;
	r[n - 1] = 0;
	rep(i, n-1) {
		if (s[i] == 'W')l[i+1] = l[i] + 1;
		else l[i+1] = l[i];
		if (s[n - 1 - i] == 'E')r[n - 2 - i] = r[n - 1-i] + 1;
		else r[n - 2 - i] = r[n - 1 - i];
	}
	int ans = l[0] + r[0];
	rep1(i, n) {
		ans = min(ans, l[i] + r[i]);
	}
	print(ans);
}

Measured memory_bytes: 8264
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int>v(n);
    vector<int>dp(n,0);

    for(int i=0;i<n;i++)
    {
        int ele;
        cin >> ele;
        v[i]=ele;
    }
     dp[1] = abs(v[0]-v[1]);
    for(int i=2;i<n;i++)
    {
        dp[i] = min( dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]) );
    }
    cout<<dp[n-1]<<endl;
}



Measured memory_bytes: 1024
h, w = map(int, input().split()) 
map = []
for _ in range(h):
  map.append(list(input()))

r = [[0] * w for _ in range(h)]
for i in range(h):
  for j in range(w):
    if map[i][j] == ".":
      if j == 0:
        r[i][j] = 1
      else:
        r[i][j] = r[i][j-1] + 1

l = [[0] * w for _ in range(h)]
for i in range(h):
  for j in range(w-1, -1, -1):
    if map[i][j] == ".":
      if j == w - 1:
        l[i][j] = 1
      else:
        l[i][j] = l[i][j+1] + 1
        
d = [[0] * w for _ in range(h)]
for i in range(w):
  for j in range(h):
    if map[j][i] == ".":
      if j == 0:
        d[j][i] = 1
      else:
        d[j][i] = d[j-1][i] + 1

u = [[0] * w for _ in range(h)]
for i in range(w):
  for j in range(h-1, -1, -1):
    if map[j][i] == ".":
      if j == h-1:
        u[j][i] = 1
      else:
        u[j][i] = u[j+1][i] + 1
ans = 0
for i in range(h):
  for j in range(w):
    num = l[i][j] + r[i][j] + d[i][j] + u[i][j] - 3
    if num > ans:
      ans = num
print(ans)


Measured memory_bytes: 359868
import numpy as np
import math
n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]

narr = np.array(x)
ans = 0

for i in range(n):
    for j in range(i+1, n):
        dis = np.linalg.norm(narr[j] - narr[i])
        if math.ceil(dis) == math.floor(dis):
            ans += 1

print(ans)


Measured memory_bytes: 12504
#define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
int main()
{
    // read input
    int N;
    cin >> N;

    // make cnt[i][j]
    vector<vector<ll>> cnt(10, vector<ll>(10, 0));
    rep(num, 1, N+1)
    {
        int i = num%10;
        int j = num;
        while (j>=10) j /= 10;
        if (i==0 or j==0)continue;
        ++cnt[i][j];
        // debug(num, j, i);
    }

    // sumup
    long long res = 0;
    rep(i, 1, 10)
        rep(j, 1, 10)
            res += cnt[i][j]*cnt[j][i];

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
f=0
while 1:
  n=input()
  if n==0: break
  C=[()]*n
  for i in range(n):
    s=raw_input()
    p=s.index(" ")
    a,b,c=map(int,s[p+1:].split(" "))
    C[i]=(i,a*3+c,s[:p])
  C=sorted(C,key=lambda x:(-x[1]))
  if f>0: print
  for e in C: print e[2]+","+str(e[1])
  f=1

Measured memory_bytes: 4228
#include <iostream>
#include <deque>
#include <cmath>
using namespace std;

int main() {
  string s;
  cin >> s;
  deque<char> w;
  deque<int> xs;
  int xc = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'x') {
      xc++;
    } else {
      w.push_back(s[i]);
      xs.push_back(xc);
      xc = 0;
    }
  }
  xs.push_back(xc);
  while (w.size() > 1) {
    if (*(w.begin()) != *(w.rbegin())) {
      cout << -1 << endl;
      return 0;
    }
    w.pop_front();
    w.pop_back();
  }
  int ops = 0;
  while (xs.size() > 1) {
    ops += abs(*(xs.begin()) - *(xs.rbegin()));
    xs.pop_front();
    xs.pop_back();
  }
  cout << ops << endl;
  return 0;
}

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

#define MAX 100000

int main() {
	int N;
	long long A[MAX];
	long long ans = 1;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] == 0) {
			ans = 0;
			cout << ans << endl;
			return 0;
		}
	}
	for (int i = 0; i < N; i++) {
		if (ans > 1000000000000000000 / A[i]) {
			ans = -1;
			break;
		} else {
			ans *= A[i];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4416
from collections import defaultdict

def main():
    n=int(input())
    mod=10**9+7
    ans=1
    l=[]
    d=defaultdict(int)
    for i in range(1,n+1):
        l+=prime_factorize(i)
    for i in l:
        d[i]+=1
    for i in d.values():
        ans*=i+1
    print(ans%mod)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


if __name__ == '__main__':
    main()

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

int main(void){
    
    int hana, taro;
    hana = taro = 0;
    
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        
        string hana_Str, taro_Str;
        cin >> hana_Str >> taro_Str;
        
        int check = hana_Str.compare(taro_Str);
        if(check == 0) { hana++; taro++; }
        else if(check < 0) { taro += 3;}
        else { hana += 3; }
    }

    cout << hana << " " << taro << endl;
    
}



Measured memory_bytes: 3136
import java.util.*;

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

        String S = scanner.next();

        int first2 = Integer.parseInt(S.substring(0,2));
        int last2 = Integer.parseInt(S.substring(2,4));
        String result = "";
        if(1<=first2 && first2<=12){
            if(1<=last2 && last2<=12){
                result = "AMBIGUOUS";
            }else{
                result = "MMYY";
            }
        }else{
            if(1<=last2 && last2<=12){
                result = "YYMM";
            }else{
                result = "NA";
            }
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 50 + 10;
int n = 50;
ll k;
int main()
{
	scanf("%lld", &k);
	ll base = k / n + 49;
	int l = k % n;
	printf("%d\n", n);
	for(int i = 1; i <= n - l; ++i) printf("%lld ", base - l);
	for(int i = n - l + 1; i <= n; ++i) printf("%lld ", base + 51 - l);
	return 0;
}

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

void enum_divisor(ll n,vector<ll> &v){
    for(ll i = 1;i*i <= n;i ++){
        if(n%i==0){
            v.push_back(i);
            if(i*i!=n) v.push_back(n/i);
        }
    }
    sort(v.begin(),v.end());
}

int main(){
    ll n,k,M=0,sa = 0;
    cin >> n >> k;
    vector<ll> a(n),v;
    for(int i = 0;i < n;i ++){
        cin >> a[i];
        M = max(M,a[i]);
        sa += a[i];
    }
    enum_divisor(sa,v);
    for (int i = v.size()-1;i >= 0;i --){
        vector<ll> sub(n);
        ll s = 0;
        for(int j = 0;j < n;j ++){
            sub[j] = a[j]%v[i];
            s += sub[j];
        }
        if(s%v[i]==0){
            ll d = s/v[i],cnt = 0;
            sort(sub.begin(),sub.end());
            for(int j = 0;j < n-d;j ++){
                cnt += sub[j];
            }
            if(cnt<=k) {cout << v[i] << endl;return 0;}
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#define int long long

int f(int b, int n) {
  if (n < b) return n;
  return f(b, n / b) + (n % b);
}

signed main() {
  int n, s;
  cin >> n >> s;
  if (n < s) {
    cout << -1 << endl;
    return 0;
  }
  if (n == s) {
    cout << n + 1 << endl;
    return 0;
  }
  for (int b = 2; b <= sqrt(n); b++) {
    if (f(b, n) == s) {
      cout << b << endl;
      return 0;
    }
  }
  for (int p = sqrt(n); p >= 1; p--) {
    if ((n - s) % p) continue;
    int b = (n - s) / p + 1;
    if (f(b, n) == s) {
      cout << b << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i=0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    ll res = 0;
    for(int i=0; i < k; i++) res += a[i];
    cout << res;    
}

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

int main()
{
    int k;
    cin >> k;
    int a, b;
    cin >> a >> b;
    
    int tmp, tmp1;
    tmp = a % k;
    
    if(tmp == 0)
        cout << "OK" << "\n";
    else{
        if(a + (k-tmp) <= b)
            cout << "OK" << "\n";
        else
            cout << "NG" << "\n";
    }
    
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int a, b; cin >> a >> b;
    if (a < 10 && b < 10) cout << a * b << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>

int main(){
  char ch;
  int counter[26] = {};
  for( int i = 0; i < 26; i++ ) counter[i] = 0;

  while( scanf( "%c", &ch ) != EOF ){
    ch = tolower(ch);
    if ( isalpha(ch) ) counter[ch-'a']++;
  }

  for ( int i = 0; i < 26; i++ ) {
    printf( "%c : %d\n", i+'a', counter[i] );
  }

  return 0;
}

Measured memory_bytes: 2688
from math import gcd
from functools import reduce


N = int(input())
X = list(map(int, input().split()))

lim = 10 ** 6 + 10
is_prime = [True] * (lim + 1)
is_prime[0] = False
is_prime[1] = False
min_factor = list(range(lim + 1))

for i in range(2, lim + 1):
    if is_prime[i]:
        for j in range(2 * i, lim + 1, i):
            is_prime[j] = False
            min_factor[j] = i

pairwise = True
appeared = set()
for v in X:
    while v > 1:
        div = min_factor[v]
        if div in appeared:
            pairwise = False
            break

        appeared.add(div)
        while v % div == 0:
            v //= div

if pairwise:
    print("pairwise coprime")
elif reduce(gcd, X) == 1:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 197084
package main
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
func newScanner() *bufio.Scanner{
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

var sc = newScanner()

func scanInt() int{
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int{
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string{
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

func main() {
	n := scanInt()
	h := scanInt()
	answer := countAttacks(n, h)
	fmt.Println(answer)
}

func countAttacks(n, h int) int {
	if n % h == 0 {
		return n / h
	}
	return n / h + 1
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    private static final String[] WEEK;
    private static final int[] DAYS;
    
    static {
        String[] sary = {
            "Wednesday", "Thursday", "Friday",
            "Saturday", "Sunday", "Monday", "Tuesday"
        };
        WEEK = sary;
        int[] iary = {
            0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
        };
        DAYS = iary;
    }
    
    public static void main(String[] args) {
        int m, d;
        while((m = scn.nextInt()) > 0) {
            d = scn.nextInt();
            for(int i = 1; i < m; i++) {
                d += DAYS[i];
            }
            System.out.println(WEEK[d % 7]);
        }
    }
}

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

int main() {
  int p, q, r, pq, qr, rp;
  cin >> p >> q >> r;
  pq = p + q;
  qr = q + r;
  rp = r + p;
  cout << min(pq, min(qr, rp)) << endl;
}

Measured memory_bytes: 3612
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
    #ifndef ONLINE_JUDGE
    if (fopen("INPUT.txt", "r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        //freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    clock_t clk;
    clk = clock();
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(K);
    set<ll> Z;
    FORI(i,0,K)
    {
        READV(x);
        FORI(j,0,x)
        {
            READV(y);
            Z.insert(y);
        }
    }
    cout<<N-Z.size()<<endl;

//-----------------------------------------------------------------------------------------------------------//


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

    return 0;
}

Measured memory_bytes: 3736
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    int a, b, c = 0;
    
    cin >> a >> b >> c;
    
    if ((a < b) && (b < c) && (a < c)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    int sum = 0;
    rep(i, n) {
        cin >> w[i];
        sum += w[i];
    }

    int mi = 1000000;
    int si = 0;
    rep(i, n) {
        si += w[i];
        mi = min(mi, abs(sum - si * 2));
    }

    cout << mi << endl;

}

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

int main(){
	int n,m; cin>>n>>m;
	bool s[n],t[n]; rep(i,n) s[i]=t[i]=false;
	rep(i,m){
		int a,b; cin>>a>>b;
		if(a==1) s[b-1]=true;
		if(b==n) t[a-1]=true;
	}
	string ans="IMPOSSIBLE";
	rep(i,n){
		if(s[i] and t[i]) ans="POSSIBLE";
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

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

using namespace std;
using ll = long long;

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

    cout << (N + 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
n,m = gets.split.map &:to_i
a = Array.new(n){|e| e = [1,false] }
a[0][1] = true
m.times do
    x,y = gets.split.map &:to_i
    if a[x-1][0] > 0
        a[x-1][0] -= 1
        a[y-1][0] += 1
        if a[x-1][1] == true
            a[y-1][1] = true
        end
        if a[x-1][0] == 0
            a[x-1][1] = false
        end
    end
end
p a.inject(0){|sum,e| e[1] == true ? sum+1 : sum}


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

int main(){
    int grid[3][3];
    cin >>grid[0][0] >>grid[0][1] >>grid[0][2];
    cin >>grid[1][0] >>grid[1][1] >>grid[1][2];
    cin >>grid[2][0] >>grid[2][1] >>grid[2][2];
    int flag = 0;
    if (grid[0][0]-grid[0][1] != grid[1][0]-grid[1][1] || grid[1][0]-grid[1][1] != grid[2][0]-grid[2][1]){
        flag = 1;
    }else if(grid[0][1]-grid[0][2] != grid[1][1]-grid[1][2] || grid[1][1]-grid[2][1] != grid[1][2]-grid[2][2]){
        flag = 1;
    }else if(grid[0][0]-grid[1][0] != grid[0][1]-grid[1][1] || grid[0][1]-grid[1][1] != grid[0][2]-grid[1][2]){
        flag = 1;
    }else if(grid[1][0]-grid[2][0] != grid[1][1]-grid[2][1] || grid[1][1]-grid[2][1] != grid[1][2]-grid[2][2]){
        flag = 1;
    }
    if(flag ==0){
        cout <<"Yes" <<endl;
    }else{
        cout << "No" <<endl;
        }
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    string s;
    cin>>s;
    int ans=INF;
    for(int i=0;i<=s.size()-3;i++){
        string tmp=s.substr(i,3);
        int t=stoi(tmp);
        int diff=abs(753-t);
        ans=min(ans,diff);
    }
    cout<<ans<<endl;
 return 0;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for (ll i=0;i<N;i++)
#define REP(i,N) for (ll i=1;i<=N;i++)
 
ll N,M,A,B,C,ANS;
string S,T,U;
double n,m,a,b,c;
 
int main() {
	cin>>N;
  ANS=0;
  A=N/500;
  N-=A*500;
  ANS+=A*1000;
  B=N/5;
  ANS+=B*5;
  cout<<ANS<<endl;
	return 0;
}

Measured memory_bytes: 256
A,B = map(int,input().split())
S = input()
ans = True
for i in range(len(S)):
    if i == A:
        if S[i] != "-":
            ans = False
    elif "0" > S[i] or "9" < S[i]:
        ans = False
print("YNeos"[not ans::2])

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

int main()
{
    int h_1, m_1, h_2, m_2, k;
    cin >> h_1 >> m_1 >> h_2 >> m_2 >> k;
    int sum = 0;
    bool flag = false;
    if(m_1 <= m_2){
        sum += m_2 - m_1;
    }
    else{
        sum += 60 + m_2 - m_1;
        flag = true;
    }
    if(flag){
        sum += (h_2 - 1 - h_1)*60;
    }
    else{
        sum += (h_2 - h_1)*60;
    }
    cout << max(0, sum - k) << endl;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);
	int d, t, s;
	cin >> d >> t >> s;

	if (d <= s * t)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}


	return 0;
}

Measured memory_bytes: 3584
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H,W,D;
    cin >> H >> W >> D;
    vP plc(H*W);
    rep(i,H){
        rep(j,W){
            int x;
            cin >> x;
            x--;
            plc[x]={i,j};
        }
    }
    vl dp(H*W);
    rep(i,H*W){
        if(i<D){
            dp[i]=0;
        }
        else{
            dp[i]=dp[i-D]+abs(plc[i].first-plc[i-D].first)+abs(plc[i].second-plc[i-D].second);
        }
    }
    int Q;
    cin >> Q;
    while(Q--){
        int l,r;
        cin >> l >> r;
        l--,r--;
        cout << dp[r]-dp[l] << endl;
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 5288
function main(i) {
  var n = Number(i.split('\n')[0]);
  var red = i.split('\n')[1].split('R').length - 1;
  if (red > n/2) {
    console.log('Yes');
  } else {
    console.log('No');
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  if(A==5 && B==5 && C==7){
    cout << "YES" << endl;
  }else if(A==5 && B==7 && C==5){
    cout << "YES" << endl;
  }else if(A==7 && B==5 && C==5){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <utility>

using namespace std;

typedef long long signed int ll;

constexpr ll NIL = -20000000000;

int g[101][101],n;

int main() {
    cin >> n;
    for(int i = 0;i < n;i++) {
        int u,k,v;
        cin >> u >> k;
        for(int j = 0;j < k;j++) {
            cin >> v;
            g[u][v]++;
        }
    }
    for(int i = 1;i <= n;i++){for(int j = 1;j <n;j++)cout<<g[i][j] << " "; cout<<g[i][n] << endl;}
}



Measured memory_bytes: 3092
// ボール: 区別なし, 箱：区別あり, 入れ方: 制限なし
#include <iostream>
using namespace std;
const int MOD = 1000000007;
const long long MAXN = 1001024;
long long fac[MAXN], finv[MAXN], inv[MAXN];

// 前処理 O(n)
void comb_init(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(long long i = 2; i < MAXN; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算 O(1)
long long COM(long long n, long long k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main() {
  
  int n, k; cin >> n >> k;
  comb_init();
  cout << COM(n + k - 1, k - 1) << endl; 
  
  return 0;
}



Measured memory_bytes: 26564
const val P = 1000000007L

fun mod(x: Long) = if (x >= 0) x % P else (P - ((-x) % P)) % P
fun modPlus(x1: Long, x2: Long) = (x1 + x2) % P
fun modMinus(x1: Long, x2: Long) = (x1 + P - x2) % P
fun modTimes(x1: Long, x2: Long) = x1 * x2 % P

// Find (x, y, r) such that r = gcd(a,b) and ax + by = r.
fun extendedGCD(a: Long, b: Long): Triple<Long, Long, Long> {
    var x0 = 1L
    var y0 = 0L
    var z0 = a
    var x1 = 0L
    var y1 = 1L
    var z1 = b
    while (true) {
        if (z1 == 0L) return Triple(x0, y0, z0)
        val q = z0 / z1
        val x2 = x0 - q * x1
        val y2 = y0 - q * y1
        val z2 = z0 - q * z1
        x0 = x1
        x1 = x2
        y0 = y1
        y1 = y2
        z0 = z1
        z1 = z2
    }
}

fun modInv(x: Long): Long {
    val (x, y, r) = extendedGCD(x, P)
    if (r != 1L) return 0  // No inverse.

    return (x + P) % P
}

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val factorials = LongArray(2 * n + 1)
    factorials[0] = 1
    for (i in 1..(2 * n)) {
        factorials[i] = (i * factorials[i - 1]) % P
    }

    for (i in 1..k) {
        if (n - k < i - 1) {
            println(0)
        } else {
            val p1 = factorials[k - 1] * modInv(factorials[i - 1]) % P * modInv(factorials[k - i]) % P
            val p2 = factorials[n - k + 1] * modInv(factorials[i]) % P * modInv(factorials[n - k + 1 - i]) % P
            println(p1 * p2 % P)           
        }
    }
}

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

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

  char c[4]; cin >> c;
  int bit;

  rep(i, 1<<3) {
    int tmp = c[0]-'0';
    rep(j, 3) {
      if(i & 1<<j) tmp += c[j+1]-'0';
      else tmp -= c[j+1]-'0';
    }
    if(tmp == 7) {
      bit = i;
    }
  }

  string ans = to_string(c[0]-'0');
  rep(i, 3) {
    if(bit & 1<<i) ans += "+"+to_string(c[i+1]-'0');
    else ans += "-"+to_string(c[i+1]-'0');
  }
  ans += "=7";
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
N, M = map(int, input().split())
A = list(map(int, input().split()))
tmp = 0
for i in range(N):
    A[i] += tmp
    A[i] %= M
    tmp = A[i]

c = Counter(A)
ans = 0
for k, v in c.items():
    if k == 0:
        ans += v
    ans += v * (v-1) // 2

print(ans)


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

using namespace std;

pair<vector<int>, vector<int>> solve(int N, const string& T){
    if(N==0){
        return make_pair(vector<int>(1, 0), vector<int>(T.size(), 0));
    }
    auto prev = solve(N-1, T);
    auto& P = prev.first;
    auto& W = prev.second;
    vector<int> D(3*P.size());
    for(int i=0;i<D.size();i++) D[i] = i/P.size();
    int salsa = 0;
    vector<int> lastSalsa(3*P.size(), 0);
    vector<int> curW(W.size());
    for(int i=0;i<T.size();i++){
        for(int j=W[i];j<D.size();j+=P.size()){
            if(salsa != lastSalsa[j]) D[j] = (3-D[j])%3;
            lastSalsa[j] = salsa;
            if(D[j] == 2) curW[i] = j;
        }
        if(T[i] == 'S'){
            salsa = 1 - salsa;
        } else {
            for(int j=W[i];j<=D.size();j+=P.size()) D[j] = (D[j]+1)%3;
        }
    }
    vector<int> curP(D.size());
    for(int i=0;i<curP.size();i++){
        if(salsa != lastSalsa[i]) D[i] = (3-D[i])%3;
        curP[i] = P.size() * D[i] + P[i%P.size()];
    }
    return make_pair(curP, curW);
}

int main(){
    int N; cin >> N;
    string T; cin >> T;
    auto res = solve(N, T).first;
    cout << res[0];
    for(int i=1;i<res.size();i++) cout << " " << res[i];
    cout << endl;
}

Measured memory_bytes: 15628
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;

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

int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

void solve() {
    int n;
    cin >> n;
    vector < pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].second >> a[i].first;
    }

    sort(rall(a));
    queue<int> q;
    int now = 0;
    for (int i = 0; i < n; i++) {
        now = (i ? a[i - 1].first - a[i].first : 0);
        while (now && !q.empty()) {
            int x = q.front();
            q.pop();
            int d = min(x, now);
            now -= d;
            x -= d;
            if (x) q.push(x);
        }
        q.push(a[i].second);
    }
    now = a.back().first;
    while (now && !q.empty()) {
        int x = q.front();
        q.pop();
        int d = min(x, now);
        now -= d;
        x -= d;
        if (x) q.push(x);
    }
    cout << (!q.empty() ? "No" : "Yes");
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    //cin >> t;
    int t = 1;
    //srand(time(0));
    while (t--) solve();
}

Measured memory_bytes: 4736
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n; cin>>n; 
    vi a(n),b,c;
    int mn1=1000000001,mn2=1000000001;
    for (int i=0;i<n;i++){
        cin >> a[i] ; 
        mn1 = min(mn1,a[i]);
    }
    for (int i=0;i<n;i++){
        int x; cin >> x; 
        if (x>mn1) {
            b.pb(x);
            mn2 = min(mn2,x);
        }
    }
    for (int i=0;i<n;i++){
        int x; cin >> x; 
        if (x>mn2) c.pb(x);
    }
    sort(a.begin(), a.end()); 
    sort(b.begin(), b.end()); 
    sort(c.begin(), c.end()); 
    int ans=0,bl=sz(b);
    for (int i=0; i<sz(b);i++){
        int in1 = lower_bound(a.begin(), a.end(),b[i])-a.begin();
        if (a[in1]<b[i]) in1++; 
        int in2 = (upper_bound(c.begin(), c.end(),b[i])-c.begin()); 
        if (in1>n) in1--;
        ans += (in1)*(sz(c)-in2); 
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}
/*
5
1 2 3 4 5 
1 2 3 4 5 
1 2 3 4 5 

*/


Measured memory_bytes: 6432