akhauriyash/Code-Regression huggingface dataset:
import sys

N, K = map(int, input().split())
steps = list(map(int, input().split()))

dp = [sys.maxsize] * N
dp[0] = 0
for i in range(1, N):
    limit = K if K <= i else i
    for j in range(1, limit + 1):
        a = abs(steps[i] - steps[i - j]) + dp[i - j]
        dp[i] = a if a < dp[i] else dp[i]

print(dp[N - 1])


Measured memory_bytes: 84872
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<ll> X, X_;
  for(int i=0; i<N; i++){
    ll in;
    cin >> in;
    X.push_back(in);
    X_.push_back(in);
  }
  sort(X.begin(), X.end());
  ll ret1 = X[N/2-1];
  ll ret2 = X[N/2];
  for(int i=0; i<N; i++){
    if(X_[i] < ret2)
      cout << ret2 << endl;
    else
      cout << ret1 << endl;
  }
  return 0;
}


Measured memory_bytes: 5476
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi P(n),Q(n);
  for(auto &a:P)cin>>a;
  for(auto &a:Q)cin>>a;
  vi num(n);
  for(int i=0;i<n;i++){
    num[i]=i;
  }
  ll cnt=0;
  ll p,q;
  do{
    bool pp=true,qq=true;
    for(int i=0;i<n;i++){
      if(P[i]!=num[i]+1)pp=false;
      if(Q[i]!=num[i]+1)qq=false;
    }
    if(pp)p=cnt;
    if(qq)q=cnt;
    cnt++;
  }while(next_permutation(ALL(num)));
  cout<<abs(p-q)<<endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    String s;
    Scanner scanner = new Scanner(System.in);
    s = scanner.nextLine();
    int n = s.length();
    int k = 1;
    int l = 1;

    boolean beforeDouble = false;
    for(int i = 1; i < n; i++){
      if((s.charAt(i) != s.charAt(i - 1)) || beforeDouble){
        k++;
        beforeDouble = false;
      }else{
        i++;
        if(i < n){
          k++;
        }
        beforeDouble = true;
      }
    }
    beforeDouble = false;
    for(int i = n - 2; i >= 0; i--){
      if((s.charAt(i) != s.charAt(i + 1)) || beforeDouble){
        l++;
        beforeDouble = false;
      }else{
        i--;
        if(i >= 0){
          l++;
        }
        beforeDouble = true;
      }
    }
    
    System.out.println(Math.max(k, l));
  }
}


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

