akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
typedef long long ll;
using namespace std;

int main() {
	ll n,a,b,c=0,d,ans=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++){
		d=i;
		while(d>0){
			c+=d%10;
			d/=10;
		}
		if(c>=a&&c<=b){
			ans+=i;
		}
		c=0;
	}
	cout << ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int digits = Integer.toString(a + b).length();
            System.out.println(digits);
        }
    }
}

Measured memory_bytes: 26416
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		String[] A = new String[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.next();
		}
		String[] B = new String[M];
		for (int i = 0; i < M; i++) {
			B[i] = sc.next();
		}
		
		for (int i = 0; i <= N - M; i++) {
			for (int j = 0; j <= N - M; j++) {
				boolean hit = true;
				if (A[i].substring(j, j + M).equals(B[0])) {
					for (int k = 1; k < M; k++) {
						if (!A[i + k].substring(j, j + M).equals(B[k])) {
							hit = false;
							break;
						}
					}
				} else {
					hit = false;
					continue;
				}
				
				if (hit) {
					System.out.println("Yes");
					return;
				}
			}
		}
		
		System.out.println("No");
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
int main(){
	vector<int> seive(2000001);
  	long int n,k;
  	cin >> n;
  	for(int i=0;i<n;i++){
    	cin >> k;
      	seive[k]++;
    }
  	long int not_divisible=0;
  	vector<int> divisible(2000001,0);
  	for(int i=1;i<=2000000;i++){
    	if(seive[i]==0 || divisible[i])
          	continue;
      	if(seive[i]==1 && !divisible[i])
          	not_divisible++;
		for(int j=i;j<2000000;j+=i)
          	divisible[j]=1;
    }
  cout << not_divisible;
  return 0;
}


Measured memory_bytes: 18792
use std::io::*;

