akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
 
int main(){
    int S;
    cin >> S;
    int h;
    h = S/3600;
    int A;
    A = S%3600;
    int m;
    m = A/60;
    int s;
    s = A%60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <string.h>

int main(void){
    char str[201];
    int length, times;

    while(1) {
        scanf("%s\n", str);
        if (str[0] == '-')
            return 0;

        length = strlen(str);
        scanf("%d\n", &times);
        for (int i = 0; i < times; i++)
        {
            int n;
            char moved[201];
            
            scanf("%d\n", &n);
    
            for(int i = 0; i < n; i++)
                moved[i] = str[i];
            moved[n] = '\0';
        
            for(int i = n; i < length; i++)
                str[i-n] = str[i];
        
            for(int i = 0; i < strlen(moved); i++)
                str[length - n + i] = moved[i];
            
        }
        printf("%s\n", str);
    }

    return 0;
}



Measured memory_bytes: 2056
import numpy as np

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
AB = np.array(AB)

# 取りうる最小の中央値と最大の中央値を計算
m = np.median(AB[:, 0])
M = np.median(AB[:, 1])

if N % 2 == 0:
    print(int((M - m) * 2 + 1))
else:
    print(int(M - m + 1))


Measured memory_bytes: 66572
#include<stdio.h>
int main()
{
	int a[30]={0};
	int n;
	for(int i=0;i<28;i++){
		scanf("%d",&n);
		a[n-1]=1;
	}
	for(int i=0;i<30;i++){
		if(a[i]==0){
			printf("%d\n",i+1);
		}
	}
	return 0;
}

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
ll mod = 1000000007;
signed main(){
    ll q,h,s,d,n,x,y,ans=0;
    cin >> q>>h>>s>>d>>n;
    x=min({8*q,4*h,2*s});
    y=d;
    if(n%2==1){
        ans+=x/2;
        ans+=(n-1)*min(x,d)/2;
    }else{
        ans+=min(x,d)*(n)/2;
    }
    cout << ans << endl;
}
    
    




Measured memory_bytes: 256
//Calc

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int a;cin>>a;
    cout<<a+a*a+a*a*a<<nnn;
    return 0;
}

Measured memory_bytes: 3592
import java.io.*;

class Main{
static int count;
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line;
while(!(line=br.readLine()).equals("0 0")){
String[] value=line.split(" ");
int n=Integer.parseInt(value[0]);
int s=Integer.parseInt(value[1]);
count=0;
search(0,n,0,s);
System.out.println(count);
}
}
static void search(int i,int n,int sum,int s){
if(n==0){
if(sum==s){
count++;
return;
}
}
if(i>9){
return;
}
for(int a=i;a<=9;a++){
search(a+1,n-1,sum+a,s);
}
}
}

Measured memory_bytes: 16640
#include<stdio.h>
#define MAX 200000
#define INFTY  2000000000

typedef long long llong;

int L[MAX/2+2], R[MAX/2+2];

llong merge(int A[], int left, int mid, int right){
  int i, j, k, n1, n2;
  llong cnt = 0;

  n1 = mid - left;
  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] = R[n2] = INFTY;
  i = j = 0;
  for( k = left ; k < right ; k++ ){
    if( L[i] <= R[j] ){
      A[k] = L[i++];
    }
    else {
      A[k] = R[j++];
      cnt += n1 - i;
    }
  }
  return cnt;
}

llong mergeSort(int A[], int left, int right){
  int mid;
  llong v1, v2, v3;
  
  if( left + 1 < right ){
    mid = ( left + right ) / 2;
    v1 = mergeSort(A, left, mid);
    v2 = mergeSort(A, mid, right);
    v3 = merge(A, left, mid, right);
    return v1+v2+v3;
  }
  else return 0;
}

int main(){
  int A[MAX], n, i;

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

  llong ans = mergeSort(A, 0, n);
  printf("%lld\n", ans);

  return 0;
}



Measured memory_bytes: 3360
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int X, Y, Z, K;

long long A[1111], B[1111], C[1111];


class node_t {
public:
  node_t(int aa, int bb, int cc, long long ss) : a(aa), b(bb), c(cc), s(ss) {};

public:
  bool operator<(const node_t& x) const {
    if (s != x.s)
      return s < x.s;

    if (a != x.a)
      return a > x.a;

    if (b != x.b)
      return b > x.b;

    return c > x.c;
  };
  
public:
  int a;
  int b;
  int c;

public:
  long long s;
};
  

