akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include <cassert>
#include<set>
#include <numeric>
using namespace std;

typedef long long int ll;

ll gcd(ll x,ll y){
    if(x<y) swap(x,y);
    //xの方が常に大きい
    ll r;
    while(y>0){
        r=x%y;
        x=y;
        y=r;
    }
    return x;
}

//オーバフローしないようにかける順番を気を付ける
ll lcm(ll x,ll y){
    return ll(x/gcd(x,y))*y;
}

set<int> getFactor(int n){
	int nn = n;
	set<int> res;
	for(int i=2;i*i<=nn;++i){
		while(n%i==0){
			res.insert(i);
			n /= i;
		}
	}
	if(n != 1) res.insert(n);
	
	return res;
}

int main(){
	int n;
	cin >> n;
	vector<int> data(n);
	for(int i=0;i<n;++i){
		cin >>data[i];
	}
	set<int> re;
	bool isPairWise = true;
	for(int i=data.size()-1;isPairWise && i>=0;--i){
		set<int> se = getFactor(data[i]);
		for(int a : se){
			//cout << a << endl;
			if(re.find(a) != re.end()){
				isPairWise = false;
				break;
			}
			re.insert(a);
		}
	}
	if(isPairWise){
		cout << "pairwise coprime" <<endl;
		return 0;
	}
	
	int tmp = data[0];
	for(int i=1;i<n;++i){
		tmp = gcd(tmp,data[i]);
	}
	
	if(tmp == 1){
		cout << "setwise coprime" <<endl;
	}else{
		cout << "not coprime" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 6792
K = gets.to_i

q = [*1 .. 9]
(K - 1).times do
  x = q.shift
  y = x%10
  x = 10*x
  q << x + y - 1 unless  y == 0
  q << x + y
  q << x + y + 1 unless y == 9
end
puts q.shift

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

using namespace std;

const int maxn=10;

double x[maxn];double y[maxn];

int vis[maxn];
int n;
double ans=0;

double C(int num){
	double ans=1;
	for(int i=1;i<=num;i++){
		ans*=i;
	}
	return ans;
}

void dfs(int u,int fa,int cnt){
	if(vis[u]) return ;
	vis[u]=1;
//	printf("%d %d\n",fa,u);
	if(fa!=-1) ans+=sqrt((x[u]-x[fa])*(x[u]-x[fa])+(y[u]-y[fa])*(y[u]-y[fa]))*C(n-cnt);
	for(int i=0;i<n;i++){
		dfs(i,u,cnt+1);
	}
	vis[u]=0;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lf%lf",x+i,y+i);
	}
	
	for(int i=0;i<n;i++){
		dfs(i,-1,1);
	}
	int tmp=1;
	for(int i=1;i<=n;i++){
		tmp*=i;
	}
	printf("%.7lf",ans/tmp);
	return 0;
}

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

vector<vector<int>> to;
vector<vector<int>> cost;
vector<int> ans;

void dfs(int v, int p = -1) {
  rep(i, to[v].size()) {
    int u = to[v][i];
    int w = cost[v][i];
    // cout << u << endl;
    if (u == p) continue;
    ans[u] = (ans[v] + w) % 2;
    dfs(u, v);
  }
}
int main() {
  int n;
  cin >> n;
  to.resize(n);
  cost.resize(n);
  ans.resize(n);
  rep(i, n - 1) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    to[u].push_back(v);
    to[v].push_back(u);
    cost[u].push_back(w);
    cost[v].push_back(w);
  }
  dfs(0);
  rep(i, n) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 16824
#include <iostream>
#include <string>
#include <algorithm> 
#include <math.h>
#include <vector>
using namespace std;

int main(){
	
	int n;
	cin >> n;
	long long arr[n];
	for(int i=0;i<n;i++){
		cin >> arr[i];
	}
	sort(arr, arr+n);
	long long ans = 0;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			for(int k=j+1;k<n;k++){
				if(arr[i]+arr[j]>arr[k] && arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k]){
					ans++;
				}
			}
		}
	}
	cout << ans;
}




Measured memory_bytes: 3148
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	A := nextInt64()
	B := nextInt64()
	C := nextInt64()
	D := nextInt64()

	if D < C {
		D, C = C, D
	}

	fmt.Println(count(B, C, D) - count(A-1, C, D))
}

func count(n, a, b int64) int64 {
	if b%a == 0 {
		return n - n/a
	}
	return n - n/a - n/b + n/lcm(a, b)
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func gcd(a, b int64) int64 {
	if b > a {
		return gcd(b, a)
	}

	if b == 0 {
		return a
	}

	return gcd(b, a%b)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)

	return i
}


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