fn dfs(v: usize, p: usize, d: &mut Vec<usize>, g: &Vec<Vec<usize>>) {
    for &nv in g[v].iter() {
        if nv != p {
            d[nv] = d[v] + 1;
            dfs(nv, v, d, &g);
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let u: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;
    let v: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;

    let mut g = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let a: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let b: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        g[a].push(b);
        g[b].push(a);
    }

    let mut t = vec![0; n];
    let mut a = vec![0; n];
    dfs(u, u, &mut t, &g);
    dfs(v, v, &mut a, &g);

    // t
    let mut td = 0;
    let mut ti = 0;
    for i in 0..n {
        if a[i] > t[i] && a[i] > td {
            td = a[i];
            ti = i;
        }
    }
    println!("{}", a[ti] - 1);
}


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

int zetsa(int a,int b){
  if(a>b){
    return a-b;
  }else{
    return b-a;
  }
}

int main(){
  int n,k;
  cin >> n >> k;

  vector<int> dp(n,INT_MAX);
  vector<int> a(n);

  for(int i=0;i<n;i++){
    cin >> a.at(i) ;
  }

  dp.at(0)=0;
  for(int i=0;i<n-1;i++){
    int d;

    for(int l=i+1;l<=i+k;l++){
      if(l>=n){break;}

      d=zetsa(a.at(i),a.at(l));

      dp.at(l)=min(dp.at(i)+d,dp.at(l));
    }
  }
  cout << dp.at(n-1) <<endl;
  return 0;
}

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


int main(){


	int x;
	cin>>x;

		int h = x / 3600;
		int m = (x/60) % 60;
		int s = x % 60;
		cout<<h<<":"<<m<<":"<<s<<endl;


		return 0;
	}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
bool sec(const pair<int, int>& a, const pair<int, int>& b) {
	return a.second < b.second;
}
#define all(c) c.begin(), c.end()
int main() {
	int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for (int i=0; i<n; i++) {
  	v[i].first = i+1;
    cin >> v[i].second;
  }
  sort(all(v), sec);
  for (int i=0; i<n; i++)
    cout << v[i].first << ' ';
  
	return 0;
}

Measured memory_bytes: 1536
/*
ID:greenty2
LANG:C++
TASK:
*/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
char s1[100],s2[100];
const int mod = 1000000007;
int main()
{
	int n;
	cin>>n;
	cin>>s1+1;
	cin>>s2+1;
	LL ans=0;
	if(s1[1]==s2[1])
	{
		ans = 3;
		int pre = 1;
		for(int i=2;i<=n;i++)
		{
			if(s1[i] == s2[i])
			{
				if(pre == 1)
				{
					ans=ans*2;
					ans = ans %mod;
				}
				else if(pre == 2)
				{
					pre = 1;
				}
			}
			else
			{
				if(pre == 1)
				{
					ans = ans*2;
					ans = ans %mod;
					pre = 2;
				}
				else if(pre ==2)
				{
					ans=ans*3;
					ans = ans %mod;
				}
				i++;
			}
			//cout<<ans<<endl;
		}
		cout<<ans<<endl;
	}
	else
	{
		ans = 6;
		int pre =2;
		for(int i=3;i<=n;i++)
		{
			if(s1[i] == s2[i])
			{
				if(pre == 1)
				{
					ans=ans*2;
					ans = ans %mod;
				}
				else if(pre == 2)
				{
					pre = 1;
				}
			}
			else
			{
				if(pre == 1)
				{
					ans = ans*2;
					ans = ans %mod;
					pre = 2;
				}
				else if(pre ==2)
				{
					ans=ans*3;
					ans = ans %mod;
				}
				i++;
			}
		}
		cout<<ans<<endl;
	}
	
	 
}

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

int main() {
  string str1;
  cin >> str1;
  if(str1 == "Sunny"){cout << "Cloudy" << endl; return 0;}
  if(str1 == "Cloudy"){cout << "Rainy" << endl; return 0;}
  if(str1 == "Rainy"){cout << "Sunny" << endl; return 0;}

}

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

int main(){
        int n,m,i,a,b,ans=0;
        priority_queue<int> q;
        cin >> n >> m;
        vector<vector<int>> v(100000);
        for(i=0;i<n;++i){
                cin >> a >> b;
                --a;
                v.at(a).push_back(b);
        }
        for(i=0;i<m;++i){
                for(auto e : v.at(i)) q.push(e);
                if(!q.empty()){
                        ans += q.top();
                        q.pop();
                }
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 8468
# coding=utf-8
import math


def is_triangle(sides_list):
    if sides_list[0] >= sides_list[1] + sides_list[2]:
        return False
    if sides_list[0] <= math.fabs(sides_list[1] - sides_list[2]):
        return False
    return True


def is_right_triangle(sides_list):
    sides_list.sort()
    if sides_list[2]**2 > sides_list[1]**2 + sides_list[0]**2:
        return 3
    if sides_list[2]**2 < sides_list[1]**2 + sides_list[0]**2:
        return 2
    if sides_list[2] ** 2 == sides_list[1] ** 2 + sides_list[0] ** 2:
        return 1


if __name__ == '__main__':
    counter = [0, 0, 0, 0]
    while True:
        sides = list(map(int, input().split()))
        if not is_triangle(sides):
            break
        counter[0] += 1
        counter[is_right_triangle(sides)] += 1

    print(' '.join(map(str, counter)))



Measured memory_bytes: 5680
#include <iostream>

using namespace std;

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

	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << H * W - H * w - W * h + w * h << '\n';


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N ;
    int A[N];
    int x=INF;
    int y=0;
    rep(i,N) {
        cin >> A[i];
        x=min(x,A[i]);
        y=max(y,A[i]);
    }
    cout << y-x << endl;






}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int n, m, x; cin >> n >> m >> x;
    vi C(n); vector<vi> A(n, vi(m));
    rep(i, n) {
        cin >> C[i];
        rep(j, m) {
            cin >> A[i][j];
        }
    }

    vi order(n); rep(i, n) order[i] = i;
    ll ans = INF;

    for (int bit = 0; bit < (1<<n); bit++) {
        vi sum(m, 0);
        ll tmp = 0;

        rep(i, n){
            if (bit & (1<<i)) {
                rep(j, m) {
                    sum[j] += A[i][j];
                }
                tmp += C[i];
            }
        }
        bool flg = true;
        rep (j, m) {
            if (sum[j] < x) flg = false;
        }
        if (!flg) continue;
        ans = min(ans, tmp);
    }

    // do {
    //     vi sum(m, 0);
    //     ll tmp = 0;
    //     for(int i : order) {

    //         int ok = 0;

    //         rep(j, m) {
    //             sum[j] += A[i][j];
    //             if (sum[j] >= x) ok++;
    //         }

    //         tmp += C[i];

    //         if (ok == m) {
    //             ans = min(ans, tmp);
    //             break;
    //         }
    //     }
    // } while(next_permutation(order.begin(), order.end()));

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


    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main()
{
	int i, N, A[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	
	int j, sum;
	long long ans = 0;
	for (i = 1, j = 2, sum = A[1]; i <= N; sum -= A[i++]) {
		for (; j <= N && (sum ^ A[j]) == sum + A[j]; j++) sum += A[j];
		ans += j - i;
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2488
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define e cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m;
ll a[2005];
ll h,w,x,y,ans=0,sum;

int main(){
	cin>>n>>x;
	for(i=0;i<n;i++){
		cin>>a[i];
		ans += a[i];
	}

	for(i=0;i<n;i++){
		sum=0;
		ll memo = a[0];
		for(j=0;j<n-1;j++){
			a[j] = min(a[j],a[j+1]);
			sum += a[j];
		}
		a[n-1] = min(a[n-1],memo);
		sum += a[n-1];
		ans = min(ans,sum+x*(i+1));
	}
	p(ans);
	
	return 0;
				
}

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

int main() {

    char c;
    cin >> c;

    if (c == 'a' || c == 'e' || c ==  'i' || c== 'o' ||c== 'u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())
for _ in range(q):
	b,e,t = map(int, input().split())
	x = a[t:t+e-b]
	a[t:t+e-b] = a[b:e]
	a[b:e] = x
print(" ".join(map(str,a)))


Measured memory_bytes: 5632
L=int(input());S=bin(L);N=len(S)-2;print(N,N+N+S.count("1")-3)
for i in range(1,N):
 print(i,-~i,0);print(i,-~i,2**~-i)
 if int(S[-i]):L^=2**~-i;print(i,N,L)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import collections
import math


def combinations_count(s, r):
    return math.factorial(s) // (math.factorial(s - r) * math.factorial(r))

def get_nc2(s):
    if nc2[s] == -1:
        t_nc2 = combinations_count(s, 2)
        nc2[s] = t_nc2
        return t_nc2
    else:
        return nc2[s]


n = int(input())
a = list(map(int, input().split()))
col_a = collections.Counter(a)
res = [-1]*(n+1)
mid = [-1]*(n+1)
mid_sum =0
nc2 = [-1]*(n+1)
nc2[0] = 0
nc2[1] = 0


# print(col_a)
# print("==Create mid table==")
for i in col_a.keys():
    tmp_l = [0]*2
    cnt_i = col_a[i]
    # print("i: " + str(i) + " , cnt_i: " + str(cnt_i))
    if mid[cnt_i] == -1:
        tmp_l[0] = get_nc2(cnt_i)
        tmp_l[1] = get_nc2(cnt_i-1)
        # print("tmp_l: " + str(tmp_l))
        mid[cnt_i] = tmp_l
        mid_sum += tmp_l[0]
    else:
        mid_sum += mid[cnt_i][0]
# print("mid_sum: " + str(mid_sum))

# print("==Create result table==")
for i in col_a.keys():
    cnt_i = col_a[i]
    # print("i: " + str(i) + " , cnt_i: " + str(cnt_i))
    if res[cnt_i] == -1:
        tmp_cnt = mid_sum - mid[cnt_i][0] + mid[cnt_i][1]
        res[cnt_i] = tmp_cnt
        # print("tmp_cnt: " + str(tmp_cnt))

for ai in a:
    print(res[col_a[ai]])


Measured memory_bytes: 121548
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) 
{ v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i]; }
template<class T, class U> void read_n(vector<pair<T, U>>& v, size_t n)
{ v = vector<pair<T, U>>(n); 
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli s;
lli a[1000001];
int main() {
  cin >> s;
  a[1] = s;
  for (lli i=2; i<=1000000; ++i) {
    a[i] = a[i-1]%2==0 ? a[i-1]/2 : 3*a[i-1]+1;
  }
  lli ans;
  for (lli i=1; i<1000000; ++i) {
    lli x = a[i];
    lli c = count(begin(a)+1, begin(a)+i, x);
    if (c>=1) { ans = i; break; }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
const int N =1000;
int main()
{
    char s[N];
    while(~scanf("%s",s))
    {
        int ans =0,l =strlen(s);
        for(int i=0,j =l-1;i<l/2;i++,j--)
        {
            if(s[i]!=s[j])
                ans++;
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, k;
    while (cin >> n >> k, n|k){
        map<int, int> m;
        vector<pair<int, int>> c;
        for (int i = 0; i < k; ++i) {
            int x;
            scanf("%d", &x);
            m[x]++;
        }
        int w = m[0];
        int s = 0, g = 0, ans = 1;
        for (int i = 1; i <= n+1; ++i) {
            if(m[i]) {
                if(s == 0) s = i;
                g = i;
            }
            else  {
                if(s != 0 && g != 0) {
                    ans = max(ans, w+g-s+1);
                    c.emplace_back(s, g);
                }
                s = 0, g = 0;
            }
        }
        if(w) {
            for (int i = 0; i < c.size()-1; ++i) {
                if(c[i+1].first-c[i].second == 2){
                    ans = max(ans, c[i+1].second-c[i].first+1);
                }
            }
        }
        cout << ans << "\n";
    } 
    
    return 0;
}



Measured memory_bytes: 7848
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

# 素因数分解、リストで返す
#############################################################


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)
    a.sort()
    return a
#############################################################


primes = defaultdict(int)

for i in range(N):
    p = prime_factorize(A[i])
    p_set = set(p)
    for pi in p_set:
        primes[pi] += 1

# print(primes)

if len(primes) == 0:
    print("pairwise coprime")
    exit()

max_cnt = max(primes.values())
min_cnt = min(primes.values())

if max_cnt == 1:
    print("pairwise coprime")
elif max_cnt != N:
    print("setwise coprime")
else:
    print("not coprime")


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

int main(){
	double a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	set<double> sug;
	set<double> wat;

	for( int i = 0; 100*i*a < f; ++i ){
		for( int j = 0; 100*j*b+100*i*a < f; ++j ){
			//cout << 100*i*a+100*j*b << endl;
			wat.insert(100*i*a+100*j*b);
		}
	}
	
	for( int i = 0; i*c < f; ++i ){
		for( int j = 0; i*c+j*d < f; ++j ){
			sug.insert(i*c+j*d);
			//cout << i*c+j*d << endl;
		}
	}
	
	double restw = 0;
	int maxi = -1, sugM = -1;

	//cout << endl;
	for( set<double>::iterator it = wat.begin(); it != wat.end(); ++it ){
		auto search = sug.upper_bound(min(((*it)*e)/100, f-*it));
		if( search != sug.begin() )
			--search;
		else
			continue;
		//cout << *it << " " <<  *search << endl;
		if( search != sug.end() && *it != 0 && restw < (100*(*search))/(*search+*it) && *it + *search <= f ){
			restw = (100*(*search))/(*search+*it) ;
			maxi =  *it + *search;
			sugM = *search;
		}
	}
	//cout << endl;
	if( maxi == -1) cout << min(100*a, 100*b) << " " << 0 << endl;
	else
		cout << maxi << " " << sugM << endl;
	return 0;
}

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

vector<int> perfect_squares;
int points[10][10];

bool is_perfect_square(int n){
	return binary_search(perfect_squares.begin(), perfect_squares.end(), n);
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, d;
	cin >> n >> d;
	
	for (int i = 0; i <= 10000; i++){
		perfect_squares.push_back(i * i);
	}
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j < d; j++){
			cin >> points[i][j];
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++){
		for (int j = i + 1; j < n; j++){
			int dist = 0;
			for (int k = 0; k < d; k++){
				dist += (points[i][k] - points[j][k]) * (points[i][k] - points[j][k]);
			}
			//cerr << dist << endl;
			if (is_perfect_square(dist)){
				++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

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















































Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll n,meda,medb;
  cin>>n;
  vector<ll>a(n),b(n);
  for(ll i=0;i<n;i++){
    scanf("%lld%lld",&a[i],&b[i]);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(n%2==0){
    meda=a[n/2]+a[n/2-1];
    medb=b[n/2]+b[n/2-1];
    cout<<medb-meda+1<<endl;
  }else{
    meda=a[n/2];
    medb=b[n/2];
    cout<<medb-meda+1<<endl;
  }
}

Measured memory_bytes: 6432
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
    }
    for (int i=n-1; i>=0; i -= 2) {
        cout << a.at(i) << " ";
    }
    for (int i=(n%2==0)?0:1; i<n; i += 2) {
        cout << a.at(i) << " ";
    }
    cout << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    vector<int> time(1000,0),in(1000,-1);
    vector<bool> login(1000,false);
    string d,t,io,ids;
    rep(i,n){
      cin >> d >> t >> io >> ids;
      int tm=stoi(t.substr(0,2))*60+stoi(t.substr(3,2));
      int id = stoi(ids);
      if(id){
        if(io=="I"){
          if(login[0]){
            in[id]=tm;
            login[id]=true;
          }else{
            login[id]=true;
          }
        }else{
          if(in[id]!=-1){
            time[id]+=tm-in[id];
            in[id]=-1;
          }
          login[id]=false;
        }
      }else{
        if(io=="I"){
          login[0]=true;
          repp(j,1,1000){
            if(login[j]) in[j]=tm;
          }
        }else{
          login[0]=false;
          repp(j,1,1000){
            if(in[j]!=-1){
              time[j]+=tm-in[j];
              in[j]=-1;
            }
          }
        }
      }
    }
    int ans=0;
    repp(i,1,n){
      ans=max(ans,time[i]);
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int N,i,j,k,count;
    string S;
    bool flag;
    count=0;
    flag=false;
    cin >> N;
    cin >> S;
    
    for (i=0;i<=N-2;i++){
        
        if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
            count+=1;
        }
        
    }
    
    cout << count<<endl;

    return 0;
    
}


Measured memory_bytes: 3496
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)
#define REPV(i,a,b) for(int i = a; i>= b; --i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define ll long long
#define INF 100000
#define ff first
#define ss second
const int M=1e9+7;


void solve()
{
	ll n, d;
	cin>>n>>d;
	ll X[n], Y[n];
	REP(i,0,n)
	{
		cin>>X[i]>>Y[i];
	}
	ll req = d*d;
	int ans = 0;
	REP(i,0,n)
	{
		ll len = X[i]*X[i] + Y[i]*Y[i];
		if(len <= req)
		++ans;
	}
	cout<<ans<<"\n";
}


int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  
  
  	solve();
  
  return 0;
}


Measured memory_bytes: 6772
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    vector<int> a(4);
    int ans = 0;
    rep(i,4){
        char c; scanf("%c",&c);
        a[i] = c-'0';
    }

    for(int mask=0;mask<(1<<3);mask++){
        int cnt = a[0];
        rep(i,3){
            if(mask & (1<<i)){
                cnt += a[i+1];
            }else{
                cnt -= a[i+1];
            }
        }

        //cout << static_cast<bitset<3>>(mask) << " " << cnt << endl;

        if(cnt == 7){
            cout << a[0];
            rep(i,3){
                if(mask&(1<<i)){
                    cout << "+";
                }else{
                    cout << "-";
                }
                cout << a[i+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
N,T = map(int,input().split())
C = [list(map(int,input().split())) for _ in range(N)]

c_min = 10000
for i,j in C:
    if j > T:
        continue
    
    c_min = min(c_min,i)

if c_min == 10000:
    print('TLE')
else:
    print(c_min)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
int main(){
  int a[3];
  rep(i,3){
    cin >> a[i];
  }
  sort(a,a+3);
  cout << a[0]+a[1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
const int N=10010;
const double PI=3.1415926535;
int a,b,x,y;
int main()
{
    cin>>a>>b>>x>>y;
    double theta=((x*60+y)/720.0-y/60.0)*2*PI;
    double res=a*a+b*b-2*a*b*cos(theta);
    printf("%.10lf",sqrt(res));
    
    return 0;
    
}

Measured memory_bytes: 4196
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
n,q=NM()
c=[0]+L()
Q=[L()+[i] for i in range(q)]
Q.sort(key=lambda x:x[1])
ans=[0]*(q)
lastapp=[0 for i in range(n+1)]

No=2
while No<=n:
    No*=2
tree=[0]*(2*No)

def update(k,x):
    k+=No-1
    tree[k]=x
    while k>0:
        k=(k-1)//2
        tree[k]=tree[k*2+1]+tree[k*2+2]

def add(k,x):
    k+=No-1
    while k>=0:
        tree[k]+=x
        k=(k-1)//2

def query(l,r):
    L=l+No-1
    R=r+No-1
    s=0
    while L<=R:
        if R&1:
            s+=tree[R]
            R-=2
        else:
            R-=1
        if L&1:
            L-=1
        else:
            s+=tree[L]
        L>>=1;R>>=1
    return s
j=1
for l,r,i in Q:
    while j<=r:
        t=c[j]
        add(lastapp[t],-1)
        add(j,1)
        lastapp[t]=j
        j+=1
    ans[i]=query(l,r)
for i in ans:
    print(i)

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

const int N = 100050;
vector<int>vc[N];
int dp[N];
int n,m;

int rec(int p)
{
    int &ret=dp[p];
    if(ret!=-1) return ret;
    ret=0;
    for(int i=0; i<vc[p].size(); i++)
    {
        ret=max(ret,rec(vc[p][i]));
    }
    ret=ret+1;
    return ret;
}

int main()
{
    scanf("%d %d",&n,&m);
    for(int i=1; i<=m; i++)
    {
        int u,v;
        scanf("%d %d",&u,&v);
        vc[u].push_back(v);
    }
    memset(dp,-1,sizeof dp);
    int ans=0;
    for(int i=1; i<=n; i++) ans=max(ans,rec(i));
    printf("%d\n",ans-1);



}


Measured memory_bytes: 8192
import java.util.*;

public class Main{


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

		int n = scan.nextInt();
		int[][] e = new int[n+1][n+1];
		for(int i = 1; i <= n; i++){
			int u = scan.nextInt();
			int k = scan.nextInt();
			for(int j = 0; j < k; j++){
				int v = scan.nextInt();
				e[u][v] = 1;
			}
		}

		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				if(j !=n)
					System.out.print(e[i][j] + " ");
				else
					System.out.println(e[i][j]);
	}
}

Measured memory_bytes: 32328
import numpy as np

def judge(s):
    l = len(s)
    for i in range(int(l/2)):
        if(s[i] != s[l-1-i]):
            return False
    return True

def main():
    args = input().rstrip().split(' ')
    S = np.array([c for c in args[0]])
    l = len(S)
    s1 = np.array([S[i] for i in range(0, int(l/2))])
    s2 = np.array([S[i] for i in range(int(l/2)+1, l)])
    if(judge(S) and judge(s1) and judge(s2)):
        print('Yes')
    else:
        print('No')
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 12416
#include <iostream>  
using namespace std;
 int main(){
     string s;
     cin>>s;
     int k=1;
     for(int i=0;i<s.length();i++){
         if(((i+1)%2)==0 &&  s[i]=='R'){
            
             cout<<"No";
             k=0;
             break;
         }else if(((i+1)%2)!=0 && s[i]=='L'){
             
             cout<<"No";
             k=0;
             break;
         }
     }
     if(k==1){
         cout<<"Yes";
     }
     return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;

  int x=c-a;
  int y=d-b;

  string s="";
  rep(i,x) s+="R";
  rep(i,y+1) s+="U";
  rep(i,x+1) s+="L";
  rep(i,y+1) s+="D";
  s+="R";
  s+="D";
  rep(i,x+1) s+="R";
  rep(i,y+1) s+="U";
  rep(i,x+1) s+="L";
  rep(i,y) s+="D";

  cout << s << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		
		int[][][] houseInfo = new int[4][3][10];	// ?£?/????????¢/??¨?±? number
		
		for (int i = 0; i < n; i++) {
			int b = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int v = sc.nextInt();
		
			houseInfo[b-1][f-1][r-1] += v;
		}

		for(int b = 0; b < 4; b++) {
			int[][] bInfo = houseInfo[b];
			
			for(int[] fInfo : bInfo) {
				for(int h : fInfo) {
					System.out.print(" " + h);
				}
				System.out.println();
			}
			
			if(b != 3) {
				for (int i = 0; i < 20; i++) {
					System.out.print("#");
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 29244
/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

int n;
string s;

string _mul(string s, int m) {
	string res;
	reverse(s.begin(), s.end());
	int sz = s.size();
	int remain = 0;
	s[n] = '0';
	for (int i = 0; i <= sz; i++) {
		int t = (s[i] - '0') * m;
		int k = t / 10;
		t %= 10;
		t += remain;
		k += t / 10;
		t %= 10;
	//	cout << t << " OOPO \n";
		remain = k;
		res += char(t + '0');
	}
//	cout << res << "   " << s << "  " << m << "\n";
	while (res[(int)res.size() - 1] == '0')
		res.pop_back();
	reverse(res.begin(), res.end());
	return res;
}

string _sum(string s, int m) {
	string ss = to_string(m);
//	cout << m << "\n";
	reverse(ss.begin(), ss.end());
	reverse(s.begin(), s.end());
	string res;
	int remain = 0;
	int sz1 = s.size();
	int sz2 = ss.size();
	if (sz1 < sz2)
		for (int i = sz1; i < sz2; i++)
			s += '0';
	if (sz1 > sz2)
		for (int i = sz2; i < sz1; i++)
			ss += '0';
	int sz = s.size();
	s += '0', ss  += '0';
	for (int i = 0; i <= sz; i++) {
		int t = (s[i] - '0') + (ss[i] - '0');
		int k = t / 10;
		t %= 10;
		t += remain;
		k += t / 10;
		t %= 10;
		remain = k;
		res += char(t + '0');
	}
	while (res[(int)res.size() - 1] == '0')
		res.pop_back();
	reverse(res.begin(), res.end());
	return res;
}


bool solve(int m) {
	string ss = _mul(s, 9);
	ss = _sum(ss, 9 * m);
	long long s = 0;
	for (int i = 0; i < ss.size(); i++)
		s += (ss[i] - '0');
	return (s <= 9 * m);
}

int main() {
	cin >> s;
	n = s.size();
	int l = 0, r = n;
//	cout << l << "  " << r << "\n";
//	cout << _mul(s, 9) << "\n";
//	cout << _sum(_mul(s, 9), 315) << " popo \n";
	while (r - l > 1) {
		int mid = (r + l) / 2;
	//	cout << mid <<  " OPOPOPOPO \n";
		if (solve(mid))
			r = mid;
		else
			l = mid;
	}
	cout << r << "\n";
}




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


int main(){

	int size;
	cin >> size;

	struct triangle{
		int elm[3];

		bool isRightTriangle(){
			for (int x = 0; x < 3; x++){
				for (int y = 0; y < 3; y++){
					for (int z = 0; z < 3; z++){
						if (x == z)continue;
						if (y == z)continue;
						if (elm[x] * elm[x] + elm[y] * elm[y] == elm[z] * elm[z])return true;
					}
				}
			}
			return false;
		}
	};

	triangle *ary = new triangle[size];

	for (int i = 0; i < size; i++){
		cin >> ary[i].elm[0] >> ary[i].elm[1] >> ary[i].elm[2];
	}

	for (int i = 0; i < size; i++){
		cout << (ary[i].isRightTriangle() ? "YES" : "NO") << endl;
	}

	delete[] ary;

	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define fastio (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using namespace std;

int main() {
    fastio;
    string top, mid, bot;
    cin >> top >> mid >> bot;
    cout << top[0] << mid[1] << bot[2] << endl;
}

Measured memory_bytes: 3520
import collections
n=input()
a=list(map(int,input().split()))
b=set(a)
c=list(b)
c.sort()
cnt=collections.Counter(a)
if len(b)==1:
  if c[0]==0:
    print('Yes')
  else:
    print('No')
if len(b)==2:
  if c[0]==0 and cnt[c[1]]%2==0 and cnt[c[0]]*2>=cnt[c[1]]:
    print('Yes')
  else:
    print('No')
if len(b)==3:
  if c[0]==0:
    print('No')
  elif cnt[c[0]]==cnt[c[1]]==cnt[c[2]] and c[0]^c[1]==c[2]:
        print('Yes')
  else:
      print('No')
if len(b)>3:
  print('No')


Measured memory_bytes: 14876
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(10);

    vector<vector<int>> A(3, vector<int>(3, -1));
    for(int i=0; i<3; i++)
    {
        for(int j=0; j<3; j++)
        {
            int temp;
            cin >> temp;
            A.at(i).at(j) = temp;
        }
    }

    int N;
    cin >> N;

    for(int i=0; i<N; i++)
    {
        int temp;
        cin >> temp;

        for(int i=0; i<3; i++)
        {
            for(int j=0; j<3; j++)
            {
                if(A.at(i).at(j) == temp)
                {
                    A.at(i).at(j) = 0;
                }
            }
        }
    }

// 縦横
    for(int i=0; i<3; i++)
    {
        if(A.at(i).at(0) == 0 && A.at(i).at(1) == 0 && A.at(i).at(2) == 0)
        {
            cout << "Yes" << endl;
            return 0;
        }

// 斜め
        if(A.at(0).at(i) == 0 && A.at(1).at(i) == 0 && A.at(2).at(i) == 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if(A.at(0).at(0) == 0 && A.at(1).at(1) == 0 && A.at(2).at(2) == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }

    if(A.at(2).at(0) == 0 && A.at(1).at(1) == 0 && A.at(0).at(2) == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
const int inf = 100000000;
const int MAX = 1<<10;

int N;
vector<int> l;
int A, B, C;
int a, b, c;
int ans;

void solve(int k, int p) {
    if(k <= N - 3) {
      //  cout << a << " " <<  b << " " << c << endl;
        getMin(ans, abs(a - A) + abs(b - B) + abs(c - C) + p);
    }
    if(k == N - 3) return ;
    solve(k + 1, p);
    a += l[k]; solve(k + 1, p + 10); a -= l[k];
    b += l[k]; solve(k + 1, p + 10); b -= l[k];
    c += l[k]; solve(k + 1, p + 10); c -= l[k];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> A >> B >> C;
    vector<int> tl(N);
    FORO(i, N) cin >> tl[i];
    ans = inf;
    FORO(i, N) {
        FORO(j, N) {
            if(i == j) continue; 
            FORO(k, N) {
                if(j == k || k == i) continue;
                l.clear();
                a = tl[i]; b = tl[j]; c = tl[k];
                FORO(t, N) {
                    if(t != i && t != j && t != k) {
                        l.pb(tl[t]);
                    }
                }
                solve(0, 0);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <map>
#include<queue>

const int INF = 1 << 28;
using namespace std;
using Graph = vector<vector<int>>;

template<class T> bool chmin(T &a, T &b) { if (a > b) { a = b; return 1; }return 0; }
template<class T> bool chmax(T &a, T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T, class U> using P = pair<T, U>;

vector<int> seen(50,-1);
int counter_for_dfs = 0;
void dfs(Graph &G, int v) {
	seen[v] = counter_for_dfs;
	counter_for_dfs++;
	for (auto v_next : G[v]) {
		if (seen[v_next]>=0)continue;

		dfs(G, v_next);
	}
}

void bfs(Graph &G) {
	vector<int> dist(G.size(), -1);
	queue<int> que;
	
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
		}
	}
	for (auto i : dist) {
		cout << i << " ";
	}
}

double distance(P<double,double> a,P<double,double> b) {
	return sqrt(pow(a.first - b.first, 2) + pow(a.second - b.second,2));
}
int main()
{
	int n;
	std::cin >> n;
	vector<int> p;
	vector<int> b;
	for (int i = 0; i < n; i++) {
		int a;
		std::cin >> a;
		p.push_back(a);
		b.push_back(a);
	}
	std::sort(b.begin(), b.end());
	int counter = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] != b[i])counter++;
	}
	std::string result;
	if (counter > 2) {
		result = "NO";
	}
	else {
		result = "YES";
	}

	std::cout << result;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		int inputNum = 0;
		int count = 0;

		while (sc.hasNext()) {
			inputNum = sc.nextInt();
			count = 0;
			for (int i = 0; i <= 9; i++) {
				for (int j = 0; j <= 9; j++) {
					for (int k = 0; k <= 9; k++) {
						for (int l = 0; l <= 9; l++) {
							if (inputNum == i + j + k + l)
								count += 1;
						}
					}
				}
			}
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 26328
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	int n,ans;
	string s;
	ans=0;
	cin >>s;
	if  (s[0]=='R'){
		if (s[1]=='R'){
			if (s[2]=='R')ans=3;
			else ans=2;
		}
		else{
			ans=1;
		}
	}
	else{
		if (s[1]=='R' && s[2]=='R') ans=2;
		else if (s[1]=='R' || s[2]=='R') ans=1;
	}
	cout <<ans<<endl;
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  vi p(n);
  REP(i, n) { cin >> p[i]; }
  int ans = 1;
  int mini = p[0];
  FOR(i, 1, n) {
    if (p[i] < mini) {
      ans++;
      mini = p[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;

const std::string ans[2] = { "No\n", "Yes\n" };
constexpr ll MOD = 1'000'000'007;
// constexpr ll MOD = 998'244'353;
int main() {
    using namespace std;
    int n;
    cin >> n;
    cout << ans[(n/100==7 || (n/10)%10==7 || n%10==7)];
    return 0;
}



Measured memory_bytes: 3596
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if (a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if (b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if (b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if (c <= a && a <= b )
        cout << c << " " << a << " " << b << endl;
    else
        cout << c << " " << b << " " << a << endl;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define INFTY 1000000002
using namespace std;
int counts,A[500002],L[250002],R[250002],n;
void merge(int *,int,int);
void mergeSort(int *,int,int);

int main(){
  int i;
  counts=0;
  cin>>n;
  for(i=0;i<n;i++)cin>>A[i];
  
  mergeSort(A,0,n);
  
  for(i=0;i<n;i++)if(i==0)cout<<A[i]; else cout<<" "<<A[i];
  cout<<endl<<counts<<endl;;
}

void merge(int A[],int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
    }
    counts++;
  }
}

void mergeSort(int A[],int left,int right){
  if(left+1<right){
    int  mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}



Measured memory_bytes: 6992
# include<iostream>
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <set>
using namespace std;

long long A[100100];
long long mi[100100];
const long long mod = 1e9+7;
long long m(long long x){
    long long ans = 1;
    long long temp = x;
    long long cnt = mod-2;
    while(cnt){
        if (cnt&1) ans=ans*temp%mod;
        temp = temp*temp%mod;
        cnt>>=1;
    }
    return ans;
}
int main(void){
    long long N;
    scanf("%lld",&N);
    mi[0] = 1;
    for (long long i=1;i<=N;i++) mi[i] = mi[i-1]*i%mod;
    long long temp = mi[N-1];
    long long anss = 0;
    long long t = 0;
    scanf("%lld",&A[1]);
    for (long long i=2;i<=N;i++){
        scanf("%lld",&A[i]);
        long long tt = A[i]-A[i-1];
        t+=temp*m(i-1);
        t%=mod;
        anss+=tt*t;
        anss%=mod;
    } 
    cout<<anss<<endl;
    return 0;
}

Measured memory_bytes: 1792
MOD = 10 ** 9 + 7


class Combination:
    """
    初期化時に O(N) の計算を行っておくことで O(1) で nCk (mod MOD) の計算を行える
    """

    def __init__(self, N):
        self.fact = [1] * (N + 1)

        for i in range(1, N + 1):
            self.fact[i] = (self.fact[i - 1] * i) % MOD

        self.invmod = [1] * (N + 1)
        self.invmod[N] = pow(self.fact[N], MOD - 2, MOD)

        for i in range(N, 0, -1):
            self.invmod[i - 1] = (self.invmod[i] * i) % MOD

    def __call__(self, n, k):
        if n < 0 or k < 0 or n < k:
            return 0
        elif n == 0 or k == 0 or n == k:
            return 1
        else:
            return self.fact[n] * \
                (self.invmod[k] % MOD) * (self.invmod[n - k] % MOD)


def main():
    n, k = list(map(int, input().split()))
    cmb = Combination(2001)

    for i in range(1, k + 1):
        if i > n - k + 1 or i > k:
            print(0)
        else:
            ans = cmb(n - k + 1, i) * cmb(k - 1, i - 1) % MOD
            print(ans)


main()

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

int solve(int a){
  int res = 0;
  if(a == 1) res = 300000;
  if(a == 2) res = 200000;
  if(a == 3) res = 100000;
  
  return res;
}

int main() {
  int x, y;
  cin >> x >> y;
  
  int ans = solve(x) + solve(y);
  if(ans == 600000) ans += 400000;
  
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main( void )
{
	int n;
	int map[101];
	unsigned long long sum[101][21];
	while(cin >> n) {
		int MAX = 0;
		for(int i=0; i < 101; ++i) {
			for(int j=0; j < 21; ++j) {
				sum[i][j] = 0;
			}
		}
		--n;
		for(int i=0; i < n; ++i) {
			cin >> map[i];
		}
		cin >> MAX;
		sum[1][map[0]] = 1;
		for(int i=1; i < n; ++i) {
			for(int j=0; j < 21; ++j) {
				if(sum[i][j]) {
					int a = j + map[i];
					int b = j - map[i];
					if(0 <= a && a <= 20) {
						sum[i+1][a] += sum[i][j];
					}
					if(0 <= b && b <= 20) {
						sum[i+1][b] += sum[i][j];
					}
				}
			}
		}

		cout << sum[n][MAX] << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll a,b;
  cin>>a>>b;
  if(a*b==15)
    cout<<"*"<<endl;
  else if(a+b==15)
    cout<<"+"<<endl;
  else
    cout<<"x"<<endl;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
      	Scanner sc = new Scanner(System.in);
      	String n = sc.nextLine();
      	String a = sc.nextLine();
      	int N = Integer.parseInt(n);
      	int p = 0;
        String[] b = a.split(" ");
      	for (int j=0;j<N-1;j++){
      		if(Integer.parseInt(b[j])==Integer.parseInt(b[j+1])){
      				p++;
      				b[j+1] = "100";
      		}
      	}
      	System.out.println(p);
    }
}

Measured memory_bytes: 21716