int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> X >> Y >> Z >> K;

  for (int i = 0; i < X; i ++)
    std::cin >> A[i];

  for (int i = 0; i < Y; i ++)
    std::cin >> B[i];

  for (int i = 0; i < Z; i ++)
    std::cin >> C[i];

  std::sort(A, A + X, std::greater<long long>());
  std::sort(B, B + Y, std::greater<long long>());
  std::sort(C, C + Z, std::greater<long long>());

  std::priority_queue<node_t> pq;

  pq.emplace(0, 0, 0, A[0] + B[0] + C[0]);

  for (std::set<std::array<int, 3>> set; ! pq.empty() && set.size() < K; ) {
    node_t node = pq.top(); pq.pop();

    if (set.count({node.a, node.b, node.c}))
      continue;

    std::cout << node.s << std::endl;

    set.insert({node.a, node.b, node.c});

    if (node.a + 1 < X)
      if (! set.count({node.a + 1, node.b, node.c}))
        pq.emplace(node.a + 1, node.b,     node.c,     A[node.a + 1] + B[node.b    ] + C[node.c]);

    if (node.b + 1 < Y)
      if (! set.count({node.a, node.b + 1, node.c}))
        pq.emplace(node.a,     node.b + 1, node.c,     A[node.a    ] + B[node.b + 1] + C[node.c]);

    if (node.c + 1 < Z)
      if (! set.count({node.a, node.b, node.c + 1}))
        pq.emplace(node.a,     node.b,     node.c + 1, A[node.a    ] + B[node.b    ] + C[node.c + 1]);
  }
  
  return 0;
}


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

typedef unsigned long long uLL;
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;
typedef pair <long long,long long> pll;
typedef pair <long long,pll> plll;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int MOD = 1000000007;

/**
knapsack for huge capacity but smaller values
*/

int n;
LL cap;
LL v[ N ] , w[ N ];
LL dp[ 101 ][ N ];

LL solve( int idx , int rem ) {
        if( rem < 0 ) return INF;
        if( rem == 0 ) return 0;
        if( idx > n ) return rem == 0 ? 0 : INF;
        if( dp[idx][rem] != -1 ) return dp[idx][rem];
        LL ret = INF;
        ret = solve( idx + 1 , rem );
        ret = min( ret , solve( idx + 1 , rem - v[idx] ) + w[idx] );
        return dp[idx][rem] = ret;
}
int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( NULL );
        cin >> n >> cap;
        LL tot = 0;
        for( int i = 1; i <= n; i++ ) cin >> w[i] >> v[i] , tot += v[i];
        LL ans = 0;
        memset( dp , -1, sizeof( dp ) );
        for( LL i = 0; i <= tot; i++ ) {
                LL mn_weight = solve( 1 , i );
                if( mn_weight <= cap ) ans = max( ans , i );
        }
        cout << ans << endl;
        return 0;
}













Measured memory_bytes: 80256
#define _GLIBCXX_DEBUG //GCC環境での[]デバッグ
#include <bits/stdc++.h> //全ての標準ライブラリ
#define rep(i,n) for(int i = 0;i < n;i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
using namespace std;
using ll = long long;
int sumVector (const std::vector<int>& v){ //int配列計算
    int sum = 0;
    rep(i, v.size()) sum += v.at(i);
    return sum; 
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,3){
        if(n % 10 == 7) {
            cout << "Yes";
            return 0;
        } 
        else {
            n /= 10;
        }
     }
    cout << "No";

}

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

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

    int res = 0;
    while (x > 0 and y > 0 and a + b >= 2 * c) {
        res += 2 * c;
        x--, y--;
    }

    while (x > 0) {
        if (a < 2 * c) {
            res += a;
            x--;
        }
        else {
            res += 2 * c;
            x--;
            y--;
        }
    }

    while (y > 0) {
        if (b < 2 * c) {
            res += b;
            y--;
        }
        else
        {
            res += 2 * c;
            y--;
        }
    }

    printf("%d\n", res);
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

const mod int = 1000000007