#define ll long long int

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll num, sum = 0;
  map<ll, ll> divisor;
  cin >> num;
  ll limit = sqrt(num);
  for (int i = 2; i <= sqrt(num); i++)
    while(num % i == 0){
      num /= i;
      divisor[i]++;
    }
  if (num != 1)
    divisor[num]++;
  map<ll, ll>::iterator iter = divisor.begin();
  while (iter != divisor.end()){
    ll cnt = 1;
    while (iter->second - cnt >= 0){
      iter->second -= cnt;
      cnt++;
      sum++;
    }
    iter++;
  }
  cout << sum << '\n';
  return 0;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

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

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int val = 0;
    rep(i, n) {
        if (i-1>=0 && s[i]=='L' && s[i-1] == 'L') ++val;
        if (i+1<=n-1 && s[i]=='R' && s[i+1] == 'R') ++val;
    }
    int cnt = 0;
    rep(i, n-1) if (s[i] != s[i+1]) ++cnt;
    val += min(cnt, 2*k);
    cout << val << endl;
    return 0;
}


Measured memory_bytes: 3716
s = input()

ans = 0
n = len(s) - 1
for i in range(2 ** n):
    op = [''] * n
    for j in range(n):
        if ((i >> j) & 1):
            op[n - j - 1] = '+'
    f = ''

    for p_n, p_o in zip(s,op+['']):
        f += p_n + p_o
    ans += eval(f)

print(ans)

Measured memory_bytes: 39664
fun main(args: Array<String>) {
    val n = readLine()!!.split(" ").map{ it.toInt() }
    val a = n[0]
    var b = n[1] - 1
    var c = 0;
    while (b > 0) {
        b -= (a-1)
        c++
    }
    println(c)
}

Measured memory_bytes: 37900
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int k,a,b,c=0;
  cin>>k;
  cin>>a>>b;
  for(int i=a;i<=b;i++)
  {if(i%k==0)
        c++;
   }
if(c>0)
    cout<<"OK"<<endl;
else
    cout<<"NG"<<endl;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main() {
	int x, a, b, judge;
	
	scanf("%d%d%d", &x, &a, &b);
	judge = b-a;
	
	if (judge <= 0) printf("delicious\n");
	else if (judge <= x) printf("safe\n");
	else printf("dangerous\n");
	
	return 0;
}

Measured memory_bytes: 128
import sys
import math

for line in sys.stdin:
    if len(line)>1:
        a, b, r = line.strip('\n').split()
        a, b, r = float(a), float(b), math.radians(float(r))
        
        h = b * math.sin(r)
        c = (a**2 + b**2 - 2*a*b*math.cos(r))**0.5
        l = a + b + c
        s = a * h / 2
        print s
        print l
        print h

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

void move(
	std::vector<std::pair<int, int>> &a,		/* answer */
	int sx, int sy,	/* start x, y */
	int tx, int ty,	/* goal  x, y */
	int d						/* direction 1 or -1 */
) {
	int mx = sx, my = ty;
	for( int y = sy; y != my + d; y += d ) {
		a.push_back( std::make_pair( sx, y ) );
	}
	for( int x = mx; x != tx + d; x += d ) {
		a.push_back( std::make_pair( x, my ) );
	}
}

void decode(
	std::vector<std::pair<int, int>> &a
)
{
	std::pair<int, int> p;
	a.erase( std::unique( a.begin(), a.end() ), a.end() );

	for( int i = 1; i < a.size(); i++ ) {
		int x1 = a[ i - 1 ].first,
				y1 = a[ i - 1 ].second,
				x2 = a[ i ].first,
				y2 = a[ i ].second;

		std::string ans = "";
		if( x1 == x2 and y1 < y2 ) {
			ans = "U";
		}
		if( x1 == x2 and y1 > y2 ) {
			ans = "D";
		}
		if( x1 < x2 and y1 == y2 ) {
			ans = "R";
		}
		if( x1 > x2 and y1 == y2 ) {
			ans = "L";
		}
		std::cout << ans;
	}
	std::cout << std::endl;
	return;
}

