akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll unsigned long long
using namespace std;
const int maxn=300010,maxN=61;
const ll mod=1000000007,TWO=500000004;
int i,j,k,n,m;
ll a[maxn],ans;
ll sum[maxN];
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		ll S=a[i];
		for(j=1;S;j++){
			sum[j]+=S%2;
			S/=2;
		}
	}
	for(i=1;i<=n;i++){
		ll S=a[i];
		for(j=1;j<maxN;j++){
			if(S%2){
				ans+=(n-sum[j])*((1ll<<j-1)%mod)%mod; 
			}else{
				ans+=sum[j]*((1ll<<j-1)%mod)%mod;
			}
			ans%=mod;
			S/=2;
		}
	}
	cout<<(ans*TWO)%mod<<endl;
	return 0;
}

Measured memory_bytes: 2560
while True:
    m, f, r = [int (x) for x in input().split(' ')]
    if m == -1 and f == -1 and r == -1: break
    if m == -1 or f == -1 or m + f < 30:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65 and m + f < 80:
        print('B')
    elif m + f >= 50 and m + f < 65:
        print('C')
    elif m + f >= 30 and m + f < 50:
        if r >= 50:
            print('C')
        else:
            print('D')

Measured memory_bytes: 7644
def  maxHeapify(i):
    l =2*i
    r = 2*i+1
    # print(A[i])
    largest =0
    if l <=H and A[l]> A[i]:
        largest = l
    else:
        largest = i

    if r <= H and A[r] > A[largest]:
        largest = r

    if largest != i :
        A[i],A[largest] = A[largest],A[i]
        maxHeapify(largest)
    # print(A)



H = int(input())

A = list(map(int,input().split()))

A = [-1]+A

for i in range(int(H/2),0,-1):
    maxHeapify(i)

Astr = list(map(str,A))

print(" ",end="")

print(" ".join(Astr[1:]))

Measured memory_bytes: 72888
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
 
 // var n= parseInt(input[0], 10);
  
 
  var a = [];
for (var f = 0; f <= 5; f++) {
      var r= parseInt(input[f], 10);
  //   console.log(r);
   a[f] = r;
 
} 
 
  
  // console.log(a);
  var ans = a[4]-a[0];
   if (ans > a[5]){console.log(':(');}
     else{console.log('Yay!');}
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8")); 
 
 
 

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,CC;
int S[101010],T[101010],C[101010],did[101010];
vector<int> st[201010];

int pre[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>CC;
	FOR(i,N) {
		cin>>S[i]>>T[i]>>C[i];
		S[i]*=2;
		T[i]*=2;
		C[i]--;
		st[S[i]].push_back(i);
	}
	
	int num=0;
	MINUS(pre);
	FOR(i,201000) {
		
		FORR(e,st[i]) {
			if(pre[C[e]]!=-1) {
				pre[C[e]]=T[e];
				did[e]++;
			}
		}
		FORR(e,st[i]) if(did[e]==0) {
			FOR(j,CC) {
				if(pre[j]!=-1 && pre[j]<S[e]-1) {
					pre[j]=-1;
					pre[C[e]]=T[e];
					break;
				}
			}
			if(j==CC) {
				pre[C[e]]=T[e];
				num++;
			}
		}
	}
	
	
	
	cout<<num<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 10112
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res

def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

s = input()
t = input()
f = defaultdict(lambda : None)
for i in range(len(s)):
    si,ti = s[i],t[i]
    if f[si] != None:
        if f[si] != ti:
            print("No")
            quit()
    else:
        f[si] = ti
f = defaultdict(lambda : None)
for i in range(len(s)):
    si,ti = s[i],t[i]
    if f[ti] != None:
        if f[ti] != si:
            print("No")
            quit()
    else:
        f[ti] = si

print("Yes")


Measured memory_bytes: 42548
// AOJ DPL_5_H Balls and Boxes 8
// n 個の区別できるボールを k 個の区別できない箱に入れる
// とき、可能な入れ方の総数を求めてください。
// ただし、
//    どのボールも、必ずいずれかの箱に入れる。
//    各箱に入れることのできるボールの数は高々1つまで。
// 2019.3.11 bal4u

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n, k;

	scanf("%d%d", &n, &k);
	puts(n <= k ? "1" : "0");
	return 0;
}


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

int main(){
        int n, b, f, r, v;
        cin >> n;
        int bill[4][3][10] = {};

        int i;
        for(i = 0; i < n; i++) {
                cin >> b >> f >> r >> v;

                bill[b - 1][f - 1][r - 1] += v;
        }

        int j, k;
        for(i = 0; i < 4; i++) {
                for(j = 0; j < 3; j++) {
                        for(k = 0; k < 10; k++) {
                                cout << " " << bill[i][j][k];
                        }
                        cout << endl;
                }
                if(i < 3) {
                        cout << "####################" << endl;
                }
        }
}



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

