akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    
    int cnt;
    for (int i = 0; i < n; i++) {
        if (s[i] == t[0])
        cnt = 0;
        int index = 0;
        for (int j = i; j < n; j++) {
            if (s[j] == t[index]) {
                cnt++;
            }
            index++;
        }
        if (cnt == n - i) {
            cout << 2 * n - cnt << endl;
            return 0;
        }
    }
    cout << 2 * n << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main(){
    int N;
    cin >> N;
    string str;
    map<string,int> S;
    for(int i=0; i<N; i++){
        cin >> str;
        if (S.count(str)) S[str]++;
        else S[str]=1;
    }
    int max = 0;
    for(auto i=S.begin(); i!=S.end(); i++) {
        if(i->second > max) max = i->second;
    }
    for(auto i=S.begin(); i!=S.end(); i++) {
        if(max==i->second) cout << i->first << endl;
    }
    return 0;
}

Measured memory_bytes: 19272
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    vector<int> num(5);
    int k;

    for ( int i = 0; i < 5; i++ ) {
        cin >> num[i];
    }
    cin >> k;

    for ( int i = 0; i < 5; i++ ) {
        for ( int j = i + 1; j < 5; j++ ) {
            if ( i == j ) {
                continue;
            }
            else if ( num[j] - num[i] > k ) {
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!" << endl;

    return 0;
}

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

int main() 
{    
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;

    if(S[K-1] == 'A')S[K-1] = 'a';
    if(S[K-1] == 'B')S[K-1] = 'b';
    if(S[K-1] == 'C')S[K-1] = 'c';

    cout << S << endl;

}

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

int A[100005], n;
int main()
{

  scanf("%d", &n);
  for(int i=0; i<n; i++)
  {
    scanf("%d", &A[i]);
  }
  int q, k, sum = 0;
  scanf("%d", &q);
  for(int i=0; i<q; i++)
  {
    scanf("%d", &k);
    if(*lower_bound(A, A+n, k) == k) sum++;
  }
  cout << sum << endl;

  return 0;
}



Measured memory_bytes: 3568
n=int(input())
numeros=[int (x) for x in input().split()]
cont=0
for x in range(0,n-2):
    if (numeros[x+1]>numeros[x] and numeros[x+1]<numeros[x+2]) or (numeros[x+1]<numeros[x] and numeros[x+1]>numeros[x+2]):
        if x==n-2:
            break
        cont+=1
print(cont)

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

namespace Algorithm
{
    class Program
    {
        const double Val = 0.006;
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var line = Console.ReadLine().Split();
            int t = int.Parse(line[0]), a = int.Parse(line[1]);
            var array = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();

            var temperature = 0d;
            var min = double.MaxValue;
            var index = 0;

            for (var i = 0; i < n; i++)
            {
                temperature = t - array[i] * Val;
                var diff = Math.Abs(a - temperature);
                if (diff < min)
                {
                    min = diff;
                    index = i + 1;
                }
            }

            Console.WriteLine(index);
        }
    }
}

Measured memory_bytes: 13332
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

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

ll solve(){
    ll res = 0;
    ll N,M; cin >> N >> M;
    string S,T; cin >> S >> T;
    if(S.front() != T.front()) return -1;
    
    ll LCM = lcm(N,M);
    
    ll x = LCM/N;
    ll y = LCM/M;
    map<ll,char> mp;
    for(int i = 0; i < S.length();i++){
        mp[i*x] = S[i];
    }
    for(int i = 0; i < T.length();i++){
        if(mp[i*y] == 0 || mp[i*y] == T[i]) continue;
        return -1;
    }
    res = LCM;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 10880
import java.util.Scanner;

public class Main {
public static void main(String args[])
{
	Scanner scan=new Scanner(System.in);
	String g=scan.next();
	int start=0;
	long sum=0;
	for(int i=0;i<g.length();i++)
	{
		sum+=Math.abs((g.charAt(i)-'0')-start);
		start=1-start;
	}
	long sum2=0;
	start=1;
	for(int i=0;i<g.length();i++)
	{
		sum2+=Math.abs((g.charAt(i)-'0')-start);
		start=1-start;
	}
	System.out.println(Math.min(sum, sum2));
	
}
}


Measured memory_bytes: 25892
#include <bits/stdc++.h>
using namespace std;
//#define int long long
    



signed main(){
    int n,k;
    cin >> n >>k;
    int x,y;
    char c;
 vector<int> m[2*k];
    for(int i=0;i<2*k;i++)for(int j=0;j<2*k;j++)m[i].push_back(0);
    for(int i=0;i<n;i++){
        cin >>x >>y >>c;
        if(c=='B'){
            m[x%(2*k)][y%(2*k)]++;
            m[(x+k)%(2*k)][(y+k)%(2*k)]++;
        }else{
            m[x%(2*k)][(y+k)%(2*k)]++;
            m[(x+k)%(2*k)][y%(2*k)]++;
        }
    }
     vector<int> msum[2*k+1];
    for(int i=0;i<2*k+1;i++)for(int j=0;j<2*k+1;j++)msum[i].push_back(0);
    for(int i=1;i<=2*k;i++){
        for(int j=1;j<=2*k;j++){
            msum[i][j]=msum[i-1][j]+msum[i][j-1]-msum[i-1][j-1]+m[i-1][j-1];
        }
    }
    int ans=0,mij=n;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            ans=max(ans,msum[i+k][j+k]-msum[i][j+k]-msum[i+k][j]+msum[i][j]);
            mij=min(mij,msum[i+k][j+k]-msum[i][j+k]-msum[i+k][j]+msum[i][j]);
        }
    }
        cout << max(ans,n-mij);

    return 0;
}