int main()
{
	int sx, sy, tx, ty;
	std::cin >> sx >> sy >> tx >> ty;

	std::vector<std::pair<int, int>> a;

	move( a, sx, sy, tx, ty,  1 );
	move( a, tx, ty, sx, sy, -1 );

	move( a, sx, sy, sx - 1, sy, -1 );
	move( a, sx - 1, sy, tx, ty + 1, 1 );
	move( a, tx, ty + 1, tx, ty, -1 );

	move( a, tx, ty, tx + 1, ty, 1 );
	move( a, tx + 1, ty, sx, sy - 1, -1 );
	move( a, sx, sy - 1, sx, sy, 1 );

	decode( a );
	
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  int result = 0;
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    if (a >= H && b >= W) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3164
program tenquestioneight
implicit none
integer N, Y, i, j, k
read(*,*) N, Y
 do i=0,2000
  do j=0,N-i
  k=N-i-j
   if ((10000*i+5000*j+k*1000).eq.Y) then
   write(*,*) i, j, k
   return
   end if
   if ((10000*i+5000*j).gt.Y) exit
  end do
 if ((10000*i).gt.Y) exit
 end do
write(*,*) -1, -1, -1
end program

Measured memory_bytes: 256
A,B,C=map(int, input().split())
K = int(input())

if A < B < C:
    print("Yes")
    exit()

for i in range(K):
    if A >= B:
        B *= 2
        continue
    if B >=C:
        C *= 2
        continue
if A < B < C:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61648
import numpy as np

N_K = list(map(int,input().split()))
H = np.array(list(map(int,input().split())))

N = N_K[0]
K = N_K[1]

dp= np.zeros(N,dtype=np.int)

for i in range(1,len(H)):

    if i < K:
        dp[i] = np.min(dp[:i] + np.abs(H[i]-H[:i]))
    else:
        dp[i] = np.min(dp[i-K:i] + np.abs(H[i]-H[i-K:i]))
    
print(dp[N - 1])

Measured memory_bytes: 22840
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        sc.close();

        if (a == b) {
            System.out.println("Draw");
        } else if (a == 1) {
            System.out.println("Alice");
        } else if (b == 1) {
            System.out.println("Bob");
        } else if (a > b) {
            System.out.println("Alice");
        } else {
            System.out.println("Bob");
        }
    }
}


Measured memory_bytes: 22740
#include <algorithm>
#include <vector>
#include <iostream>

int main(int argc, char* argv[])
{
  int a,b,c;
  std::cin >> a >> b >> c;

  std::vector<int> numbers;
  
  numbers.push_back(a);
  numbers.push_back(b);
  numbers.push_back(c);
  
  stable_sort(numbers.begin(),numbers.end());
  
  std::vector<int>::iterator itr = numbers.begin();  
  std::cout << *itr << " " << *(itr+1) << " " << *(itr+2) << std::endl;

  return 0;
}

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