happy = 0
rl = 0
before = s[0]
if before == 'R' and s[1] == 'R':
    happy += 1
for i in range(1, n):
    if before == 'R' and s[i] == 'L':
        rl += 1
    if s[i] == 'L' and s[i-1] == 'L':
        happy += 1
    if i < n-1:
        if s[i] == 'R' and s[i+1] == 'R':
            happy += 1
    before = s[i]

if rl < k:
    print(n-1)
else:
    print(happy + k*2)

Measured memory_bytes: 73140
function Main(input) {
    var sum  = function(arr) {
        var sum = 0;
        arr.forEach(function(elm) {
            sum += elm;
        });
        return sum;
    };
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    var L1 = input[0].map(e => parseInt(e, 10));
    var H = L1[0];
    var W = L1[1];
    var K = L1[2];
    var bitmap = [];
    var tmp = [];
    for (var i = 0; i < H; i++){
        tmp = [];
        for (var j = 0; j < W; j++){
            if (input[i + 1][0].substr(j, 1) == '.') tmp.push(0);
            if (input[i + 1][0].substr(j, 1) == '#') tmp.push(1);
        }
        bitmap.push(tmp);
    }
    var tmpBitMap;
    var tmpSaved;
    var blackCount;
    var ans = 0;
    for (var i = 0; i < Math.pow(2, H); i++){
        blackCount = 0;
        tmpBitMap = bitmap.slice();
        // console.log("here", tmpBitMap);
        tmp01 = i.toString(2);
        tmp01 = ('000000' + tmp01).substr(-1*H);
        // console.log("01",tmp01);
        for (var j = 0; j < tmp01.length; j++){
            if (tmp01.substr(j, 1) === '1'){
                tmpBitMap[j] = Array.from({length: W}, () => 0);
            }
        }
        tmpSaved = [];
        for (var x of tmpBitMap){
            tmpSaved.push(x.slice());
        }

        for (var k = 0; k < Math.pow(2, W); k++){
            tmp02 = k.toString(2);
            tmp02 = ('000000' + tmp02).substr(-1*W);
            // console.log("02",tmp02);
            for (var l = 0; l < tmp02.length; l++){
                if (tmp02.substr(l, 1) === '1'){
                    for (var col of tmpBitMap){
                        col[l] = 0;
                    }
                }
            }
            // console.log(tmpBitMap);
            for (var x of tmpBitMap){
                blackCount += sum(x);
            }
            if (blackCount === K) ans ++;
            // if (blackCount === K) console.log("OK");
            blackCount = 0;
            tmpBitMap = [];
            for (var x of tmpSaved){
                tmpBitMap.push(x.slice());
            }
        }
        

    }
    console.log(ans);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 

Measured memory_bytes: 36604
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main()
{
    string s;   cin >> s;
    int l = s.length();
    s += "ZZZZZZZZ";

    ll abc, a, bc, ans;
    abc = 0;
    a = 0;
    bc = 0;
    ans = 0;
    int i=0;
    while(i < l){
        if(s.substr(i,3) == "ABC"){
            abc++;
            ans += abc + a;
            i += 3;
        }else if(s.substr(i,1) == "A"){
            a++;
            i++;
        }else if(abc > 0 && s.substr(i,2) == "BC"){
            ans += abc + a;
            i += 2;
        }else{
            abc = 0;
            a = 0;
            bc = 0;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
	int a, b;
	string s;
	while (cin >> a >> b >> s)
	{
		int flag = 1;
		if (s.length()  != a + b + 1)
			flag = 0;
		int cnt = 0;
		for (auto op : s)
		{
			if (op == '-')
				cnt ++;
			else if (!(op >= '0' && op <= '9'))
				flag = 0;
		}
		if (cnt != 1)
			flag = 0;
		int pos = -1;
		for (int i = 0; i < s.length(); i ++)
			if (s[i] == '-')
				pos = i;
		if (pos != a)
			flag = 0;
		if (!flag)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        int h = Integer.parseInt(scanner.nextLine());
        int w = Integer.parseInt(scanner.nextLine());

        System.out.println((n - h + 1) * (n - w + 1));
    }
}


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

#ifdef DEBUG
#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))

#define LOGM(msg) (cerr << (msg))

#define LOGV(vec, sep) {                                        \
    cerr << #vec << " =";                                       \
    for (const auto& v : (vec)) cerr << " " << v;               \
    cerr << (sep); }

#define LOGA(arr, N, sep) {                                     \
        cerr << #arr << " =";                                   \
        for (int i = 0; i < N; ++i) cerr << " " << (arr)[i];    \
        cerr << (sep); }

#define LOGA2(arr, N, M, sep) {                                 \
        cerr << #arr << " =\n";                                 \
        for (int i = 0; i < N; ++i) {                           \
            for (int j = 0; j < M; ++j)                         \
                cerr << (arr)[i][j] << " ";                     \
            cerr << endl;                                       \
        } cerr << (sep); }
