akhauriyash/Code-Regression huggingface dataset:
import bisect
I=lambda:map(int,input().split())
N,Q=I()
S=input()
m=[]
for i in range(N-1):
    if S[i]=='A' and S[i+1]=='C':
        m += [i]
#print(m)
for i in range(Q):
    l,r=I()
    if m==[]:print(0);continue
    li=bisect.bisect_left(m,l-1)
    ri=bisect.bisect_left(m,r-1)
    #print(i,li,ri)
    print(ri-li-1 if m[ri-1]==r else ri-li)


Measured memory_bytes: 5768
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	string s;
	cin >> s;
	cout << "ABC" << s;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
   string s;
   cin>>s;
   if (s=="Sunny"){cout<<"Cloudy"<<endl;}
else if(s=="Cloudy"){cout<<"Rainy"<<endl;}
else if(s=="Rainy"){cout<<"Sunny"<<endl;}

}



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

int main(){
    int64_t n, d, p, q, j, ans = 0;
    cin >> n >> d ;
    for (int i = 0; i < n; i++){
        cin >> p >> q;
        j = d * d - ( p * p + q * q);
        if(0 <= j) ans++;
    }
    cout <<  ans  << endl;

}

Measured memory_bytes: 3640
s=str(input())
if s=='SUN':
  print(7)
elif s=='MON':
  print(6)
elif s=='TUE':
  print(5)
elif s=='WED':
  print(4)
elif s=='THU':
  print(3)
elif s=='FRI':
  print(2)
elif s=='SAT':
  print(1)