Measured memory_bytes: 32384
#include <iterator>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <vector>
#include <sstream>
#include <iomanip>
#include <string>
using namespace std;
int main(int argc, char **argv) {
  int N;
  cin >> N;

  vector<int> v;
  v.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }

  vector<int> c;
  c.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> c[i];
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (c[i] < v[i])
      ans += v[i] - c[i];
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str, T: str):
    count = 0
    for s, t in zip(S, T):
        if s != t:
            count += 1
    print(count)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9672
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int x,a,b,c; cin >> a >> b >> c >> x;
  ll ans=0;
  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        if(i*500+j*100+k*50==x){ans++;}
  }}}

  cout << ans << endl;    
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;

int main(void)
{
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;

    bool isPost = true;
    for (int i = 0; i < S.size(); i++)
    {
        if (i == A)
        {
            if (S[i] != '-')
            {
                isPost = false;
            }
        }
        else
        {
            if (!(S[i] >= '0' && S[i] <= '9'))
            {
                isPost = false;
            }
        }
    }

    if (isPost == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main(){
    double D, T, S;
    cin >> D >> T >> S;

    if (D/S > T){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}


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

using namespace std;
int n,i,a,b,c,nr,ok,v[100005];
long long sum;
int main()
{
    cin>>a>>b;
    if ((a+b)%2==0)
    {
        cout << (a+b)/2;
    }
    else
    {
        cout<<"IMPOSSIBLE";
    }
}


Measured memory_bytes: 256
s = list(input())
s = list(map(int, s))

ss = []

def numToString(s):
    if s >= 0:
        s = '+' + str(s)
    else:
        s = str(s)
    return s

for i in range(2):
    if sum(s) == 7:
        ss += str(s[0])
        ss += list(map(numToString, s[1:4]))
        ss = ''.join(ss)
        print(ss + '=7')
        exit()

    for j in range(2):
        if sum(s) == 7:
            ss += str(s[0])
            ss += list(map(numToString, s[1:4]))
            ss = ''.join(ss)
            print(ss + '=7')
            exit()

        for k in range(2):
            if sum(s) == 7:
                ss += str(s[0])
                ss += list(map(numToString, s[1:4]))
                ss = ''.join(ss)
                print(ss + '=7')
                exit()

            s[3] *= -1
        s[2] *= -1
    s[1] *= -1



Measured memory_bytes: 9120
#include<iostream>
using namespace std;
#define ll long long

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

  bool A[H][W];
  string s;
  for(ll h=0; h<H; ++h){
    cin >> s;
    for(ll w=0; w<W; ++w){
      A[h][w] = s[w]=='#';
    }
  }

  for(ll h=0; h<H; ++h){
    for(ll w=0; w<W; ++w) cout << ((w==0 || (h%2==0 && w<W-1) || A[h][w]) ? '#' : '.');
    cout << endl;
  }

  cout << endl;

  for(ll h=0; h<H; ++h){
    for(ll w=0; w<W; ++w) cout << ((w==W-1 || (h%2==1 && w>0) || A[h][w]) ? '#' : '.');
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>    
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define int long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define fone for(i=0;i<n;i++)
#define endl "\n"
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N          = 5000*100+1;
const ll N2      = 1000*1000+5;
const ld PI  = 3.14159265;
const ll R   = 250;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ return (a.second < b.second); }

signed  main ()
{
  fastio();
  int n;
  cin>>n;
  double dp[n+1],p[n];
  fill(dp,0);
  dp[0]=1;
  for(int i=0;i<n;i++)
  {
    cin>>p[i];
    for(int j=n-1;j>=0;j--)
    {
    
        {
            dp[j+1]+=dp[j]*p[i];
            dp[j]=dp[j]*(1.0-p[i]);
        }
    }
  }
  double ans=0;
  for(int i=0;i<=n;i++)
  {
    if(i>n/2)
    {
        ans+=dp[i];
    }
    //cout<<ans<<endl;
  }
  cout<<fixed<<setprecision(10);
  cout<<ans<<endl;
  
}

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

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;       //人数
            int s;       //必要な個数
            int i;

            n = int.Parse(Console.ReadLine());

            s = 0;       //合計を０に初期化

            for (i = 1; i <= n; i++)　　　　//1→nの繰り返し
            {
                s = s + i;    //s+=iでも良い
            }

            Console.WriteLine(s);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    long long n,k,h[100005],dp[100005];
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=0;i<n;i++){
        dp[i]=10000000000;
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<k;i++){
        for(int j=0;j<i;j++){
            dp[i]=min(dp[i],abs(h[i]-h[j])+dp[j]);
        }
    }
    for(int i=k;i<n;i++){
        for(int j=1;j<=k;j++)
        dp[i]=min(dp[i],abs(h[i]-h[i-j])+dp[i-j]);
    }
    cout<<dp[n-1]<<endl;
    return(0);
}

Measured memory_bytes: 5192
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  Bint a,b;
  cin>>a>>b;
  if(a>b) cout<<"GREATER"<<endl;
  if(a<b) cout<<"LESS"<<endl;
  if(a==b) cout<<"EQUAL"<<endl;
}


