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

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
    }

    int s, t;
    cin >> s >> t;
    s--, t--;
    vector<vector<int>> cnt(3, vector<int>(n, 1e9));
    cnt[0][s] = 0;
    priority_queue<int, vector<int>, greater<>> que[3];
    que[0].push(s);
    while (1) {
        bool change = false;
        for (int i = 0; i < 3; i++) {
            if (!que[i].empty()) {
                change = true;
                int a = que[i].top();
                que[i].pop();
                int c = cnt[i][a];
                for (int b : adj[a]) {
                    if (c + 1 < cnt[(i + 1) % 3][b]) {
                        cnt[(i + 1) % 3][b] = c + 1;
                        que[(i + 1) % 3].push(b);
                    }
                }
            }
        }
        if (!change) break;
    }
    if (cnt[0][t] == 1e9) {
        cout << -1 << endl;
        return 0;
    }
    cout << cnt[0][t] / 3 << endl;
}

Measured memory_bytes: 7296
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// get a integer
		int a = sc.nextInt();
		// get two integers separated with half-width break
		int b = sc.nextInt();
		int c = sc.nextInt();
		// get a string
		int cnt_5 = 0;
		int cnt_7 = 0;
				
		if(a == 5) {
			cnt_5++;
		} else if(a == 7) {
			cnt_7++;
		}
		
		if(b == 5) {
			cnt_5++;
		} else if(b == 7) {
			cnt_7++;
		}
		
		if(c == 5) {
			cnt_5++;
		} else if(c == 7) {
			cnt_7++;
		}
			
		if(cnt_5 == 2 && cnt_7 == 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
		
	}
}

Measured memory_bytes: 22612
import queue
import sys
imput = sys.stdin.readline

n,m = map(int,input().split()) 

conne = [[] for _ in range(n+1)]
dist = [999999]*(n+1)
par = [0] * (n+1)

for i in range(m):
    a,b = map(int,input().split()) 
    conne[a].append(b)
    conne[b].append(a)
    
q=queue.Queue()
dist[1] = 0
q.put((1,0))

while not q.empty():
    
    x,d = q.get()
    
    for i in conne[x]:
        if dist[i]==999999:
            q.put((i,d+1))
            par[i] = x
            dist[i] = d+1

if max(dist[1:]) == 999999:
    print("No")
    
else:
    print("Yes")    
    
    for i in par[2:]:
        print(i)
    

Measured memory_bytes: 104848
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define inf 1072114514

#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int min(int a, int b)
{
  if (a < b)
  {
    return a;
  }
  return b;
}

int sortfncsj(const void *a, const void *b)
{
  if (*(int *)a > *(int *)b)
  {
    return 1;
  }
  if (*(int *)a == *(int *)b)
  {
    return 0;
  }
  return -1;
}

int main(void)
{
  int i, n, k, a[524288], r = inf;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++)
  {
    scanf("%d", &a[i]);
  }
  qsort(a, n, sizeof(int), sortfncsj);
  for (i = k - 1; i < n; i++)
  {
    r = MIN(r, a[i] - a[i - k + 1]);
  }
  printf("%d\n", r);
  return 0;
}


Measured memory_bytes: 892
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {

    int n, k, q;
    
    cin >> n >> k >> q;
    
    int a[q], count[n];
    string ans[n];
    
    for(int i=0; i<n; i++) {
        count[i] = 0;
        ans[i] = "No";
    }
    
    for(int i=0; i<q; i++) {
        cin >> a[i];
        count[a[i]-1]++;
        //if(count[a[i]-1] > q - k) ans[a[i]-1] = "Yes";
    }
    
    for(int i=0; i<n; i++)
    {
        if(count[i] > q - k) ans[i] = "Yes";
    }
    
    for(int i=0; i<n; i++) cout << ans[i] << endl;
    
    
    
    return 0;
    
}


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

int main(){
    string s,t;
    cin>>s>>t;
   if(s.length()!=t.length()){
        cout<<"No";
    }if(s==t){
        cout<<"Yes";
    }else{
       string temp=s;
       for(int i=1;s!=t; ){
           reverse(s.begin(),s.end());
           reverse(s.begin(),s.begin()+i);
           reverse(s.begin()+i,s.end());
           if(temp==s)break;
           if(s==t){
              cout<<"Yes";
              return 0;
           }
       }
       cout<<"No";
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - *e**** ********e* *e****e* ****e**
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            int k = int.Parse(Console.ReadLine()) - 1;

            var chars = s.ToCharArray().Distinct().ToList();
            
            foreach(var c in chars)
            {
                if (c != s[k])
                {
                    s = s.Replace(c, '*');
                }
            }

            Console.WriteLine(s);
        }
    }
}