int main(){
  int N; cin >> N;
  vector<int> D(N);
  for(int i =0; i < N;i ++){
    cin >> D[i];
  }
  
  long long int ans = 0;
  
  for(int i = 0; i < N; i++){
    for(int j = i+1 ; j < N;j++){
      ans += D[i] * D[j];
    }
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const int SIZE=2*1e5;
const LL INF=1<<30;
const LL p=7+1e9;
string s;
LL A[SIZE],B[SIZE];
LL N,K;

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

	REP(i,N) cin >> A[i] >> B[i];
	LL maxim=0;
	REP(i,N){
		if((A[i]&K)==A[i]) maxim+=B[i];
	}
	REP(j,31){
		if((K & (1<<j))==0) continue;
		LL ans=0;
		REP(i,N){
			//cout << A[i] << " " << (1<<j) << endl;
			if((A[i]&(1<<j))!=0){
				continue;
			}else if((A[i]^(A[i]&K))>1<<j){
				continue;
			}
			ans+=B[i];
		//	cout << ans << endl;
		}
		maxim=max(ans,maxim);
	}
	cout << maxim << endl;
	//cin >> N;REP(i,N) {cin >> A[i];}
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline void write(int x)
{
    if(x<0)
	{
    	putchar('-');
		x=-x;
	}
    if(x>9)
		write(x/10);
    putchar(x%10+'0');
}
int main()
{
	ios::sync_with_stdio(false);
    int n,m,a,d=-1,s;
    n=read();
    m=read();
	while(m--)
    {
    	a=read();
    	if(a>d)
    		d=a;
    }
    s=d*2-n-1;
    if(s<0) s=0;
    write(s);
    puts("");
    return 0;
}

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


int main() {
	
	int m, d,cnt=0;
	cin >> m >> d;
	
	for(int i=1; i<=m; i++){
		for(int j=10; j<=d; j++){
			int d1 = j/10;
			int d2= j%10;
			if(d1*d2==i && d1>=2 && d2 >=2) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	
	return 0;
}

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

A = [0] + A + [0]

s = 0
for i in range(N+1):
    s += abs(A[i] - A[i+1])


for i in range(1, N+1):
    print(s + abs(A[i-1]-A[i+1]) - (abs(A[i-1] - A[i]) + abs(A[i] - A[i+1])))

Measured memory_bytes: 64876
def resolve():
    N, M = list(map(int, input().split()))
    isac = {}
    wa = {}
    ac = 0
    penalty = 0

    for _ in range(M):
        p, S = list(input().split())
        p = int(p)
        if p not in wa:
            wa[p] = 0
        if S == 'AC':
            if isac.get(p) != True:
                ac += 1
                penalty += wa[p]
                isac[p] = True
        else:
            wa[p] += 1

    print(ac, penalty)
    return


resolve()

Measured memory_bytes: 24648
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

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

using namespace std;
long long INF = (1LL<<62);
typedef long long LL;

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

	string S;
	cin >> S;
	LL N = S.size();
	for(int i=N-1; i>=0; i--){
		if(S[i] == 'B'){
			S.pop_back();
		}
		else{
			break;
		}
	}
	N = S.size();
	LL ans = 0, c = N-1;
	for(int i=S.size()-1; i>=0; i--){
		if(S[i] == 'B'){
			ans += (c - i);
			c--;
		}
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
   string s; int i,t, k;
   cin>>k>>s;
   if(k==0) cout<<s;
   else
   {
       for(i=0;i<s.size();i++)
       {
           if( (char) s[i]+k <='Z')
           {
               s[i]=s[i]+k;
           }
           else
           {
              t=64 + (k-( 'Z'-s[i]));
               s[i]=  (char)t;
           }
       }
       cout<<s<<endl;
   }

}


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

#define nax 100009
#define FOR(i,n,m) for(ll i =(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
#define sz(v) int(v.size())
#define all(v) v.begin() , v.end()

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

int main(){
	int a,b; cin>>a>>b;
	if(b==1){
		cout<<0;
		return 0;
	}
	int w = a,c = 1;
	while(w<b){
		w+=a-1; c++;
	}

	cout<<c<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int N, A[100010];
    int min = 2000000001;

    cin >> N;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i] < 0) {
            A[i] = -A[i];
            cnt++;
        }
        if (min > A[i]) min = A[i];
    }

    long long sum = 0;
    if (cnt % 2) {
        sum -= min; sum -= min;
    }
    for (int i = 0; i < N; i++) sum += A[i];

    cout << sum << '\n';
}

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

int main(){
string s; cin>>s;
  ll m=0;
  rep(i,s.size()){
  if(s.at(i)=='0') m++;
  }
 ll t=s.size();
  cout<<min(m,t-m)*2<<endl;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
  string s;
  cin>>s; 
  if(s=="Sunny")
  {
    cout<<"Cloudy"<<endl;
  }
  else if(s=="Cloudy")
  {
    cout<<"Rainy"<<endl;
  }
  else
  {
    cout<<"Sunny"<<endl;
  }
}

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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;

string res;

int main()
{
    char a;
    cin >> a;

    if (a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o')
    {
        println("vowel");
    }
    else
    {
        println("consonant");
    }
    
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string S; cin >> S;
	stack<char> lifo;
	int remove = 0;
	for (char c : S) {
		if (!lifo.empty() && c == 'T' && lifo.top() == 'S') {
			lifo.pop();
			remove += 2;
		} else {
			lifo.push(c);
		}
	}
	print(S.size() - remove);
}

Measured memory_bytes: 720
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
#include <ctime>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	string S;
	cin >> S;
	if (S[0] == 'R' && S[1] == 'R' && S[2] == 'R')cout << 3;
	else {
		if (S[0] == 'R' && S[1] == 'R' && S[2] != 'R')cout << 2;
		else if (S[0] != 'R' && S[1] == 'R' && S[2] == 'R')cout << 2;
		else if (S[0] != 'R' && S[1] != 'R' && S[2] != 'R')cout << 0;
		else cout << 1;
	}
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int n, m, ans;

bool is_Hamming( int d ) {
	if ( d == 1 ) {
		return true;
	}
	if ( d % 2 == 0 ) {
		return is_Hamming( d / 2 );
	}
	if ( d % 3 == 0 ) {
		return is_Hamming( d / 3 );
	}
	if ( d % 5 == 0 ) {
		return is_Hamming( d / 5 );
	}
	return false;
}

int main() {
	while ( ~scanf( "%d", &n ) && n ) {
		scanf( "%d", &m );
		ans = 0;
		for ( int i = n; i <= m; i++ ) {
			ans += is_Hamming( i );
		}
		printf( "%d\n", ans );
	}
	return 0;
}

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

namespace Atc_0032
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());

            long result = 0;

            for (long i = 1; i < N; i++)
            {
                result += (N - 1) / i;
            }

            Console.WriteLine(result);

        }
    }
}

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

namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine(arr[0] * 500 >= arr[1] ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13268
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
// Practice is the only shortcut to improve
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
#define mp(x,y) make_pair(x,y)
#define yes dbg("YES")
#define no dbg("NO")
#define tst int t;cin>>t;while(t--)
#define srt(v) sort(v.begin(),v.end());
#define rsrt(v) sort(v.begin(),v.end(),greater<int>());
#define rj ios::sync_with_stdio(false);cin.tie(0);
#define rvs(v) reverse(v.begin(),v.end());
#define F first
#define S second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define PI 2*acos(0.0)
#define pii pair<int,int>
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define coutv(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define cinv(v) for(auto &it:v)cin>>it;
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using ordered_set =tree<T, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;
*/
//sieve bool b[1000005];void primenire(){int i, j;b[0]=true;b[1]=true;for(i=4; i<=1000000; i+=2){b[i]=true;}for(i=3; i<=1001; i+=2){if(!b[i]){for(j=i*i; j<=1000001; j+=2*i){b[j]=true;}}}}
//power ll power(ll a,ll b){if(b==0) return 1LL;if(b&1) return a*power(a,b-1);else return power(a,b/2)*power(a,b/2);}
//bigmod long long int m(long long int a,long long int b,long long int c){if(b==0)return 1;if(b%2==0){long long int  tmp=m(a,b/2,c);return ((tmp%c)*(tmp%c))%c;}elsereturn ((a%c)*(m(a,b-1,c)%c))%c;}
//MaxSubarraySum ll mss(vector<ll>v){ll mx=v[0];ll sz=v.size();for(int i=1;i<=sz;i++){ll t=v[i]+v[i-1];if(t>=v[i]) v[i]=t;mx=max(mx,v[i]*1LL);}return mx;}
//combination ll com[1001][1001];void combination(){com[1][1]=1;com[1][0]=1;for(ll i=2; i<=1000; i++){com[i][0]=1;for(ll j=1; j<=i; j++){com[i][j]=com[i-1][j]+com[i-1][j-1];}}}
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------
ll a,b;
ll cnt=0;
vi v[1000000];
bool vis[1000000];
void dfs(ll n)
{

   vis[n]=1;
   cnt++;
   for(auto it:v[n]) if(!vis[it]) dfs(it);
}
void solve()
{
   cin>>a>>b;

   fr(i,1,b)
   {
      ll c,d;
      cin>>c>>d;
      v[c].pb(d);
      v[d].pb(c);
   }
   ll mx=0;
   fr(i,1,a)
   {
      cnt=0;
      if(!vis[i]) dfs(i);
      mx=max(mx,cnt);
   }
   cout<<mx<<endl;

}
int main()
{
    rj
    solve();



    return 0;
}



Measured memory_bytes: 39748
#include <stdio.h>

#define MAX 101
#define NIL -1
#define INF (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int prim();

int G[MAX][MAX];
int n;

int main() {
  int e, i, j;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      scanf("%d", &e);
      if (e == NIL) {
	G[i][j] = INF;
      } else {
	G[i][j] = e;
      }
    }
  }

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

  return 0;
}