Measured memory_bytes: 256
/* c */
#include <bits/stdc++.h>
#define Fail puts("NO"), exit(0);
#define eps 1e-10
#define maxn 100010
#define maxm 4010
#define inf 1000000007
#define mod 1000000007
#define G 3
#define pi acos(-1)
#define mp(x, y) make_pair(x, y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef bitset<maxn> bit;
int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch - '0' < 0 || ch - '0' > 9) {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch - '0' >= 0 && ch - '0' <= 9) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
int n;
int gcd(int x, int y) {
    if (!y)
        return x;
    return gcd(y, x % y);
}
int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            for (int k = 1; k <= n; k++)
                ans = ans + gcd(gcd(i, j), k);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
n=int(input())
a=list(map(int,input().split()))
MOD= 10**9 + 7
toki = [0]*(n+1)
shigi=0

toki[0] = sum(a)-a[0]
for i in range(1, n-1):
  toki[i] = toki[i-1]-a[i]
  
for i in range(n-1):
  shigi += (a[i] * toki[i])

print(shigi%MOD)

Measured memory_bytes: 31448
n=int(input())
A,B=[],[]
for _ in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
ans=0
for a,b in zip(A[::-1],B[::-1]):
    a+=ans
    ans+=b-a%b if a%b else 0
print(ans)

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

#define REP(i,n) for(i=0;i<n;i++)

//prototype declaration
int iin();
long long llin();
double din();
char cin();
void stin(char *s);
void iout(int i);
void llout(long long i);
void dout(double i);
void cout(char c);
void stout(char *s);
int gcd(int a, int b);
int lcm(int a, int b);
long long llgcd(long long a, long long b);
long long lllcm(long long a, long long b);
int asc(const void *a, const void *b);
int desc(const void *a, const void *b);
double to_deg(double rad);

//main function
int main() {
    int n = iin(), tmp, i;
    for (i = 1; i < 10; i++) {
        if (n % i == 0) {
            tmp = n / i;
            if (tmp >= 1 && tmp <= 9) {
                stout("Yes");
                return 0;
            }
        }
    }
    stout("No");
    return 0;
}

//body function
int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

/*
    int型の最大公約数
*/

int gcd(int a, int b) {
    int r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

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

    return b;
}

/*
    int型の最小公倍数
*/