func main() {
	var N int
	fmt.Scan(&N)
	s1 := make([]byte, 0)
	s2 := make([]byte, 0)
	for i := 0; i < 2; i++ {
		var s string
		fmt.Scan(&s)
		if i == 0 {
			s1 = []byte(s)
		} else {
			s2 = []byte(s)
		}
	}
	// log.Println(s1)
	// log.Println(s2)
	ans := 1
	var double = true
	if N == 1 {
		fmt.Println("3")
		return
	}
	for i := 0; i < N; i++ {
		if i == 0 {
			if s1[i] == s2[i] {
				ans *= 3
				double = false
			} else {
				ans *= 6
				double = true
				i++
			}
		} else {
			if s1[i] == s2[i] {
				if double {
					ans *= 1
				} else {
					ans *= 2
				}
				double = false
			} else {
				if double {
					ans *= 3
				} else {
					ans *= 2
				}
				double = true
				i++
			}
		}
		ans = ans % mod
		// log.Println(i, ans)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
from itertools import zip_longest
n = int(input())
c = [0]*2
for _ in range(n):
    s = input().split()
    for a, b in zip_longest(s[0], s[1], fillvalue='`'):
        if ord(a) > ord(b):
            c[0] += 3
            break
        if ord(a) < ord(b):
            c[1] += 3
            break
    if ord(a) == ord(b):
        c[0] += 1;c[1] += 1

print(*c)


Measured memory_bytes: 5648
#pragma comment(linker, "/stack:640000000")

#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<stdio.h>
using namespace std;
#define ll long long int
#define scanl(a) scanf("%lld",&a)
#define scanii(a,b) scanf("%d%d",&a,&b)
#define scaniii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scanll(a,b) scanf("%lld%lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scani(a) scanf("%d",&a)
#define clr(a) memset(a,0,sizeof(a))
#define clr_(a) memset(a,-1,sizeof(a))
#define pb(a) push_back(a)
#define pii pair<int,int>
#define sqr(a) a*a
#define eps 1e-9
#define inf INT_MAX
#define pi acos(-1.0)
#define ff first
#define ss second
#define INF 1e18
#define endl '\n'
#define vsort(v) sort(v.begin(),v.end())
#define all(v) v.begin(),v.end()
int fx[]={0,0,-1,1,-1,1,1,-1};
int fy[]={1,-1,0,0,1,1,-1,-1};
#ifdef shaft
     #define debug(args...) {cerr<<"Debug: "; dbg,args; cerr<<endl;}
#else
    #define debug(args...)  // Just strip off all debug tokens
#endif

struct debugger{
    template<typename T> debugger& operator , (const T& v){
        cerr<<v<<" ";
        return *this;
    }
}dbg;
ll vis[200000];
int done[200000];
vector<pair<int,ll> >adj[200010];
int n,m;
void dijkstra( int s ) {
    clr(done);
    priority_queue<pair<ll,int> > pq;
    for ( int i = 0; i < n; i++ ) vis[i] = INF;
    vis[s]=0LL;
    pq.push( make_pair(-0,s) );
    while ( !pq.empty() ) {

        int s = pq.top().second;
        ll cost = pq.top().first * -1;

        pq.pop();

        if ( done[s] == 1 ) {
            continue;
        }

        for ( int i = 0; i < adj[s].size(); i++ ) {
            int t = adj[s][i].first;
            ll e = adj[s][i].second;

            if ( cost + e < vis[t] ) {
                vis[t] = cost + e;
                pq.push ( make_pair ( -vis[t], t ) );
            }
        }

        done[s] = 1;
    }

}
int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    #ifdef shaft
       // freopen("in.txt","r",stdin);
        ///freopen("out.txt","w",stdout);
    #endif ///shaft
    scani(n);
    for(int i=1;i<n;i++)
    {
        int u,v,w;scaniii(u,v,w);
        u--;v--;
        adj[u].pb(make_pair(v,w));
        adj[v].pb(make_pair(u,w));
    }
    int q,k;scanii(q,k);k--;
    dijkstra(k);
    for(int i=1;i<=q;i++)
    {
        int x,y;
        scanii(x,y);x--;y--;
        printf("%lld\n",vis[x]+vis[y]);
    }
    return 0;
}



Measured memory_bytes: 14192
#include <stdio.h>

int main(){
    int i, j;
    int h, w;
    
    while(scanf("%d %d", &h, &w), h > 0 && w > 0){
        for(i = 0; i < h; ++i){
            for(j = 0; j < w; ++j){
                putchar('#');
            }
            
            putchar('\n');
        }
        
        putchar('\n');
    }
    
    return 0;
}

Measured memory_bytes: 572
#include<iostream>
#define Mod 1000000007
using namespace std;
int main()
{
	long long a;
	long long sum, i;
	while (scanf("%lld", &a) != EOF)
	{
		sum = 1;
		for (i = 1; i <= a; i++)
		{
			sum *= i;
			if (sum >= Mod)
			{
				sum %= Mod;
			}
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    a, b, c, k = ns()
    t1 = max(k - a - b, 0)
    t2 = min(k, a)

    print(-t1 + t2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10580
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define all(v) v.begin() , v.end()
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999;
const ll MOD=1000000007;
const ll MAX_N=100010;
ll a,b,c,d,e,f,x,y,z,k,m,n,l,h,w,t,ans=0,sum;
vp p;
string s;
ll solve(){
    a=l*n+n*(n-1)/2;
    if(l*(l+n-1)<0)return a;
    else{
        if(labs(l)>labs(l+n-1)){
            return a-(l+n-1);
        }
        else{
            return a-l;
        }
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>l;
    cout<<solve()<<endl;
    
}

Measured memory_bytes: 256
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;

void solve(long long H, long long W, long long N, long long s_r, long long s_c, std::string S, std::string T) {
	bool ans = true;
	map<int, int> char_to_index;
	char_to_index['L'] = 0;
	char_to_index['R'] = 1;
	char_to_index['U'] = 2;
	char_to_index['D'] = 3;
	LL pos[4] = { s_c - 1, W - s_c, s_r - 1, H - s_r };
	LL max_pos[4] = { W - 1, W - 1, H - 1, H - 1 };
	for (LL i = 0; i < N; ++i) {
		if (--pos[char_to_index[S[i]]] < 0) {
			ans = false;
			break;
		}
		LL index = char_to_index[T[i]] ^ 1;
		pos[index] = min(max_pos[index], pos[index] + 1);
	}
	cout << (ans ? "YES" : "NO") << endl;
}

int main() {
	long long H, W, N, s_r, s_c;
	std::string S, T;
	std::cin >> H >> W >> N >> s_r >> s_c;
	std::cin >> S >> T;
	solve(H, W, N, s_r, s_c, S, T);
	return 0;
}


Measured memory_bytes: 4104
#define _GLIBCXX_DEBUG

#include"bits/stdc++.h"
using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//comparision
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 (a>b) { a=b; return 1; } return 0; }

//pair
#define fir first
#define sec second
#define mp make_pair

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(long long a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

////////////////////

void Main() {
    //code here
    int n = gi;
    vec<int> nums = gim(n);
    int res = 0;
    REP(i, n-2) {
        vec<int> sNums = {nums[i], nums[i+1], nums[i+2]};
        sort(ALL(sNums));
        if (sNums[1] == nums[i+1]) res++;
    }
    print(res);
}

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


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<LL> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL INF = 1e9;
const LL mod = 1000000007;
const LL LINF = 1e18 + 10;
const LL MAX = 1e5 + 1;

int n;
int m;
VI g[MAX];
int ye = 0;
int path[MAX];
char used[MAX];

void dfs(int v)
{
	used[v] = 1;
	path[ye++] = v;
	for(auto i: g[v])
		if (used[i] == 0)
		{
			dfs(i);
			return;
		}
}

bool solve(int v)
{
	ye = 0;
	memset(used, 0, sizeof(used));
	used[v] = 1;
	if (SZ(g[v]) == 1)
	{
		path[ye++] = v;
		dfs(g[v][0]);
		return 1;
	}

	path[ye++] = v;
	dfs(g[v][0]);
	for (auto i : g[v])
		if (used[i] == 0)
			return 0;

	return 1;
}

int cmp(int x, int y)
{
	return SZ(g[x]) < SZ(g[y]);
}

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

	cin >> n >> m;
	int u, v;
	FOR(i, 0, m)
	{
		cin >> u >> v;
		--u; --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	if (n == 2)
	{
		cout << 2 << endl << 1 << " " << 2;
		return 0;
	}

	int best = 0;
	FOR(i, 1, n)
		if (SZ(g[i]) < SZ(g[best]))
			best = i;
	bool x;
	
	VI all;
	FOR(i, 0, n)
		all.push_back(i);

	sort(ALL(all), cmp);
	srand(time(NULL));
	int counter = 0;
	best = all[0];
	while (1)
	{
		x = solve(best);
		if (x)
			break;

		if (counter < 100)
			best = all[++counter];
		else
			best = rand() % n;
	}

	cout << ye << endl;
	FOR(i, 0, ye)
		cout << path[i] + 1 << " ";
	cin >> n;	
	return 0;
}

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

int main()
{
	int n,a[100005];
	cin>>n;
	for(int i=1;i<=n;i++){
		int b;
		cin>>b;
		a[b]=i;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<" ";
	cout<<endl;
}

Measured memory_bytes: 1152
from collections import defaultdict 
import sys
input = sys.stdin.readline
from math import gcd

MOD = 1000000007

dic1 = defaultdict(int)

All_zero = 0

S = set()
N = int(input())
ans = 0 #仲が悪い数を数える
for i in range(N):
    a, b = map(int, input().split())
    if a == 0 and b == 0: #なんでもOK
        All_zero += 1
    elif a == 0:
        S.add((0, 1))
        dic1[(0, 1)] += 1
    elif b == 0:
        S.add((1, 0))
        dic1[(1, 0)] += 1
    else:
        GCD = gcd(a, b)
        a //= GCD
        b //= GCD
        if a < 0: #aを必ず正にする
            a *= -1
            b *= -1
        S.add((a, b))
        dic1[(a, b)] += 1
        
lst = []
for a, b in S:
    tmp11 = dic1[(a, b)]
    A = a
    B = b
    if B <= 0:
        B *= -1
        A *= -1
    tmp2 = dic1[(B, -A)]
    # print (a, b, A, B)
    dic1[(B, -A)] = 0
    if tmp11 > 0:
        lst.append((tmp11, tmp2))

# print (lst)

ans = 1
for a, b in lst:
    tmp = (pow(2, a, MOD) - 1) + (pow(2, b, MOD) - 1) + 1 #左側を入れる、右側を入れる、両方入れない
    ans *= tmp
    ans %= MOD

ans = (ans - 1 + All_zero) % MOD
print (ans % MOD)

# print (S)

Measured memory_bytes: 186936
N = int(input())
S = input()
r = []
g = []
b = []
n_r = n_g = n_b = 0

for i in range(N):
    if S[i] == "R":
        r.append(i)
        n_r += 1
    elif S[i] == "G":
        g.append(i)
        n_g += 1
    else:
        b.append(i)
        n_b += 1

all = n_r*n_b*n_g

tmp = 0
for i in range(1,N+1):
    j = 0
    while j+2*i<=N-1:
        if S[j] != S[j+i] and S[j+i] != S[j+2*i] and S[j] != S[j+2*i]:
            tmp += 1
#            print(j,j+i,j+i*2)
        j += 1
print(all-tmp)

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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}

template<typename S>
void print(S a){
    cout<<a<<endl;
}

template<typename U>
void pprint(U a){
    cout<<a;
}

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

    string n;
    cin>>n;
    ull ans;
    int tmp;
    rep(i,n.length()){
        tmp = n[i]-'0';
        ans += tmp;
    }
    if(ans%9==0){
        print("Yes");
    }else{
        print("No");
    }


    return 0;
}




Measured memory_bytes: 3780
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
 
#define T long long
 
T Abs(T n){
	return n>0?n:-n;
}
 
int main(){
	T n,k;
	std::cin>>n>>k;
	if(n>k){
		n=n%k;
	}
	while(1){
		if(Abs(n-k)>=n){
			std::cout<<n<<std::endl;
			return 0;
		}else if(n%k==0){
			std::cout<<0<<std::endl;
			return 0;
		}
		n=Abs(n-k);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int main() {
    ll K;
    cin >> K;
    
    ll p = K / 50;
    ll q = K % 50;
    
    ll a[50];
    fill(a, a + 50, 49 + p * (51));
    for (int i = 0; i < q; ++i) {
        a[i] += 51;
    }
    for (int i = 0; i < 50; ++i) {
        a[i] -= K;
    }
    
    cout << 50 << endl;
    for (int i = 0; i < 50; i++) {
        printf("%lld ", a[i]);
    }
    
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Here your code !
 
import math
 
def func():
    try:
        (rows,columns) = [ int(item) for item in input().rstrip().split(" ") ]
        data = [ [ int(item) for item in input().rstrip().split(" ") ] for i in range(rows) ]
    except:
        return inputError()
        
    [item.append(sum(item)) for item in data]
    data.append( [sum( [ item[i] for item in data ] ) for i in range(columns+1) ])
    
    result=""
    for row in data:
        for item in row:
            result += str(item)+" "
        result=result.rstrip()
        result += "\n"
    print(result.rstrip())

def inputError():
    '''
    print("input Error")
    return -1
    '''
 
    print("input Error")
    return -1
     
func()

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

int main() {
  ll n;
  cin >> n;
  
  vector<ll> vec(n+1);
  rep(i, n+1)
    vec.at(i) = i;
  
  ll ans = 0;
  
  rep(i, n+1){
    if(vec.at(i) % 3 != 0 && vec.at(i) % 5 != 0)
      ans += vec.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 11080
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	while (1) {
		int a; cin >> a;
		if (!a)break;

		for (int i = 0; i <9; ++i) {
			int b; cin >> b; a -= b;
		}
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 3064
import java.util.Scanner;
class Main{
 public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   int[][] A = new int[3][3];

   for(int i=0;i<3;i++) {
	   for(int j=0;j<3;j++) {
		   A[i][j] = sc.nextInt();
	   }
   }
   int n = sc.nextInt();
   for(int k=0;k<n;k++) {
	   int b = sc.nextInt();
   		for(int i=0;i<3;i++){
   			for(int j=0;j<3;j++){
   				if(A[i][j] == b) {
   					A[i][j] = 0;
   				}
   			}
		}
   }
   boolean Judge = false;
   for(int i=0;i<3;i++) {
	   if(A[i] [0]==0&&A[i][1]==0&&A[i][2]==0) {
		   Judge = true;
	   }
	   if(A[0] [i]==0&&A[1][i]==0&&A[2][i]==0) {
		   Judge = true;
	   }
	if(A[0][0]==0&&A[1][1]==0&&A[2][2]==0) {
		Judge = true;
	}
	if(A[0][2]==0&&A[1][1]==0&&A[2][0]==0) {
		Judge = true;
	}
   }
   if(Judge==true) {
	   System.out.println("Yes");
   }
   else {
	   System.out.println("No");
	   }
 }
}

Measured memory_bytes: 21844
import scala.io.StdIn._
import scala.annotation.tailrec
import scala.collection._

object Main {

  def sieve(top: Int): Iterator[Int] = {
    val topId = (top - 3) / 2 + 1
    val (cmpsts, sqrtLmtNdx) = (new Array[Int]((topId >>> 5) + 1), (Math.sqrt(top).toInt - 3) / 2)

    @inline
    def isCmpst(ci: Int): Boolean = (cmpsts(ci >>> 5) & (1 << (ci & 31))) != 0

    @inline
    def setCmpst(ci: Int): Unit = cmpsts(ci >>> 5) |= 1 << (ci & 31)

    @tailrec
    def get(cndId: Int): Unit = {
      if(cndId <= sqrtLmtNdx){
        if(!isCmpst(cndId)){
          val p = 2 * cndId + 3

          @tailrec
          def cull(cmpstId: Int): Unit =
            if(cmpstId <= topId){
              setCmpst(cmpstId)
              cull(cmpstId + p)
            }

          cull((p * p - 3) >>> 1)
        }
        get(cndId + 1)
      }
    }

    get(0)

    @tailrec def next(cndId: Int): Int =
      if ((cndId > topId) || !isCmpst(cndId)) 2 * cndId + 3
      else next(cndId + 1)

    Iterator.single(2) ++ Iterator.iterate(3)(p => next((p - 1) >>> 1)).takeWhile(_ <= top)
  }

  @tailrec
  def loop(s: String){
    if(s != null){
       val Array(n,_*) = s.split(" ").map(_.toInt)
       if(n<2) println(0)
       else println(sieve(n).size)
       loop(readLine)
    }
  }

  def main(args: Array[String]): Unit = loop(readLine)
}

Measured memory_bytes: 65164
unittest
{
	assert( [ "2 2 2 8", "4 6", "1 5", "3 8" ].parse.expand.solve == "19\n17\n15\n14\n13\n12\n10\n8" );
	assert( [ "3 3 3 5", "1 10 100", "2 20 200", "1 10 100" ].parse.expand.solve == "400\n310\n310\n301\n301" );
	assert( [
			"10 10 10 20",
			"7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488",
			"1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338",
			"4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736"
		].parse.expand.solve == "23379871545\n22444657051\n22302177772\n22095691512\n21667941469\n21366963278\n21287912315\n21279176669\n21160477018\n21085311041\n21059876163\n21017997739\n20703329561\n20702387965\n20590247696\n20383761436\n20343962175\n20254073196\n20210218542\n20150096547" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto xyzk = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	input.popFront;
	auto cs = input.front.split.to!( long[] );
	return tuple( xyzk[ 3 ], as, bs, cs );
}

auto solve( long k, long[] as, long[] bs, long[] cs )
{
	as.sort!( ( a, b ) => b < a );
	bs.sort!( ( a, b ) => b < a );
	cs.sort!( ( a, b ) => b < a );
	
	auto abcs = [ as, bs, cs ];
	auto pss = [ [ 0L, 0L, 0L ] ];
	auto ts = [ 0L:[ 0L:[ 0L: ( as[ 0 ] + bs[ 0 ] + cs[ 0 ] ) ] ] ];
	
	// pss[ 0 .. pi ]は順番確定済、pss[ pi .. $ ]は順番未確定
	for( auto pi = 1L; pi < k; pi++ )
	{
		// 順番確定済の最後のやつから次の候補を計算
		for( auto abci = 0L; abci < abcs.length; abci++ )
		{
			if( pss[ pi - 1 ][ abci ] + 1 < abcs[ abci ].length )
			{
				auto ps = pss[ pi - 1 ].dup;
				ps[ abci ]++;
				
				// 候補が未確定領域に無かったら追加
				if( ps[ 0 ] !in ts || ps[ 1 ] !in ts[ ps[ 0 ] ] || ps[ 2 ] !in ts[ ps[ 0 ] ][ ps[ 1 ] ] )
				{
					auto t = as[ ps[ 0 ] ] + bs[ ps[ 1 ] ] + cs[ ps[ 2 ] ];
					ts[ ps[ 0 ] ][ ps[ 1 ] ][ ps[ 2 ] ] = t;
					
					auto ms = pss[ pi .. $ ].find!( ( a, b ) => ts[ a[ 0 ] ][ a[ 1 ] ][ a[ 2 ] ] < b )( t );
					pss.insertInPlace( pss.length - ms.length, ps );		// 美味しい順で挿入
				}
			}
		}
	}
	
	auto anss = pss[ 0 .. k ].map!( ( a ) => ts[ a[ 0 ] ][ a[ 1 ] ][ a[ 2 ] ] );
	return anss.map!( to!string ).join( "\n" );
}


Measured memory_bytes: 4092
n = int(input())
ans = [0] * (n+1)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            tmp = x**2+y**2+z**2+x*y+y*z+z*x
            if(tmp<=n):
                ans[tmp] += 1

print('\n'.join(map(str,ans[1:])))

Measured memory_bytes: 73748
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

void bfs(vector<vector<int>>& t, vector<int>& d, int s) {
    int n = t.size();
    for (int i = 0; i < n; i++) {
        d[i] = n;
    }

    d[s] = 0;

    priority_queue<int> que;
    que.push(s);
    while (!que.empty()) {
        int q = que.top();
        que.pop();

        for (int i = 0; i < static_cast<int>(t[q].size()); i++) {
            if (d[t[q][i]] > d[q] + 1) {
                d[t[q][i]] = d[q] + 1;
                que.push(t[q][i]);
            }
        }
    }
}

int main() {
    int n, u, v;
    cin >> n >> u >> v;
    u--;
    v--;

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

    vector<int> d_u(n), d_v(n);
    bfs(t, d_u, u);
    bfs(t, d_v, v);

    int res = 0;
    for (int i = 0; i < n; i++) {
        if (d_u[i] < d_v[i]) {
            res = max(res, d_v[i] - 1);
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 6656
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - RGB Triplets
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 4000;

/* typedef */

typedef long long ll;

/* global variables */

char s[MAX_N + 4];
int ds[3][MAX_N], dns[3], cs[4], bs[MAX_N];

/* subroutines */

bool found(int ds[], int dn, int d) {
  int k = lower_bound(ds, ds + dn, d) - ds;
  return (k < dn && ds[k] == d);
}

/* main */

int main() {
  int n;
  scanf("%d%s", &n, s);

  for (int i = 0; i < n; i++)
    switch (s[i]) {
    case 'R': ds[0][dns[0]++] = i; bs[i] = 1; break;
    case 'G': ds[1][dns[1]++] = i; bs[i] = 2; break;
    case 'B': ds[2][dns[2]++] = i; bs[i] = 4; break;
    }

  ll sum = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (s[i] != s[j]) {
	int k = j + (j - i), h;

	switch (bs[i] | bs[j]) {
	case 3 : h = 2; break;
	case 5 : h = 1; break;
	case 6 : h = 0; break;
	}

	int x = upper_bound(ds[h], ds[h] + dns[h], j) - ds[h];
	if (x < dns[h]) {
	  int y = lower_bound(ds[h], ds[h] + dns[h], k) - ds[h];
	  sum += (dns[h] - x) - ((y < dns[h] && ds[h][y] == k) ? 1 : 0);
	}
      }	

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 3272
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char a[105];
	while(~scanf("%s",a))
	{
		int ans=0;
		int s=strlen(a);
		for(int i=0;i<s/2;i++)
		if(a[s-i-1]!=a[i])
		ans++;
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 256
def main():
    h,w,m=map(int,input().split())
    target=set()
    for i in range(m):
        th,tw=map(int,input().split())
        target.add((th-1,tw-1))
    lines=[0]*w
    rows=[0]*h
    for th,tw in target:
        lines[tw]+=1
        rows[th]+=1
    max_lines=max(lines)
    max_rows=max(rows)
    max_wi=[i for i,wi in enumerate(lines) if wi==max_lines]
    max_hi=[i for i,hi in enumerate(rows) if hi==max_rows]
    # print('rows\t',max_rows,max_hi,'\nlines\t',max_lines,max_wi)
    ans=max_lines+max_rows-1
    isLoop=True
    for wi in max_wi:
        if isLoop:
            for hi in max_hi:
                if not (hi,wi) in target:
                    ans+=1
                    isLoop=False
                    break
    return ans

if __name__=='__main__':
    ans=main()
    print(ans)


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

int main() {
  int N,M; 
  cin >> N >> M;
  char A[50][50],B[50][50];
 for(int i=0;i<N;++i){ 
   for(int j=0;j<N;++j)
      cin >> A[i][j]; 
 }
    

 for(int i=0;i<M;++i){
   for(int j=0;j<M;++j)
     cin >> B[i][j];
 }
   bool abcde =false;
  for(int i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
           if(i+M-1>=N or j+M-1>=N) continue;
            bool abc=true;
            for(int h=0;h<M;h++){
                for(int k=0;k<M;k++){
                    if(A[i+h][j+k]!=B[h][k]){
                        abc = false;                                                
                    }
                }
            }
              if(abc) abcde =true;
            
        }
  }
            if(abcde){
                cout<<"Yes"<< endl;
                return 0;
            }
        
    
  else{
    cout<<"No"<< endl;
    return 0;
  }
}
        
  


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

bool is_prime(int x){
  if(x==1){
    return false;
  }else if(x==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(x);i++){
      if(x%i==0){
        return false;
      }
    }
  }
  return true;
}

bool like_2017(int x){
  if(x%2==0){
    return false;
  }else{
    return is_prime(x) && is_prime((x+1)/2);
  }
}

int cnt[100010];

int main(){
  for(int i=1;i<=100000;i++){
    cnt[i]=cnt[i-1];
    if(like_2017(i)){
      cnt[i]++;
    }
  }
  
  int q;
  cin>>q;
  int l,r;
  REP(i,q){
    cin>>l>>r;
    cout<<cnt[r]-cnt[l-1]<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

class Main{
	public static void main(String args[]) {

		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		StringTokenizer stk;
		List kazu=new ArrayList<Integer>();
		int sousuu=0;

		try {
			str=bfr.readLine();
			stk=new StringTokenizer(str," ");

			while(stk.hasMoreTokens()) {
				sousuu+=Integer.parseInt(stk.nextToken());
			}

			System.out.println(sousuu);


		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}


Measured memory_bytes: 24360
//writer：Sakura
//problem：
//id：
//from：

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
//#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int h,w;
char s[55][55];
bool flag=0;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d %d",&h,&w);
	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]=='#'){
				flag=0;
				for(int k=0;k<4;k++){
					int nx,ny;
					nx=i+dx[k];ny=j+dy[k];
					if(nx>=0 && ny>=0 && nx<h && ny<w && s[nx][ny]=='#'){
						flag=1;
					}
				}
				if(!flag){
					puts("No");
					exit(0);
				}
			}
		}
	}
	puts("Yes");
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R')cout<<3<<endl;
    else if((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R'))cout<<2<<endl;
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R')cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define MAX (ll)(5e3 + 4)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	int n;
	cin >> n;
	string st, tm = "ABC";
	cin >> st;
	int cc = 0;
	for (int i = 0; i + 2 < st.size (); i++) {
		if (st.substr (i, 3) == tm) {
			cc++;
		}
	}
	cout << cc << "\n";
}
			


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

#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl

using namespace std;
typedef long long ll;

const int maxn = 102;

ll w[maxn];
ll v[maxn];
ll dp[maxn][100005];

int main(){
	ll n, W;
	scanf ("%lld %lld", &n, &W);
	for (ll i = 1; i <= n; i++)
		scanf ("%lld %lld", &w[i], &v[i]);
	for (ll i = 1; i <= n; i++){
		for (ll j = 1; j <= W; j++){
			if (j < w[i])
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = max (dp[i - 1][j], v[i] + dp[i - 1][j - w[i]]);
		}
	}
	cout << dp[n][W] << '\n';
	return 0;
}

Measured memory_bytes: 78336
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    vector<string> s(n, string(m, '.'));
    if (n % 2){
        for (int i = 0; a > 0 && i < m - 1; i += 2){
            s[n - 1][i] = '<';
            s[n - 1][i + 1] = '>';
            a--;
        }
    }
    if (m % 2){
        for (int j = 0; b > 0 && j < n - 1; j += 2){
            s[j][m - 1] = '^';
            s[j + 1][m - 1] = 'v';
            b--;
        }
    }
    bool f = false;
    for (int i = 0; i < n - 1; i += 2) for (int j = 0; j < m - 1; j += 2){
        f = false;
        if (a >= 2){
            s[i][j] = s[i+1][j] = '<';
            s[i][j+1] = s[i+1][j+1] = '>';
            a -= 2;
        }else if (b >= 2){
            s[i][j] = s[i][j+1] = '^';
            s[i+1][j] = s[i+1][j+1] = 'v';
            b -= 2;
        }else if (b){
            s[i][j] = '^';
            s[i+1][j] = 'v';
            b--;
            f = true;
        }else if (a){
            s[i][j] = '<';
            s[i][j+1] = '>';
            a--;
        }
    }
    if (n % 2 && m % 2 && b == 0 && a == 1 && f){
        s[n - 3][m - 2] = '<';
        s[n - 3][m - 1] = '>';
        s[n - 2][m - 1] = '^';
        s[n - 1][m - 1] = 'v';
        a--;
    }
    if (a == 0 && b == 0){
        cout << "YES" << endl;
        REP(i,n) cout << s[i] << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


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

typedef std::pair<int, int> ipair;
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k;i--)
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define mp make_pair

const int mod = 1000000007;
const ld pi = acos(-1);
const int maxn = 200006;

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}
#define IOS  std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int32_t main(){
    int n;  cin>>n;
    if(n&1){
    double ans = 1/(2*(double)n);
    cout<<fixed<<setprecision(10)<<(0.5 + ans)<<endl;
    }
    else
    cout<<0.5<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n = II()
    c = S()
    dp1 = [0] * (n + 1)
    dp2 = [0] * (n + 1)
    W = c.count("W")
    R = c.count("R")
    for i in range(1, n + 1):
        dp1[i] = (c[i - 1] == "W") + dp1[i - 1]
        dp2[i] = (c[i - 1] == "R") + dp2[i - 1]
    ans = inf
    for i in range(n + 1):
        w = max(dp1[i], R - dp2[i], i - dp2[i])
        ans = min(ans, w)
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 71820