Measured memory_bytes: 13276
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {

    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input!{
        n: u64,
    }
    println!("{}", n.pow(3)+n.pow(2) +n)
}


Measured memory_bytes: 2092
#include <cstdio>
#include <algorithm>  

using namespace std;

int main()
{
    long long int n, k;
    scanf("%lld%lld", &n, &k);
    if(n== 0){
        printf("0");
    }
    else if(n>=k){
        printf("%lld", min(n%k, abs(n%k-k)));
    }
    else{
        if(k-n>n){
            printf("%lld", n);
        }
        else{
            printf("%lld", k-n);
        }
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll dp[110][2];

int main() {

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

    dp[0][0] = 1; //dp[0][1] = 0になっている
    for (ll i = 0; i < n; ++i) {
        for (ll j = 0; j < 2; ++j) {
            dp[i + 1][j] += dp[i][j]; //選ばない
            dp[i + 1][(j + a[i]) % 2] += dp[i][j]; //選ぶ
        }
    }

    cout << dp[n][p] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int s[11];
int main(){
	int n, m, q, tot, maxn=0;
	cin >> n >> m >> q;
	int a[q+1], b[q+1], c[q+1], d[q+1];
	for (int i=1; i<=q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
	while (s[0]!=1){
		tot=0;
		s[n]++;
		int x=n;
		while (s[x]>=m&&x>0){
			s[x-1]++;
			x--;
			for (int i=x+1; i<=n; i++) s[i]=s[x];
		}
		for (int i=1; i<=q; i++)
			if (s[b[i]]-s[a[i]]==c[i]) tot+=d[i];
		maxn=max(maxn, tot);
	}
	cout << maxn << endl;
	return 0;
}

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

char abcd[5];
int main(){
    cin >> abcd;
    int nums[4];
    int sum = 0;
    for(int i = 0; i < 4; i++){
        nums[i] = abcd[i] - '0';
        sum += nums[i];
    }
    for(int i = 0; i < (1 << 3); i++){
        int tmp = sum;
        for(int j = 0; j < 3; j++){
            if((i >> j) & 1 == 1){
                tmp -= 2 * nums[j + 1];
            }
        }
        if(tmp == 7){
            cout << nums[0];
            for(int j = 0; j < 3; j++){
                cout << (((i >> j) & 1) ? '-' : '+') << nums[j+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		
		int ans = 0;
		for(int i = 1;i <= N;++i) {
			int num = i;
			int x = 0;
			for(int j = (int)Math.log10(N);j >= 0;--j) {
				x += num / (int)Math.pow(10, j);
				num = i % (int)Math.pow(10, j);
			}
			if(A <= x && x <= B)
				ans += i;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define reptArIn(i,a,b,ar) for( i=a; i<b; ++i) cin>>ar[i];
#define fo(i,a,b) for(i=a; i<b; ++i)
#define foe(i,a,b) for(i=a; i<=b; ++i)
#define rep(i,n) for(i=1;i<=n;i++)
#define all(a) a.begin(), a.end()
#define pb push_back
#define ins insert
#define mk make_pair
#define f first
#define s second
#define mod 1000000007
#define vi vector<int>
#define vll	vector<ll>
#define vvi	vector<vi>
#define pii	pair<int,int> //typedef pair<int,int> pii;
#define pll	pair<ll , ll>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  new_data_set;
//mp.reserve(4096);
//mp.max_load_factor(0.25);

int main()
{
	ll n,w,i,j;
	cin>>n>>w;
	ll wt[n],val[n];
	ll dp[n+1][w+1];
	fo(i,0,n)
	{
		cin>>wt[i]>>val[i];
	}
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=w;j++)
		{
			if(i==0||j==0)
			dp[i][j]=0;
			else if(wt[i-1]<=j)
			dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
			else
			dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][w]<<endl;
	return 0;
}

Measured memory_bytes: 79104
import sys
input = sys.stdin.readline

def main():
    N,K = map(int,input().split())
     
    def modpow(a,n,mod):
        res = 1
        while n > 0:
            if n & 1:
                res = res * a % mod
            a = a * a % mod
            n >>= 1
        return res
     
    def modinv(a,mod):
        return modpow(a,mod - 2,mod)
     
    def cnk(a,b):
        MOD = 10**9+7
        ret = 1
        for i in range(b):
            ret *= (a-i)
            ret %= MOD
            ret = ret * modinv(i+1,MOD) % MOD
        return ret
     
     
    for i in range(1,K+1):
        if i > N - K +1:
            print(0)
        elif i == 1:
            print(N-K+1)
        else:
            print(cnk(N-K+1,i)*cnk(K-1,i-1)%(10**9+7))
if __name__ == '__main__':
    main()


Measured memory_bytes: 44892
// https://atcoder.jp/contests/agc031/tasks/agc031_a

fun main() {
    agc031a()
}

fun agc031a() {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    val BASE_NUM = 1_000_000_007L
    val reveal = s.groupingBy { it }.eachCount()
    val count = reveal.values.map { (it + 1).toLong() }.reduce { acc, i ->
        acc * i % BASE_NUM
    }
    println(count - 1)
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll H, W;
    cin >> H >> W;
    vector<string> A(H+2);
    REP(i,1,H+1) {
        cin >> A[i];
        A[i] = "." + A[i] + ".";
    }
    REP(i,0,W+1) {
        A[0] += ".";
        A[H+1] += ".";
    }

    ll i = 1, j = 1;
    bool f = true;
    ll d = 0;
    while(i < H+1 && j < W+1) {
        if(i == H && j == W) {
            if(d == 0 && A[i][j-1] == '#') {
                f = false;
                break;
            }
            else if(d == 1 && A[i-1][j] == '#') {
                f = false;
                break;
            }
            else break;
        }
        if(A[i+1][j] == '#' && A[i][j+1] == '.') {
            if(d == 0 && A[i][j-1] == '#') {
                f = false;
                break;
            }
            else if(d == 1 && A[i-1][j] == '#') {
                f = false;
                break;
            }
            else {
                ++i;
                d = 0;
            }
        }
        else if(A[i+1][j] == '.' && A[i][j+1] == '#') {
            if(d == 0 && A[i][j-1] == '#') {
                f = false;
                break;
            }
            else if(d == 1 && A[i-1][j] == '#') {
                f = false;
                break;
            }
            else {
                ++j;
                d = 1;
            }
        }
        else {
            f = false;
            break;
        }
    }
    if(f) PR("Possible");
    else PR("Impossible");

    return 0;
}

/*

*/

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;

int main(){
    int N;cin>>N;
    vector<int> vec(N);
    int tmp=0,res=0;
    for(int i=0;i<N;i++){
        int x;
        cin >> x;
        vec[i] = x;
        tmp = tmp + x;
    }
    int max = *max_element(vec.begin(),vec.end());
    if (max<tmp-max){
        cout << "Yes" <<endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main(){
    queue<pair<string, ll>> que;
    ll n, q;
    cin >> n >> q;
    REP(i, n){
        string name;
        ll t;
        cin >> name >> t;
        que.emplace(name, t);
    }

    ll cur = 0;
    while(!que.empty()){
        auto x = que.front(); que.pop();
        if(x.second <= q){
            cur += x.second;
            cout << x.first << ' ' << cur << endl;
        }else{
            cur += q;
            que.emplace(x.first, x.second - q);
        }
    }
    return 0;
}



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

using namespace std;
using ll = long long;

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

    int n, q;
    cin >> n;
    vector<int> s(n);
    for(int i = 0; i < n; ++i) cin >> s[i];
    cin >> q;
    int t, ans = 0;
    for(int i = 0; i < q; ++i) {
        cin >> t;
        if(t == *lower_bound(s.begin(), s.end(), t)) ans++;
    }

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

    return 0;
}


Measured memory_bytes: 3272
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int[] b = new int[a];
    int sum = 0; 
    int ans = 0;
    for(int i = 0;i < b.length;i++){
      b[i] = sc.nextInt();
      sum += b[i];
    }
    for(int j = 1;j < b.length;j++){
      int half = 0;
      int tmp = 0;
      for(int x = 0;x < j;x++){
        half += b[x];
        tmp = sum - (half * 2);
        tmp = Math.abs(tmp);
        if(x == 0 ||tmp < ans){
          ans = tmp;
        }
      }
    }
    System.out.println(ans);
  }
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector <long long> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int length;
    length=unique(a.begin(),a.end())-a.begin();
    int j;
    for(j=0;j<length-1;j++)
    {
        cout<<a[j]<<" ";
    }
    cout<<a[j]<<endl;
    return 0;
}



Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define ll long long

using namespace std;

pair<int,int> ar[103];
ll dp[103][100005];

int main(){
    std::ios_base::sync_with_stdio(false); std::cin.tie(0);
    int N,W,a,b;
    cin >> N >> W;
    for(int i=1; i < N+1; i++){
        cin >> a >> b;
        ar[i] = make_pair(a,b); //weight value
    }
    //for(int i=0; i < 100002;i++ ) dp[0][i] = 0; //weight = 0
    //for(int i=0; i < 101; i++) dp[i][0]= 0; // no. of items = 0
    for(int i=1; i <= N; i++){
        for(int j=1; j <= W; j++){
            //cout << i  << " " << j << " ";
            int weight = ar[i].first; int value = ar[i].second;
            ll ans2 = 0;
            ll ans1 = dp[i-1][j]; //don't carry ith item
            if( j >= weight ){
                ans2 = dp[i-1][j-weight] + value; //carry ith item
            }
            //cout << ans1 << " " << ans2 << "\n";
            dp[i][j] = max(ans1,ans2);
        }
    }
    /*for(int i=1; i <= N; i++){
        for(int j=1; j <= W; j++){
            cout << dp[i][j] << " ";
        }
        cout << "\n";
    }
    cout << "\n";*/
    cout << dp[N][W];

}


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

int main(){
  int n;
  cin>>n;
  int dp[n+1][3];
  for(int i=0;i<n+1;i++){
    for (int j=0;j<3;j++){
      dp[i][j]=0;
    }
  }
  
  int a[n][3];
  for (int i=0;i<n;i++){
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  }
  
  dp[0][0]=a[0][0];
  dp[0][1]=a[0][1];
  dp[0][2]=a[0][2];
  
  for (int i=0;i<n-1;i++){
    for(int j=0;j<3;j++){
      for (int k=0;k<3;k++){
        if(j==k){
          continue;
        }
        dp[i+1][k]=max(dp[i][j]+a[i+1][k],dp[i+1][k]);
      }
    }
  }
  
  cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<endl;
  return 0;
}

    
  









Measured memory_bytes: 2560
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

ll gcd(ll x,ll y){
  if(x%y == 0) return y;
  else return gcd(y,x%y);
}
int main(){
  int h,w;
  cin >> h >> w;
  char s[h][w];
  int dist[h][w];
  int ans = 0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s[i][j];
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j] == '#') continue;
      for(int ii=0;ii<h;ii++){
        for(int jj=0;jj<w;jj++){
          dist[ii][jj] = MOD;
        }
      }
      dist[i][j] = 0;
      queue<pair<int,int> > q;
      q.push(make_pair(i,j));
      while(!q.empty()){
        pair<int,int> now = q.front();
        q.pop();
        int x = now.first;
        int y = now.second;
        ans = max(ans,dist[x][y]);
        if(0 <= x-1 && dist[x-1][y] == MOD && s[x-1][y] == '.'){
          dist[x-1][y] = dist[x][y]+1;
          q.push(make_pair(x-1,y));
        }
        if(0 <= y-1 && dist[x][y-1] == MOD && s[x][y-1] == '.'){
          dist[x][y-1] = dist[x][y]+1;
          q.push(make_pair(x,y-1));
        }
        if(x+1 < h && dist[x+1][y] == MOD && s[x+1][y] == '.'){
          dist[x+1][y] = dist[x][y]+1;
          q.push(make_pair(x+1,y));
        }
        if(y+1 < w && dist[x][y+1] == MOD && s[x][y+1] == '.'){
          dist[x][y+1] = dist[x][y]+1;
          q.push(make_pair(x,y+1));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int N,K,sum=0,kinds;
    cin>>N>>K;
    map<int,int> mp;
    rep(i,N){
        int x;
        cin>>x;
        mp[x]++;
    }
    kinds=mp.size();
    vi B(kinds);
    int o=0;
    for(auto x:mp){
        B[o]=x.second;
        o++;
    }
    if(kinds<=K){
        cout<<0<<endl;
        return 0;
    }
    sort(ALL(B));
    for(auto x:B){
        //cout<<sum<<endl;
        sum+=x;
        kinds--;
        if(kinds<=K)break;
    }
    cout<<sum<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main() {
	ll n, ans = 0;
	cin >> n;
	ll ncpy = n;
	for (ll i = 2; i * i <= ncpy; i++) {
		int q = i;
		while(n % q == 0) {
			n /= q;
			q *= i;
			ans++;
		}
		while(n % i == 0) n /= i;
	}
	if (n > 1) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
N, Y = map(int, input().split())

flag = True

for i in range(Y // 10000 + 1):
    for k in range((Y - 10000*i) // 5000 + 1):
        l = int((Y - 10000*i - 5000*k) / 1000)
        if (i + k + l) == N:
            print(str(i) + " " + str(k) + " " + str(l))
            flag = False
            break
    if flag == False:
        break
if flag:
    print("-1 -1 -1")

Measured memory_bytes: 3188
n = int(input())
mod = 1000000007

dp = [[[[0]*4 for i in range(4)] for i in range(4)] for i in range(101)]

# 0,1,2,3 ="AGCT"
for num in range(1):
  for c1 in range(4):
    for c2 in range(4):
      for c3 in range(4):
        for add in range(4):
          if c2 == 0 and c1 == 1 and add ==2:
            continue
          if c2 == 0 and c1 == 2 and add ==1:
            continue
          if c2 == 1 and c1 == 0 and add ==2:
            continue  
          if c3 == 0 and c2 == 1 and add ==2:
            continue
          if c3 == 0 and c1 == 1 and add ==2:
            continue
          dp[3][add][c1][c2] = 1

for num in range(1,n):
  for c1 in range(4):
    for c2 in range(4):
      for c3 in range(4):
        for add in range(4):
          if c2 == 0 and c1 == 1 and add ==2:
            continue
          if c2 == 0 and c1 == 2 and add ==1:
            continue
          if c2 == 1 and c1 == 0 and add ==2:
            continue  
          if c3 == 0 and c2 == 1 and add ==2:
            continue
          if c3 == 0 and c1 == 1 and add ==2:
            continue
          dp[num+1][add][c1][c2] += dp[num][c1][c2][c3]
          dp[num+1][add][c1][c2] %= mod

ans = 0

for c1 in range(4):
  for c2 in range(4):
    for c3 in range(4):
      ans += dp[n][c1][c2][c3]
      ans %= mod
if n ==1:
  print(4)
elif n ==2:
  print(16)
else:
  print(ans)

Measured memory_bytes: 3316
n = int(input())
dat = []
dat2 = []
for i in range(n):
    a = int(input())
    dat.append(a)
    dat2.append(a)
dat.sort()
m = dat[n-1]
#print(m)
for i in range(n):
    #print("in: {0}".format(dat2[i]))
    if dat2[i] == m:
        print(dat[n-2])
    else:
        print(m)

Measured memory_bytes: 81880
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int       lint;
typedef vector<int>         vi;
typedef vector<lint>        vl;
typedef pair<int, int>      pii;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<lint>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define M               10000000
#define MOD             10000007
#define INF             1e9+7
#define REP(i,a,b)      for(int i = int(a); i <= int(b); i++)
#define REPL(i,a,b)     for(lint i = lint(a); i <= lint(b); i++)
#define fastIO()        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    deque<char>x, y, z;

    REP(i, 0, a.size() - 1) x.push_back(a[i]);
    REP(i, 0, b.size() - 1) y.push_back(b[i]);
    REP(i, 0, c.size() - 1) z.push_back(c[i]);

    bool af = true, bf = false, cf = false;
    while(true){
        if(af){
            af = false;
            if(x.empty()){
                cout<<"A\n";
                break;
            }
            char k = x.front();
            x.pop_front();
            if(k == 'a') af = true;
            if(k == 'b') bf = true;
            if(k == 'c') cf = true;
        }
        else if(bf){
            bf = false;
            if(y.empty()){
                cout<<"B\n";
                break;
            }
            char k = y.front();
            y.pop_front();
            if(k == 'a') af = true;
            if(k == 'b') bf = true;
            if(k == 'c') cf = true;
        }
        else if(cf){
            cf = false;
            if(z.empty()){
                cout<<"C\n";
                break;
            }
            char k = z.front();
            z.pop_front();
            if(k == 'a') af = true;
            if(k == 'b') bf = true;
            if(k == 'c') cf = true;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import sys

mod = 10 ** 9 + 7
sys.setrecursionlimit(mod)

def modpow(a, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        half = modpow(a, p // 2)
        return half * half % mod
    else:
        return a * modpow(a, p - 1) % mod

def combinations(a, b):
    if 2 * b > a:
        return combinations(a, a - b)
    mul = 1
    div = 1
    for i in range(b):
        mul *= (a - i)
        div *= (i + 1)
        mul %= mod
        div %= mod
    return mul * modpow(div, mod - 2) % mod

N, M = map(int, input().split())
i = 2
ans = 1
while i * i <= M:
    if M % i == 0:
        c = 0
        while M % i == 0:
            c += 1
            M /= i
        ans *= combinations(N + c - 1, N - 1)
        ans %= mod
    i += 1

if M != 1:
    ans *= combinations(N + 1 - 1, N - 1)
    ans %= mod

print(ans)

Measured memory_bytes: 38768
#include <stdio.h>

int main(){
  int n;
  int p[20]={};
  scanf("%d",&n);
  int i;
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  int count = 0;
  int x,y;
  for(i=1;i<n-1;i++){
    x = p[i] - p[i-1];
    y = p[i] - p[i+1];
    if(x*y < 0) count+=1;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;



int main(void) {
	static constexpr uint64 MOD = 1000000007;
	uint32 n;
	std::string s;
	std::cin >> n >> s;
	uint64 dp[5003][5003] = {};
	dp[0][0] = 1;
	for (uint32 i = 1;i <= n;++i) {
		dp[i][0] = (dp[i - 1][1] * 2 + dp[i - 1][0]) % MOD;
		for (uint32 j = 1;j <= i;++j) {
			dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j + 1] * 2) % MOD;
		}
	}
	std::cout << dp[n][s.length()] << "\n";
	return 0;
}

Measured memory_bytes: 195840
#include <iostream>

using namespace std;
using ll = long long;
const int MX = 1000100;
ll f[MX],inv[MX],fi[MX];
constexpr ll mod = 1000000007;
void solve(){
    inv[1] = 1;
    for(int i=2;i<MX;i++){
        inv[i] = mod - (mod/i)*inv[mod%i]%mod;
    }
   f[0] = fi[0] = 1;
    for(int i=1;i<MX;i++){
        f[i] = f[i-1]*i%mod;
        fi[i] = fi[i-1]*inv[i]%mod;
    }
}

ll nck(ll n, ll k){
    if(n<0 || k<0 || n<k) return 0;
    return f[n]*fi[k]%mod*fi[n-k]%mod;
}

ll val(ll l,ll r, ll n){
    return (nck(r + n,n) - nck(l + n - 1,n) + mod)%mod;
}
int main(){
    ll i,j,n,m,l,r;
    cin >> n >> m >> l >> r;
    solve();
    ll ans1 = val(l,r,n),ans2 = 0,f = 1;
    for(i=0;i<=n - m;i++){
        ll sum = 0;
        for(j=0;(m + i)*j<=(r - m);j++){
            (sum += (val(l - (m + i)*(j + 1),r - (m + i)*(j + 1),n) - val(l - m*(j + 1) - i*j,r - m*(j + 1) - i*j,n) + mod)) %= mod;
        }
        ll x = nck(n - m,i)*sum%mod;
        ans2 += f*x;
        if(ans2<0) ans2 += mod;
        ans2 %= mod;
        f *= -1;
    }
    cout << (ans1 - nck(n,m)*ans2%mod + mod)%mod << endl;
}

Measured memory_bytes: 23808
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int a;

signed main() {
	cin >> a;
	cout << a + a * a + a * a*a << endl;
}

Measured memory_bytes: 3620
/*#include<iostream>
#include<string.h>

using namespace std;
const int inf = 1e7;
const int man = 5e2+10;
//int maze[man][man];
int vis[man],dis[man];
int c[15][15];
//int jishu[10];
int h,w;
/*
int dij(int u)
{
	memset(vis,0,sizeof(vis));
	for(int i =1 ;i <= 9 ;i++)
	{
		dis[i] = c[u][i];
	}
	vis[u] = 1;
	for(int i =1 ;i < 9;i++)//必须是小于9，不能等于，debug了好久。。。
	{
		int minn = inf ,v = -1;
		for(int j =1 ;j <= 9 ;j++)
		{
			if(!vis[j]&&dis[j]<minn)
			{
				v = j;
				minn = dis[j];
			}
		}
		vis[v] = 1;
		for(int j = 1; j <= 9 ;j++)
		{
			if(!vis[j])
			{
				dis[j] = min(dis[j],dis[v]+c[v][j]);
			}
		}
	}
	return dis[1];
}


void floyd()
{
	for(int k = 0; k <= 9 ;k++)
	{
		for(int i = 0 ;i <= 9 ;i++)
		{
			for(int j =0;j<= 9 ;j++)
			{
				c[i][j] = min(c[i][j],c[i][k] + c[k][j]);
			}
		}
	}
}

void solve()
{
	cin >> h >> w;
	 for (int i = 0; i < 10; i++)
       for (int j = 0; j < 10; j++)
             cin>>c[i][j];
//		floyd();
     int ans = 0;
     for(int i=0;i<h;i++)
         for (int j = 0; j < w ; j++)
		 {
		 	int A;
            scanf("%d", &A);
            if (A >= 0)
                 ans += c[A][1];
         }
		//cout << dij(8) << endl;
		cout << ans << endl;
}

int main()
{
	solve();
	return 0;
}
*/
#include<iostream>
#include<string.h>

using namespace std;
const int inf = 1e7;
const int man = 5e2+10;
int maze[man][man];
int vis[man],dis[man];
int c[15][15];
int jishu[10];
int h,w;

int dij(int u)
{
	memset(vis,0,sizeof(vis));
	for(int i =0 ;i <= 9 ;i++)
	{
		dis[i] = c[u][i];
	}
	vis[u] = 1;
	for(int i =0 ;i < 9;i++)//必须是小于9，不能等于，debug了好久。。。
	{
		int minn = inf ,v = -1;
		for(int j =0 ;j <= 9 ;j++)
		{
			if(!vis[j]&&dis[j]<minn)
			{
				v = j;
				minn = dis[j];
			}
		}
		vis[v] = 1;
		for(int j = 0; j <= 9 ;j++)
		{
			dis[j] = min(dis[j],dis[v]+c[v][j]);
		}
	}
	return dis[1];
}

void solve()
{
	cin >> h >> w;//单组输入.

		for(int i = 0; i < 10 ;i++)
		{
			for(int j = 0 ;j < 10 ;j++)
			{
				cin >> c[i][j];
			}
		}
		memset(jishu,0,sizeof(jishu));
		for(int i = 1 ; i <= w ;i++)
		{
			for(int j = 1; j<= h ;j++)
			{
				cin >> maze[i][j];
				if(maze[i][j] >= 0 )
				{
					jishu[maze[i][j]]++;
				}
			}
		}
		int ans = 0;
		//cout << dij(8) << endl;
		for(int i = 0 ; i <= 9 ;i++)
		{
			if(jishu[i])
			{
				int k = jishu[i];
				ans= ans +dij(i)*k;
			}
		//	cout << jishu[i] << endl;
		}
		cout << ans << endl;

}

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

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

#define INF   1000000000

int main(void) {
	int n, ans;
	vector<int> v;

	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];

	int av = accumulate(v.begin(), v.end(), 0) / n;
	ans = INF;
	for (int i = -1; i <= 1; ++i) {
		int x = av + i;
		if ((x < -100) || (x > 100))
			continue;
		int sum = 0;
		for (int j = 0; j < n; ++j)
			sum += (v[j] - x) * (v[j] - x);
		if (sum < ans)
			ans = sum;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

  int main(void)
{
  int a, b;
  scanf("%d %d", &a, &b);

  if(a < b)
    printf("a < b\n");

   else if(a > b) 
    printf("a > b\n");

   else 
    printf("a == b\n");

  return 0;
}

Measured memory_bytes: 580
m, d = map(int, input().split())
ans = 0
for i in range(2, m+1):
    for j in range(20, d+1):
        s = str(j)
        d10 = int(s[0])
        d1 = int(s[1])
        if d1 == 1 or d10 == 1:
            continue
        elif i == d1 * d10:
            #print(i,d10,d1)
            ans += 1
print(ans)


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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
ll n;
    ci(n);
  vll A(n);
  if(n==1){
    co(1)
  }
  else{
    A[0]=2;
    A[1]=1;
  FOR(i,2,n){
    A[i]=A[i-1]+A[i-2];
  }
  co(A[n-1]+A[n-2])
}
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

    int a = sc.nextInt();
    int b = sc.nextInt();
    double C = Math.toRadians(sc.nextInt());
    double c = Math.sqrt((a*a) + (b*b) - 2 * a * b * Math.cos(C));

    double L = a + b + c;
    double h = b * Math.sin(C);
    double S = a * h / 2;

    System.out.format("%f\n%f\n%f\n", S, L, h);
  }
}


Measured memory_bytes: 26492
let () = print_endline @@ Scanf.scanf "%d %d %d %d" @@ fun sx sy tx ty ->
  String.make (tx - sx) 'R' ^
  String.make (ty - sy) 'U' ^
  String.make (tx - sx) 'L' ^
  String.make (ty - sy) 'D' ^
  "D" ^
  String.make (tx - sx + 1) 'R' ^
  String.make (ty - sy + 1) 'U' ^
  "L" ^
  "U" ^
  String.make (tx - sx + 1) 'L' ^
  String.make (ty - sy + 1) 'D' ^
  "R"

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

#define MAX 100000

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

	int l, r ;
	int tempL=0, tempR=MAX;
	for (int i = 0; i < m; i++) {
		cin >> l >> r;
		tempL = max(l, tempL);
		tempR = min(r, tempR);
	}

	int ans = tempR - tempL + 1;
	if (ans < 0) { ans = 0; }
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1

    def connected_count(self):
        return sum(x < 0 for x in self.table)


n, m, q = list(map(int, input().split()))
uft = UnionFind(n)
hyper_paths = set()

for line in sys.stdin:
    a, b, c = list(map(int, line.split()))
    if c == 1:
        hyper_paths.add((a, b))
        continue
    uft.union(a, b)

for a, b in hyper_paths:
    if uft.find(a, b):
        print('No')
        exit()

cc = uft.connected_count()

min_m = n if len(hyper_paths) > 0 else n - 1
max_m = n - cc + cc * (cc - 1) // 2

print('Yes' if min_m <= m <= max_m else 'No')


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

bool visited[200005];
vector<int> adj[200005];

int dfs(int u) {
    if (visited[u])
        return 0;
    visited[u] = true;
    int ret = 1;
    for (int v : adj[u])
        ret += dfs(v);
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m;
    cin >> n >> m;
    for (int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    int ret = 0;
    for (int i=0; i<n; i++)
        ret = max(ret, dfs(i));
    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 20968
// https://atcoder.jp/contests/abc136/tasks/abc136_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    string S;
    cin >> S;
    int len = S.length(), idx = 0;
    vector<int> ans(len);
    FOR(i, 1, len) {
        // RL の境界を探す
        if (S[i - 1] == 'R' && S[i] == 'L') {
            // 連続するLを探す
            int a = i + 1;
            while (a < len && S[a] == 'L') {
                a++;
            }
            a--;
            int t = a - idx + 1;
            if ((i - idx) % 2 == 0) {
                ans[i - 1] = t / 2;
                ans[i] = CEIL(t, 2);
            } else {
                ans[i - 1] = CEIL(t, 2);
                ans[i] = t / 2;
            }
            i = a;
            idx = i + 1;
        }
    }
    REP(i, len) { cout << ans[i] << (i == len - 1 ? "\n" : " "); }
}
signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 4200
P=0
L=[]
N,D = map(int,input().split())

# 座標リストLを作成
for i in range(N):
    X = list(map(int,input().split()))
    L.append(X)

# 座標リストを1から順々に最後の座標までaに入れつつループ 
for a in range(0,N-1):  
    #print(L[a])
    for b in range(a+1,N): #a+1番目から最後までの座標を順にループ
       # print(" " + str(L[b]))
        f = 0
        s = 0
        for i,j in zip(L[a],L[b]): #対応要素毎にループ
            f = f + (i-j)**2  
            #print("  " +str(i)+ ";"+str(j)+";;"+str(f))   
        f = f **0.5 #それぞれの２乗を足したものをルートをとる
        #print(f)
        P = P + f.is_integer()  #fが整数ならばPを１増やす　違えば増やさない
print(P)

Measured memory_bytes: 3188
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, char> Pc;
typedef pair<int, string> Ps;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
struct Node { int data; Node *left, *right; Node(int data) : data(data), left(NULL), right(NULL) {} };
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int N, M;
  cin >> N >> M;
  vector<ll> H(N);
  REP(i, N) cin >> H[i];
  int a, b;
  vector<bool> isGood(N, true);
  REP(i, M) {
    cin >> a >> b;
    a--, b--;
    if (H[a] <= H[b]) {
      isGood[a] = false;
    }
    if (H[a] >= H[b]) {
      isGood[b] = false;
    }
  }

  int ans = 0;
  REP(i, N) {
    if (isGood[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int a, b;
	cin >> a >> b;
	if (b >= a)print(a); else print(a - 1);




	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define stop system("pause")
#define INP freopen("input.txt","r",stdin)
#define OUTP freopen("solve1.txt","w",stdout)
#define int long long
using namespace std;

typedef long long ll;

unordered_map<int,int> w;

main()
{
    ios_base::sync_with_stdio(0);
    int n; cin >> n;
    vector<int> v;
    set<int> s;
    int cnt = 0;
    for(int i(0); i < n;i++){
        int x; cin >> x;
        s.insert(x);
        w[x]++;
        if(x == 0)cnt++;
    }
    if(cnt == n){
        cout << "Yes";
        return 0;
    }
    if(n%3 != 0){
        cout << "No";
        return 0;
    }
    if(s.size() > 3){
        cout << "No";
        return 0;
    }
    if(s.size() == 3){
        int x = 0;
        for(auto&a : s)x^=a;
        if(x){
            cout << "No";
            return 0;
        }
        for(auto&a : s){
            if(w[a]!=n/3){
                cout << "No";
                return 0;
            }
        }
        cout << "Yes";
        return 0;
    }
    if(s.size() == 2 && !cnt){
        cout << "No";
        return 0;
    }
    int qwe = w[*(--s.end())];
    if(qwe!=2*n/3){
        cout << "No";
    }else cout << "Yes";
    return 0;
}
/*
*/



Measured memory_bytes: 7332
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	string S;
	cin >> S;
	int ans1 = 0, ans2 = 0;
	for(int i = 0; i < S.size(); i ++){
		if(i%2 == 0 && S[i] == '0')ans1 ++;
		if(i%2 == 1 && S[i] == '1')ans1 ++;
		if(i%2 == 0 && S[i] == '1')ans2 ++;
		if(i%2 == 1 && S[i] == '0')ans2 ++;
	}
	cout << min(ans1, ans2) << endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int isprime(int n){
    for(int i=2; i*i<=n; i++){
        if(n%i==0)
        return 0;
    }
    return 1;
}
int main(){
    int num;
    while(1){
        scanf("%d", &num);
        if(num==0)break;
        for(int i=num; i>2; i--){
            if(isprime(i)==1)
                if(isprime(i-2)==1){
                    printf("%d %d\n", i-2, i);
                    break;
                }
        }
    }
    return 0;
}

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

int main()
{
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;

    if (s == u)
    {
        a -= 1;
    }
    else
    {
        b -= 1;
    }
    cout << a << ' ' << b << endl;

    return 0;
}

Measured memory_bytes: 256