akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;




int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(true){
        if(c-b<=0){
            cout<<"Yes"<<endl;
            return 0;
        }
        c-=b;
        if(a-d<=0){
            cout<<"No"<<endl;
            return 0;
        }
        a-=d;
    }


    return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        int count = 0;
        for (int i = 0; i < c.length - 1; i++) {
            if (c[i] != c[i+1]) count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 28104
import numpy as np

b = input().split()
l = np.zeros((int(b[0]), 3))
for i in range(int(b[0])):
	buf = input().split()
	for j in range(3):
		l[i][j] = int(buf[j])
r = 0

for p in range(8):
	rbuf = 0
	box = ((-1)**p)*l.T[0]+((-1)**(p//2))*l.T[1]+((-1)**(p//4))*l.T[2]
	box = np.sort(box)[::-1]
	for i in range(int(b[1])):
		rbuf += box[i]
	if(rbuf > r):
		r = rbuf
		
print(int(r))

Measured memory_bytes: 21124
#include <iostream>
#include <vector>

using namespace std;

long long n;

long long c(long long m) {
    return (m * (m + 1)) / 2;
}

long long search1() {
    long long st = 1, dr = n + 1;
    while(st < dr) {
        long long mid = st + (dr - st)/2;
        long long res = c(mid);
        if(res <= n) {
            st = mid + 1;
        } else {
            dr = mid;
        }
    }
    return st - 1;
}

void solve() {
    long long res = search1();
    long long r1 = c(res);
    if(r1 == n) {
        for(int i = 1; i <= res; i++) {
            cout << i << endl;
        }
    } else {
        long long dist = n - r1;
        for(int i = 1; i <= res - dist; i++) {
            cout << i << endl;
        }
        for(int i = res - dist + 1; i <= res; i++) {
            cout << i + 1 << endl;
        }
    }
}

int main() {
    cin >> n;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
signed main(){
    int n;
    cin >> n;
    int arr[n][3];
    for(int i=0; n>i; i++){
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }
    int dp[n][3];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];
    for(int i=1; n>i; i++){
        dp[i][0] = arr[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = arr[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = arr[i][2] + max(dp[i-1][1], dp[i-1][0]);
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}










Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define int long long
using namespace std;
int pt[123456], s;
set<int>st;
void f() {
	for (int i = 1; i <= s; i++)pt[i] = i;
	return;
}
int root(int i) {
	if (pt[i] == i)return i;
	else return pt[i] = root(pt[i]);
}
void unite(int a, int b) {
	pt[root(b)] = root(a);
	root(b);
	return;
}
signed main() {
	int n;
	cin >> n >> s;
	f();
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		int p, q; cin >> p;
		st.insert(p);
		for (int i = 1; i < k; i++) {
			cin >> q;
			if (pt[p] != q && pt[q] != p)unite(p, q);
			st.insert(q);
		}
	}
	for (int i = 1; i <= s; i++) root(i);
	int key = pt[*(st.begin())];
	for (auto i = st.begin(); i != st.end(); i++) {
		if (*i != key && pt[*i] != key) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n"; return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;


int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    cout << (s=="ABC" ? "ARC":"ABC") << endl;
}

Measured memory_bytes: 3652
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)
Q = Array.new(gets.to_i).map{
  gets.chomp.split(" ").map(&:to_i)
}

ans = A.inject(:+)
H = Hash.new{|h, k| h[k] = 0}
A.each{|a|
  H[a] += 1
}

Q.each{|b, c|
  if H.key?(b) then
    ans += (c-b) * H[b]
    H[c] += H[b]
    H.delete(b)
  end
  puts ans
}


Measured memory_bytes: 27996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;


int main()
{
	int N;

	cin >> N;
	int cnt = 0;

	for (int ni = 1; ni <= N; ni++){
		if ( ni % 2 == 1){
			cnt++;
		}
	}

	double ans = (double)cnt / N;

	printf("%.9f", ans);
	//std::cout << ans;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];

    for(int i = n - 1; i >= 0; i--) {
        if(i != n - 1) {
            cout << " ";
        }
        printf("%d", a[i]);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3208
/* 	* In the name of GOD 
 	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long

int32_t main(){
	int n;
	cin >> n;
	int ans = 0, mn = 1000000000000000ll, a[n];
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort (a, a + n);
	reverse (a,a + n);
	int x = 1, y = 1, i = 0;
	while (x < n){
		int z = i;
		for (; i < z + y / 2; i++){
			ans += a[i] * 2;
		}
		if (y % 2){
			ans += a[i];
			i++;
		}
		x += y;
		y *= 2;
		y = min(y, n - x);
	}
	cout << ans;
}


Measured memory_bytes: 5176
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int dp[1000][5][5][5];
//main
signed main(){
  string s;cin>>s;
  int fans=0,ans=0;
  for(char p:s){
    if(p=='A'||p=='C'||p=='G'||p=='T')ans++;
    else{
      fans=max(ans,fans);ans=0;
    }
  }
  fans=max(fans,ans);
  cout<<fans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
 #include<string>
 #include<algorithm>
 using namespace std;
 
 int main()
 {
 	int n,d,x;
 	int arr[100+5];
 	while(cin>>n>>d>>x)
 	{
 		for(int i=0;i<n;i++) cin>>arr[i];
 		int tot=0;
        for(int i=0;i<n;i++)
        {
          if(d%arr[i]==0) tot=tot+d/arr[i];
 		  else tot=tot+(int)(d/arr[i])+1;
	    }
	    cout<<tot+x<<endl;
	 }
 	return 0;
 }
 

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

namespace cswork {
    class Program {
        static void Main (string[] args) {
                        List<long> l = ReadList();
            long a = l[0];
            long b = l[1];
            long c = l[2];
            long k = l[3];

            if (k <= a) {
                Write (k);
            } else
            if (k <= a + b) {
                Write (a);
            } else {
                Write (a - (k - (a + b)));
            }

            Exit ();
        }

        public static void Write (string str) {
            Console.WriteLine (str);
        }

        public static void Write (int i) {
            Console.WriteLine (i);
        }

        public static void Write (double d) {
            Console.WriteLine (d);
        }

        public static string ReadStr () {
            return Console.ReadLine ();
        }

        public static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }

        public static long Read () {
            return long.Parse (Console.ReadLine ());
        }

        public static double ReadDouble () {
            return double.Parse (Console.ReadLine ());
        }

        public static void Exit () { }

        public static List<string> ReadListStr () {
            return new List<string> (ReadStr ().Split (" "));
        }

        public static List<long> ReadList () {
            return ReadListStr ().ConvertAll (x => long.Parse (x));
        }
    }
}

Measured memory_bytes: 27932
import java.util.Scanner;

public class Main{
  public static void main(String [] args){
    Scanner scanner = new Scanner(System.in);
    int number = Integer.parseInt( scanner.nextLine() );
    
    if (number == 3 || number ==5 || number == 7){
      System.out.println("YES");
    }
    else{
      System.out.println("NO");
    }

    scanner.close();
  }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

int N;
int a[200000];
int b[200000];
vector<int> c;
vector<int> d;

constexpr ll base1 = 1007, base2 = 2009, mod1 = 1000000007, mod2 = 1000000009;
struct RollingHash {
    vector<ll> hash1, hash2, pow1, pow2;
    RollingHash (const vector<int> &S) {
        int length = S.size();
        hash1.assign(length + 1, 0);
        hash2.assign(length + 1, 0);
        pow1.assign(length + 1, 1);
        pow2.assign(length + 1, 1);
        rep(i, length) {
            hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
            pow1[i + 1] = pow1[i] * base1 % mod1;
            pow2[i + 1] = pow2[i] * base2 % mod2;
        }
    }
    pair<ll, ll> get(int l, int r) const {
        ll res1 = hash1[r] - hash1[l] * pow1[r - l] % mod1;
        if (res1 < 0) res1 += mod1;
        ll res2 = hash2[r] - hash2[l] * pow2[r - l] % mod2;
        if (res2 < 0) res2 += mod2;
        return pair<ll, ll>{res1, res2};
    }
};

int main() {
  cin >> N;
  rep(i, N) {
    cin >> a[i];
  }
  rep(i, N) {
    cin >> b[i];
  }
  c.resize(2 * N);
  d.resize(N);
  rep(i, N) {
    c[i] = (a[(i+1)%N] ^ a[i]);
    d[i] = (b[(i+1)%N] ^ b[i]);
  }
  rep(i, N) {
    c[i+N] = c[i];
  }
  RollingHash rc(c), rd(d);
  rep(k, N) {
    if(rc.get(k, k + N) == rd.get(0, N)) {
      cout << k << " " << (a[k] ^ b[0]) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 26404
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;
int par[100001];//親
int trank[100001];//木の深さ

//n要素で初期化
void init(int n) {
    for(int i = 0; i < n; i++){
        par[i] = i;
        trank[i] = 0;
    }
}

//木の根を求める
int find(int x){
    if(par[x] == x){
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(trank[x] < trank[y]){
        par[x] = y;
    } else {
        par[y] = x;
        if(trank[x] == trank[y]) trank[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x) == find(y);
}

signed main()
{
    int n,m;
    cin >> n >> m;
    init(m);
    std::vector<int> check(m,0);
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        std::vector<int> l(k);
        for(int j = 0; j < k; j++){
            cin >> l[j];
            l[j]--;
            check[l[j]] = 1;
        }
        for(int j = 1; j < k; j++){
            unite(l[j],l[j - 1]);
        }
    }
    int flag = -1;
    for(int i = 0; i < m; i++){
        if(check[i] == 0){
            continue;
        }
        if(flag == -1){
            flag = find(i);
        } else {
            if(flag != find(i)){
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 2560
/*zhen hao*/
#include <bits/stdc++.h>
using namespace std;

#define lson l, m, rt*2
#define rson m + 1, r, rt*2+1
#define xx first
#define yy second

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;

const int N = 1e5 + 10;
int a[N * 3];

int main() {
#ifdef JUDGE
  freopen("case.in", "r", stdin);
#endif
  int n;
  cin >> n;
  for (int i = 0; i < 3 * n; i++) {
    scanf("%d", a + i);
  }
  sort(a, a + n * 3);
  LL r1 = 0, r2 = 0;
  for (int i = 0, j = n, k = 3 * n - 2; i < n; i++) {
    r1 += a[j]; j++;
    r2 += a[k]; k -= 2;
  }
  cout << max(r1, r2) << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B;
	static const int L=100;
	string Grid[L];
	cin>>A>>B;
	for(int i=0;i<L;i++)
	for(int j=0;j<L;j++)
	{
		if(i<50)
		Grid[i]+='#';
		else
		Grid[i]+='.';
	}
	int x=0;
	while(x<A-1)
	{
		Grid[(x/50)*2][(x%50)*2+1]='.';
		x++;
	}
	x=0;
	while(x<B-1)
	{
		Grid[(x/50)*2+51][(x%50)*2+1]='#';
		x++;
	}
	cout<<L<<" "<<L<<endl;
	for(int i=0;i<L;i++)
	{
		cout<<Grid[i]<<endl;
	}
}

Measured memory_bytes: 256
//==================================================================================================
// Name        : A.cpp
// Author      : lotus.eater086
// Copyright   : If you're reading this then this warning is for you. Every word you read of this 
//               useless fine print is another second of your life. Don't you've other things to do?
//               Is your life so empty that you honestly can't think of a better way to spend these
//               moments ? Or are you so impressed with authority that you give respect and 
//               credence to all who claim it ? Do you read everything you're supposed to read ? Do
//               you think everything you're supposed to think ? Buy what you're told you should 
//               want ? Get out of your apartment . Meet a member of the opposite sex. Stop the 
//               excessive shopping and self-improvement . Quit your boring job.
//               Start a fight. Prove you're alive. If you don't claim your humanity you'll become a
//               statistic. You've been warned !

// Description : 
// Date        : 2019-07-27
// Time        : 17:57:46
// Directory   : c:\Users\Lenovo\cpPractise\deliberatePractise\code_folder
// FilePath    : c:\Users\Lenovo\cpPractise\deliberatePractise\code_folder\A.cpp
//==================================================================================================
    

#include <bits/stdc++.h>
#define LL long long
#define endl "\n"

using namespace std ;
    
//
template < typename T >

inline T read( T &x )
{

    x = 0 ;

    int f = 0 ;

    char ch = getchar() ;

    while( ch < '0' || ch > '9' )  {

        f |= ( ch == '-' ) , ch = getchar() ;

    }

    while( ch >= '0' && ch <= '9' )  {

        x = ( x << 1 ) + ( x << 3 ) + ch - '0' , ch = getchar() ;

    }

    return x = f ? -x:x ;

}
//

int main( void )

{

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

   

    LL a , b ;

    read( a ) , read( b ) ;

    LL sum = (a+b) ;

    if( sum % 2 == 0 )  cout << sum/2 << endl ;

    else  cout << "IMPOSSIBLE\n" ;  

  

    return 0 ;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define N 2019
const LL MOD=1e9+7;

int n;
LL k;
LL ans1,ans2;
int a[N];

int main()
{
	ios_base::sync_with_stdio(0);
	
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	for(int j=i+1;j<=n;j++)
		if(a[i]>a[j]) ans1++;
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
		if(a[i]>a[j]) ans2++;
	cout<<(ans1*k+k*(k-1)/2%MOD*ans2)%MOD<<'\n';
	
	return 0;
}

Measured memory_bytes: 256
import sys

N, M = map(int, input().split())
ab = [tuple(map(int, line.split())) for line in sys.stdin.readlines()]
ab.sort(key = lambda x : x[1])

ans = 0
last = -1
for a, b in ab:
    if a < last:
        continue
    else:
        ans += 1
        last = b

print(ans)

Measured memory_bytes: 23716
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll n, m, k;
const ll mod = 1e9 + 7;
ll mypow(ll a, ll b) {
	if (b == 0)return 1;
	if (b % 2)
		return (a*mypow((a*a) % mod, b / 2)) % mod;
	else
		return mypow((a*a) % mod, b / 2);
}
ll fac[200010];
ll rev[200010];
ll mul(ll a, ll b) {
	return (a*b) % mod;
}
ll sub(ll a, ll b) {
	return (a - b + mod) % mod;
}
ll sum(ll a, ll b) {
	return (a + b) % mod;
}
ll Comb(ll a, ll b) {
	return mul(rev[a - b], mul(fac[a], rev[b]));
}
int main()
{
	rev[0] = 1;
	fac[0] = 1;
	for (int i = 1; i <= 200000; i++) {
		fac[i] = (fac[i - 1] * i) % mod;
		rev[i] = mypow(fac[i], mod - 2);
	}
	scanf("%lld %lld %lld", &n, &m, &k);
	ll dap = 0;
	for (ll i = 2; i <= n; i++) {
	
		dap = sum(dap, sub(mul(mul(i - 1, m), mul(m, i)),mul(mul(mul(i, i - 1), rev[2]), mul(m,m))));
	}
	for (ll i = 2; i <= m; i++) {
		dap = sum(dap, sub(mul(mul(i - 1, n), mul(n, i)), mul(mul(mul(i, i - 1), rev[2]), mul(n,n))));
	}
	dap = mul(dap, Comb(n*m - 2, k - 2));
	printf("%lld", dap);
}


Measured memory_bytes: 3328
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


def gen(k, c0, c1, w):
    ww = w // 2
    w = 2 * ww
    n_rows = k // ww + 1
    remaining = k % ww
    res = []
    line = c1 * w
    for i in range(2 * n_rows):
        if i % 2 == 1:
            res.append(line)
        else:
            i //= 2
            if i != n_rows - 1:
                s = ''.join((c0 + c1) * ww)
            else:
                s = ''.join((c0 + c1) * remaining) + c1 * (w - 2 * remaining)
            res.append(s)
    return res


a, b = ril()
h, w = 100, 100
c0, c1 = '.', '#'
res = []
res += gen(a - 1, c0, c1, w)
res.append(c0 * w)
if b > 1:
    res += gen(b - 1, c1, c0, w)

print(len(res), w)
for s in res:
    print(s)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void) {
        unsigned long n, d;
        cin >> n >> d;
        int count = 0;
        unsigned long long d2 = d * d;                                                                                                                                                               for (unsigned long i = 0; i < n; i++) {                                                                                                                                                              long long x, y;
                cin >> x >> y;
                unsigned long long dist2 = x * x + y * y;                                                                                                                                                    if (dist2 <= d2)
                        count++;
        }
        cout << count << endl;
        return 0;
}

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

using namespace std;

int N, A[1001];
void print_r() {
	for (int i = 0; i < N; i++) {
		cout << A[i];
		if (i != N - 1) cout << " ";
	}
	cout << endl;
}
int main()
{
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	print_r();
	for (int i = 1; i < N; i++) {
		int v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j + 1] = v;
		print_r();
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
#include<vector>
int main()
{
  int n,k;
  cin>>n>>k;
  const int INF=1e9+7;
  vector<long long int>h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];}

  vector<long long int> s(n,INF);
  s[0]=0;
  for(long long int i=0;i<n;i++)
  {
    for(long long int j=i+1;j<=i+k;j++)
    {
      if(j<n)
      s[j]=min(s[j],s[i]+abs(h[j]-h[i]));
    }
 }
 cout<<s[n-1];
 return 0;
}


Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
 
    int N = S.size();
    long long ans = 0;
    long long count_B = 0;
    for (int i=0; i<N; i++) {
        if(S[i]=='B'){
            count_B++;
            //if(S[i+1]=='W'){
                //S[i+1-count_B]='W';
                //S[i+1]='B';
                //ans+=count_B;
                //i++;
            }
             else{
                 ans+=count_B;
            }
        //}
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>

using namespace std;

int h, w, sx, sy, tx, ty;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
bool vis[1010][1010], v[1010][1010];
char g[1010][1010];

struct nodes{
    int r, c, d;
    nodes(int r = 0, int c = 0, int d = 0) : r(r), c(c), d(d) {}
    bool operator < (const nodes& a) const {
        return d > a.d;
    }
};

bool check(int x, int y) { 
    return x >= 0 && y >= 0 && x < h && y < w && g[x][y] == '.'; 
}

void bfs() {
    priority_queue<nodes> q;
    q.push(nodes(sx, sy, 0));
    vis[sx][sy] = true, v[sx][sy] = true;
    while (q.size()) {
        nodes u = q.top();
        q.pop();
        if (u.r == tx && u.c == ty) { printf("%d\n", u.d); return; }
        for (int i = 0 ; i < 4; i++) {
            int r = u.r + dx[i], c = u.c + dy[i];
            if ((!check(r, c)) || vis[r][c]) continue;
            vis[r][c] = true;
            q.push(nodes(r, c, u.d));
        }
        int r = u.r - 2, c = u.c - 2;
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                int nr = r + i, nc = c + j;
                if ((!check(nr, nc)) || v[nr][nc]) continue;
                v[nr][nc] = true;
                q.push(nodes(nr, nc, u.d + 1));
            }
        }
    }
    printf("-1\n");
}


int main() {
#ifndef ONLINE_JUDGE
    freopen("D:/MYCODE/vsCode-c/test.in", "r", stdin);
    freopen("D:/MYCODE/vsCode-c/test.out", "w", stdout);
#endif
    scanf("%d%d%d%d%d%d", &h, &w, &sx, &sy, &tx, &ty);
    sx--, sy--, tx--, ty--;
    for (int i = 0; i < h; i++) scanf("%s", g[i]);
    // for (int i = 0; i < h; i++) printf("%s\n", g[i]);
    bfs();
    return 0;
}

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

int main() 
{
	string s;

	cin >> s;

	int a = 0, b = 0, c = 0;
	for (int i = 0; i <= 2; i++)
	{
		if (s[i] == 'a') a++;
		if (s[i] == 'b') b++;
		if (s[i] == 'c') c++;
	}

	if (a == 1 && b == 1 && c == 1) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
/*よくばりセット2019/07/13 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define INT_MAX 999999999
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x>y?y:x;}
ll llmax(ll x,ll y){return x>y?x:y;}
ll llmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}
int lcm(int x,int y){
    int tmp;
    tmp=x%y;
    while(tmp!=0){
        x=y;
        y=tmp;
        tmp=x%y;
    }
    return y;
}

int main(){
    int w,h,c;
    scanf("%d %d %d",&w,&h,&c);
    
    int lcd=lcm(max(w,h),min(w,h));
    //printf("%d\n",lcd);
    printf("%d\n",(w/lcd)*(h/lcd)*c);
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>

using namespace std;
const long long int divider = 1000000007;

int main() {
	int N, K;
	cin >> N >> K;
	vector<vector<long long int>> pascar(N + 10, vector<long long int>(N + 10));
	pascar[0][0] = 1;
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j <= i; ++j) {
			if (j == 0 || j == i) {
				pascar[i][j] = 1;
			} else {
				pascar[i][j] =
				    (pascar[i - 1][j] + pascar[i - 1][j - 1]) % divider;
			}
		}
	}
	for (int i = 1; i <= K; ++i) {
		if (N - K < i - 1) {
			cout << 0 << endl;
		} else {
			cout << pascar[K - 1][i - 1] * pascar[N - K + 1][i] % divider
			     << endl;
		}
	}
}


Measured memory_bytes: 32000
#include <stdio.h>
int main(){
	int tyukan[999], kimatu[999], saite[999], a=0, b;
	while(1){
		scanf("%d %d %d",&tyukan[a] ,&kimatu[a], &saite[a]);
		if(tyukan[a] == -1 && kimatu[a] == -1 && saite[a] == -1)break;
		a++;
	}
	for(b = 0; b < a; b++){
		if(tyukan[b] == -1 || kimatu[b] == -1){
			printf("F\n");
		}else if(tyukan[b]+kimatu[b]<30){
			printf("F\n");
		}else if(tyukan[b]+kimatu[b]<50){
			if(saite[b]>=50){
				printf("C\n");
			}else{
				printf("D\n");
			}
		}else if(tyukan[b]+kimatu[b]<65){
			printf("C\n");
		}else if(tyukan[b]+kimatu[b]<80){
			printf("B\n");
		}else{
			printf("A\n");
	
	
		}
	}
//	scanf("%d", a);
return 0;
}

Measured memory_bytes: 592
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def main():
    N, M = map(int, input().split())

    div = make_divisors(M)
    sort_div = sorted(div)

    ans = 0
    for a in sort_div:
        if a <= M // N:
            ans = a
        else:
            break

    print(ans)


main()

Measured memory_bytes: 38640
n, m = gets.strip.split.map(&:to_i)
xyz = readlines.map {|line| line.strip.split.map(&:to_i) }

if m.zero?
  p 0
  exit
end


p [
  xyz.map {|x, y, z| x+y+z}.sort.reverse[0..m-1].inject(0, :+),
  xyz.map {|x, y, z| x+y-z}.sort.reverse[0..m-1].inject(0, :+),
  xyz.map {|x, y, z| x-y+z}.sort.reverse[0..m-1].inject(0, :+),
  xyz.map {|x, y, z| x-y-z}.sort.reverse[0..m-1].inject(0, :+),
  xyz.map {|x, y, z| -x+y+z}.sort.reverse[0..m-1].inject(0, :+),
  xyz.map {|x, y, z| -x+y-z}.sort.reverse[0..m-1].inject(0, :+),
  xyz.map {|x, y, z| -x-y+z}.sort.reverse[0..m-1].inject(0, :+),
  xyz.map {|x, y, z| -x-y-z}.sort.reverse[0..m-1].inject(:+)
].max


Measured memory_bytes: 2168
#include <stdio.h>

int main(void){
    char S[100000];
    int count1=0;
    int count2=0;
   scanf("%s",S);
  
   int i=0;
   do{
    if(S[i]=='0')
      count1+=1;
    else if(S[i]=='1')
      count1+=0;
     i+=1;
     if(S[i]=='1')
      count1+=1;
    else if(S[i]=='0')
      count1+=0;
     i+=1;
   }while(S[i]=='1'||S[i]=='0');
     
  
    int k=0;
   do{
    if(S[k]=='1')
      count2+=1;
      else if(S[k]=='0')
      count2+=0;
      
      k+=1;
      
      if(S[k]=='0')
      count2+=1;
      else if(S[k]=='1')
      count2+=0;
      k+=1;
      }while(S[k]=='0'||S[k]=='1');

    if(count1<count2) 
    printf("%d",count1);
    else
    printf("%d",count2);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int n, m, c, i, j, k, ans;
char s[15];
int main(){
	scanf("%s", s);
	m = ans = 753;
	for(i=0; s[i+2]; i++){
		sscanf(s+i, "%3d", &n);
		c = n>m ? n-m : m-n;
		if(c < ans) ans = c;
	}
	printf("%d\n", ans);
	return 0;
}

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

const int maxn = 100000 + 5;
int N;
int P[maxn];

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

int solve()
{
	int ans = P[0];
	for(int i = 1; i < N; i++)
		ans = gcd(ans, P[i]);
	return ans;
}

int main()
{
	cin >> N;
	for(int i = 0; i < N; i++) cin >> P[i];
	printf("%d\n", solve());
}

Measured memory_bytes: 640
def groupby2(ar):
    a2=[[ar[0],1]]
    for i in range(1,len(ar)):
        if a2[-1][0]==ar[i]:
            a2[-1][1]+=1
        else:
            a2.append([ar[i],1])
    return a2

inf=10000000
S=input()
l=len(S)
a=[inf]*(l+1)
if l==2:
    print(1)
else:
    b=groupby2(list(S))
    l2=len(b)
    if l2==1:
        print(b[0][1]*(b[0][1]+1)//2)
    else:
        c=(b[0][1]*(b[0][1]+1)//2)
        for i in range(l2-1):
            y=b[i]
            x=b[i+1]
            c+=(x[1]*(x[1]+1)//2)
            if x[0]==">":
                c-=min(x[1],y[1])
        print(c)


Measured memory_bytes: 36892
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
	int n;cin>> n;
	vector<int> a(n);
	for(int i=0; i<n; i++)cin >> a[i];
	long long ans=a[0]/2;
	a[0]%=2;
	for(int i=1; i<n; i++){
		if(a[i-1]%2&&a[i]!=0){
			ans++;a[i]--;
		}
		ans+=a[i]/2;
		a[i]%=2;
	}
	cout << ans << endl;
	return 0;
}	


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

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    
    if ((a[0] == a[1] && a[1] == a[2]) || (a[0] != a[1] && a[1] != a[2])) {
        cout << "No" << "\n";
    }
    else {
        cout << "Yes" << "\n";
    }
    return 0;
	
}


Measured memory_bytes: 256
#include <iostream>
    using namespace std;
 
    int main()
    {
   int a , b , c ;
   cin >> a >> b >> c ;
 
    if ( (a==c && a != b )  || (a==b && a != c )||(b==c) && (b!=a) )
   cout << "2";
 
    else if ( a == b &&   b == c  )
   cout <<"1";
 
   else //if (a!=b && a!=c && b != c )
   cout <<"3";
        return 0;
    }

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a;
    for(int i=0;i<n;i++){
        int b;
        cin >> b;
        a.push_back(b);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int ans = 0;
    for(int i=0;i<k;i++){
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
ll k, num;
int cnt = 1;
int main()
{
	cin >> k;
	num = 7;
	if (k % 2 == 0)
	{
		cout << -1;
		return 0;
	}
  if (k == 7 || k==1)
	{
		cout << 1;
		return 0;
	}
	while (num)
	{
		if (cnt > 10000000)
		{
			cout <<-1;
			return 0;
		}
		num *= 10;
		num += 7;
		if(num>k)num %= k;
		cnt++;
	}
	cout << cnt;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//int[] array = new int[1000000000*2];
		int h = sc.nextInt();
		int a = sc.nextInt();
		if(a>=h)
			System.out.println(1);
		else if(h%a==0)
			System.out.println(h/a);
		else
			System.out.println(h/a+1);
    }
}

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

typedef uint32_t u32;
typedef uint64_t u64;
typedef std::pair<int, int> pii;

bool isprime2[420100];

int main() {

  for(int i = 0; i < 420000; ++i) {
    isprime2[i] = false;
  }
  for(int i = 0; i < 60000; ++i) {
    isprime2[i * 7 + 1] = isprime2[i * 7 + 6] = true;
  }
  isprime2[1] = false;
  for(int i = 0; i < 1000; ++i) {
    if( isprime2[i] ) {
      for(int j = i + i; j < 420000; j+=i) {
        isprime2[j] = false;
      }
    }
  }

  std::vector<int> prime2s;
  for(int i = 0; i <= 300000; ++i) {
    if( isprime2[i] ) {
      prime2s.push_back(i);
    }
  }
  
  for(;;) {
    int n;
    std::cin >> n;
    if( n == 1 ) break;
    std::cout << n << ":";
    for(int i = 0; i < (int)prime2s.size(); ++i) {
      if( n % prime2s[i] == 0 ) {
        std::cout << ' ' << prime2s[i];
      }
    }
    std::cout << std::endl;
  }
  
  return 0;
}

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

int main(){
    int N;
    long long W;
    vector<long long> vs_1, vs_2, vs_3, vs_4;
    long long w, v, w1;
    cin >> N >> W;
    cin >> w1 >> v;
    vs_1.push_back(v);
    for(int i=1; i<N; i++){
        cin >> w >> v;
        switch(w-w1){
            case 0:
                vs_1.push_back(v);
                break;
            case 1:
                vs_2.push_back(v);
                break;
            case 2:
                vs_3.push_back(v);
                break;
            case 3:
                vs_4.push_back(v);
        }
    }
    sort(vs_1.begin(), vs_1.end(), greater<long long>());
    sort(vs_2.begin(), vs_2.end(), greater<long long>());
    sort(vs_3.begin(), vs_3.end(), greater<long long>());
    sort(vs_4.begin(), vs_4.end(), greater<long long>());
    long long max = 0, tmp, w_sum;
    for(int i=0; i<=vs_1.size(); i++){
        for(int j=0; j<=vs_2.size(); j++){
            for(int k=0; k<=vs_3.size(); k++){
                for(int l=0; l<=vs_4.size(); l++){
                    w_sum = w1*i + (w1+1)*j + (w1+2)*k + (w1+3)*l;
                    if(w_sum > W) continue;
                    tmp = accumulate(vs_1.begin(), vs_1.begin()+i, 0)
                    + accumulate(vs_2.begin(), vs_2.begin()+j, 0)
                    + accumulate(vs_3.begin(), vs_3.begin()+k, 0)
                    + accumulate(vs_4.begin(), vs_4.begin()+l, 0);
                    if(max <= tmp) max = tmp;
                }
            }
        }
    }
    cout << max;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    vector<bool> P1(h,true);
    vector<bool> P2(w,true);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                P1[i]=false;
                P2[j]=false;
            }
        }
    }
    for(int i=0;i<h;i++){
        if(!P1[i]){
            for(int j=0;j<w;j++){
                if(!P2[j]){
                    cout<<s[i][j];
                }
            }
            cout<<endl;
        }
    }
}


Measured memory_bytes: 256
#include <stdio.h>
      #include <math.h>
      int main(){
        int i,j,count=0,number,n;
        scanf("%d",&n);
        count=n;
        for(i=0;i<n;i++){
          scanf("%d",&number);
          if(number>2&&number%2==0 ) count--;
          else{
            for(j=3;j<=sqrt(number);j+=2){
              if(number%j==0){
                count--;
                break;
              }
            }
          }
        }
        printf("%d\n",count);
        return 0;
      }



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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

struct data {
	llong pos;
	llong many;
	llong cost;

	data(llong pos, llong many, llong cost) :
		pos(pos),
		many(many),
		cost(cost)
	{};

	bool operator>(const data &right) const {
		return cost > right.cost;
	};
};

llong N, M, S, T;;
vector<vector<llong>> edges;

llong dijkstra(llong start, llong goal) {
	vector<vector<llong>> dis(N+1, vector<llong>(3, inf));
	dis[start][0] = 0;

	priority_queue<data, vector<data>, greater<data>> que;
	que.push(data(start, 0, 0));
	while (que.size()) {
		data now = que.top();
		que.pop();

		if (now.cost > dis[now.pos][now.many]) continue;

		for (auto edge : edges[now.pos]) {
			data next(edge, (now.many+1)%3, now.cost+1);
			if (dis[next.pos][next.many] > next.cost) {
				dis[next.pos][next.many] = next.cost;
				que.push(next);
			}
		}
	}

	if (dis[goal][0] == inf || dis[goal][0]%3 != 0) {
		return -1;
	} else {
		return dis[goal][0]/3;
	}
}

int main() {
	cin >> N >> M;
	edges.resize(N+1);
	for (llong i = 0; i < M; ++i) {
		llong from, to;
		cin >> from >> to;
		edges[from].push_back(to);
	}
	cin >> S >> T;

	cout << dijkstra(S, T) << endl;

	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) max_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)

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

    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << (double)(W * H) / 2.0 << " ";
    if(x * 2 == W && y * 2 == H) cout << "1" << endl;
    else cout << "0" << endl;
    return 0;
}

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

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == -1) break;
            var alist = new List<int>();
            while (n > 0)
            {
                alist.Add(n % 4);
                n /= 4;
            }
            if (alist.Count() == 0) alist.Add(0);
            var m = alist.Count() - 1;
            for (int i = m; i >= 0; i--)
                if (i == 0) Console.WriteLine(alist[0]);
                else Console.Write(alist[i]);
        }
    }
}

Measured memory_bytes: 9616
#include<bits/stdc++.h>
#define MAX_V 101
using namespace std;

struct edge { 
  int to, cost;
  edge(){}
  edge(int to,int cost):to(to),cost(cost){};
};
typedef pair<int ,int> P;
const int INF = 1 << 30;
int V; //ノードの数
vector<edge> Graph[MAX_V];
int min_cost[11][MAX_V];

int c,m,s,d;
void Dijkstra(int s,int chip){ // s:スタートからの最小コストをmin_costに設定
  priority_queue<P,vector< P >, greater<P> > que;
  min_cost[chip][s] = 0;
  que.push(P(0,s));
  
  while(!que.empty()){
    P p = que.top();que.pop();
    int now = p.second;
    int cost = p.first;
    if(min_cost[chip][now] < cost) continue;
    
    for(int i = 0; i < Graph[now].size(); i++){
      edge e = Graph[now][i];
      int a;
      if(chip == 0){
	a = min_cost[chip][now] + e.cost;
      }else{
	a = min(min_cost[chip][now] + e.cost, min_cost[chip-1][now] + e.cost / 2);
      }
      if(min_cost[chip][e.to] > a){
	min_cost[chip][e.to] = a;
	que.push(P(min_cost[chip][e.to], e.to));
      }
    }
  }
}

int main(){
  
  while(cin >> c >> V >> m >> s >> d && (c||V||m||s||d)){
    s--;
    d--;
    
    for(int i=0;i<m;i++){
      int a,b,f;
      cin>>a>>b>>f;
      a--;b--;
      Graph[a].push_back(edge(b,f));
      Graph[b].push_back(edge(a,f));
    }
    for(int i=0;i<=c;i++){
      for(int j=0;j<MAX_V;j++){
	min_cost[i][j] = INF;
      }
    }
    for(int i=0;i<=c;i++){
      Dijkstra(s,i);
    }

    cout<<min_cost[c][d]<<endl;
    
    for(int i=0;i<MAX_V;i++) Graph[i].clear();
  }
  return 0;
}
    
    

Measured memory_bytes: 1220
#include <iostream>
// #include<bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

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

    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
    }

    map<string, int> res;
    for(string s : S) {
        res[s] = 0;
    }

    cout << res.size() << endl;
}


Measured memory_bytes: 23092
#include<bits/stdc++.h>
using namespace std;
const int N=605;

int n,m;
vector<int> g[N];
double dp[N];

double calc(int id){
    for(int u=n-1;u>=1;--u){
        double sum=0,Max=0;
        int cnt=0;
        for(int i=0;i<(int)g[u].size();++i){
            int v=g[u][i];
            sum+=dp[v]+1;
            Max=max(Max,dp[v]+1);
            ++cnt;
        }
        if(cnt>=2 && id==u){
            --cnt;
            sum-=Max;
        }
        dp[u]=sum/cnt;
    }
    return dp[1];
}

int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;++i){
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
    }
    double ans=2e9;
    for(int i=0;i<=n-1;++i) ans=min(ans,calc(i));
    printf("%.10lf\n",ans);
    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>

#define N 50

int a[N];

int fib(int n){

  if(n==0 || n==1) return a[n] = 1;
  if(a[n]!=-1) return a[n];
  return a[n] = fib(n-1) + fib(n-2);
  
}

int main(){

  int n,i;
  for(i=0;i<N;i++){
    a[i] = -1;
  }

  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
  
}


Measured memory_bytes: 2104
N = int(input())
max = -9999
list_mochi = []
for i in range(N):
        d = int(input())
        list_mochi.append(d)
list_mochi.sort()
n = len(list_mochi)
X_mochi = []
for j in range(n):
        if max < list_mochi[j]:
                max = list_mochi[j]
                X_mochi.append(list_mochi[j])
print(len(X_mochi))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
typedef long long ll;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
struct edge { int to,w,nxt; } e[N<<1];
int tot=1,h[N];
void adde(int u,int v) {
    e[++tot]=(edge){v,1,h[u]};h[u]=tot;
    e[++tot]=(edge){u,-1,h[v]};h[v]=tot;
}
int n,m,V,E,col[N],cnt[3];
bool vis[N],vise[N];
ll ans=0;
bool flag=0;
void dfs(int u) {
    V++;vis[u]=1;
    cnt[col[u]]++;
    for(int i=h[u];i;i=e[i].nxt) {
        if(vise[i>>1]) continue; vise[i>>1]=1,E++;
        int v=e[i].to;
        if(!vis[v]) col[v]=(col[u]+e[i].w+3)%3,dfs(v);
        else if(col[v]!=(col[u]+e[i].w+3)%3) flag=1;
    }
}
int main() {
    cin>>n>>m;
    for(int i=1,u,v;i<=m;i++) u=gi(),v=gi(),adde(u,v);
    for(int i=1;i<=n;i++)
        if(!vis[i]) {
            V=E=cnt[0]=cnt[1]=cnt[2]=0;flag=0;dfs(i);
            if(flag) ans+=1ll*V*V;
            else if(!cnt[0]||!cnt[1]||!cnt[2]) ans+=E;
            else ans+=1ll*cnt[0]*cnt[1]+1ll*cnt[1]*cnt[2]+1ll*cnt[2]*cnt[0];
        }
    printf("%lld\n",ans);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 8576
#include<iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    if(n==1){ cout << 1 << endl; }
    else if(n%2==0) { cout << 0.5 << endl; }
    else { cout << (n+1)/(n*2.0)<< endl;}
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }

#define INF 1 << 30
int main() {
	ll A, B, C, D, E, x, y, z;
	cin >> A >> B >> C >> D;
	E = lcm(C, D);
	x = B / C - (A - 1) / C;
	y = B / D - (A - 1) / D;
	z = B / E - (A - 1) / E;
	printf("%lld\n", (B - A + 1) - (x + y - z));
	return 0;
}


Measured memory_bytes: 256