int lcm(int a, int b) {
    int r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    long long型の最大公約数
*/

long long llgcd(long long a, long long b) {
    long long r;

    if (a < b) {
        r = a;
        a = b;
        b = r;
    }

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

    return b;
}

/*
    long long型の最小公倍数
*/

long long lllcm(long long a, long long b) {
    long long r = llgcd(a, b);
    a /= r;
    return a * b;
}

/*
    int型の昇順用比較関数
*/

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

/*
    int型の降順用比較関数
*/

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

/*
    弧度法を度数法に
*/

double to_deg(double rad) {
    return rad * 180.0 / (atan(1.0) * 4.0);
}


Measured memory_bytes: 128
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int S = sc.nextInt();
    int h = S/3600;
    S = S%3600;
    int m = S/60;
    int t = S % 60;
   
    System.out.println(h+":"+m+":"+t);
  }
}

Measured memory_bytes: 26140
#include<stdio.h>
#include <limits.h>

#define N 101
#define Black 2
#define White 0
#define Gray  1



int n=0;
//int z=0;
int G[N][N];
int d[N];
//int f[N];
int color[N];
int que[N];
int head=0;
int tail=0;

void Enqueue(int s){
  que[tail] = s;
  tail++;
}

int Dequeue(){
  int y;
  y = que[head];
  head+=1;
  return y;
} 
  

void BFS(int s){
  int u,w;
  for(u=1;u<=n;u++){
    color[u] = White;
    d[u] = -1;
  }
  color[s] = Gray;
  d[s] = 0;
  Enqueue(s);
  while(head != tail){
    u = Dequeue();
    for(w=1;w<=n;w++){
      if(color[w] == White && G[u][w] == 1){
        color[w] = Gray;
        d[w] = d[u] + 1;
        Enqueue(w);
      }
    }
    color[u] = Black;
  }
}



main(){
  int i,j,s,v,r;
  int p = 1;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1; j<=n;j++){
      G[i][j] = 0;
    }
  }
  for(i=1;i<=n;i++){
    scanf("%d%d", &v,&r);
    for(j=1;j<=r;j++){
      scanf("%d",&s);
      G[i][s] = 1;
    }
  }
  BFS(p);
  for(i=1;i<=n;i++){
    printf("%d %d\n",i, d[i]);
  }
  return 0;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

int main(){
	long long A, B;
	cin >> A >> B;
	cout << max(0LL, A - 2 * B) << endl;

}

Measured memory_bytes: 3600
program ABC058C
    implicit none
    integer(8)::n,i,j,tail
    integer(8),dimension(26)::li,L
    character(10000)::out
    character(50)::S
    read(5,*)n
    L=0

    do i=1,n
        li=0
        read(5,*)S
        do j=1,len_trim(S)
            li(ichar(S(j:j))-96)=li(ichar(S(j:j))-96)+1
        end do

        do j=1,26
            if(i==1)then
                L(j)=li(j)
            else
                L(j)=min(li(j),L(j))
            end if
        end do
    end do

    tail=1
    do i=1,26
        do j=1,L(i)
            out(tail:tail)=char(i+96)
            tail=tail+1
        end do
    end do
    print'(A)',out(1:tail-1)
