akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  
  int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  rep(i,n){
    cin >> a[i] >> b[i] >> c[i];
  }
  const int INF = 1001001001;
  vector<vector<int>> dp(n,vector<int>(3,INF));
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  rep(i,n-1){
    dp[i+1][0] = max(dp[i][1]+a[i+1],dp[i][2]+a[i+1]);
    dp[i+1][1] = max(dp[i][2]+b[i+1],dp[i][0]+b[i+1]);
    dp[i+1][2] = max(dp[i][0]+c[i+1],dp[i][1]+c[i+1]);
  }
  cout << *max_element(all(dp[n-1])) << endl;
}

Measured memory_bytes: 9852
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, M;
pair<ll, ll>p[100000];
ll res;
int cnt;

int main() {
	cin >> N >> M;
	for (int i = 0; i != N; ++i) {
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p + N);
	for (int i = 0; i != N; ++i) {
		if (cnt + p[i].second >= M) {
			cout << res + (M - cnt)*p[i].first << endl;
			return 0;
		}
		res += p[i].first*p[i].second;
		cnt += p[i].second;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

#define MAX_N 200010

LL fact[ MAX_N ];
LL factInv[ MAX_N ];

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

LL calc( int W, int H )
{
	return ( ( fact[ W + H - 2 ] * factInv[ W - 1 ] % MOD ) * factInv[ H - 1 ] ) % MOD;
}

int main()
{
	int H, W, A, B;
	cin >> H >> W >> A >> B;

	fact[ 0 ] = fact[ 1 ] = 1;
	for( int i = 2; i < MAX_N; ++i )
	{
		fact[ i ] = ( fact[ i - 1 ] * i ) % MOD;
	}

	for( int i = 0; i < MAX_N; ++i )
	{
		factInv[ i ] = calcPow( fact[ i ], MOD - 2, MOD );
	}

	LL ans = 0;

	for( int i = B; i < W; ++i )
	{
		ans += ( calc( H - A, i + 1 ) * calc( A, W - i ) ) % MOD;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3328
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());




// -----------------------------------------------------------------------

int fre[26];
void solve(){
	char t;
	cin>>t;
	if(t=='a' || t=='e' || t=='i' || t=='o' || t=='u' ){
		cout<<"vowel";
	}else cout<<"consonant";
}


// -----------------------------------------------------------------------


int32_t main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
//	cin>>t;
	while(t--)
	solve();
	return 0;
}


Measured memory_bytes: 256
from math import gcd

K = int(input())

ans = 0
ans += sum(range(1, K + 1))
for i in range(1, K):
    for j in range(i + 1, K + 1):
        ans += gcd(i, j) * 6
for i in range(1, K - 1):
    for j in range(i + 1, K):
        for k in range(j + 1, K + 1):
            ans += gcd(gcd(i, j), k) * 6
print(ans)


Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

void Main(){
    string N;
    cin >> N;
    ll ans = 0;
    rep(i,N.size()){
        ans += (N[i] - '0');
    }
    yesno(ans%9==0);
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
    int main(void){
        // Your code here!
        int A, B, C;
            cin >> A >> B >> C;
        if(A == B && B == C){
            cout << "No" << endl;
        }else if(A == B || B == C || A == C){
            cout << " Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    return 0;}


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

int main(){
  int n;
  int c=0;
  cin >> n;
  for(int i=1;i<=n;i++){
    if(i%2 == 1)c++;
  }
  cout << (float)c/n;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
///1<<3シフト演算子 とは　0001の1を三つずらして1000にする, これは8を表しておりつまりbitは0から7まで
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"Yes"<<endl
#define cno cout<<"No"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)    c
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換


int main(){
    
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int> > a(n, vector<int>(m));
    rep(i,n){
        cin >> c.at(i);
        rep(j,m) cin >> a.at(i).at(j);
    }
    
    int cost = 1000000000;

    rep(bit,1 << n){
        vector<int> nattoku(m,0);
        int cost_now = 0;
            rep(i,n){
                if(bit & (1 << i)){
                    rep(j,m) nattoku.at(j) += a.at(i).at(j);
                    cost_now += c.at(i);
                }
            }
        bool ok = true;
        rep(i,m) if(nattoku.at(i) < x) ok = false;
        if(ok) cost = min(cost,cost_now);
    }
    if(cost == 1000000000) cout << -1 << endl;
    else cout << cost << endl;
    return 0;
}
    




Measured memory_bytes: 3596
#include<stdio.h>
 
long long fibodp(int n) {
	long long fibodp[200] = {0};
	fibodp[1] = 1;
	fibodp[2] = 2;
	for(int i = 3; i <= n; i++) {
  	fibodp[i] = fibodp[i-1] + fibodp[i-2];
	}
 	return fibodp[n];
}
int a;
int main(void){
	int a;
	scanf("%d", &a);
	printf("%lld\n", fibodp(a));
	return 0;
}


Measured memory_bytes: 2104
n, k = [int(i) for i in input().split()]
r, s, p = [int(i) for i in input().split()]
t = input()

x = [0 for i in range(n)]
y = [None for i in range(n)]

t = list(t)

def hoge(my_hand, target_char, value, x):
  for i in range(n):
    if t[i] == target_char:
      if i - k < 0:
        x[i] = value
        y[i] = my_hand
      else:
        if y[i - k] != my_hand:
          x[i] = value
          y[i] = my_hand

rr = [r, 'r', 's']
pp = [p, 'p', 'r']
ss = [s, 's', 'p']

fuga = [rr, pp, ss]

fuga.sort(key=lambda x: x[0], reverse=True)

for f in fuga:
  hoge(f[1], f[2], f[0], x)

print(sum(x)) 


Measured memory_bytes: 5748
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

int m,d;

int main(){
  int ans=0;
  cin >> m >> d;
  REP(i,d){
    REP(j,m){
      int d1=i+1;
      int d10=d1/10;
      d1%=10;
      if (d1>=2){
        if (d10>=2){
            if (d1*d10==j+1)ans++;
        }
      }
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b , k;
    int  cnt = 0;
    cin >> a >> b >> k;
    int max_inp;
    if(a > b)
    {
        max_inp = b;
    }
    else
    {
        max_inp = a;
    }

    for(int i = max_inp; i >= 1;i--)
    {
        if((a % i == 0) && (b % i == 0))
        {
            cnt++;
        }
        if (cnt == k)
        {
            cout << i;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll p(N);
    for(ll i=0;i<N;i++)cin>>p[i];
    
    ll ans=0;
    ll max=0;
    for(int i=0;i<N;i++){
        ans+=p[i];
        if(p[i]>max)max=p[i];
    }
    ans-=max/2;
    cout<<ans<<endl;
    
    return 0;
}


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

signed main() {
  int N;
  cin >> N;
  
  vector<int> P(N);
  for( int i = 0; i < N; i++ ) cin >> P.at(i);
  
  int bef = 10000000;
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    if( P.at(i) <= bef ){
      bef = P.at(i);
      ans++;
    }
  }
  cout << ans << endl;
  
}
  

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int h = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] AopB = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
            // List<long> kl=new List<long>(hs.Keys);
            // kl.Sort();
            // foreach(long k in kl){
            //     s[1]-=hs[k];
            //     if(s[1]<1){Console.WriteLine("{0}",k);break;}
            // }
            Console.WriteLine(x>=1200?"ARC":"ABC");
        }
        //最小公倍数
        static long Lcm(long a, long b)
        {
            return a/Gcd(a,b)*b;
        }

        //最大公約数
        static long Gcd(long m, long n)
        {
            if(n==0)return m;
            return Gcd(n,m%n);
        }
    }
}


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

const int MOD = 1e9+7;

int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  if(n%2==1){
    rep(i,n){
      if(i%2==0) b[i]=i;
      else b[i]=i+1;
    }
  }else{
    rep(i,n){
      if(i%2==0) b[i]=i+1;
      else b[i]=i;
    }
  }
  if(a!=b) cout<<0<<endl;
  else{
    ll ans=1;
    rep(i,n/2){
      ans*=2;
      ans%=MOD;
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3940
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    String T = sc.next();
    int leng = S.length();
    
    for(int i=0; i<S.length(); i++){
      if(S.equals(T)){
        System.out.println("Yes");
        return;
      }
      S = S.charAt(leng-1) + S;
      S = S.substring(0,leng);
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 22100
A, B, C, D, E, F = map(int, input().split())

sugar_water = -1
sugar = -1
concentration = -1

for i in range(F//(A*100)+1):
    for j in range((F-A*100*i)//(B*100)+1):
        for k in range((F-A*i*100-B*100*j)//C+1):
            for l in range((F-A*i*100-B*100*j-C*k)//D+1):
                x = i * A + j * B
                y = k * C + l * D
                if x == 0:
                    continue
                if x * E >= y and concentration < (100 * y)/(x*100+y):
                    sugar_water = 100 * x + y
                    sugar = y
                    concentration = (100 * y)/(x*100+y)

print(sugar_water,sugar)

Measured memory_bytes: 3064
//AtCoder ABC086 A - Product
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll a,b;
    cin>>a>>b;
    auto c=a*b;
    cout<<(c%2==1?"Odd":"Even")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <cstdint>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 1000000007;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    ll K;
    cin >> N >> M >> K;
    vector<ll> A(N+1), B(M+1);
    vector<pair<ll,int>> RA(N+1), RB(M+1);
    ll sum = 0,sum2=0;
    A[0] = 0;
    B[0] = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
        sum += A[i];
        RA[i].first = sum;
        RA[i].second = i;
    }
    for (int i = 1; i <= M; ++i) {
        cin >> B[i];
        sum2 += B[i];
        RB[i].first = sum2;
        RB[i].second = i;
    }
    RB[0].first = 0;
    RA[0].first = 0;
    RB[0].second = 0;
    RA[0].second = 0;
    ll time = K;
    int ans = 0;
    vector<ll> BB(M+1);
    for (int i = 0; i <= M; ++i) {
        BB[i] = RB[i].first;
    }
    for (int i = 0; i <= N; ++i) {
        time = K;
        time -= RA[i].first;
        int temp = 0;
        temp += RA[i].second;
        if (time < 0)continue;
        decltype(BB)::iterator it = std::lower_bound(BB.begin(), BB.end(), time);
        if (it == BB.end()) {
            temp += RB[M - 1].second;
        }
        else {
            std::size_t pos = std::distance(BB.begin(), it);
            if (time == RB[pos].first) {
                temp += RB[pos].second;
            }
            else {
                temp += RB[pos - 1].second;
            }   
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 14284
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int n, m, s, g1, g2, res; cin >> n >> m >> s >> g1 >> g2, n; cout << res << endl){
        vvi d(n, vi(n, inf));
        rep(u, n) d[u][u] = 0;
        rep(i, m){
            int u, v, c; cin >> u >> v >> c;
            u--, v--;

            d[u][v] = c;
        }

        rep(k, n) rep(i, n) rep(j, n){
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
        
        res = inf; s--, g1--, g2--;
        rep(u, n){
            res = min(res, d[s][u] + d[u][g1] + d[u][g2]);
        }
    }

	return 0;
}

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

int main() {
  string X,Y,Z;
  cin >> X >> Y >> Z;
  cout << Z << " " << X << " " << Y << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio,std.string,std.conv,std.math;

int main()
{
	double EPS = 1e-12;
	string s;
	while((s = readln.chomp).length != 0)
	{
		string[] _s = s.split(" ");
		double a[8];
		foreach(i;0..8)
		{
			a[i] = _s[i].to!double;
		}

		if(fabs(((a[2]-a[0])*(a[6]-a[4]))+((a[3]-a[1])*(a[7]-a[5]))) <= EPS)
		{
			writeln("YES");
		}
		else 
		{
			writeln("NO");
		}
	}
	return 0;
}

Measured memory_bytes: 1076
#include<stdio.h>

static const int N = 500;
static const int INFTY = (1<<21);

#define NIL -1

int p[100];
int key[100];
int n;


main(){
  int i,j,a,b,c,sum;
  int M[100][100];
  int l[100];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for (j=0;j<n;j++){
      scanf("%d",&a);
      M[i][j] = (a==-1)?INFTY:a;
    }
  }



  for(c=0;c<n;c++){
    key[c]=100000000;

    p[c]=NIL;

    l[c]=NIL;
  }
  key[0]=0;

  while(1){
    int c=NIL;
    int b=100000000;


    for(i=0;i<n;i++){
     

      if(key[i]<b && l[i]==NIL){
	b=key[i];
	c=i;
      }
    }
	
      
    
    if(c==NIL){
      break;
    }

    for(b=0;b<n;b++){
      if(M[c][b] < key[b] && l[b]==NIL){
	key[b]=M[c][b];
	p[b]=c;
      }
    }
    l[c]=0;
  }


  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

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

  return 0;
}

Measured memory_bytes: 636
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int n,x,a[100010],ans=-1;
vector<int> v;
int GCD(int a,int b){
	if (a%b==0) return b;
	return GCD(b,a%b);
}
int main(){
	cin>>n>>x;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<n;i++) v.push_back(abs(x-a[i])),x=a[i];
	ans=v[0];
	for (int i=1;i<v.size();i++)
		ans=GCD(max(ans,v[i]),min(ans,v[i]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1276
#include<algorithm>
#include<iostream>

const int INF = 1 << 29;

int n, m;
int d[2][3000][3000];

int main()
{
	while( std::cin >> n >> m, n | m )
	{
		for( int i = 0; i != n; ++i )
			for( int j = 0; j != n; ++j )
				for( int k = 0; k != 2; ++k )
					d[k][i][j] = i == j ? 0 : INF;

		for( int i = 0; i != n; ++i )
		{
			int a, b, c, t;
			std::cin >> a >> b >> c >> t;
			d[0][a-1][b-1] = d[0][b-1][a-1] = c;
			d[1][a-1][b-1] = d[1][b-1][a-1] = t;
		}

		for( int k = 0; k != m; ++k )
			for( int i = 0; i != m; ++i )
				for( int j = 0; j != m; ++j )
					for( int l = 0; l != 2; ++l )
						d[l][i][j] = std::min( d[l][i][j], d[l][i][k] + d[l][k][j] );

		int k;
		std::cin >> k;
		while( k-- )
		{
			int p, q, r;
			std::cin >> p >> q >> r;

			std::cout << d[r][p-1][q-1] << std::endl;
		}
	}

	return 0;	
}

Measured memory_bytes: 62596
import sys

def read_int():
    l = sys.stdin.readline().rstrip('\n').split(' ')
    return int(l[0])

def read_int_list():
    l = sys.stdin.readline().rstrip('\n').split(' ')
    return [int(i) for i in l]

N, M, K = tuple(read_int_list())
A = read_int_list()
B = read_int_list()

ans = 0
sum_k =  0

ai = 0
bi = 0

for i in range(len(A)):
    if sum_k + A[i] > K:
        break
    sum_k += A[i]
    ai = i + 1

for i in range(len(B)):
    if sum_k + B[i] > K:
        break
    sum_k += B[i]
    bi = i + 1

ans = ai + bi

for i in range(ai - 1, -1, -1):
    sum_k -= A[i]
    ai = i
    while bi < len(B) and sum_k + B[bi] <= K:
        sum_k += B[bi]
        bi += 1
    ans = max(ans, ai+bi)
print(ans)



Measured memory_bytes: 40972
#include<bits/stdc++.h>
using namespace std;
int main(){
        long long int n;
        cin >> n;
        long long int ans = 0;

        for(long long int i = 1; i <= n; i++){
                if( !(i % 3) && !(i % 5)){
                }
                else if(!(i%3)){

                }
                else if(!(i%5)){
                }else{
                        ans += i;
                }
        }
        cout << ans << endl;
}


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

int main(){

    int a,b,c;
    cin>> a >> b >> c;

    cout << a+b+c-max(a,max(b,c)) <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N,M;
string str;
struct UnionFind {
	vector<int> data;
	void init(int n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if(x != y) {
			if(data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
}uf;
int main(){
	cin>>N>>M;
	uf.init(N);
	rep(i,M){
		int x,y,z;
		cin>>x>>y>>z;
		x--;y--;
		uf.unionSet(x,y);
	}
	int ans=0;
	rep(i,N){
		if(uf.root(i)==i)ans++;
	}
	cout<<ans<<endl;
}

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

int main(){
    int a,b,i;
    int p,q;
    int ans=0;
    int x=0;
    scanf("%d %d",&a,&b);
    if(a<b) {
        for(i=0;i<b;i++)printf("%d",a);
    }  else  {
        for(i=0;i<a;i++)printf("%d",b);
    } 
}

Measured memory_bytes: 128
h, w = map(int, input().split())
n = int(input())
list_A = list(map(int, input().split()))
ans = [[0]*w for _ in range(h)]
cnt = -1
x = []
y = []
for i in range(w):
    if i % 2 == 0:
        x += [i for i in range(h)]
    else:
        l = [i for i in range(h)]
        l.reverse()
        x += l

for i in range(w):
    for _ in range(h):
        y.append(i)

for i, num in enumerate(list_A):
    for _ in range(num):
        cnt += 1
        ans[x[cnt]][y[cnt]] = i+1

for l in ans:
    print(*l)

Measured memory_bytes: 4076
#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; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll n; cin >> n;
    if(n == 0) cout << 0 << endl;
    while(n!=0){
        res += to_string(abs(n)%2);
        if(n%2==0) n /= (-2);
        else{
            if(n>=0){
                n/= 2;
                n*=-1;
            }else{
                n*=-1;
                n++;
                n/=2;
            }
        }
    }
    reverse(res.begin(),res.end());
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int ok = 0;
        while(n){
            ok |= (n % 10 == 7);
            n /= 10;
        }
        if(ok){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }
}

Measured memory_bytes: 34216
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }
    int ans = 1e8;
    rep(i, 1<<n) {
        vector<int> b(m, 0);
        int cost = 0;
        rep(j, n) {
            if ((i>>j) & 1) {
                cost += c[j];
                rep(k, m) {
                    b[k] += a[j][k];
                }
            }
        }
        bool ok = true;
        rep(k, m) {
            if (b[k] < x) ok = false;
        }
        if (ok) {
            ans = min(ans, cost);
        }
    }
    if (ans == 1e8) cout << -1 << endl;
    else            cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3580
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
div = 10**9 + 7

import math
def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

if abs(N - M) == 0:
    temp = math.factorial(N) * math.factorial(M) * 2 
    print(temp%div)
elif abs(N - M) == 1:
    temp = math.factorial(N) * math.factorial(M)
    print(temp % div)

else:
    print(0)


Measured memory_bytes: 5184
<?php
fscanf(STDIN, "%s", $w);
$text = array();
$total_string = strlen($w);
for ($i = 0; $i < $total_string; $i++) {
    if (isset($text[$w[$i]])) {
        $text[$w[$i]]++;
    } else {
        $text[$w[$i]] = 1;
    }
}
foreach ($text as $obj) {
    if ($obj % 2  == 1) {
        echo 'No';
       exit;
    }
}
echo 'Yes';
exit;
?>


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

int main(){
	double xa, xb, xc, xd, ya, yb, yc, yd;
	double tc, td;
	while (cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd) {
		if ( (xa-xb)*(xc-xd) == -1*(ya-yb)*(yc-yd)) {
			cout << "YES" << endl;
		}else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main{

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int[][]a=new int[n][3];
		
		for(int j=0;j<n;j++)
			for(int l=0;l<3;l++)
			a[j][l]=scan.nextInt();
			
		for(int i=0;i<n;i++)
			{Arrays.sort(a[i]);	
			if(a[i][0]*a[i][0]+a[i][1]*a[i][1]==a[i][2]*a[i][2])
				System.out.println("YES");
			else
				System.out.println("NO");
			}
}}

Measured memory_bytes: 35792
def resolve():
    N = int(input())
    facts = [i ** 5 for i in range(120)]
    for a, a5 in enumerate(facts):
        for b, b5 in enumerate(facts):
            if a5 + b5 == N:
                print(a, -b)
                break
            if a5 - b5 == N:
                print(a, b)
                break
        else:
            continue
        break


resolve()

Measured memory_bytes: 9072
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int x;
    cin >> x;

    bool p[200010];
    for (int i = 2; i <= 200000; i++) p[i] = 1;

    p[0] = p[1] = 0;
    for (int i = 2; i <= 200000; i++) {
        if (p[i]) {
            for (int j = i * 2; j <= 200000; j += i) p[j] = 0;
        }
    }
    for (int i = x; i <= 200000; i++) {
        if (p[i]) {
            cout << i << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n,L,T;
vl a;

int main(){
	cin>>n>>L>>T;
	a=vl(n);
	ll I=0;
	for(int i=0;i<n;i++){
		ll x,t;
		cin>>x>>t;
		if(t==1){
			a[i]=(x+T)%L;
			I=(I-(T+x)/L%n+n)%n;
		}
		else{
			a[i]=(x-T%L+L)%L;
			(I+=(T+L-x-1)/L)%=n;
		}
	}
	sort(a.begin(),a.end());
	for(int i=0;i<n;i++) cout<<a[(n-I+i)%n]<<endl;
}

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

int main(){
  long long n,x;
  cin>>n>>x;
  vector<long long>l(n+1);
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  vector<long long>dp(n+1);
  dp[0]=0;
  for(int i=1;i<n+1;i++){
    dp[i]=dp[i-1]+l[i-1];
  }

  int ans=0;
  for(int j=0;j<n+1;j++){
    if(dp[j]<=x){
      ans++;
    }
  }

  cout<<ans<<endl;
  
}
  

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  const int NUM=20;
  int n,i;
  scanf("%d",&n);	// 数を取得
  int a[NUM];
  int b[NUM];
  int c[NUM];
  int point[NUM-1];	
  int pointnum=0;	// 追加ポイントの数
  
  for(i=0; i<n; i++)
  {
    scanf("%d",&a[i]);
    
    // a[i-1],a[i]が連続の場合は、a[i-1]を保持する
    if(i>0)
    {
      if(a[i]-a[i-1] == 1)
      {
        point[pointnum]=a[i-1];
        pointnum++;
      }
    }
  }

  int bsum=0;

  for(i=0; i<n; i++)
  {
    scanf("%d",&b[i]);
//    printf("%d ", b[i]);
    bsum += b[i];
  }
  int pointsum=0;
  for(i=0; i<n-1; i++)
  {
    scanf("%d",&c[i]);
//    printf("%d ", c[i]);
  }
  int csum=0;	// 追加ポイントのサム値
  for(i=0;i<pointnum;i++)
  {
//    printf("point[i]= %d\n",point[i]);
    csum += c[point[i]-1];
//    printf("%d unko\n", csum);
  }
  printf("%d",bsum+csum);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
struct union_find{
    vector<int> par; 
    vector<int> size;
    //1からnまで初期化:par[i] = i(1<=i<=n)
    union_find(int n){
        par.push_back(0);
        size.push_back(0);
        for(int i = 1;i<=n;i++){
            par.push_back(i);
            size.push_back(1);
        }
    }
    int root(int a){
        if (par[a] == a) return a;
        par[a] = root(par[a]);
        return root(par[a]);
    }
    void unite(int a,int b){
        if (root(a) == root(b)) return;
        size[root(b)]+=size[root(a)];
        par[root(a)] = root(b);
    }
    bool same(int a,int b){
        return (root(a) == root(b));
    }
    //頂点aが含まれる木の大きさ(頂点数)
    int treesize(int a){
        return size[root(a)];
    }
};
int main(){
    int n,m;
    cin >> n >> m;
    union_find tree(n);
    int k,l;
    int check[m];
    fill_n(check,m,-1);
    for(int i = 0;i<n;i++){
        cin >> k;
        for(int j = 0;j<k;j++){
            cin >> l;
            l--;
            if(check[l]==-1) check[l]=i+1;
            else{
                tree.unite(i+1,check[l]);
            }
        }
    }
    //for(int i = 0;i<n;i++) cout << tree.par[i+1] << " ";
    //cout << tree.treesize(1) << endl;
    if(tree.treesize(1)==n) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

using namespace std;

int main()
{
    char n[200010];
    cin>>n;
    int s=0;
    for (unsigned int i=0;i<strlen(n);++i)
        s=s+n[i]-'0';
    if (s%9)
        cout<<"No";
    else
        cout<<"Yes";
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[4]={0};
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s=="AC")
            arr[0]++;
        else if(s=="WA")
            arr[1]++;
        else if(s=="TLE")
            arr[2]++;
        else if(s=="RE")
            arr[3]++;
    }
    cout<<"AC x "<<arr[0]<<"\n";
    cout<<"WA x "<<arr[1]<<"\n";
    cout<<"TLE x "<<arr[2]<<"\n";
    cout<<"RE x "<<arr[3]<<"\n";
    return 0;
}


Measured memory_bytes: 3624
# 全てを先に計算しておき、累積和を使って結果を表示する。 今度コソ累積和
# それにより、同じ計算を何度もしなくてすむ。最大10^5になるはず。
# 

import math
from itertools import accumulate

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


# 2017に似た数

def is_like2017(n):
    if is_prime(n) and is_prime((n+1)//2):
        return True
    else:
        return False


Q = int(input())

l_list = [0]*Q
r_list = [0]*Q

for i in range(Q):
    l_list[i], r_list[i] = map(int, input().split())
    
min_value = min(l_list)
max_value = max(r_list)

ans = []

for i in range(min_value, max_value+1):
    if i % 2 == 0:
        ans.append(0)
    elif is_prime(i) and is_like2017(i):
        ans.append(1)
    else:
        ans.append(0)

ans = [0] + list(accumulate(ans))        
        
for i in range(Q):
    print(ans[r_list[i]-min_value+1]-ans[l_list[i]-min_value])
   

Measured memory_bytes: 16804
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <typeinfo>
#include <list>
#include <queue>
#include <stack>
#include <limits.h>
#include <unordered_set>
#include <map>
#include <cstring>

using namespace std;

typedef long long ll;

int mod = 1e9 + 7;

ll Solve(ll K, ll A, ll B) {
    if (B > A + 2 && K > A) {
        return (K + 1 - A) / 2 * (B - A) + ((K + 1 - A) & 1) + A;
    }
    return 1 + K;
}


int main() {
    ios::sync_with_stdio(false);
    ll K, A, B;
    cin >> K >> A >> B;
    cout << Solve(K, A, B);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc152() {
	ll N, M;
	string ans;

	cin >> N >> M;

	if (N == M) ans = "Yes";
	else ans = "No";

	cout << ans << "\n";
}

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

	solve_abc152();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  string s; cin >> s;
  string a = "abcdefghijklmnopqrstuvwxyz";
  
  if(s.size() == 1) {
    cout << 0 << endl;
    return 0;
  }
  
  vector<int> ans(26, 0);
  rep(i, 26) if(count(s.begin(), s.end(), a[i]) == 0) ans[i] = 1000000000;
  
  rep(i, 26) {
    int k = 0;
    rep(j, s.size()) {
      if(s[j] == a[i]) {
        ans[i] = max(ans[i], k);
        k = 0;
      } else {
        k++;
      }
    }
    ans[i] = max(ans[i], k);
  }
  //rep(i, 26) cout << a[i] << ans[i] << endl;
  sort(all(ans));
  cout << ans[0] << endl;
  
    
}

Measured memory_bytes: 3632
N, K = [int(i) for i in input().split()]
people_have = []
for i in range(K):
  d = input()
  A = [int(i) for i in input().split()]
  people_have.extend(A)
people_not_have = set([int(i+1) for i in range(N)]) - set(people_have)
print(len(people_not_have))

Measured memory_bytes: 9304
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int a, b;
    cin >> a >> b;
    cout << max(0, a - b * 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
 
int A, B, N;
map<P, int> mp;
vector<vector<ll>> dp(20, vector<ll>(20, -1));

ll rec(int y = 0, int x = 0){
    
    auto itr = mp.find(make_pair(x, y));
    if(itr != mp.end()) return 0;
    if(y >= B || x >= A) return 0;
    if(y == B - 1 && x == A - 1) return 1;
    
    ll res = 0;
    res += rec(y + 1, x);
    res += rec(y, x + 1);
    
    return res;
}

int main(void){
    
    do{
        scanf("%d %d", &A, &B);
        if(A == 0 && B == 0) continue;
        scanf("%d", &N);
        for(int i = 0; i < N; ++i){
            int a, b; scanf("%d %d", &a, &b);
            --a, --b;
            mp[make_pair(a, b)] = 1;
        }
        cout << rec() << endl;
        mp.clear();
        for(int i = 0; i < B; ++i) for(int j = 0; j < A; ++j) dp[i][j] = -1;
    }while(A != 0 && B != 0);
    
    return 0;
}


Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;

            string serarchstring = Console.ReadLine();

            while (true)
            {


                string[] sentence = Console.ReadLine().Split(' ');

                if (sentence[0] == "END_OF_TEXT") break;



                foreach(var input in sentence)
                {
                    if(input.ToUpperInvariant() == serarchstring.ToUpperInvariant())
                    {
                        count += 1;
                    }
                }
            }

            Console.WriteLine(count);



        }
    
    }

}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    if(n%2==0){
        printf("%.12f\n",0.5);
    }else{
        printf("%.12f\n",(double)(n/2+1)/n);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n = 0, m = 0, ans[200500];

signed main() {

	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> m;
	int rez = 0, las = 0; cin >> las;
	for(int i = 2; i <= n; i++) {
		int x = 0; cin >> x;
		if(las <= x) {
			rez += x - las;
			if(x - las >= 2) {
				ans[las + 2]--;
				if(x <= m - 1) ans[x + 1] += x - las;
				if(x <= m - 2) ans[x + 2] -= x - las - 1;
			}
		} else {
			rez += x + 1;
			if(las <= m - 2) ans[las + 2]--;
			ans[1]--;
			if(x <= m - 1) ans[x + 1] += x + m - las;
			if(x <= m - 2) ans[x + 2] -= x + m - las - 1;
		}

		las = x;
	}
	for(int i = 1, j = 0; i <= m; i++) {
		j += ans[i];
		rez += j;
		ans[i] = rez; 
	}
	int t = ans[1];
	for(int i = 1; i <= m; i++) t = min(t, ans[i]);
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

const int MAX_N = 1e5+10;

int main(int argc, char const *argv[])
{
    int n, k, h, cnt = 0;
    cin >> n >> k;
    for (size_t i = 0; i < n; i++)
    {
        cin >> h;
        if (h>=k) cnt++;
        else continue;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i = 0 ; i < n ; ++i)
#define rep1(i,n) for(int i = 1 ; i <= n ; ++i)
using namespace std;
typedef long long ll;
const ll MOD = 1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};

int h,w;
char a[1010][1010];
mint dp[1010][1010];
int main()
{
  cin >> h >> w;
  rep(i,h) rep(j,w) cin >> a[i][j];
  dp[0][0].x = 1;
  rep(i,h){
    rep(j,w){
      if( a[i][j] == '#') continue;
      else{
	if( i > 0 && j > 0) {
	  dp[i][j] = dp[i-1][j] + dp[i][j-1];
	}
	else if( i > 0 ) {
	  dp[i][j] = dp[i-1][j];
	}
	else if( j > 0 ) {
	  dp[i][j] = dp[i][j-1];
	}
      }
    }
  }
  cout << dp[h-1][w-1].x << "\n";
  
  return 0;
}


Measured memory_bytes: 9216
#! usr/bin/env python
# -*- coding: utf-8 -*-

MAX_V = 10 ** 5


def main():
    n = int(input())
    v = list(map(int, input().split()))

    odd, even = [0] * (MAX_V+1), [0] * (MAX_V+1)
    for i in range(n):
        if i % 2:
            odd[v[i]] += 1
        else:
            even[v[i]] += 1

    nc, ne = [i for i in range(MAX_V+1)], [i for i in range(MAX_V+1)]
    nc.sort(key=lambda no: odd[no], reverse=True)
    ne.sort(key=lambda no: even[no], reverse=True)

    if nc[0] == n // 2 and ne[0] == n // 2:
        # 1種類
        print(n//2)
    else:
        if nc[0] == ne[0]:
            print(min(n-odd[nc[0]]-even[ne[1]], n-even[ne[0]]-odd[nc[1]]))
        else:
            print(n-odd[nc[0]]-even[ne[0]])


if __name__ == '__main__':
    main()


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

int main(){
    int n, w;
    cin >> n >> w;
    int value[110];
    int weight[110];
    int dp[110][10010];
    rep(i,n) cin >> value[i] >> weight[i];
    //初期値
    rep(i,w+1) dp[0][i] = 0;
    rep(i,n){
        rep(j,w+1){
            if(j>=weight[i]) dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]]+value[i]);
            else dp[i+1][j] = dp[i][j];
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}



Measured memory_bytes: 7072
function Main(input) {
  const lines = input.split("\n");
  const cnt = parseInt(lines[0]);
  const obj = {
  	"AC":0,
    "WA":0,
    "TLE":0,
    "RE":0
  }
  for(let i = 1; i <= cnt; i++){
  	obj[lines[i]]++;
  }
  for(let i in obj){
  	console.log(`${i} x ${obj[i]}`);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 37316