#else
#define LOG(var, sep)
#define LOGM(msg)
#define LOGV(vec, sep)
#define LOGA(arr, N, sep)
#define LOGA2(arr, N, M, sep)
#endif

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, string& s)
{
    vector<int> rs;

    for (int i = 0; i < N; ++i)
        if (s[i] == 'R')
            rs.emplace_back(i);

LOGV(rs, endl);
    int ans = 0;

    for (int i = 0; i < N; ++i)
    {
LOG(i, ' '); LOG(s, endl);
        if (s[i] == 'R')
            continue;

        if (not rs.empty() and rs.back() > i)
        {
LOGM("--- "); LOG(rs.back(), endl);
            ++ans;
            swap(s[i], s[rs.back()]);
            rs.pop_back();
LOGM("new "); LOG(s, endl);
        }
    }
     
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    string s;

    cin >> N >> s;

    auto ans = solve(N, s);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4440
#include <iostream>

using namespace std;

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

    int A = 1;

    if (D == 1)
        A = 100;
    if (D == 2)
        A = 10000;

    int B = 0;

    for (int i = 0; i < N; i++)
        B += A;

    if (N == 100)
        B += A;

    cout << B << endl;
    
    return 0;
}

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

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

   for(i=n-1; i>=0; i--){
    if(i+1 > n/2){
      b[i] = (a[i] == 0) ? 0 : 1;
    }else{
      for(int j=((i+1)*2)-1; j<n; j+=i+1){
	tsum += b[j];
	}
      if(tsum % 2 == 0){
	b[i] = (a[i] == 0) ? 0 : 1;
      }else{
	b[i] = (a[i] == 0) ? 1 : 0;
      }
      tsum = 0;
    }
  if(b[i] == 1)
	c++;
  }
   cout << c << endl;
  for(i=0; i<n; i++){
    if(b[i] == 1){
      cout << i+1 << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 2432
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j; //loop variables
    int n; //test cases
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        a[i] = a[i]-(i+1);
    }
    sort(a, a+n);
    long long sum = 0, sum1=0, sum2=0;
    if(n%2!=0)
    {

        for(i=0;i<n;i++)
        {   //cout<<a[i]<<" ";

            sum+=(long long)abs(a[i]-a[n/2]);
        }
        cout<<sum;
    }
    else
    {
        for(i=0;i<n;i++)
        {
            sum1+=(long long)(abs(a[i]-a[n/2]));
            sum2+=(long long)(abs(a[i]-a[(n-1)/2]));
        }
        if(sum1<sum2)
            cout<<sum1;
        else
            cout<<sum2;
    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] t=new int[n+1];
		int[] x=new int[n+1];
		int[] y=new int[n+1];
		for(int i=1;i<=n;i++){
			t[i]=sc.nextInt();
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();
		}
		
		for(int i=1;i<=n;i++){
			int dt=t[i]-t[i-1];
			int dx=Math.abs(x[i]-x[i-1]);
			int dy=Math.abs(y[i]-y[i-1]);
			int time=dt-dx-dy;
			if(time<0||time%2==1){
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 91148
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;
int main(void){
    long long N, K; cin >> N >> K;
    if ( K % 2 == 1) {
        long a = N/K;
        cout << a*a*a << endl;
    } else {
        long long a = N/K;
        long long b = (N+(K/2)) / K;
        cout << a*a*a + b*b*b << endl;
    }
}

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

int main() {
	const int N = 5;
	int ans = 50000;
	
	vector<int> dishes(N);
	for(int i=0;i<5;i++){
		cin >> dishes[i];
	}
	
	do{
		int count_time = 0;
		for(int i=0;i<4;i++){
			int dish = dishes[i];
			count_time += (dish / 10)*10 + 10*(dish%10 != 0);
		}
		count_time += dishes[4];
		ans = min(ans, count_time);
	}while(next_permutation(dishes.begin(), dishes.end()));
	
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;
const int MOD = 1000000007;

int main() {
	string s;
	cin >> s;
	s[5] = s[13] = ' ';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[int(_) for _ in input().split()]

if 0 in A:
    print(0)
else:
    now=1
    ok=True
    for a in A:
        now*=a;
        if now>1e18:
            ok=False
            break
    if ok:
        print(now)
    else:
        print(-1)

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

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> inv(N), nxt(N + 2), prv(N + 2);
    iota(nxt.begin(), nxt.end(), 1UL);
    nxt.back() = N + 1;
    iota(prv.begin(), prv.end(), -1UL);
    prv.front() = 0;
    for(unsigned long i = 0, p; i < N; ++i){
        cin >> p;
        inv[p - 1] = i + 1;
    }
    unsigned long ans{0};
    for(unsigned long p = 0, i; p < N; ++p){
        i = inv[p];
        ans += (p + 1) * ((nxt[nxt[i]] - nxt[i]) * (i - prv[i]) + (prv[i] - prv[prv[i]]) * (nxt[i] - i));
        prv[nxt[i]] = prv[i];
        nxt[prv[i]] = nxt[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0 ; i < n ; i++) {
            p[i] = sc.nextInt();
        }
        int count = 0;
        for (int i = 0 ; i < n  ; i++) {
            if (p[i] == i + 1) {
                count++;
                if (i < n - 1) {
                    p[i + 1] = p[i];
                }
            }
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 50480
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int a[] = new int[n];
		long ans = 0;
		for(int i=0;i<n;i++) {
			a[i] = scan.nextInt();
		}
		
		for(int i=1;i<n;i++) {
			if(a[i-1] > a[i]) {
				ans += a[i-1] - a[i];
				a[i] += a[i-1] - a[i];
			}
		}
		
		System.out.println(ans);
		
		
		
		
	}
	
	
	public static int gcd(int x,int y) {
		if(x%y == 0) {
			return y;
		}else {
			return gcd(y,x%y);
		}
	}
}
 





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

using namespace std;
#define INF 99999
#define _GLIBCXX_DEBUG

//repetition
//------------------------------------------
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REPS(i,a,n) for(int i=(a);i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define fi first
#define se second

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;


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

    int N, A;
    cin >> N >> A;
    cout << N * N - A;
}

Measured memory_bytes: 892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] inputNum = br.readLine().split(" ");
		int a = Integer.parseInt(inputNum[0]);
		int b = Integer.parseInt(inputNum[1]);

		int d = a/b;
		int r = a%b;
		double f = (double)a/b;

		DecimalFormat dmmft = new DecimalFormat("0.00000");
		System.out.println(d + " " +  r  + " " + dmmft.format(f) );


	}

}

Measured memory_bytes: 17120
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define loop(i, sta, end, inc) for(int i = sta; i <= end; i += inc)
#define itr(it, l)             for(auto it = l.begin(); it != l.end(); it ++)
#define in(a, b, c)            assert( b <= a && a <= c)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define what_is(x) cerr<<#x<<" ="<<x<<" ";
#define error(args...)  { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define LINT_MAX  9223372036854775807
#define LINT_MIN -9223372036854775808
#define EPS 1e-9
#define MOD 1000000007
#define DEBUG 0

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
void err(istream_iterator<string> it) { cerr<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    if(DEBUG == 0)return;
	cerr << *it << " = " << a <<" ";
	err(++it, args...);
}

long long A[3000];
long long dp[3000][3000];
int main(){
   // freopen("test.txt", "r", stdin);
    int n;cin>>n;
    forn(i,n)cin>>A[i];
    forn(k,n){
    	forn(i,n-k){
    		if(i==i+k)dp[i][i]=A[i];
    		else dp[i][i+k]=max(A[i]-dp[i+1][i+k],A[i+k]-dp[i][i+k-1]);
    	}
    }
    cout<<dp[0][n-1]<<endl;
    
    return 0;
}



Measured memory_bytes: 70144
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>
#include <numeric>

int main(){
	int h, w, input;
	std::cin >> h >> w >> input;
	h -= input;
	std::cin >> input;
	w -= input;
	std::cout << h * w << std::endl;
	return 0;
}



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

typedef long long ll;

ll num(ll x){
	ll tmp=1,ans=0;
	ll y=x;
	while(x>1){
		x/=5;
		tmp*=5;
	}
	while(tmp>1){
		ans+=(y/tmp);
		tmp/=5;
	}
	return ans;
}

int main(){
	ll n;
	cin>>n;
	if(n%2!=0){
		cout<<0<<endl;
	}else{
		cout<<num(n/10)+n/10<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> lpii;
typedef unsigned long long ull;
const double eps = 1e-8;
const double pi = acos(-1.0);
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353;
const int N = 2e5 + 10;
ll fact[N];
ll inv[N];

ll qpow(ll a, ll b, ll c) {
    ll res = 1;
    while(b) {
        if(b & 1) res = res * a % c;
        a = a * a % c;
        b >>= 1;
    }
    return res;
}

void init() {
    fact[0] = 1;
    for(int i = 1; i < N; i++) {
        fact[i] = fact[i - 1] * i % mod;
    }
    inv[N - 1] = qpow(fact[N - 1], mod - 2, mod);
    for(int i = N - 2; i >= 0; i--) {
        inv[i] = inv[i + 1] * (i + 1) % mod;
    }
}
ll n, m, k;

void solve() {
    init();
    cin >> n >> m >> k;
    ll ans = 0;
    for(int i = 0; i <= k; i++) {
        ans = (ans + ((((fact[n - 1] * inv[n - 1 - i] % mod) * inv[i] % mod) * m) % mod) * qpow(m - 1, n - i - 1, mod) % mod) % mod;
    }
    cout << ans << endl;
}

int main() {
#ifdef ONLINE_JUDGE
#else
    freopen("std1.in","r",stdin);
#endif
    ios::sync_with_stdio(false);
    int t = 1;
    //cin >> t;
    //scanf("%d", &t);
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 6760
//#include "pch.h"
#include <iostream>
#include <string>

using namespace std;



int main() {


	int h, w;
	string str[100];

	cin >> h >> w;

	for (int i = 0; i < h; i++) {
		cin >> str[i];
	}

	for (int i = 0; i < h; i++) {
		cout << str[i] << endl;
		cout << str[i] << endl;
	}


	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int top, S[200];

void push(int x) {
  S[++top] = x;
}

int pop() {
  return S[top--];
}

int main() {
  int a, b;
  top = 0;
  char c[10];
  while (cin >> c) {
    if (c[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    }
    else if (c[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    }
    else if (c[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    }
    else {
      push(atoi(c));
    }
  }
  cout << pop() << endl;
  return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
#include <iomanip>  
using namespace std;
int main() {
	int len, hal, cnt = 0;
	string s;
	cin >> s;
	len = s.length();
	hal = len / 2;
	for (int i = 0; i < hal; ++i) {
		if (s[i] != s[len - i - 1])cnt = cnt + 1;
	}
	cout << cnt << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

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



Measured memory_bytes: 3632
from collections import deque
n = int(input())
ai = [int(input()) for i in range(n)]

ai.sort()

deq = deque()
deq.appendleft(ai[0])

#print(ai)
#print()

for i in range(n-1):
    if i % 4 == 0:
        deq.appendleft(ai[n-i//2-1])
        #print(n-i//2-1)
    elif i % 4 == 1:
        deq.append(ai[n-i//2-2])
        #print(n-i//2-2)
    elif i % 4 == 2:
        deq.appendleft(ai[i//2])
        #print(i//2)
    elif i % 4 == 3:
        deq.append(ai[i//2+1])
        #print(i//2+1)
        #print(n-i//3-2)
    #print(deq)
    
ans = 0

#print(deq)

for i in range(n-1):
    ans += abs(deq[i+1] - deq[i])


ai.sort(reverse=True)

deq = deque()
deq.appendleft(ai[0])

#print(ai)
#print()

for i in range(n-1):
    if i % 4 == 0:
        deq.appendleft(ai[n-i//2-1])
        #print(n-i//2-1)
    elif i % 4 == 1:
        deq.append(ai[n-i//2-2])
        #print(n-i//2-2)
    elif i % 4 == 2:
        deq.appendleft(ai[i//2])
        #print(i//2)
    elif i % 4 == 3:
        deq.append(ai[i//2+1])
        #print(i//2+1)
        #print(n-i//3-2)
    #print(deq)
    
ans2 = 0

#print(deq)

for i in range(n-1):
    ans2 += abs(deq[i+1] - deq[i])
#print(ans2)
print(max(ans,ans2))

Measured memory_bytes: 59096
function main(input) {
  var inputs = input.split(" ").map(x => parseInt(x, 10));
  var a = inputs[0];
  var b = inputs[1];
  var c = inputs[2];

  console.log(a + b >= c ? "Yes" : "No")
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    string s;
    cin>>s;
    string r=s;
    reverse(r.begin(),r.end());
    if(s==r) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b, c, d, s, t;
    double x, y, det;
    while(scanf("%d %d %d %d %d %d", &a, &b, &s, &c, &d, &t) != EOF){
        det = a * d - b * c;
        x = (s * d + t * (-b)) / det;
        y = (s * (-c) + t * a) / det;
        x = x == 0 ? 0 : x;
        y = y == 0 ? 0 : y;
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <cstdlib>




int mins(int a,int b){
  if(a==-1)return b;
  if(b==-1)return a;
  else return (a>b)?b:a;
}
int main(void){
  int m,n;
  scanf("%d%d",&n,&m);
  while(n!=0){

    int dkmp[150][10][77];//動計(メモ再)用。
    int maps[150][10][2];//盤面用。
    //memset(maps,-1,sizeof(maps));
    memset(dkmp,-1,sizeof(dkmp));
    memset(maps,-1,sizeof(maps));
    int i=0;
    int j=0;
    int xm;
    for(i=0;i<n;i++){
      scanf("%d",&xm);
      for(j=0;j<xm;j++){
	scanf("%d%d",&(maps[i][j][0]),&(maps[i][j][1]));
      }
    }
    //maps[i][j]には、岸からi+1つめの石で、j列にある石のあれ。
    //maps[n][x]は、向こう岸。だった。
    //maps[i][j][0]には、岸からi+1つめの石のある列。
    //maps[i][j][1]には、岸からi+1つめの石のあるすべ。
    for(j=0;j<10;j++){
      if(maps[0][j][0]!=-1){
	dkmp[0][j][m]=0;
      }
      if(maps[1][j][0]!=-1 && m!=0){
	dkmp[1][j][m-1]=0;
      }
    }
    int mema,memb,memc,memd,meme,memf;
    for(j=0;j<10;j++){
      if(maps[1][j][0]==-1)break;
      mema=-1;
      memd=maps[1][j][0];//行
      meme=maps[1][j][1];//滑りやすさ    
      for(i=0;i<10;i++){
	if(dkmp[0][i][m]!=-1){
	  memb=0;//=dkmp[0][p][m];累積
	  memc=maps[0][i][0];//行
	  memf=maps[0][i][1];//滑りやすさ
	  mema=mins(mema,abs(memd-memc)*(meme+memf)+memb);
	}
	else break;
      }
      dkmp[1][j][m]=mema;
    }


    //ここから動計部
    //maps[i][j][m]には、i個目のj
    int k=0,p=0;
    for(i=2;i<n;i++){//岸からi個目の石
      for(j=0;j<10;j++){//j番目の石
	if(maps[i][j][0]==-1)break;
	else{//石がそこにあれば
	  memd=maps[i][j][0];//行
	  meme=maps[i][j][1];//滑りやすさ    
	  for(k=0;k<=m;k++){//残りk回飛べるとき。
	    mema=-1;
	    for(p=0;p<10;p++){//石pから飛んできたとする。
	      if(dkmp[i-1][p][k]!=-1){
		memb=dkmp[i-1][p][k];//累積
		memc=maps[i-1][p][0];//行
		memf=maps[i-1][p][1];//滑りやすさ
		mema=mins(mema,abs(memd-memc)*(meme+memf)+memb);
	      }
	      else break;
	    }
	    if(k<m){
	      for(p=0;p<10;p++){//石pから飛んできたとする。
		if(dkmp[i-2][p][k+1]!=-1){
		  memb=dkmp[i-2][p][k+1];//累積
		  memc=maps[i-2][p][0];//行
		  memf=maps[i-2][p][1];//滑りやす
		  mema=mins(mema,abs(memd-memc)*(meme+memf)+memb);
		}
		else break;
	      }
	    }
	    dkmp[i][j][k]=mema;
	  }
	}
      }
    }

    //printf("%d\x0020%d\n",m,dkmp[n-1][0][0]);
    int ans=-1;
    for(i=0;i<10;i++){
      if(maps[n-1][i][0]==-1)break;
      for(j=0;j<=m;j++){
	ans=mins(ans,dkmp[n-1][i][j]);
	//printf("%d\n",dkmp[n-1][i][j]);
      }
    }
    for(i=0;i<10;i++){
      if(maps[n-2][i][0]==-1)break;
      for(j=1;j<=m;j++){
	ans=mins(ans,dkmp[n-2][i][j]);
      }
    }

    printf("%d\n",ans);
    scanf("%d%d",&n,&m);
  }
  return 0;
}

Measured memory_bytes: 1496
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

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

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
string ring;
string Search;
int main()
{
  int N;
  int ans = 0;
  cin >>ring;
  cin >>N;
  for(int i = 0;i < N;i++){
    cin >>Search;
    string sum =Search+Search;
    int j = 0;
    for(int i = 0;i <sum.length();){
      if(ring[j] ==sum[i]){
	j++;
	i++;
	if(j==ring.length()){
	  ans++;
	  break;
	}
	
      }else{
	if(j ==0)
	  i++;
	j = 0;
      }
      
    }
  }
  cout <<ans<<endl;
  return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; ll d, a;
	cin >>n >>d >>a;
	vector<pii> ha(n);
	rep(i, n) cin >>ha[i].first >>ha[i].second;
	sort(all(ha));
	priority_queue<pii, vector<pii>, greater<pii> > q;
	ll ans = 0, crdm= 0;
	rep(i, n){
		for(;!q.empty() && q.top().first < ha[i].first;){
			crdm -= q.top().second; q.pop();
		}
		if(ha[i].second <= crdm) continue;
		ll asu = (ha[i].second - crdm + a -1) / a;
		ans += asu; crdm += a * asu;
		q.emplace(ha[i].first + 2*d, a*asu);
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
int main(){ 
  char c[3][3];
for(int i=0;i<3;i++)
{
  for(int j=0;j<3;j++)
  {
    cin>> c[i][j];
  }
  cout<<c[i][i];
}
}

Measured memory_bytes: 256
import sys
import math
import itertools


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    list = [[3, 5, 7]]
    N=int(input())
    for i in range(9):
        new = []
        for j in list[-1]:
            a = 10 * j
            new.append(a + 3)
            new.append(a + 5)
            new.append(a + 7)
        list.append(new)

    pass
    count =0
    for sub in list:
        for j in sub:
            s =str(j)
            if j>N:
                print(count)
                exit()
            if "3" in s and "7" in s and "5" in s:
                count +=1






if __name__ == "__main__":
    main()


Measured memory_bytes: 13492
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <complex>

using namespace std;
typedef long long ll;


typedef complex<double> xy_t;
double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

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

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define re(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl;

ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans=0;
ll a,b,c,d,e,f,g,h,w;
ll start,end;

ll x[500005],y[500005],z[500005];
bool flag;


int main(){
    cin>>a>>b>>c;
    p(max(a,max(b,c))*9+a+b+c);
    
    return 0;
    
}



Measured memory_bytes: 6400
#include<cstdio>
int a,b,c,x,i,j,k,ans;
int main()
{
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for (i=0;i<=a&&500*i<=x;i++)
      for(j=0;j<=b&&100*j+500*i<=x;j++)
        for(k=0;k<=c&&50*k+100*j+500*i<=x;k++)
          if(500*i+100*j+50*k==x)
        	ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> stringconvert(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}

ll N, K;
int main()
{
	cin >> N >> K;
	ll sum = K;
	if (N > K) {
		ll t = N / K;
		sum = t * K + K;
	}
	
	cout << min(abs(sum - N), abs(K - abs(sum - N))) << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <random>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    int x,a; cin >> x >> a;
    if (x < a)
    {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
    return 0;
}

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

int main(){
    int n, ans=0;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    rep(i,n) cin >> a.at(i);
    rep(k,n) cin >> b.at(k);
    rep(l,n-1) cin >> c.at(l);
    
    rep(i,n){
        ans+=b.at(a.at(i)-1);
        if(i>=1 && a.at(i)-a.at(i-1)==1){
            ans+=c.at(a.at(i-1)-1);
        }
    }

    cout << ans << endl;
}

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

void solve(int P, int V, int *num, int N, int **Path){
	int i, p[] = {2, 3, 5, 7, 11, 13, 17, 19};
	if(P == 1){
		(*num)++;
	}
	else{
		for(i = 0; i < N; i++){
			if(P%p[i] == 0 && Path[V][i] == 1){
				solve(P/p[i], i, num, N, Path);
			}
		}
	}
}

int main(){
	int N, M, a, b, i, j, P = 1, p[] = {2, 3, 5, 7, 11, 13, 17, 19};
	scanf("%d%d", &N, &M);
	for(i = 0; i < N; i++){
		P *= p[i];
	}
	int **Path;
	Path = (int **)malloc(sizeof(int *) * N);
	for(i = 0; i < N; i++){
		Path[i] = (int *)malloc(sizeof(int) * N);
		for(j = 0; j < N; j++){
			Path[i][j] = -1;
		}
	}
	for(i = 0; i < M; i++){
		scanf("%d%d", &a, &b);
		Path[a-1][b-1] = 1;
		Path[b-1][a-1] = 1;
	}
	int *num;
	num = (int *)malloc(sizeof(int));
	*num = 0;
	solve(P/2, 0, num, N, Path);
	printf("%d\n", *num);
	free(num);
	for(i = 0; i < N; i++){
		free(Path[i]);
	}
	free(Path);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define rep(i,e) for(int i=0;i<(e);++i)

long long dist[100][100];
int N, M, L, K, A, H;

int main() {
  while(cin>>N>>M>>L>>K>>A>>H){
    if(N==0) break;

    rep(i, N)rep(j, N){
      if(i==j) dist[i][j] = 0;
      else dist[i][j] = INF;
    }
    bool isFridge[100]={};

    rep(i, L){
      int lt; cin>>lt;
      isFridge[lt] = true;
    }
    isFridge[A]=true; isFridge[H]=true;
    rep(i, K){
      int x, y, t; cin>>x>>y>>t;
      dist[x][y] = t;
      dist[y][x] = t;
    }

    rep(k, N)rep(i, N)rep(j, N){
      dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
    }

    rep(i, N)rep(j, N){
      if(dist[i][j]>M || !isFridge[i] || !isFridge[j]){
        dist[i][j] = INF;
      }
    }

    rep(k, N)rep(i, N)rep(j, N){
      dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
    }

    if(dist[H][A]==INF) cout<<"Help!"<<endl;
    else if(dist[H][A]<=M) cout<<dist[H][A]<<endl;
    else cout<<dist[H][A]*2-M<<endl;
  }

  return 0;
}


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

import sys
sys.setrecursionlimit(10**6)

def search(values,hp,vp,item):
	if not (0<=hp<len(values)): return
	if not (0<=vp<len(values[hp])): return
	if item!=values[hp][vp]: return
	values[hp][vp]=True
#	for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]:
#		search(values,hp+dh,vp+dv,item)
	search(values,hp-1,vp,item)
	search(values,hp+1,vp,item)
	search(values,hp,vp-1,item)
	search(values,hp,vp+1,item)

def solve(values):
	count,valid_items=0,set(['@','#','*'])
	for i in range(len(values)):
		for j in range(len(values[i])):
			if values[i][j] in valid_items:
				search(values,i,j,values[i][j])
				count+=1
	return count

def main():
	line, values = input().strip(), list()
	while line!='0 0':
		H,W = list(map(int,line.split(' ')))
		value = list()
		for _ in range(H):
#			value.append(list(x for x in input().strip()))
			value.append(list(input().strip()))
		print(solve(value))
#		values.append(value)
		line = input().strip()
#	for value in values:
#		print(solve(value))

if __name__=='__main__':
	main()

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

int main()
{
    int a,b,c,d;

    scanf("%d%d%d",&a,&b,&c);

    d = (a+b+c)/2;

    int f = d*(d-a)*(d-b)*(d-c);

    int e = sqrt(f);

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


    return 0;
}


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

typedef long long ll;
const ll MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  for(int i = 0 ; i <= 50000 ; i ++){
    int x = (int)(i*(double)(1.08));
    if(x == n){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

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

#define mx 100005

using namespace std;

int n, m, a, b, rt, pa[mx];
vector<int> ch[mx];
bool nt[mx], anc[mx] = {true};

 void search(int now){
	 anc[now] = true;
	 for(int i : ch[now]){
		 if(anc[pa[i]]) pa[i] = now;
		 if(nt[i]){
			 nt[i] = false;
			 search(i);
		 }
	 }
	 anc[now] = false;
 }

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n + m - 1; i++){
		scanf("%d%d", &a, &b);
		ch[a].push_back(b);
		nt[b] = true;
	}
	for(rt = 1; nt[rt]; rt++);
	search(rt);
	for(int i = 1; i <= n; i++) printf("%d\n", pa[i]);
}


Measured memory_bytes: 11520
use proconio::{fastout, input};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        a: usize,
        b: usize
    }
    let mut res = 0;
    let mut now = 1;
    while now < b {
        now += a - 1;
        res += 1;
    }
    println!("{}", res);
}


Measured memory_bytes: 2196
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (A, B, T) = (input[0], input[1], input[2])
print(T/A*B)


Measured memory_bytes: 7776
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    double a,b,h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <cmath>
#include <bitset>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
  ll N;
  ll L[1010];
  cin >> N;
  rep(i,N){
    cin >> L[i];
  }
  ll tmp[3];
  ll ans = 0;
  
  rep(i,N){
    FOR(j,i+1,N) {
      FOR(k,j+1,N){
        if(i!=j && j!=k && i!=k && L[i]!=L[j] && L[j]!=L[k] && L[i]!=L[k]){
          tmp[0] = L[i];
          tmp[1] = L[j];
          tmp[2] = L[k];
          sort(tmp, tmp+3);
          if(tmp[2] < tmp[0]+tmp[1]){
            ans++;
            //cout << tmp[0] << tmp[1] << tmp[2] << endl;
          }
        }
      }
    }
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 3664