end program ABC058C

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<string>
#include<algorithm>
#define REP(i,n) for(int i=0; i<int(n); i++)
using namespace std;
int main() {
	string S, A;
	int N ;
	cin >> N;
	cin >> S;
	int n = 0;
	A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	for (int i = 0; i < S.length(); i++) {
		for (int j = 0; j < A.length(); j++) {
			if (S[i] == A[j]) {
				n = (j + N) % 26;
			}
		}
		S[i] = A[n];
	}
	for (int i = 0; i < S.length(); i++) {
		cout << S[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
void lsort(int a[], int left, int middle, int right){
  int b[right+1];
  int i = left, j = middle+1;
  for(int k = left; k<=right; k++) {
    //exsting i 
    if(i<=middle&& (j>right||a[i]<a[j])) {
       b[k] = a[i++];
    }else {
      b[k] = a[j++];
    }
  }
  for(int k = left; k<=right; k++){
      a[k] = b[k];
  }
}
void mergesort(int a[], int left, int right){
  if(left>=right) return ; 
  int middle = (left+right)/2;
  mergesort(a,left, middle);
  mergesort(a, middle+1, right);
  lsort(a, left, middle,right);
}

int main(){
  int n = 0;
  scanf("%d",&n);
  int a[n+1];
  long sum = 0;
  for(int i = 0; i<n ; i++){
    scanf("%d",&a[i]);
    sum += a[i];
  }
  
  mergesort(a, 0,n-1);
  /*for(int i = 0; i<n ; i++){
    printf("%d ",a[i]);
  }*/
  printf("%d %d %ld\n",a[0], a[n-1], sum);
  return 0;
}


Measured memory_bytes: 2780
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define endl '\n'

using namespace std;

ll n;
string s;
ll ans, r, g, b;

int main() {
    ios_base::sync_with_stdio(0);

    cin >> n;
    cin >> s;
    s = "*" + s;

    for(int i=1; i <= n; ++i) {
        if(s[i] == 'R') {
            r++;
        }
        else if(s[i] == 'G') {
            g++;
        }
        else {
            b++;
        }
    }
    
    ans = r * g * b;

    for(int i=1; i <= n - 1; ++i) {
        for(int j=i + 1; j <= n; ++j) {
            if(s[i] != s[j]) {
                int k = (2 * j - i);
                if(k > 0 && k <= n) {
                    if(s[k] != s[i] && s[k] != s[j] && k > j) {
                        //cout << s[i] << ' ' << s[j] << ' ' << s[k] << endl;
                        ans--;
                    }
                }
            }
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3644
n = gets.to_i
n.times do
    order = gets.chomp
    s = gets.chomp
    order.reverse.each_char do |c|
        case c
        when ?J
            s = s[-1] + s[0..-2]
        when ?C
            s = s[1..-1] + s[0]
        when ?E
            s = s[-(s.size/2)..-1] + s[s.size/2..s.size-1-s.size/2] + s[0..s.size/2-1] if s.size > 1
        when ?A
            s = s.reverse
        when ?P
            s = s.each_char.map{|l| l =~ /\d/ ? (l.to_i-1)%10 : l}.join
        when ?M
            s = s.each_char.map{|l| l =~ /\d/ ? (l.to_i+1)%10 : l}.join
        end
    end
    puts s
end

Measured memory_bytes: 8676
import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		//String []s=br.readLine().split(" ");
		String s=br.readLine(), ans="No";
		char ch[]=s.toCharArray();
		
				
		int len=s.length();
		if(len>=6)
			if(ch[2]==ch[3] && ch[4]==ch[5])
				ans="Yes";		
		
		out.println(ans);
		
		
	}
	
	
}




Measured memory_bytes: 22484
#include <iostream>
using namespace std;
int main(void){
  int n;
  cin >> n;
  for(int i = 0; i < 3; i++){
  	if(n % 10 == 7){
      cout << "Yes" << endl;
      return 0;
    }
    n /= 10;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten53 300005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
vector<ll> vll,vh,vw;
ll numh[ten53],numw[ten53];
//priority_queue<pair<ll,ll>> pq;          //decreasing

int main(void)
{
    ll m,n,i,j,k=0,d,pre=0,h,w;
    string s;
    cin>>h>>w>>m;
    if(w*m>=h) cout<<"Yes";
    else cout<<"No";
    return 0;
}





Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
const int N = 1e2+9;
const double pi = acos(-1.0);
#define ll long long
//ll dp[N];
//ll a[N];
ll n,m,d,x;
int _,__,___;
int main()
{
  //  freopen("in.txt","r",stdin);
  
ios::sync_with_stdio(false);
 cin>>n;
   for(int i = 0; i < n; i++)
   {
       int t;
       cin>>t;
       if(t%4==0) _++;
       else if(t%2==0) __++;
       else ___++;
   }
   if(_>=(n>>1) || _ >= ___) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main(void) {
  int a, b, g;
  while (scanf("%d %d", &a, &b) != EOF) {
    g = gcd(a, b);
    printf("%d\n", g);
  }
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define int long long

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int n,m; cin >> n >> m;
  static int a[101010][3];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 3; j++){
      cin >> a[i][j];
    }
  }

  int ans = 0;
  for(int i = 0; i < (1 << 3); i++){
    vector<int> v(n,0);
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < n; k++){
        v[k] += a[k][j] * ((i >> j & 1) ? 1 : -1);
      }
    }
    sort(v.rbegin(),v.rend());
    int res = 0;
    for(int j = 0; j < m; j++){
      res += v[j];
    }
    ans = max(ans,res);
  }
  cout << ans << endl;

  return 0;
}


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

typedef long long ll;

using namespace std;
int main() {
	ll N, k, m, res = 0;
	cin >> N;
	for (ll i = 1; i < sqrt(N)+1 ; i++)
	{
		if (N % i == 0) {
			m = (N / i) - 1;
			if (m > i) { res += m; }
		}
	}
	cout << res << endl;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int a, b, c; cin >> a >> b >> c;
    for (int i = 1; i <= b; i++) {
        if (a * i % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int R,G,B,N,i,j,m,ans=0;
  scanf("%d%d%d%d",&R,&G,&B,&N);
  for(i=0;i<=N/R;i++){
    m=N-R*i;
    for(j=0;j<=m/G;j++)
    if((m-G*j)%B==0)ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	static int p, q, a, n, cnt;
	
	static void search(int num, int den, int pro, int emt){
		// num = 分子(numerator) , den = 分母(denominator)
		// pro = 積(product) , emt = 要素個数(element)
		if(p*den==q*num){
			cnt++;
			return;
		}
		else if(emt==n||p*den<q*num){
			return;
		}
		else{
			emt++;
			// multi = 掛ける(multiply)
			for(int multi=pro;den*multi<=a;multi++){
				int den_new = den*multi;
				int num_new = num*multi+den;
				search(num_new,den_new,multi,emt);
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true){
			p = stdIn.nextInt();
			q = stdIn.nextInt();
			a = stdIn.nextInt();
			n = stdIn.nextInt();
			if((p|q|a|n)==0){
				return;
			}
			cnt = 0;
			search(0,1,1,0);
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 12000
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

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

    // int T;cin>>T;while(T--) 
    {
        deque<char> s;
        string st;
        cin>>st;
        ifr(i,0,st.length()) s.pb(st[i]);
        bool rev=0;
        int q,t,f;
        char c;
        cin>>q;
        while(q--) {
            cin>>t;
            if(t==1)
                rev^=1;
            else {
                cin>>f>>c;
                if(rev) {
                    if(f==1) s.pb(c);
                    else s.pf(c);
                }else {
                    if(f==1) s.pf(c);
                    else s.pb(c);
                }
            }
        }
        if(rev) reverse(all(s));
        for(auto it:s) cout<<it;
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll p[1100];
ll x[1100],y[1100],z[1100];
int main(){
    ll n,m,ans=0;
    cin>>n>>m;
    rep(i,0,n)cin>>x[i]>>y[i]>>z[i];
    
    rep(i,0,2){
        rep(j,0,2){
            rep(k,0,2){
                ll cnt=0,pos=0,tmp=0;
                if(i==0){
                    if(j==0){
                        if(k==0){
                            rep(h,0,n)p[h]=x[h]+y[h]+z[h];
                            sort(p,p+n,greater<ll>());
                            rep(g,0,m)tmp+=p[g];
                        }
                        else{
                            rep(h,0,n)p[h]=x[h]+y[h]-z[h];
                            sort(p,p+n,greater<ll>());
                            rep(g,0,m)tmp+=p[g];
                        }
                    }
                    else{
                        if(k==0){
                            rep(h,0,n)p[h]=x[h]-y[h]+z[h];
                            sort(p,p+n,greater<ll>());
                            rep(g,0,m)tmp+=p[g];
                        }
                        else{
                            rep(h,0,n)p[h]=x[h]-y[h]-z[h];
                            sort(p,p+n,greater<ll>());
                            rep(g,0,m)tmp+=p[g];
                        }
                    }
                }
                else{
                    if(j==0){
                        if(k==0){
                            rep(h,0,n)p[h]=-x[h]+y[h]+z[h];
                            sort(p,p+n,greater<ll>());
                            rep(g,0,m)tmp+=p[g];
                        }
                        else{
                            rep(h,0,n)p[h]=-x[h]+y[h]-z[h];
                            sort(p,p+n,greater<ll>());
                            rep(g,0,m)tmp+=p[g];
                        }
                    }
                    else{
                        if(k==0){
                            rep(h,0,n)p[h]=-x[h]-y[h]+z[h];
                            sort(p,p+n,greater<ll>());
                            rep(g,0,m)tmp+=p[g];
                        }
                        else{
                            rep(h,0,n)p[h]=-x[h]-y[h]-z[h];
                            sort(p,p+n,greater<ll>());
                            rep(g,0,m)tmp+=p[g];
                        }
                    }
                }
                ans=max(ans,tmp);
            }
        }
    }
    cout<<ans;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    bool flag = false;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (a % 2) flag = true;
    }

    cout << (flag ? "first" : "second") << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define lun(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<60);
const int inf=(1<<30);
const int nmax=1e5+50;
const ll mod=1e9+7;
using namespace std;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    int x;
    cin>>x;
    if(x>=30)cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
const int mod = 1000000007;
int n;
string s;
int main(){
  cin >> n >> s;
  cout << (s.substr(0,n/2)+s.substr(0,n/2) == s && n != 1 ? "Yes" : "No" )<< endl; 
}


Measured memory_bytes: 256
object Main {

  class UnionFind(val n: Int) {
    private[this] val par = Array.range(0, n)

    def root(x: Int): Int = if(par(x) == x) x else {par(x) = root(par(x)); par(x)}

    def same(x: Int, y: Int): Boolean = root(x) == root(y)

    def unite(x: Int, y: Int): Unit = par(root(x)) = root(y)
  }

  def main(args: Array[String]): Unit = {
    val Array(n,q,_*) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
    val uf = new UnionFind(n)

    for(i <- 1 to q){
      val Array(com,x,y,_*) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
      if(com==0)uf.unite(x,y)
      else println(if(uf.same(x,y)) 1 else 0)
    }
  }
}

Measured memory_bytes: 150616
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PB push_back
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int gcd(int a, int b) {
    if (b == 0)
    {
        return a;
    }

    return gcd(b,a%b);
}

int main()
{
    FIO
    ll a,b;
    cin>>a>>b;
    ll temp; 
    temp = (a*b);
    cout<<temp/gcd(a,b);
    
    return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    A = tuple(map(int,input().split()))
    ans = count(A, N, M)
    print(ans)
def count(A, N, M):
    t = hMt(A[0])
    B = [A[0]//(2**t)]
    for val in A[1:]:
        if hMt(val) != t:
            ans = 0
            return ans
        B.append(val//(2**t))
    T = nlcm(B)
    MdivT = (M//(2**(t-1)))//T
    ans = countodd(MdivT)
    return ans
def countodd(num):
    if num%2 == 0:
        ans = num//2
    else:
        ans = num//2 + num%2
    return ans
def nlcm(A):
    LCM = A[0]
    for val in A[1:]:
        #print("%d %d gcm:%d LCM:%d"%(LCM,val,gcm(LCM,val),lcm(LCM,val)))
        LCM = lcm(LCM,val)
    return LCM
    
def gcm(a, b):
    abtuple = (a,b)
    abmin = min([0,1], key=lambda x:abtuple[x])
    remainder = abtuple[1-abmin]%abtuple[abmin]
    if remainder == 0:
        return abtuple[abmin]
    return gcm(abtuple[abmin], remainder)
def lcm(a,b):
    prod = a*b
    ans = prod//gcm(a,b)
    return ans
def hMt(num):
    ans = 0
    tmp = num
    while tmp%2 == 0:
        tmp = tmp//2
        ans += 1
    return ans
main()

Measured memory_bytes: 20192
# import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb

# def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
INF = 1001001001001
# MOD = 1000000007


def main():

    N = int(input())
    P = list(map(int, input().split()))

    ans = 0
    min_num = INF
    for p in P:
        min_num = min(min_num, p)
        if min_num >= p:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 76240
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = 998244353;
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, m, k; cin >> n >> m >> k;
    vector<ll> fac(n, 0);
    vector<ll> inv(n, 0);
    vector<ll> finv(n, 0);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i=2; i<n; ++i) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
    ll ans = 0;
    rep(i, k+1) {
        // ans += m % MOD * factorial(n-1ll) % MOD * modinv(factorial(i), MOD) % MOD * modinv(factorial(n-1ll-i), MOD) % MOD * modpow(m-1ll, n-1ll-i) % MOD;
        ans += m % MOD * fac[n-1] % MOD * finv[i] % MOD * finv[n-1-i] % MOD * modpow(m-1ll, n-1ll-i) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7836
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1<<21)
#define white 0
#define gray 1
#define black 2

int n;
int W[100][100];
int color[100],d[100],p[100];

void dijkstra(int s) {
  d[s] = 0;

  while(1) {

    int mini = INF,u;
    for(int i = 0;i < n;i++) {
      if(color[i] != black && mini > d[i]) {
        mini = d[i];
        u = i;
      }
    }

    if(mini == INF) break;
    color[u] = black;

    for(int i = 0;i < n;i++) {
      if(color[i] != black && W[u][i] != INF) {
        if(d[u] + W[u][i] < d[i]) {
          d[i] = d[u] + W[u][i];
        }
      }
    }

  }

  for(int i = 0;i < n;i++) {
    cout << i << " " << d[i] << endl;
  }
}


int main() {

  cin >> n;
  for(int i = 0;i < n;i++) {
    for(int j = 0;j < n;j++) {
      W[i][j] = INF;
    }
  }

  for(int i = 0;i < n;i++) {
    int u,k;
    cin >> u >> k;
    color[i] = white;
    d[i] = INF;
    for(int j = 0;j < k;j++) {
      int v,c;
      cin >> v >> c;
      W[u][v] = c;
    }
  }

  dijkstra(0);

}





Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
    int N, M;
    cin >> N >> M;
    if(N==M)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  int ans=0;
  cin>>n;
  int a,b;
  cin>>a>>b;
  for(int i=1;i<n;i++){
    int x,y;
    cin>>x>>y;
    if(x==y){
      a=max(a,b);
      b=max(a,b);
    }else{
      int& t1=(x<y?a:b);
      int& t2=(x<y?b:a);
      if(x>y)swap(x,y);
      int t=max((t1+x-1)/x,(t2+y-1)/y);
      t1=t*x;
      t2=t*y;
    }
  }
  cout<<a+b<<endl;
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int a, b, c; cin >> a >> b >> c;
  cout << (a*b/2) << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main(){
	map<int, int> fr;
	int ans = 0;
	int N; cin>>N; int a;
	for(int x=0; x<N; x++){
		cin>>a;
		fr[a]++;
		fr[a-1]++;
		fr[a+1]++;
		ans = max(ans, fr[a]);
		ans = max(ans, fr[a-1]);
		ans = max(ans, fr[a+1]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 1e5;

int prime[MAX_N];
bool is_prime[MAX_N*2];

int siege(int n) {
    int p = 0;
    fill(is_prime, is_prime+n, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            prime[p++] = i;
            for (int j = 2*i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return p;
}

int main(void) {
    int p = siege(MAX_N*2);
    int N, P;
    while (cin >> N >> P) {
        if (N == -1 && P == -1) break;

        int t = 0;
        int func_M[1000];
        int st = upper_bound(prime, prime+p, N) - prime;
        for (int i = st; i < st+40; i++) {
            for (int j = i; j < st+40; j++) {
                func_M[t++] = prime[i]+prime[j];
            }
        }
        sort(func_M, func_M+t);
        cout << func_M[P-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 3412
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#define llint long long
#define mod 1000000007
#define inf 1000000000000

using namespace std;
typedef pair<int, int> P;

struct edge{
	int to, cost;
	edge(int a, int b){
		to = a, cost = b;
	}
};

llint n, m;
llint s, t;
vector<edge> g[100005], G[300005];
llint dist[300005];


void dijkstra()
{
	for(int i = 1; i <= 3*n; i++) dist[i] = inf;
	dist[s] = 0;
	
	priority_queue< P, vector<P>, greater<P> > Q;
	Q.push( make_pair(0, s) );
	
	int v, d;
	while(Q.size()){
		d = Q.top().first;
		v = Q.top().second;
		Q.pop();
		if(dist[v] < d) continue;
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i].to] > d + G[v][i].cost){
				dist[G[v][i].to] = d + G[v][i].cost;
				Q.push( make_pair(dist[G[v][i].to], G[v][i].to) );
			}
		}
	}
}

int main(void)
{
	cin >> n >> m;
	llint u, v;
	for(int i = 1; i <= m; i++){
		cin >> u >> v;
		g[u].push_back(edge(v, 1));
	}
	cin >> s >> t;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < g[i].size(); j++){
			int u = g[i][j].to;
			for(int k = 0; k < 3; k++){
				G[i+k*n].push_back(edge(u+(k+1)%3*n, 1));
			}
		}
	}
	dijkstra();
	
	
	llint ans = dist[t];
	if(ans >= inf) cout << -1 << endl;
	else cout << ans/3 << endl;
	
	return 0;
}

Measured memory_bytes: 24448
#!/usr/bin/env python3
def main():
    import numpy as np

    N = int(input())

    cnt = np.zeros((10, 10), dtype=np.int64)
    for n in [str(x) for x in range(1, N + 1)]:
        cnt[int(n[0])][int(n[-1])] += 1

    print((cnt[:, :] * cnt.T[:, :]).sum())


if __name__ == '__main__':
    main()


Measured memory_bytes: 40696
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  double n; cin >> n;
  int b = (n+1)/2;
  printf("%.6f\n",(double)(b/n));

  return 0;
}


Measured memory_bytes: 256