Measured memory_bytes: 2940
#include<algorithm>
#include<iostream>
#include<cstring>
#include<iomanip>
#include<sstream>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define per(i,n,x) for(int i=n;i>=x;i--)
#define sz(a) int(a.size())
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
#define lson l,mid,p<<1
#define ll long long
#define pb push_back
#define mp make_pair
#define se second
#define fi first
using namespace std;
const double eps=1e-8;
const int mod=1e9+7;
const int N=2e5+10;
const int inf=1e9;
int n,m;
int k;
ll a[N],b[N];
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>m>>k;
	rep(i,1,n) cin>>a[i];
	rep(i,1,m) cin>>b[i];
	int ans=0;
	rep(i,1,m){
		b[i]+=b[i-1];
		if(k>=b[i]){
			ans=i;
		}
	}
	rep(i,1,n){
		a[i]+=a[i-1];
		if(k>=a[i]){
			int p=k-a[i];
			int pos=upper_bound(b+1,b+m+1,p)-b-1;
			ans=max(ans,i+pos);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int n,ans=0;
    for(int i = 1; i <= N; i+=2){
        n = i;
        int count = 0;
        for(int j = 1; j <= n; j++){
            if(n % j == 0){
                count++;
            }
        }
        if(count == 8){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

if k <= (n - 1) * (n - 2) // 2:
    g = [[0] * (n + 1) for _ in range(n + 1)]
    for u in range(1, n + 1):
        for v in range(u + 1, n + 1):
            g[u][v] = 1

    cnt = n - 1
    for u in range(2, n + 1):
        for v in range(u + 1, n + 1):
            if k:
                g[u][v] = 0
                k -= 1
            cnt += g[u][v]

    print(cnt)
    for u in range(1, n + 1):
        for v in range(u + 1, n + 1):
            if g[u][v]:
                print(u, v)

else:
    print(-1)


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

int main(){
	int n, m;
	cin >> n >> m;
	int a[10];
	for(int i = 1; i <= 10; i++) a[i] = -1;
	bool f = true;
	for(int i = 1; i <= m; i++){
		int x, y;
		cin >> x >> y;
		if(a[x] != -1 && a[x] != y)f = false;
		else a[x] = y;
	}
	int s = 0;
	if(a[1] == -1) s += pow(10,n - 1);
	else if(a[1] == 0) f = false;
	else s += a[1] * pow(10,n - 1);
	for(int i = 2; i <= n; i++){
		if(a[i] == -1) a[i] = 0;
		s += a[i] * pow(10,n - i);
	}
	if(!f)  s = -1;
	if(n == 1 && a[1] == 0) s = 0;
	if(n == 1 && m == 0) s = 0;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 512
def is_palindrome str
  str == str.reverse
end
 
def solve s, t
  
  return  0 if is_palindrome(s) 
  return -1 unless is_palindrome(t)
  
  tl = t.length
  o = (tl+1)/2 - 1
  i = j = k = l = m = cnt = 0
  
  r = s.reverse
  
  loop do
      
    while s[i] == 'x' do
      i+=1; k+=1;
    end
    
    while r[j] == 'x' do
      j+=1; l+=1;
    end
    
    cnt += ( k - l ).abs
    
    k = l = 0

    break if m == o
    
    i += 1; j += 1; m += 1
  end
  
  return cnt
end
 
s = gets.chomp
t = s.gsub("x","")
 
puts solve s, t


Measured memory_bytes: 2300
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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<_>>()
    };

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"4 150
150 140 100 200"# => r#"2"#,

r#"1 500
499"# => r#"0"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        k: usize,
        h: [usize; n],
    }

    h.iter().filter(|&&j| k <= j).count().to_string()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
using ll = long long;
using vi = vector<int>;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
const int INFTY = 1e9+7;

int main() {
  int N, M;
  cin >> N >> M;
  vi S(N), T(M);
  rep(i,N) cin >> S[i];
  rep(j,M) cin >> T[j];

  Graph dp(N+1, vi(M+1));  // 1-indexed
  rep(i,N+1) dp[i][0] = 1;
  rep(j,M+1) dp[0][j] = 1;
  
  for (int i=1; i<=N; i++) {
    int sum = 0;
    for (int j=1; j<=M; j++) {
      if (S[i-1] == T[j-1]) {
        sum += dp[i-1][j-1];
        sum %= INFTY;
      }
      dp[i][j] = (dp[i-1][j] + sum) % INFTY;
    }
  }

  cout << dp[N][M] << endl;
  return 0;
}


Measured memory_bytes: 16000
a=list(input())
b=a[::-1]
n=len(a)
if n==1:
    print(0)
else:
    x=0
    y=0
    for i in range(n-1):
        if a[i]==a[i+1]:
            x+=1
            if a[i]=='0':
                a[i+1]='1'
            else:
                a[i+1]='0'
        if b[i]==b[i+1]:
            y+=1
            if b[i]=='0':
                b[i+1]='1'
            else:
                b[i+1]='0'
    print(min(x,y))


Measured memory_bytes: 4652
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int X, Y, Z; cin >> X >> Y >> Z;
   int N = X + Y + Z;
   V<int> A(N), B(N), C(N);
   for (int i = 0; i < N; i++) {
      cin >> A[i] >> B[i] >> C[i];
   }

   V<P<int,int>> p(N);
   for (int i = 0; i < N; i++) {
      p[i] = make_pair(A[i] - B[i], i);
   }
   sort(p.begin(), p.end());

   V<V<int>> score(2, V<int>(N+1, -INF));

   {
      priority_queue<P<int,int>> que;
      int total = 0;
      for (int i = 0; i < Y; i++) {
         int id = p[i].second;
         que.push({C[id] - B[id], id});
         total += B[id];
      }
      score[0][Y] = total;
      for (int i = Y; i < N; i++) {
         int id = p[i].second;
         que.push({C[id] - B[id], id});
         total += B[id] + C[que.top().second] - B[que.top().second];
         que.pop();
         score[0][i+1] = total;
      }
   }

   {
      priority_queue<P<int,int>> que;
      int total = 0;
      for (int i = 0; i < X; i++) {
         int id = p[N-1-i].second;
         que.push({C[id] - A[id], id});
         total += A[id];
      }
      score[1][N-X] = total;
      for (int i = X; i < N; i++) {
         int id = p[N-1-i].second;
         que.push({C[id] - A[id], id});
         total += A[id] + C[que.top().second] - A[que.top().second];
         que.pop();
         score[1][N-(i+1)] = total;
      }
   }

   int ans = -INF;
   for (int i = 0; i <= N; i++) {
      chmax(ans, score[0][i] + score[1][i]);
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int x = 0;
    vector<int> v(n);
    for (int &i : v)
    {
        cin >> i;
        x ^= i;
    }
    for (int i = 0; i < n; i++)
    {
        cout << (x ^ v[i]) << " ";
    }
    return 0;
}

Measured memory_bytes: 4784
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    int num[n];
    int MAX,MIN;
    for(int i = 0;i < n;i++){
        cin >> num[i];
        if(i == 0){
            MAX = num[i];
            MIN = num[i];
        }
        MAX = max(MAX,num[i]);
        MIN = min(MIN,num[i]);
    }
    cout << MAX - MIN << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue 优先队列
#include <map>
#include <set> //multiset  set<int>::reverse_iterator rit; for(rit=s.rbegin();rit!=s.rend();rit++)
#include <vector>
#include <stack>
#include <cmath>
#include <utility>
#include <sstream>
#include <string>
#define mod 1000000007
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
const db eps=1e-6;
const int INF=0x3f3f3f3f;
const int N=50;
using namespace std;
int t,n,m=0,a[N]={0};
char c[N]={0};

ll C(int a,int b){
	ll c=1,d=1,e=a;
	while(a){
		c*=a--;
	}
	while(e--){
		d*=b--;
	}
	return d/c;
}

int flag=0;
int main(){
	scanf("%s",c);
	for(int i=0;i<strlen(c);i++){
		a[c[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		if(a[i]%2==1){
			if(flag==0){
				a[i]--;
				a[i]/=2;
				flag=1;
			}else{
				flag=2;
			}
		}else{
			a[i]/=2;
		}
	}
	if(flag==2){
		printf("0\n");
	}else{
		sort(a,a+26);
		int s=strlen(c)/2;
		ll sum=1;
		for(int i=0;i<26;i++){
			if(a[i]!=0){
				sum*=C(a[i],s);
				s-=a[i];
			}
		}
		printf("%lld\n",sum);
	}
	return 0;
}


Measured memory_bytes: 3284
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    char s[6];
    scanf("%s",s);
    if(s[2]==s[3] && s[4]==s[5])printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){

int A,B,C,D,P;

cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    cin >> P;
 
    int X = A*P;
    int Y = B;
    if(P>C){
        Y += D*(P-C);
    }
 
    if(X<Y){
        cout << X << endl;
    }
    else{
        cout << Y << endl;
    }




return 0;
}



Measured memory_bytes: 3072
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll w, a, b;
  cin >> w >> a >> b;

  ll ans;
  if (a + w <= b)
    ans = b - a - w;
  else if (a <= b + w)
    ans = 0;
  else
    ans = a - b - w;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
ll gcd(ll a,ll b) 
{ 
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 
bool isprime(ll n)
{
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int main()
{
	ll m,d,i,ctr=0;
	cin>>m>>d;
	for(i=22;i<=d;i++)
	{
		ostringstream str1; 
   		str1<<i;  
    	string s= str1.str(); 
    	ll n=(s[0]-'0')*(s[1]-'0');
    	//cout<<i<<" "<<n<<endl;
    	if(n<=m&&s[0]-'0'>=2&&s[1]-'0'>=2)
    	ctr++;
	}
	cout<<ctr;
	return 0;
}

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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
void Yes(){
  cout << "Yes" << endl;
}
void YES(){
  cout << "YES" << endl;
}
void No(){
  cout << "No" << endl;
}
void NO(){
  cout << "NO" << endl;
}
int main(){
  int A,B;
  cin >> A >> B;
  
  if(A>B){
  	if(B!=1) cout << "Alice" << endl;
    else cout << "Bob" << endl;
  }else if(B>A){
  	if(A!=1) cout << "Bob" << endl;
    else cout << "Alice" << endl;
  }else cout << "Draw" << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; ++i) {
            a[i] = sc.nextInt();
        }

        long[][] b = new long[N][N];
        long ans = 0;
        for (int i = 0; i < N; ++i) {
            b[0][i] = a[i];
            ans += a[i];
        }
        for (int k = 1; k < N; ++k) {
            long sum = 0;
            for (int i = 0; i < N; ++i) {
                int idx = (i > 0 ? i - 1 : N - 1);
                b[k][i] = Math.min(b[k - 1][idx], a[i]);
                sum += b[k][i];
            }
            ans = Math.min(ans, (long)k * x + sum);
        }
        _out.println(ans);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

int main(){
  int A, B, C, D ,E; cin >> A >> B >> C >> D >> E;
  int k; cin >> k;
  int chk = 0;
  if (E - A > k) chk++;
  if (chk ==0){
    cout << "Yay!" << endl;
  }
  else {
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
int arr[50];
int n;
int solve(int key,int num)
{
	if(key==0)
	return 1;
	if(key<0||num==n) 
	return 0;
	if(solve(key-arr[num],num+1)||solve(key,num+1))
	return 1;
	return 0;
}
int main(int argc, char *argv[])
{
	int m,i,key;
	scanf("%d",&n); 
	for(i=0;i<n;i++)
	scanf("%d",&arr[i]);
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		scanf("%d",&key);
		if(solve(key,0))
		printf("yes\n");
		else
		printf("no\n");	
	}
	return 0;
}


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

typedef long long ll;
ll f[200001], finv[200001], dp[200001], ans[200001];
int child[200001];
const ll mod = 1000000007;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

vector<int> v[200001];
int n;

void dfs(int p, int x){
    child[x] = 1;
    for(int j : v[x]){
        if(j == p)  continue;
        dfs(x, j);
        child[x] += child[j];
    }
    dp[x] = f[child[x]-1];
    for(int j : v[x]){
        if(j == p)  continue;
        dp[x] = dp[x]*finv[child[j]]%mod*dp[j]%mod;
    }
}

void dfs2(int p, int x){
    for(int j : v[x]){
        if(j == p)  continue;
        ans[j] = ans[x]*finv[n-1]%mod*f[n-1-child[j]]%mod*f[child[j]]%mod*modpow(dp[j], mod-2)%mod;
        ans[j] = ans[j]*f[n-1]%mod*finv[n-child[j]]%mod;
        for(int k : v[j]){
            if(k == x)  continue;
            ans[j] = ans[j]*finv[child[k]]%mod*dp[k]%mod;
        }
        dfs2(x, j);
    }
}

int main(){
    f[0] = finv[0] = 1;
    for(int i = 1; i <= 200000; i++){
        f[i] = f[i-1]*i%mod;
    }
    finv[200000] = modpow(f[200000], mod-2);
    for(int i = 199999; i >= 1; i--){
        finv[i] = finv[i+1]*(i+1)%mod;
    }

    cin >> n;
    for(int i = 0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dfs(0, 1);
    ans[1] = dp[1];
    dfs2(0, 1);
    for(int i = 1; i <= n; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 21812
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h, m, s;
    cin >> s;
    h = s / (60 * 60);
    m = (s - h * 60 * 60) / 60;
    s = s - 60 * 60 * h - m * 60;
    string ans = to_string(h) + ":" + to_string(m) + ":" + to_string(s);
    cout << ans << endl;
   // system("pause");
    return 0;
}


Measured memory_bytes: 3272
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>


//マクロ
/*動かない・・・
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _roverload3(_1,_2,_3,name,...) name
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(...) _roverload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
//*/
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
//*/
#define All(a) (a).begin(),(a).end()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
//*/
using namespace std;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
int h, w;
vector<vector<char>> s(20,vector<char>(20));
queue<pair<int, int>> que;

//使用する関数
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;
}

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

	cin >> h >> w;
	REP(i, h) {
		REP(j, w) {
			cin >> s[i][j];
		}
	}
	int ans = 0;
	REP(i, h)REP(j, w) {
		if (s[i][j] == '#')continue;
		//cout <<"start "<< i << " " << j << endl;
		que.push(make_pair(i, j));
		vector<vector<int>> dist(h, vector<int>(w, -1));
		dist[i][j] = 0;
		while (!que.empty()) {
			pair<int,int> v = que.front();
			que.pop();

			REP(k, 4) {
				int x = v.second + dx[k];
				int y = v.first + dy[k];
				//cout << x << " " << y << endl;
				if (x < 0 || x >= w || y < 0 || y >= h)continue;
				if (s[y][x] == '#')continue;
				//cout << s[y][x] << endl;
				if (dist[y][x] != -1) continue;

				dist[y][x] = dist[v.first][v.second] + 1;
				que.push(make_pair(y, x));
			}
		}
		REP(k, h)REP(l, w) {
			chmax(ans, dist[k][l]);
		}
		//cout << ans << endl;
	}
	cout << ans << endl;
}

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

int main(){
    int n, i;
    long long a = 1;
    cin >> n;
    for(i=1; i<=n; i++){
        a *= (long long)i;
        a %= 1000000007;
    }
    cout << a;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1e9
#define EPS 10e-8

int main(){
  vector<string> S;
  ll N,L;
  string s;
  cin >> N >> L;
  rep(i,N){
    cin >> s;
    S.push_back(s);
  }
  sort(S.begin(),S.end());
  rep(i,N){
    cout << S[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	aa := make([]int64, n+1)
	bb := make([]int64, n)
	var ans int64
	for i := 0; i < n+1; i++ {
		aa[i] = getNextInt64(scanner)
	}
	for i := 0; i < n; i++ {
		bb[i] = getNextInt64(scanner)
	}

	for i := 0; i < n; i++ {
		if aa[i] < bb[i] {
			ans += aa[i]
			bb[i] -= aa[i]
			aa[i] = 0
			if aa[i+1] < bb[i] {
				bb[i] -= aa[i+1]
				ans += aa[i+1]
				aa[i+1] = 0
			} else {
				ans += bb[i]
				aa[i+1] -= bb[i]
			}
			continue
		}
		ans += bb[i]
		aa[i] -= bb[i]
		bb[i] = 0
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 4736
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	N := sc.i()

	if (N % 1000) == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(1000 - (N % 1000))
	}

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


Measured memory_bytes: 1772
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();

		PriorityQueue<Double> pq = new PriorityQueue<Double>();
		for (int i = 0; i < n; i++) {
			pq.add(sc.nextDouble());
		}

		while (pq.size() > 1) {
			pq.add((pq.poll() + pq.poll()) / 2);
		}
		System.out.println(pq.peek());
		sc.close();
	}

}


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

int main() {
  int N;
  cin >> N;
  
  int X[N], Y[N], H[N];
  
  for(int i=0; i<N; i++) {
    cin >> X[i] >> Y[i] >> H[i];
  }
  
  if(N==1) {
    cout << X[0] << " " << Y[0] << " " << H[0] << endl;
  }
  
  int t = 0;
  for(int i=0; i<N; i++) {
    if(H[i]!=0) {
      t = i;
    }
  }
  
  bool flag = false;
  for(int x=0; x<=100; x++) {
    for(int y=0; y<=100; y++) {
      int tmp = abs(X[t]-x) + abs(Y[t] - y) + H[t];
      for(int i=0; i<N; i++) {
        int h = abs(X[i]-x) + abs(Y[i] - y) + H[i];
        if(H[i] != 0) {
          if(tmp==h) {
            flag = true;
          } else {
            flag = false;
            break;
          }
        } else {
          if(tmp<=h) {
            flag = true;
          } else {
            flag = false;
            break;
          }
        }
      }
      if(flag==true) {
        cout << x << " " << y << " " << tmp << endl;
        return 0;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
 int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i<N; i++)
    cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  int a=1;
  for (int i=0; i<N; i++)
    if (i-1<0)
      continue;
    else if (vec.at(i-1)<vec.at(i))
             a++;
  cout << a << endl;
}

Measured memory_bytes: 256
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

	

from collections import Counter
import bisect
N = int(input())
A = list(map(int,input().split()))
cnt = Counter(A)
A.sort()
ans = 0
MX = 10**6
P = [0] * (MX+1)
for a in A:
    if P[a]==0:
        for i in range(MX+1):
            x = a*i
            if x > MX:
                break
            P[x] = 1
        if cnt[a]==1:
            ans+=1
print (ans)

Measured memory_bytes: 39068
#include<stdio.h>
int main(void)
{
	int n,x[100],m,a,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&x[i]);
	}
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d",&a);
		if(x[a]+1!=x[a+1]&&x[a]<2019){
			x[a]++;
		}
	}
	for(i=1;i<=n;i++){
		printf("%d\n",x[i]);
	}
	return 0;
}


Measured memory_bytes: 2132
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
long long n,m,i,j,a[100005],s,cnt[100005];
int main()
{
	scanf("%lld",&n);
	fz1(i,n){
		scanf("%lld",&a[i]);
		cnt[i]=a[i];
	}
	fz1(i,n){
		s+=a[i]/2;
		a[i]%=2;
		if(i<n){
			int t=min(a[i],a[i+1]);
			s+=t;a[i]-=t;a[i+1]-=t;
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N + 1];
int B[MAX_N + 1];

void solve() {
	ll sum;
	int N;
	vector<int> d;


	cin >> N;

	fi(N) {
		int temp;
		cin >> temp;
		d.push_back(temp);
	}

	fi(N) {
		for (int n = i + 1; n < N; n++) {
          	sum += d[i] * d[n];
		}
	}

	ce(sum);
}

int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
    int X;
    cin >> X;
    int p[100000];

    int nPrime = 1;
    p[0] = 2;
    if (X == 2) cout << 2;
    else {
        int n = 3;
        while (true) {
            bool f = true;
            for (int i = 0; i < nPrime; ++i) {
                if (n % p[i] == 0) {
                    f = false;
                    break;
                }
            }
            if (f) {
                p[nPrime] = n;
                nPrime++;
                if (n >= X) {
                    cout << n;
                    break;
                }
            }
            n++;
        }
    }

    return 0;
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

    vector<int> d(n);
    rep (i, 0, n)
	cin >> d[i];
    
    sort(d.begin(), d.end());
    int s = d[n / 2 - 1];
    int t = d[n / 2];
    int res = t - s;

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 640
n,k = map(int,input().split())
maxi = 10**5
lst = [0]*(maxi+1)
for i in range(n):
    a,b = map(int,input().split())
    lst[a] += b
for ans in range(1,maxi+1):
    if k<=lst[ans]:
        print(ans)
        exit()
    k -= lst[ans]

Measured memory_bytes: 46168
// Aizu Vol-10 1036: Monster Factory
// 2017.8.21 bal4u@uu

#include <stdio.h>
char *gets();

#define MAX 10000
char in1[MAX+5], in2[MAX+5], out[MAX+5];

int main()
{
	char k, *i1, *i2, *o;

	while (1) {
		gets(in1); if (in1[0] == '-') break;
		gets(in2), gets(out);
		i1 = in1, i2 = in2, o = out, k = *i2++;
		while (*i1 || *i2) {
			if (*o == k) k = *i1++, o++;
			else {
				putchar(k);
				if (*i2) k = *i2++;
				else goto NEXT;
			}
		}
		putchar(k);
NEXT:;	putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 524
import java.util.Scanner;

public class Main {

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

		int e = a - b;
		if (e >= 0) {
			System.out.println("delicious");
		} else {
			if (-e <= x) {
				System.out.println("safe");
			} else {
				System.out.println("dangerous");
			}
		}

		sc.close();
	}
}

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

int main(){
	string s;
  	cin >> s;
  	int counter = 0;
  	if(s[0]=='1') ++counter;
  	if(s[1]=='1') ++counter;
  	if(s[2]=='1') ++counter;
  	cout << counter << endl;
}

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

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  
  if (N > K) {
    cout << (K * X) + ((N - K) * Y) << endl;
  } else {
    cout << N * X << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
cities = {}
r = []
for i in range(n):
    c, s = input().split(" ")
    r.append([c,int(s)])
    if cities.get(c) == None:
        cities[c] = [i]
    else:
        cities[c].append(i)

# sort

for c, num in sorted(cities.items()):
    for j in sorted(num, key=lambda x:r[x][1], reverse=True):
        print(j+1)


Measured memory_bytes: 3060
li, ri = map(int, input().split())
ln, rn = map(int, input().split())
ISONO = True
NAKAJIMA = False

def search(li, ri, ln, rn, turn):
  if li == None and ri == None:
    return False
  if ln == None and rn == None:
    return True

  if turn == ISONO:
    ret = False
    if li and ln:
      ret = ret or search(li, ri, ln + li if ln + li < 5 else None, rn, not turn)
    if li and rn:
      ret = ret or search(li, ri, ln, rn + li if rn + li < 5 else None, not turn)
    if ri and ln:
      ret = ret or search(li, ri, ln + ri if ln + ri < 5 else None, rn, not turn)
    if ri and rn:
      ret = ret or search(li, ri, ln, rn + ri if rn + ri < 5 else None, not turn)

  if turn == NAKAJIMA:
    ret = True
    if li and ln:
      ret = ret and search(li + ln if li + ln < 5 else None, ri, ln, rn, not turn)
    if li and rn:
      ret = ret and search(li + rn if li + rn < 5 else None, ri, ln, rn, not turn)
    if ri and ln:
      ret = ret and search(li, ri + ln if ri + ln < 5 else None, ln, rn, not turn)
    if ri and rn:
      ret = ret and search(li, ri + rn if ri + rn < 5 else None, ln, rn, not turn)

  return ret

if search(li, ri, ln, rn, ISONO):
  print("ISONO")
else:
  print("NAKAJIMA")


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


int main() {
	const int64_t INF = 1e18;
	int n; cin >> n;
	vector<int64_t> a(n);
	int64_t maxi = -INF;
	int idx = -1;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		if(a[i] > maxi) {
			maxi = a[i];
			idx = i;
		}
	}
	if(maxi < 0) {
		cout << maxi << '\n';
		cout << n - 1 << '\n';
		for(int i = n - 1; i > idx; --i) {
			cout << i + 1 << '\n';
		}
		for(int i = 0; i < idx; ++i) {
			cout << 1 << '\n';
		}
		return 0;
	}
	int64_t sum[2] = {};
	vector<vector<bool>> idxs(2, vector<bool>(1010));
	for(int i = 0; i < n; ++i) {
		if(a[i] >= 0) {
			sum[i % 2] += a[i];
			idxs[i % 2][i] = true;
		}
	}
	int ii = (sum[0] < sum[1]);
	cout << sum[ii] << '\n';
	vector<int> ans;
	for(int i = n - 1; i >= 0; --i) {
		if(not idxs[ii][i]) {
			idxs[ii].erase(idxs[ii].end() - 1, idxs[ii].end());
			ans.push_back(i + 1);
		} else {
			break;
		}
	}
	for(int i = 0; i < n; ++i) {
		if(not idxs[ii][i]) {
			ans.push_back(1);
		} else {
			idxs[ii].erase(idxs[ii].begin(), idxs[ii].begin() + i);
			break;
		}
	}
	int r = -1;
	for(int i = (int)idxs[ii].size() - 1; i >= 0; --i) {
		if(idxs[ii][i]) {
			int l = i + 1;
			if(r != -1) {
				for(int j = (l + r) / 2; j >= l; --j) {
					ans.push_back(j + 1);
				}
			}
			r = i - 1;
		}
	}
	cout << ans.size() << '\n';
	for(int i : ans) {
		cout << i << '\n';
	}
	return 0;
}

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

int main() {
	int x, y;

	cin >> x >> y;

	if(y % 2 == 0)
	{
		if (x * 2 <= y && y <= x * 4)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	else
	{
		cout << "No" << endl;
	}
}

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

public class Program
{
	public static void Main()
	{
		var loopNum = _GetIntReadLine();
		var sum = 0;
		for(var i1 = 1 ; i1 <= loopNum ; ++ i1)
		{
			for(var i2 = i1 ; i2 <= loopNum ; ++ i2)
			{
				for(var i3 = i2 ; i3 <= loopNum ; ++ i3)
				{
					if(i1 == i2 && i2 == i3)
					{
						sum += i1;
					}
					else
					{
						var nums = (new[] { i1 , i2 , i3 }).Distinct().OrderBy(i => i).ToList();
						var count = nums.Count;
						var gcd = _Gcd(nums);
						switch(count)
						{
						case 2: gcd *= 3; break;
						case 3: gcd *= 6; break;
						}
						sum += gcd;
					}
				}
			}
		}
		Console.WriteLine(sum);
	}

	private static int _Gcd(List<int> iNums)
	{
		while(true)
		{
			var a = iNums[0];
			var b = iNums[1];
			iNums.RemoveRange(0 , 2);
			var gcd = _Gcd(a , b);
			if(iNums.Count == 0) { return gcd; }
			iNums.Insert(0 , gcd);
		}
    }
	private static int _Gcd(int a , int b)
	{
		var key = a + "_" + b;
		if(_memories.ContainsKey(key)) { return _memories[key]; }

		if (a < b) { return _Gcd(b, a); }
		while (b != 0) 
		{
			var remain = a % b;
			a = b;
			b = remain;
		}

		_memories.Add(key , a);
		return a;
	}

	private static int _loopNum;
	private static Dictionary<string , int> _memories = new Dictionary<string , int>();

	private static string		_GetReadLine()		  { return Console.ReadLine(); }
	private static int			_GetIntReadLine()	  { return int.Parse(_GetReadLine()); }
	private static List<string> _GetListReadLine()	  { return _GetReadLine().Split(' ').ToList(); }
	private static List<int>	_GetIntListReadLine() { return _GetListReadLine().Select(iText => int.Parse(iText)).ToList(); }
}

Measured memory_bytes: 43652
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007
#define DEBUG 0


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}


int main()
{

	
	int n;
	cin >> n;

	vector<int> a(n);
	vector<bool> seen(n, false);

	for (int i = 0; i < a.size(); i++) {
		cin >> a[i];
	}

	int now = 1;
	seen[0] = true;
	int ans = 0;
	while (true) {
		
		now = a[now-1];
		if (seen[now-1]) {
			ans = -1;
			break;
		}
		seen[now-1] = true;
		ans++;

		if (now == 2) {
			break;
		}


	}

	if (ans < 0) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;

}



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

using namespace std;

int main(){
  int N,M; cin >> N >> M;
  vector<string> A(N); vector<string> B(M);
  for(int i = 0; i < N; i++){ cin >> A[i];}
  for(int j = 0; j < M; j++){ cin >> B[j];}
  
  for(int i = 0; i <= N - M; i++){
    for(int j = 0; j <= N - M; j++){
      bool flag = true;
      for(int x = 0; x < M; x++){
        for(int y = 0; y < M; y++){
          if(B[x][y] != A[i + x][j + y]){flag = false;}}}
      if(flag){cout << "Yes" << endl; return 0;} }}
  
  cout << "No" << endl;
  
  return 0;}

Measured memory_bytes: 256
# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

s = input()

renzoku = 0
res = 0
for tenki in s:
    if tenki == "R":
        renzoku += 1
    else:
        renzoku = 0
    res = max(renzoku, res)
print(res)


Measured memory_bytes: 9024
#include <bits/stdc++.h>
 
using namespace std;
		
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    vector<int> v;
    int x;
    cin>>n;
    while(n--){
    	cin>>x;
    	v.push_back(x);
	}
	sort(v.begin(),v.end(),greater<int>());
	int k=1;
	int i=0;
	int alice=0,bob=0;
	while(i<v.size()){
		if(k&1){
			alice+=v[i];
			i++;k++;
		}
		else{
			bob+=v[i];
			i++;k++;
		}
	}
	cout<<(alice-bob);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
typedef pair<int, int> P;

int n, m, s, t, a[100005], dist[100005];
vector<P> g[100005];
bool used[100005];
const int INF = 1e9;

void dijkstra(int s) {
	fill(dist, dist+n, INF);
	fill(used, used+n, false);
	priority_queue<P, vector<P>, greater<P> > que;
	que.push(P(0, s));
	while (!que.empty()) {
		int d, t;
		tie(d, t) = que.top();
		que.pop();
		if (used[t]) continue;
		used[t] = true;
		dist[t] = d;
		for (P e : g[t]) {
			if (dist[e.second] > d + e.first) que.push(P(d+e.first, e.second));
		}
	}
}

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> s >> t;
	s--;
	t--;
	FOR(i, n) {
		cin >> a[i];
		if (i <= s) a[i] = 0;
		if (i > 0) g[i].push_back({0, i-1});
	}
	FOR(i, m) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		g[x].push_back({a[y], y});
	}
	dijkstra(s);
	cout << dist[t] << endl;
	return 0;
}

Measured memory_bytes: 11448
S = input()

flag = True
for i,s in enumerate(S):
    if len(S)%2==1:
        print('No')
        flag = False
        break
    elif i%2==1:
        if s != 'i':
            print('No')
            flag = False
            break
    elif i%2==0:
        if s != 'h':
            print('No')
            flag = False
            break
if flag == True:
    print('Yes')

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

int main()
{
    int N;
    cin >> N;
    map<string, int> votes;
    for(int i =0; i < N; i++)
    {
        string s;
        cin >> s;
        votes[s] ++;
    }
    int max = 0;
    for(auto it:votes)
    {
        if(it.second > max) max = it.second;
    }
    for(auto it:votes)
    {
        if(it.second == max)cout << it.first << endl;
    }
}

Measured memory_bytes: 25216
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>

using namespace std;

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

  tuple<double, int, int> mx;
  for (int i = 0; i * 100 * a <= f; i++) {
    for (int j = 0; i * 100 * a + j * 100 * b <= f; j++) {
      int w = i * 100 * a + j * 100 * b;
      if (w == 0) continue;
      for (int k = 0; w + k * c <= f; k++) {
        for (int l = 0; w + k * c + l * d <= f; l++) {
          int s = k * c + l * d;
          if (100 * s <= w * e) {
            mx = max(mx, make_tuple((double)s / (s + w) * 100, s, s + w));
          }
        }
      }
    }
  }

  cout << get<2>(mx) << ' ' << get<1>(mx) << endl;
}

Measured memory_bytes: 256
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
int fac[maxn];
int a[maxn];
int n;
int c[maxn];
int cnt[maxn];
void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    if(n == 2) {
        cout << 2 << endl;
        return;
    }
    for (int i = 2; i < n; i++) {
        int t = (i - c[i - 1]) * 2 - 1;
        if(a[i - 1] >= t) {
            c[i] = c[i - 1];
        } else {
            //c[i] = (a[i - 1] + 2) / 2 - i;
            int t = i;
            while(t * 2 - 1 > a[i - 1]) t--;
            c[i] = i - t;
        }
        //cout << i << " " << c[i] << endl;
        cnt[c[i] ]++;
    }
    for (int i = n - 1; i >= 1; i--) cnt[i] += cnt[i + 1];
    ll res = 1;
    //cout << "asd" << endl;
    for (int i = n; i >= 1; i--) {
            //cout << i << " " << n - i + 1 << " " << cnt[n - i + 1] << endl;
        res = res * (i - cnt[n - i + 1]) % mod;
    }
    cout << res << endl;
}
int main() {
   // freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 1408
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (n, m) = (it.next().unwrap(), it.next().unwrap());
		
		let mut ans = n - 1;

		if n <= m {
			ans += 1;
		}

		println!("{}",ans);
}

Measured memory_bytes: 4352