int main() {
    int n, m;
    cin >> n >> m;
    
    int mat[n][m]{};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> mat[i][j];
        }
    }
    
    int vec[m]{};
    for (int j = 0; j < m; j++) {
        cin >> vec[j];
    }
    
    int res[n]{};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            res[i] += mat[i][j] * vec[j];
        }
        cout << res[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3124
N,M=list(map(int,input().strip().split(' ')))
B=[]
MOD=10**9+7
for _ in range(M):
    B+=[int(input())]
broken=set(B)
dp=[0]*(N+1)
dp[0]=1
for i in range(1,len(dp)):
    if i in broken:
        dp[i]=0
    else:
        if i==1:
            dp[1]=dp[0]
        else:
            dp[i]=(dp[i-1]+dp[i-2])%(MOD)
print(dp[-1])

Measured memory_bytes: 13216
#include <iostream>
#include <array>
#include <map>
#include <string>
using namespace std;

struct dice {
    array<int, 6> a;
    map<int, int> m;
};

int main()
{
    dice d[2];
    array<array<string, 6>, 6> tbl = {
        "", "2345", "4135", "1425", "3215", "",
        "3254", "", "0534", "5024", "", "2304",
        "1453", "5043", "", "", "0513", "4103",
        "4152", "0542", "", "", "5012", "1402",
        "2351", "", "5031", "0521", "", "3201",
        "", "3240", "1430", "4120", "2310", ""};

    for (auto &x: d) {
        int i = 0;
        for (int &y: x.a) {
            cin >> y;
            x.m[y] = i++;
        }
    }

    bool flag = false;
    auto s = tbl[ d[0].m[d[1].a[0]] ][ d[0].m[d[1].a[1]] ];

    for (size_t i = 0; i < s.size(); i++) {
        if (d[0].a[s[i] - '0'] != d[1].a[i + 2]) {
            flag = false;
            break;
        }
        flag = true;
    }

    cout << (flag ? "Yes" : "No") << endl;
}


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

class UnionFind {
	vector<int>par, high;
public:
	UnionFind(int n) {
		par = high = vector<int>(n);
		for (int i = 0; i < n; i++)par[i] = i;
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (high[x] > high[y]) {
			par[y] = x;
		}
		else {
			par[x] = y;
			if (high[x] == high[y])high[y]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};
unordered_map<int, unordered_map<int, int>>E;
int main() {
	int n, k, l; scanf("%d%d%d", &n, &k, &l);
	UnionFind road(n), rail(n);
	rep(i, k) {
		int p, q; scanf("%d%d", &p, &q); p--; q--;
		road.unite(p, q);
	}
	rep(i, l) {
		int r, s; scanf("%d%d", &r, &s); r--; s--;
		rail.unite(r, s);
	}
	rep(i, n) {
		E[road.find(i)][rail.find(i)]++;
	}
	rep(i, n) {
		printf("%d", E[road.find(i)][rail.find(i)]);
		if (i == n - 1)printf("\n");
		else printf(" ");
	}
}

Measured memory_bytes: 31304
from collections import defaultdict

n, k = map(int, input().split())
*a, = map(int, input().split())
a = [a[i] - 1 for i in range(n)]
ans = 0

if k <= n:
    i = 0
    while(k > 0):
        ans = a[i]
        i = a[i]
        k -= 1
    ans += 1

else:
    # 周期と周期の場所をチェック
    start_period = 1
    period_i = -1
    # 街名に対する初めて訪れる順番の辞書
    d = defaultdict(int)
    d[0] = 1
    i = 0
    count = 1
    while(1):
        if a[i] in d.keys():
            period_i = count
            start_period = d[a[i]]
            break

        d[a[i]] = count + 1
        i = a[i]
        count += 1
        
    # 初めて訪れる順番に対する街名の逆引き辞書
    d_r = {i:k for k, i in d.items()}

    ans = d_r[start_period + ((k - (start_period - 1)) % (period_i - start_period + 1))] + 1
    
    
print(ans)


Measured memory_bytes: 37288
#include<stdio.h>
 
#define MAXLEN 20000
 
int garea,gareas[(MAXLEN/2)+1],gcnt,gend;
 
 
int getArea( char *inputs, int start, int end )
{
    int i;
    int ravine,water;
    
    gareas[gcnt]=ravine=water=0;
    for( i=start; i!=end; i++ ) {
        if( '\\'== *(inputs+i) ) {
           	water+=(ravine*2);
            ravine++;
            water++;
        } else if( 0 != ravine && '/' == *(inputs+i) ) {
        	ravine--;
        } else {
	     	water+=ravine;
        }       
    }
	gareas[gcnt]+=water;
    
    return gareas[gcnt];
}
  
int checkRavine( char *inputs, int start )
{
    int i;
    int ravine, minh, tmpi;
    
    ravine=0;
    tmpi=minh=MAXLEN;
    for( i=start; i<=gend && '\0'!=*(inputs+i); i++ ) {
        if( 0 <= ravine && '\\'== *(inputs+i) ) {
            ravine++;        
        } else if( 0 != ravine && '/' == *(inputs+i) ) {
            ravine--;
            if( ravine < minh ) {
        		minh=ravine;
        		tmpi=i;
            }
            if( 0 == ravine ) {
            	garea+=getArea( inputs, start, i+1 );
            	gcnt++;
			    gend=MAXLEN;           	
                return i-start;
            }
        }
    }
	gend=tmpi;
    if( MAXLEN==minh ) { gend=i; }
    return 0;
}
 
 
void getAreas( char *inputs )
{
    int i,next;
     
    next=0;
    for( i=0; i<=gend && '\0'!=inputs[i]; i++ ) {
    	if( '_' !=inputs[i] && '/' !=inputs[i] ) {
	        next=checkRavine( inputs, i );
	        i+=next;
        }
    }
 
    return;
}
 
int main( void ) 
{
    char inputs[MAXLEN+1];
    int i;
 
    scanf( "%s", inputs );
    garea=gcnt=0;
    gend=MAXLEN;
    getAreas( inputs );
     
    printf( "%d\n", garea );
    
    if( gcnt ) {
        printf( "%d ", gcnt );
        for( i=0; i<gcnt; i++ ) {
            printf( "%d", gareas[i] );
            if( i < gcnt-1 ) {
            	printf( " " );  
            }
        }
        printf( "\n" );
       
    } else {
        printf( "0\n" );
    }
     
    return 0;
}

Measured memory_bytes: 576
#include <iostream>

using namespace std;

int main(int argc, char *argv[]){
	//?????????
	int num_of_people[4][3][10];
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				num_of_people[i][j][k] = 0;
			}
		}
	}
	//??\???
	int count;
	cin >> count;
	for(int i = 0; i < count; i++){
		int b,f,r,v;
		cin >> b >> f >> r >> v;
		num_of_people[b - 1][f - 1][r - 1] += v;	
	}
	//??????
	for (int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				cout << " " << num_of_people[i][j][k];
				if (k == 10 - 1){
					cout << "\n";
				}
			}
		}
		if (i != 4 - 1){
			cout << "####################\n";
		}
	}
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
using namespace std;
const int N = 1000000;


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

    vector<string> w(n);
    rep(i,n) cin >> w[i];

    bool shiritori = true;

    for (int i = 0; i < n - 1; ++i) {
        if(w[i].back() != w[i + 1].front()){
            shiritori = false;
        }
    }

    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if(w[i] == w[j]){
                shiritori = false;
            }
        }
    }

    if(shiritori)print("Yes");
    else print("No");
}