int prim() {
  int u, mincost, i, v, sum = 0;
  int d[MAX], pi[MAX], color[MAX];

  for (i = 0; i < n; i++) {
    d[i] = INF;
    pi[i] = NIL;
    color[i] = WHITE;
  }
  d[0] = 0;
  while (1) {
    mincost = INF;
    u = NIL;
    for (i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] < mincost) {
	mincost = d[i];
	u = i;
      }
    }
    if (u == NIL) {
      break;
    }
    color[u] = BLACK;
    for (v = 0; v < n; v++) {
      if (color[v] != BLACK && G[u][v] != INF) {
	if (d[v] > G[u][v]) {
	  pi[v] = u;
	  d[v] = G[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for (i = 0; i < n; i++) {
    if (pi[i] != NIL) {
      sum += G[i][pi[i]];
    }
  }
  return sum;
}



Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[10];
		int[] b = {0,0,0};
		for(int i = 0; i < 10; i++){
			a[i]=sc.nextInt();
		}
		for(int i = 0; i < 10; i++){
			if(a[i]>b[0]){
				b[2]=b[1];
				b[1]=b[0];
				b[0]=a[i];
			}
			else if(a[i]>b[1]){
				b[2]=b[1];
				b[1]=a[i];
			}
			else if(a[i]>b[2])
				b[2]=a[i];
		}
		for(int i = 0; i < 3; i++)
			System.out.println(b[i]);
	}
}

Measured memory_bytes: 12000
import math
lst = []
for i in range(5):
  lst.append(int(input()))
minu = 9
temp = 0
count = 0
for j in range(5):
  if int(str(lst[j])[-1]) < minu and int(str(lst[j])[-1]) > 0:
    minu = int(str(lst[j])[-1])
    temp = lst[j]
    count += 1
if count > 0:
  lst.remove(temp)
else:
  temp = lst[0]
  del lst[0]
time = 0
for k in range(4):
  kari = math.ceil(int(lst[k])/10)
  time += int(kari * 10)
time += temp
print(time)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int field[505][505];

int main(){
  int H, W;
  cin >> H >> W;
  rep(i,H){
    rep(j,W){
      cin >> field[i][j];
    }
  }

  vector<string> ret;
  rep(i,H){
    rep(j,W){
      if(field[i][j]%2 == 1){
        int type = 0;
        if(j+1 < W) type = 1;
        else if(i+1 < H) type = 2;
        
        if(type == 1){
          field[i][j]--;
          field[i][j+1]++;
          stringstream ss;
          ss << i+1 << " " << j+1 << " " << i+1 << " " << j+2;
          ret.push_back(ss.str());
        }
        else if(type == 2){
          field[i][j]--;
          field[i+1][j]++;
          stringstream ss;
          ss << i+1 << " " << j+1 << " " << i+2 << " " << j+1;
          ret.push_back(ss.str());
        }
      }
    }
  }

  cout << ret.size() << endl;
  rep(i,ret.size()){
    cout << ret[i] << endl;
  }
  
  return 0;
}




Measured memory_bytes: 10996
package main

import "fmt"

func main() {
	var h, n int

	fmt.Scan(&h)
	fmt.Scan(&n)

	type Magic struct {
		damage int
		cost int
	}

	magics := make([]Magic, n)

	var d, c int

	dp := make([]int, h + 1)

	for i := 0; i < n; i++ {
		fmt.Scan(&d)
		fmt.Scan(&c)
		magics[i] = Magic{d, c}
	}

	for i := 0; i < h; i++ {
		if i > 0 && dp[i] == 0 {
			continue
		}

		for _, m := range magics {
			next_cost := dp[i] + m.cost
			next_i := i + m.damage

			if next_i >= h {
				next_i = h
			} 

			if dp[next_i] == 0 || dp[next_i] > next_cost {
				dp[next_i] = next_cost
			}
		}
	}

	fmt.Println(dp[h])
}


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

int main() {
	int h, w, x, y;
	cin >> h >> w >> x >> y;
	if(h * w % 2 == 1 && (x + y) % 2 == 1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}



Measured memory_bytes: 3120
#include <iostream>
#include <fstream>
#define nmax 1001
#define md 1000000007
using namespace std;
ifstream fin("p.in");
ofstream fout("p.out");

int n,m;
long long dp[nmax][nmax];

int main()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++)
            {
                char ch;
                cin>>ch;
                if(ch=='#') dp[i][j]=-1;
            }

    int val=1;
    for(int i=1; i<=n; i++)
        if(dp[i][1]!=-1) dp[i][1]=val%md;
        else val=0;

    val=1;
    for(int j=1; j<=m; j++)
        if(dp[1][j]!=-1) dp[1][j]=val%md;
        else val=0;

    for(int i=2; i<=n; i++)
        for(int j=2; j<=m; j++)
            if(dp[i][j]!=-1)
                {
                    int val_1=0,val_2=0;
                    if(dp[i-1][j]!=-1) val_1=dp[i-1][j];
                    if(dp[i][j-1]!=-1) val_2=dp[i][j-1];
                    dp[i][j]=(val_1+val_2)%md;
                }

    /*for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=m; j++)
                fout<<dp[i][j]<<" ";
            fout<<endl;
        }*/

    cout<<dp[n][m];
    return 0;
}


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

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

   map<string, int> week;
   week["SUN"] = 7;
   week["MON"] = 1;
   week["TUE"] = 2;
   week["WED"] = 3;
   week["THU"] = 4;
   week["FRI"] = 5;
   week["SAT"] = 6;
   if (week["SUN"] - week[S] == 0)
      cout << 7 << endl;
   else
      cout << week["SUN"] - week[S] << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


void priv(vector<string> &a){
  int N = a.size();
  rep(i, N){
    cout <<a[i];
    if (i == N-1) cout <<endl;
    else cout <<" ";
  }
}

bool bubbleSort(vector<string> &a, int N){
  int res = 0;
  bool flag = true;
  while (flag){
    flag = false;
    for (int j=N-1; j>=1; j--){
      if (a[j-1][1] > a[j][1]){
        swap(a[j-1], a[j]);
        res++;
        flag = 1;
      }
    }
  }
  priv(a);
  return true;
}

bool selectionSort(vector<string> &a, int N){
  int res = 0;
  for (int i=0; i<N; i++){
    int minj = i;
    for (int j=i; j<N; j++){
      if (a[minj][1] > a[j][1]) minj = j;
    }
    if (a[i][1] > a[minj][1]) res++;
    swap(a[i], a[minj]);
  }
  priv(a);
  return res;
}


int main() {
  int N; cin >>N;
  vector<string> a(N); rep(i, N) cin >>a[i];
  vector<string> b = a;
  bubbleSort(a, N);
  cout <<"Stable" <<endl;
  selectionSort(b, N);
  cout <<(a == b ? "Stable" : "Not stable") <<endl;
}


Measured memory_bytes: 3160
h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(str(input()))
b = '#'*(w+2)
lst = [b]

for i in range(h):
    c = ['#', a[i], '#']
    lst.append(''.join(c))

lst.append(b)

for i in range(h+2):
    print(lst[i])

Measured memory_bytes: 3064
(let ((abc (vector (read) (read) (read))))
  (loop for i below 3
        for res = (= (svref abc i) (+ (svref abc (mod (1+ i) 3))
                                      (svref abc (mod (+ 2 i) 3))))
        if res
        do (return (format t "~A~%" "Yes"))
        finally (format t "~A~%" "No")))

Measured memory_bytes: 14052
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main()
{
	int K;
	input(K);

	ll res = 0;
	rep(a, 1, K + 1)
	{
		rep(b, 1, K + 1)
		{
			rep(c, 1, K + 1)
			{
				res += gcd(gcd(a, b), c);
			}
		}
	}

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

Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <functional>

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

using namespace std;

int main(void) {
    int n;
    cin >> n;
    vector<pair<int,int> > v(n);
    REP(i,n){
        v[i].second = i;
    }
    int a,b,c,d;
    REP(i,n*(n-1)/2){
        cin >> a >> b >> c >> d;
        a--;b--;
        if (c>d)
            v[a].first+=3;
        else if(c<d)
            v[b].first+=3;
        else{
            v[a].first++;
            v[b].first++;
        }
    }
    sort(v.begin(),v.end(),greater<pair<int,int> >());
    vector<int> rank(n);
    REP(i,n){
        rank[v[i].second] = i+1;
        if (i>0 && v[i].first==v[i-1].first)
            rank[v[i].second] = rank[v[i-1].second];
    }
    REP(i,n){
        cout << rank[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll GCD(ll a, ll b){
    if(b==0) return a;
    else return GCD(b,a%b);
}
 
int main(){
    ll t; cin >> t;
    rep(z,t){
        ll a,b,c,d; cin >> a >> b >> c >> d;
        if(a<b || d<b) puts("No");
        else{
            if(c>=b) puts("Yes");
            else{
                if(a%b > c) puts("No");
                else{
                    ll g;
                    g = GCD(d%b,b);
                    if(b-c <= g) puts("Yes");
                    else puts("No");
                }
            }
        }
    }
}


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

using namespace std;
int n;
const int maxn = 100000 + 1;
int a[maxn];
int x;
int main()
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(a[i] % 2 == 1){
			x++;
		}
	}
	if(x % 2 == 1){
		cout << "NO";
	}
	else{
		cout << "YES";
	}
	return 0;
}


Measured memory_bytes: 640
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Sat Jan  5 17:29:43 2019
//
package main

import "fmt"

func main() {
	var X, Y, Z int
	fmt.Scan(&X, &Y, &Z)

	i := 0
	for ; Y*i+Z*(i+1) <= X; i++ {
	}
	fmt.Println(i - 1)
}


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

int main() {
  
  vector<int> t(3);
  rep(i,3) cin >> t[i];
  sort(t.begin(), t.end());
  
  if(t[0] == 5 && t[1] == 5 && t[2] == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}


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

using namespace std;

#define int long long
#define fi first
#define se second

void test_case(){
	int n;
	cin>>n;
	vector<int> arr(n);
	map<int,int> freq,inc,exc;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		freq[arr[i]]++;
	}
	int si=0,se=0;
	for(auto x:freq){
		inc[x.fi]=x.se*(x.se-1)/2;
		exc[x.fi]=(x.se-1)*(x.se-2)/2;
		si+=inc[x.fi],se+=exc[x.fi];
	}
	for(int i=0;i<n;i++){
		int ans=si-inc[arr[i]]+exc[arr[i]];
		cout<<ans<<"\n";
	}
	
}

signed main(){
	int t=1;
	//cin>>t;
	while(t--)test_case();
}


Measured memory_bytes: 26880
#include <stdio.h>

#define MAX 500000

int H,A[MAX+1];
int i;

int left(int i){
  return i*2;
}
int right(int i){
  return i*2+1;
}

void maxHeapify(int i){
  int l,r,largest;
  int change;

  l = left(i);
  r = right(i);

  if((l<=H)&&(A[l]>A[i])){
    largest = l;
  }else{
    largest = i;
  }
  if((r<=H)&&(A[r]>A[largest])){
    largest = r;
  }
  if(largest != i){
    change = A[i];
     A[i] = A[largest];
     A[largest] = change;
     maxHeapify(largest);
  }
}

int main(){
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  for(i=H/2;i>=1;i--){
    maxHeapify(i);
  }
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define oo 100005
using namespace std;
char s[oo];
int tot, fa[oo], n, now;
int main ()
{
    scanf("%s", s + 1);
    n = strlen(s + 1);
    int flag = 1;
    for(int i = 1; i <= n / 2; ++ i)
    if(s[i] != s[n - i]) flag = 0;
    if(s[1] == '0') flag = 0;
    if(s[n] == '1') flag = 0;
    if(!flag) {puts("-1"); return 0;}
    now = ++ tot;
    for(int i = 2; i <= n; ++ i)
    {
        if(s[i] == '0') continue;
        fa[now] = ++ tot; now = tot;
        while(tot < i) fa[++ tot] = now;
    }
    while(tot < n) fa[++ tot] = now;
    for(int i = 1; i <= n; ++ i)
    if(i != now) printf("%d %d\n", i, fa[i]);
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <utility> //pair

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

typedef long long ll;

using namespace std;

int main() {
    
    int r;
    
    cin >> r;
    
    if(r<1200){
        cout << "ABC" << endl;
    }else if(r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    return 0;
}


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

int main(){
    int N;
    int num[110];
    int alice = 0;
    int bob = 0;

    cin >> N;
    for(int i=0; i<N; i++) cin >> num[i];
    sort(num, num+N, greater<int>());

    for(int turn=0; turn<N; turn++){
        if(turn%2 == 0) alice += num[turn];
        else bob += num[turn];
    }

    cout << alice-bob << endl;
}

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

#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }
/*
#include <bits/stdc++.h>
using namespace std;
 */
struct BIT {
	vector<int> v;
	int n;

	BIT() { init(); }
	BIT(int size) :n(size){ init(); }

	void init() {
		v.clear();
		v.resize(n + 1, 0);
	}

	int sum(int i, int idx = 1) {
//		idx--; idx *= -1; i += idx;
		int ret = 0;
		while (i) {
			ret += v[i];
			i -= i & -i;
		}
		return ret;
	}

	void add(int i, int x, int idx = 1) {
//		idx--; idx *= -1; i += idx;
		while (i <= n) {
			v[i] += x;
			i += i & -i;
		}
	}
};

int main() {
	int n = in(), q = in();
	BIT bit(n);

	rep(_, q) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		if (a)
			cout << bit.sum(c) - bit.sum(b - 1) << endl;
		else 
			bit.add(b, c);
	}
}

Measured memory_bytes: 3220
io = STDIN
N=io.gets.to_i
a=io.gets.split.map(&:to_i)
b=io.gets.split.map(&:to_i)
c=io.gets.split.map(&:to_i)
cnt=b.inject(:+)
a.each_cons(2) do |i,j| #1,2,3
  cnt+=c[i-1] if i+1==j
end
p cnt


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

int main(){

  int c[2];
  for(int i=0;i<2;i++){
    cin >> c[i];
    if(c[i]==2){
      c[i]=1;
    }else if(c[i]==4||c[i]==6||c[i]==9||c[i]==11){
      c[i]=2;
    }else{
      c[i]=3;
    }
  }

  if(c[0]==c[1]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
const int p=998244353;
using namespace std;
int T,n,a,b,c,d;long long dp[3200][3200];
int main(){
	scanf("%d%d%d%d",&a,&b,&c,&d);
	dp[a][b]=1;
	
	for(int i=a;i<=c;i++)
	for(int j=b;j<=d;j++)
	dp[i+1][j]=(dp[i+1][j]+dp[i][j]*j%p)%p,dp[i][j+1]=(dp[i][j+1]+dp[i][j]*i%p)%p,
	dp[i+1][j+1]=(dp[i+1][j+1]+p-dp[i][j]*i%p*j%p)%p;
	
	printf("%d",dp[c][d]);
	
} 

Measured memory_bytes: 78712
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    H, W = map(int, input().split())
    A = [''] * H
    for i in range(H):
        A[i] = input()

    row = [False]*H
    col = [False]*W
    for i in range(H):
        for j in range(W):
            if A[i][j] == '#':
                row[i] = True
                col[j] = True

    for i in range(H):
        if row[i]:
            for j in range(W):
                if col[j]:
                    print(A[i][j], end='')
            print()



if __name__ == '__main__':
    main()

Measured memory_bytes: 4468
#include <iostream>
using namespace std;
int f[110000], n;
void dfs(int lig, int tim) {
    if (tim == n ) {
        cout << -1 << endl;
        return;
    } else if (lig == 2) {
        cout << tim;
        return;
    } else {
        dfs(f[lig], tim + 1);
    }
}
int main(void){
    // Your code here!
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        f[i] = a;
    }
    dfs(1, 0);
}


Measured memory_bytes: 640