Measured memory_bytes: 256
import math
import heapq

n,m = map(int,input().split())

a = list(map(int,input().split()))
a = list(map(lambda x:x*(-1),a))
heapq.heapify(a)

for _ in range(m):
    max = heapq.heappop(a)
    max = max/2
    heapq.heappush(a,max)

a = list(map(lambda x:x*(-1),a))
a = list(map(math.floor,a))

print(sum(a))

Measured memory_bytes: 14380
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, p;
ll ans;
string s;
ll now = 1;
ll a[200005];
ll d[10005];

int main()
{
    cin>>n>>p>>s;
    if(p == 2)
    {
        for(ll i = 0; i < s.size(); i++)
        {
            if(((ll)(s[i] - '0')) % 2 == 0) ans += i + 1;
        }
        cout<<ans<<endl;
        return 0;
    }
    else if(p == 5)
    {
        for(ll i = 0; i < s.size(); i++)
        {
            if(((ll)(s[i] - '0')) % 5 == 0) ans += i + 1;
        }
        cout<<ans<<endl;
        return 0;
    }
    for(ll i = s.size() - 1; i >= 0; i--)
    {
        a[i] = a[i + 1] + (s[i] - '0') * now;
        a[i] %= p;
        now *= 10;
        now %= p;
    }
    d[0] = 1;
    for(ll i = 0; i < s.size(); i++)
    {
        ans += d[a[i]];
        d[a[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll N;
int cnt = 0;

void dfs(ll n, int a, int b, int c) {
    if (n > N) return;
    if (a && b && c) cnt++;
    dfs(10 * n + 3, a+1, b, c);
    dfs(10 * n + 5, a, b+1, c);
    dfs(10 * n + 7, a, b, c+1);
}

int main() {
    cin >> N;
    dfs(0, 0, 0, 0);
    print(cnt);
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
p = Counter(iil())
m = iil()
t = Counter(iil())

#print(p)
#print(t)

flag = True
for k,v in t.items():
    if p.get(k,0) < v:
        flag = False
print('YES' if flag else 'NO')

Measured memory_bytes: 55256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,a;
	cin>>n;
	long long sum=0;
	rep(i,n){
		cin>>a;
		sum+=a-1;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,m,i,j,cc=0;
    cin>>n>>m;
    map<ll,ll>check;
    map<ll,ll>ara;
    map<ll,ll>fuck;
    ll p[m],y[m],dj[m];
    for(i=0;i<m;i++){
        cin>>p[i]>>y[i];
        dj[i]=y[i];
        check[y[i]]=p[i];
    }
    sort(y,y+m);
    for(i=0;i<m;i++){
        fuck[check[y[i]]]++;
        ara[y[i]]=fuck[check[y[i]]];
    }
    for(i=0;i<m;i++){
        ll x=ara[dj[i]];
        ll y=p[i];
        printf("%06ld",y);
        printf("%06ld\n",x);
    }
return 0;
}


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

int main(){
    string s, t;
    cin >> s >> t;
    int ans = t.size(), cnt = 0;
    for(int i=0; i<=s.size()-t.size(); i++){
        int flag = s.compare(0, t.size(), t);
        if(flag != 0){
            string s1 = s.substr(i, t.size());
            cnt = 0;
            for(int j=0; j<s1.size(); j++){
                if(s1[j] != t[j]) cnt++;
            }
        }else{ ans = 0; }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); (i)--)
#define debug(x) cout << #x << " : " << x << '\n'

const int INF = 1e9;

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

  int ans = 0;
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  FOR(i, 0, N) {
    cin >> x[i];

    int temp = min(x[i], K - x[i]);
    ans += 2 * temp;
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    print((1000 - (n % 1000)) % 1000);
    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount
	
#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n, u;
	while (scanf("%d%d", &n, &u), n | u)
	{
		int c[32], r[32];
		for (int i = 0; i < n; ++i)
		{
			int k;
			scanf("%d%d", c + i, &k);
			r[i] = 0;
			while (k--)
			{
				int t;
				scanf("%d", &t);
				r[i] |= 1 << t;
			}
		}

		int res = n;
		for (int bits = 1; bits < n; ++bits)
		{
			int i = (1 << bits) - 1;
			do
			{
				bool ok = true;
				int s = 0;
				for (int j = 0; j < n; ++j)
				{
					if (i >> j & 1)
					{
						if ((i & r[j]) != r[j])
						{
							ok = false;
							break;
						}
						else
							s += c[j];
					}
				}
				if (ok && s >= u)
				{
					res = bits;
					goto end;
				}

				// combination
				int leastBit = i & -i;
				int mostBits = i + leastBit;
				int leastSequentialBits = i & ~mostBits;
				i = mostBits | ((leastSequentialBits / leastBit) >> 1);
			} while (i < 1 << n);
		}
end:
		printf("%d\n", res);
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define inf 1000000007000000007
typedef long long ll;
using namespace std;

#define N 110
int n;
struct Edge{ll to,lim,revindex;};
vector<Edge> v[N];
ll dis[N];

void Make_Edge(int from,int to,ll lim){
	v[from].push_back((Edge){to,lim,v[to].size()});
	v[to].push_back((Edge){from,0,v[from].size()-1});
}

void BFS(int start){
	lol(i,N)dis[i]=inf;
	dis[start]=0;
	queue<int> Q;
	Q.push(start);
	while(!Q.empty()){
		int x=Q.front(); Q.pop();
		lol(i,v[x].size()){
			if(dis[v[x][i].to]==inf&&v[x][i].lim>0){
				dis[v[x][i].to]=dis[x]+1;
				Q.push(v[x][i].to);
			}
		}
	}
}

int DFS(int x,int goal,ll minedge){
	if(x==goal)return minedge;
	for(int i=0;i<v[x].size();i++){
		if(dis[x]<dis[v[x][i].to]&&v[x][i].lim>0){
			int mini=DFS(v[x][i].to,goal,min(minedge,v[x][i].lim));
			if(mini>0){
				v[x][i].lim-=mini;
				v[v[x][i].to][v[x][i].revindex].lim+=mini;
				return mini;
			}
		}
	}
	return 0;
}

ll Dinic(int start,int goal){
	ll flow=0;
	while(1){
		BFS(start);
		if(dis[goal]==inf)return flow;
		flow+=DFS(start,goal,inf);
	}
}

int main(){
	ll sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		ll a;cin>>a;
		if(a>0){Make_Edge(i,n+1,a);sum+=a;}
		else Make_Edge(0,i,-a);
		for(int j=i;j<=n;j+=i){
			Make_Edge(i,j,inf);
		}
	}
	n+=2;
	cout<<sum-Dinic(0,n-1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    long N,M;
    long SEKI;
    M=0;
    long kekkan[100002];
    SEKI=1;
    cin >> N >> M;
    kekkan[0]=-1;
    kekkan[M+1]=N+1;
    for(int i=1;i<M+1;i++){
        cin >> kekkan[i];
    }
    for(int j=0;j<M+1;j++){
        if (kekkan[j]==kekkan[j+1]-1){
            SEKI=0;
            break;
        }
        else{
            long a= 1; 
            long b= 0;
            long c= 0;
            for(int t = kekkan[j]+1;t< kekkan[j+1]-1; t++) {
            c=b;
            b=a;
            a=(a+c)%1000000007;
            }
            SEKI=(SEKI*a)%1000000007 ;

        }
    }
    cout << SEKI << endl;

    
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    if (n % 2 != 0)
    {
        cout << n/2 +1 << "\n";
    }
    else
    {
        cout << n/2 << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int n;

	scanf("%d", &n);

	int m;

	m = (int)(double)n / 1.08;

	if ((int)((double)m *1.08) == n)
	{
		printf("%d\n", m);

		return 0;
	}

	if ((int)((double)(m + 1) *1.08) == n)
	{
		printf("%d\n", m + 1);

		return 0;
	}

	printf(":(\n");

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<algorithm>
#include<iomanip>
#define mp make_pair
#define lli long long int
#define modi 1000000007
#define pb push_back
using namespace std;
int main(){
int i;
string s;
cin>>s;
if(s.length()<2)
    cout<<0<<endl;
else{
        int count=0;
    for(i=0;i<s.length()-1;i++){
        if(s[i]==s[i+1]){
            s[i+1]=((s[i+1]-'0')+1)%2+'0';
            count++;
        }
    }
    //cout<<s<<endl;
cout<<count<<endl;
}
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 105, mo = 1e9 + 7 ;
using namespace std ;

int n, a[N], dp[N][N][N] ;

inline void upd(int &x, int y) {
	x = (x + y) % mo ; 
}

int main() {
	scanf("%d", &n) ;
	rep(i, 1, n * 2 - 1) scanf("%d", &a[i]) ;
	sort(a + 1, a + 2 * n) ;
	dp[n][1][1] = 1 ;
	for (int i = n; i > 1; -- i) rep(j, 1, (n - i) * 2 + 1) rep(k, 1, j) {
		int L = j, u = i - 1, mid = k ;
		if (a[u] != a[u + 1]) ++ L, ++ mid ; 
		if (a[2 * n - u] != a[2 * n - u - 1]) ++ L ; 
		rep(p, 1, L) {
			if (p <= mid) upd(dp[u][L - max(mid - p - 1, 0)][p], dp[i][j][k]) ; else
			  upd(dp[u][L - max(p - mid - 1, 0)][mid + 1], dp[i][j][k]) ;
		}
	}
	int ans = 0 ;
	rep(i, 1, 2 * n - 1) rep(j, 1, i) upd(ans, dp[1][i][j]) ;
	printf("%d\n", ans) ;
	return 0 ; 
}

Measured memory_bytes: 3456
/*
Date: 2017/01/15 19:44:51 Sunday
*/
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=(a);i<=(n);++i)
#define dep(i,a,n) for(int i=(a);i>=(n);--i)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 
#endif
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x3f3f3f3f;
const int mo=1000000007;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
template<class T1,class T2>inline void gn(T1&r,T2&s){gn(r),gn(s);}
template<class T1,class T2,class T3>inline void gn(T1&r,T2&s,T3&t){gn(r),gn(s),gn(t);}
template<class T1,class T2,class T3,class T4>inline void gn(T1&r,T2&s,T3&t,T4&u){gn(r),gn(s),gn(t),gn(u);}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll powmod(ll a,ll b,ll mo) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111;
int l,m,n,t,C;
int a[N];
int main(){
#ifdef LOCAL
	freopen("A.in","r",stdin);//freopen("A.out","w",stdout);
#endif
	scanf("%d",&n);
	rep(_,1,n){
		int p=_;
		rep(i,2,p){
			while(p%i==0)p/=i,a[i]++;
			if(i>p)break;
		}
	}
	int ans=1;
	rep(i,1,n)ans=1ll*ans*(a[i]+1)%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 200005
#define INF 1000005
#define endl "\n"
lli arr[MAX];
lli f[INF];
bool p[INF];
bool flag[MAX];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	for(lli i = 2; i<=INF; i++){
		if(!p[i]){
			for(lli j = i*i; j<=INF; j+=i){
				p[j] = true;
 			}
		}
	}
	lli n;
	cin>>n;
	for(lli i = 0; i<n; i++){
		cin>>arr[i];
		f[arr[i]]++;
	}
	lli c = 0;
	bool flag = false;
	for(lli i = 0; i<n; i++){
		flag = false;
		f[arr[i]]--;
		if(!p[arr[i]]){
			if(f[1] || f[arr[i]]){
			}
			else{
				c++;
			}
			f[arr[i]]++;
			continue;
		}
		for(lli j = 1; j*j <= arr[i]; j++){
			if(arr[i]%j == 0){
				if(f[j] || f[arr[i]/j]){
					flag = true;
					break;
				}
			}
		}
		if(!flag){
			c++;
		}
		f[arr[i]]++;
	}
	cout<<c<<endl;
	
}

Measured memory_bytes: 13832
#include<iostream>
using namespace std;
main(){
    int a = 0, b = 0;
    cin >> a >> b;
    if (a > b){
        cout << "a > b" << endl;

    }
    else{
        if(a == b){
            cout <<"a == b" << endl;

        }
        else{
            cout << "a < b" << endl;
        }
    }
    return 0;
    
}


Measured memory_bytes: 3104
#include <cstdio>
#include <algorithm>
using namespace std;

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

const int INF = 10000000;
const int MAX_V = 1000;
int graph[MAX_V][MAX_V];
int n;

bool visited[MAX_V];
int cost[MAX_V];

void init_graph() {
    REP(i, MAX_V) {
        REP(j, MAX_V) {
            if (i == j) graph[i][j] = 0;
            else        graph[i][j] = INF;
        }
    }
}

void make() {
    REP(i, n) {
        int u, v, c;
        scanf("%d %d %d", &u, &v, &c);
        graph[u][v] = c; graph[v][u] = c;
    }
}

void init_dijkstra() {
    REP(i, MAX_V) visited[i] = false;
    REP(i, MAX_V) cost[i] = INF;
}

void dijkstra(int start) {
    init_dijkstra();

    cost[start] = 0;

    while (true) {
        int mi = INF;
        int nxt = -1;
        visited[start] = true;
        REP(i, MAX_V) {
            if (visited[i]) continue;
            if (i != start) {
                int d = cost[start] + graph[start][i];
                if (d < cost[i]) {
                    cost[i] = d;
                }
            }
            if (mi > cost[i]) {
                mi = cost[i];
                nxt = i;
            }
        }
        start = nxt;
        if (nxt == -1) break;
    }
}

void solve() {
    while (true) {
        scanf("%d", &n);

        if (n == 0) break;

        init_graph();

        make();

        int mi = INF;
        int town = 0;
        REP(i, MAX_V) {
            dijkstra(i);
            int sm = 0;
            REP(j, MAX_V) {
                if (cost[j] < INF)
                    sm += cost[j];
            }
            if (sm > 0 && sm < mi) {
                mi = sm;
                town = i;
            }
        }

        printf("%d %d\n", town, mi);
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4936
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long
#define mod 1000000007;

int main() {
	ll n, m;
	pair<ll, ll> cost[100010];
	ll ans = 0, now = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> cost[i].first >> cost[i].second;
	}
	sort(cost, cost + n);
	for(int i=0;i<n;i++) {
		if (now >= m)break;
		ll hoge = m - now;
		if (hoge < 0)hoge = 0;
		ans += min(cost[i].second, hoge) * cost[i].first;
		now += min(cost[i].second, hoge);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10 ** 6)
N=int(input())
l=[-1]*N
tree=[[] for i in range(N)]
for i in range(N-1):
   A,B,C=list(map(int,input().split()))
   A-=1;B-=1
   tree[A].append((B,C))
   tree[B].append((A,C))
Q,V=list(map(int,input().split()))
def DFS(now,past,dis):
   l[now]=dis
   for i in tree[now]:
      if i[0]==past:
         continue
      elif l[i[0]] == -1:
         DFS(i[0],now,dis+i[1])
DFS(V-1,-1,0)
for i in range(Q):
   s,e=list(map(int,input().split()))
   s-=1;e-=1
   print(l[s]+l[e])

Measured memory_bytes: 136268
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
int flag=0;
void recur(int a,int b,int c,int k){
  if(k==0){
    if(b>a && c>b) flag=1;
    return ;
  }
  recur(a*2,b,c,k-1);
  recur(a,b*2,c,k-1);
  recur(a,b,c*2,k-1);
}
void  solve(){
  int a,b,k,c;
  cin>>a>>b>>c;
  cin>>k;
  recur(a,b,c,k);
  if(flag) cout<<"Yes\n";
  else cout<<"No\n";
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3652
#include <stdio.h>
int main(void)
{
    long int q,h,c,d,n;
    scanf("%ld %ld %ld %ld",&q,&h,&c,&d);
    scanf("%ld",&n);
    long int a=q*4,b=h*2;
    long int e;
    if(a<=b && a<=c)
      e=a;
    else if(b<=a && b<=c)
      e=b;
    else
      e=c;
    //printf("%ld %ld %ld %ld,%ld\n %ld",a,b,c,d,n,e);
    long long int ans;
    if(e*2 >= d)
    {
        if(n%2==0)
          ans=n*d/2;
        else
          ans=(n-1)*d/2+e;
    }
    else
    {
        ans=n*e;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 128
n,m=map(int,input().split())
a_s=[]
b_s=[]
for i in range(m):
  a,b=map(int,input().split())
  a_s.append(a)
  b_s.append(b)

for i in range(1,n+1):
  print(a_s.count(i)+b_s.count(i))


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

int main() {
	string n; cin >> n;
	int a, b; cin >> a >> b;

	int ans = 0;;
	for (int i = 0; i < stoi(n); i++) {
		vector<int> v;
		for (auto & e : to_string(i + 1)) {
			v.push_back(e - '0');
		}

		int sum = 0;
		for (int j = 0; j < v.size(); j++) {
			sum += v[j];
		}

		if (a <= sum && sum <= b) ans += (i+1);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    //自明なケース
    if(a1 > b1 && a2 > b2) {
        cout << 0 << endl;
        return 0;
    }
    if(a1 < b1 && a2 < b2) {
        cout << 0 << endl;
        return 0;
    }
    ll c1 = (a1 - b1) * t1, c2 = (a2 - b2) * t2;
    if(c1 + c2 == 0) {
        cout << "infinity" << endl;
        return 0;
    }
    if(c1 > 0 && c1 + c2 > 0) {
        cout << 0 << endl;
        return 0;
    }
    if(c1 < 0 && c1 + c2 < 0) {
        cout << 0 << endl;
        return 0;
    }
    ll itv = abs(c1 + c2);
    /*
    for(int i = 0; i < 120; i++) {
        if(i % 2 == 0) {
            cout << i / 2 * (c1 + c2) << " ";
        } else {
            cout << (i + 1) / 2 * c1 + (i - 1) / 2 * c2 << " ";
        }
    }
    cout << endl;
    */
    if(abs(c1) % itv != 0) {
        cout << abs(c1) / itv * 2 + 1 << endl;
    } else {
        cout << abs(c1) / itv * 2 << endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;
class program{
  static void Main(){
    int n = int.Parse(Console.ReadLine());
    int[] a = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    int[] table = new int[100001];
    long ans = 0;
    for(int i = 0;i<n;i++){
      table[a[i]]++;
      ans += a[i];
    }
    n = int.Parse(Console.ReadLine());
    var sans = new StringBuilder();
    for(int i = 0;i<n;i++){
      int[] bc = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
      ans += (bc[1]-bc[0])*table[bc[0]];
      table[bc[1]] += table[bc[0]];
      table[bc[0]] = 0;
      sans.Append(ans.ToString() + "\n");
    }
    Console.WriteLine(sans);
  }
}

Measured memory_bytes: 54876
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n,i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}




Measured memory_bytes: 25172
Sa = list(input())
Sb = list(input())
Sc = list(input())

turn = 'a'
last_turn = 'A'
while 1:
    if turn == 'a':
        last_turn = 'A'
        if len(Sa) == 0:
            break
        turn = Sa.pop(0)
    elif turn == 'b':
        last_turn = 'B'
        if len(Sb) == 0:
            break
        turn = Sb.pop(0)
    elif turn == 'c':
        last_turn = 'C'
        if len(Sc) == 0:
            break
        turn = Sc.pop(0)
    #print(last_turn)
    #print(Sa)
    #print(Sb)
    #print(Sc)
#print(last_turn)

print(last_turn)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct line
{
   ll  m;
   ll c;
   ll eval(int x)
   {
       return (1LL*m*x+c);

   }
   long double insertX(line l)
   {
       return (long double)(c-l.c)/(l.m-m);

   }

};
int main()
{
    int n;
    ll C;
    cin>>n>>C;
    ll h[n];
    deque<line> hull;
    hull.push_back({0,0});
    for(int i=0;i<n;i++) cin>>h[i];
    vector<ll> dp(n);
    ll ans;
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        while(hull.size()>=2&&(hull.back().eval(h[i])>hull[hull.size()-2].eval(h[i]))) hull.pop_back();
        ll best=hull.back().eval(h[i])+1LL*h[i]*h[i]+C;
         if(i==0) best=0;
        dp[i]=best;
       
        ll intercept=best+1LL*h[i]*h[i] ;   
        if(i==n-1){ans=intercept;}
        line l1={-2*1LL*h[i],intercept};
        while(hull.size()>=2&&hull[1].insertX(l1)<hull[0].insertX(hull[1]))
        {
            hull.pop_front();

        }
        hull.push_front(l1);

    }
    cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 5504
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val lx = sc.nextInt()
  val x = (1..n).map { sc.nextInt() }.sorted()


  val list = x.map { Math.abs(lx - it) }

  val ngcd = ngcd(list)
  println(ngcd)

}

private fun gcd(a: Int, b: Int): Int {
  if (b > 0) {
    return gcd(b, a % b)
  }
  return a
}

private fun ngcd(a: List<Int>): Int {
  var res: Int
  res = a.get(0)
  for (i in 1 until a.size) {
      if (res == 1) break
      res = gcd(a.get(i), res)
  }
  return res
}

Measured memory_bytes: 62360
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#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, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

ll f(ll h){
    if(h>1) return 2*f(h/2)+1;
    if(h=1) return 1;
}

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

    ll hp;
    cin>>hp;

    cout<<f(hp)<<endl;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<climits>
using namespace std;
 
#define N 1010
int n;
 
int g[N][N];
 
int weight[N];
bool us[N];
 
//prim
void prim(){
 
  int v;
  
  weight[0]=0;
   
  while(true){
    v=-1;
    
    for(int i=0;i<n;i++){
      if(us[i]!=true && (v==-1 ||weight[i]<weight[v]))v=i;
    }
 
    if(v==-1)break;
    us[v]=true;
  
 
    for(int i=0;i<n;i++){
      if(weight[i]>(g[v][i]+weight[v])){
 
        weight[i]=(g[v][i]+weight[v]);
        //      cout <<"fsafa"<<endl;
      }
    }
  }
  
}
 
 
int main(){
 
  int u,k1,c,v;
 
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      g[i][j]=9953535;
    }
  }
 
  //load n
  cin >>n;
 
  //load data
  for(int i=0;i<n;i++){
    weight[i]=INT_MAX;
    us[i]=false;
    scanf("%d %d",&u,&k1);
    for(int j=0;j<k1;j++){
      scanf("%d %d",&v,&c);
      g[u][v]=c;
      //    cout <<g[i][j]<<" ";
    }
    //    cout <<endl;
  }
 
 
 
 
  //print
  prim();
 
  for(int i=0;i<n;i++){
    cout <<i<<" "<<weight[i]<<endl;
  }
  return 0;
 
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y;
  cin>>x>>y;
  if(y%2==1){
    cout<<"No"<<endl;
  }
  else if(2*x<=y && y<=2*2*x){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long N;
long long tmp;
long long A,B,C;
A=-1;
B=-1;
C=-1;
long long A_num,B_num,C_num;
A_num=0;
B_num=0;
C_num=0;
cin>>N;
bool judge=false;
long long D=-1;
for(long long i=0;i<N;++i){
  cin>>tmp;
  if(A==-1){
    A=tmp;
    A_num+=1;
  }
  else if(tmp==A){
    A_num+=1;
  }
  else if(B==-1){
    B=tmp;
    B_num+=1;
  }
  else if(tmp==B){
    B_num+=1;
  }
  else if(C==-1){
    C=tmp;
    C_num+=1;
  }
  else if(tmp==C){
    C_num+=1;
  } 
  else{
    D=0;
  }
}
//値が1つのパターン
if(B==-1 && C==-1 && A==0){
  judge=true;
}
if(N%3==0){
  tmp=A^B;
  tmp^=C;
    if(A_num==B_num && B_num==C_num && tmp==0){
      judge=true;
    }
    else if(A_num==2*B_num && C_num==0 && B==0){
          judge=true;
        }
    else if(2*A_num==B_num && C_num==0 && A==0){
              judge=true;
            }
  }
if(D==0){
  judge=false;
}
if(judge){
  cout<<"Yes"<<"\n";
}
else{
  cout<<"No"<<"\n";
}
return 0;
}

Measured memory_bytes: 256
n = int(input()[:4])
a = n//100
b = n%100
if 0<a<=12 and 0<b<=12:
    print('AMBIGUOUS')
elif 1<=a<=12 and (b>=13 or b==0):
    print('MMYY')
elif 1<=b<=12 and (13<=a or a==0):
    print('YYMM')
else:
    print('NA')

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

int main(){
	string s;
	int k;

	cin >> k >> s;

	if(s.size() <= k){
		cout << s << endl;
	}else{
		for(int i=0; i<k; i++){
			cout << s[i];
		}
		cout << "..." << endl;
	}

	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
using namespace std;
const int MAXN=1000001;
int a[MAXN],b[MAXN],n,ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
	for(int i=1;i<=n;i++){
		ans+=b[i]-a[i];
	}
	ans+=n;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2304
from sys import stdin
from collections import defaultdict
from heapq import heappush, heappop

N, M = [int(x) for x in stdin.readline().rstrip().split()]
data = defaultdict(list)

for _ in range(N):
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    data[A].append(B)

ans = 0
h_queue = []

for i in range(1,M+1):
    for j in data[i]:
        heappush(h_queue,-j)
    if len(h_queue) > 0:
        ans -= heappop(h_queue)

print(ans)

Measured memory_bytes: 27812
#151_E
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
mod = 10 ** 9 + 7

f = [1 for _ in range(n)]
f_inv = [1 for _ in range(n)]
for i in range(2, n):
    f[i] = (f[i-1] * i) % mod
    f_inv[i] = pow(f[i], mod-2, mod)
def comb(n,k):
    return f[n]*f_inv[k]*f_inv[n-k]%mod   
ans = 0
for i in range(n-k+1):
    ans = (ans + comb(n-i-1, k-1) * (a[-i-1]-a[i]))%mod
print(ans)

Measured memory_bytes: 15120
#include <bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;
 
int main(){
  int cnt=3,a,b,c;
  cin>>a>>b>>c;
  if(a==b)cnt--;
  if(b==c)cnt--;
  if(c==a)cnt--;
  cout<<max(1,cnt)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;

signed main() {
  int N;
  cin >> N;
  
  int ans = 0;
  for( int i = 1; i <= N; i++ ){
    if( i % 3 == 0 ) continue;
    else if( i % 5  == 0 ) continue;
    else ans += i;
  }
  cout << ans << endl;
}

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

using namespace std;using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

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

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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);
}

int main() {
  int N, L;
  cin >> N >> L;
  vector< int > uku;
  int all = 0;
  for(int i = 0; i < N; i++) {
    uku.emplace_back(L + i);
    all += L + i;
  }
  int64 ans = inf, ret;
  for(int i = 0; i < N; i++) {
    if(chmin(ans, abs(all - (all - uku[i])))) {
      ret = all - uku[i];
    }
  }
  cout << ret << endl;
}








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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    ll n , a , b;
    cin >> n >> a >> b;
    ll ans = n + n;
    if(abs(a-b) % 2 == 0)ans = min(ans , abs(a-b) / 2);
    ans = min(ans , b - 1);
    ans = min(ans , n - a);

    ll mvs = a - 1;
    {
        ll A = a - mvs , B = b - mvs;
        if(abs(A-B) % 2 == 0)ans = min(ans , abs(A-B) / 2 + mvs);
        B--;
        if(abs(A-B) % 2 == 0)ans = min(ans , abs(A-B) / 2 + mvs + 1);
    }

    mvs = n - b;
    {
        ll A = a + mvs , B = b + mvs;
        if(abs(A-B) % 2 == 0)ans = min(ans , abs(A-B) / 2 + mvs);
        A++;
        if(abs(A-B) % 2 == 0)ans = min(ans , abs(A-B) / 2 + mvs + 1);
    }

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
l = []

for i in range(N):
    l.append(int(input()))
    
def dfs(syn, n, a, b, c):
    if n == N:
        if a*b*c != 0:
            mp = abs(A-a) + abs(B-b) + abs(C-c)
            mp += syn * 10 - 30
            return mp
        else:
            return 10**9
    else:
        branch1 = dfs(syn+1, n+1, a + l[n], b, c)
        branch2 = dfs(syn+1, n+1, a, b + l[n], c)
        branch3 = dfs(syn+1, n+1, a, b, c + l[n])
        branch4 = dfs(syn, n+1, a, b, c)
        return min(branch1, branch2, branch3, branch4)
        
print(dfs(0, 0, 0, 0, 0))

Measured memory_bytes: 3064