akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned int ui;
#define infin (ll)(pow(10,9)+7)
#define push_back pb;
using namespace std;
int factorize(int x)
{
   int count=0;
   for(int i=1;i<=(int)(sqrt(x));i++)
   {
      if (x%i==0)
         {
            if (i==x/i)
               count+=1;
            else
               count+=2;
         }
   }
   return(count);
}
int main()
{
   int n;
   cin>>n;
   ll ways=0;
   for(int i=1;i<n;i++)
   {
      int ans=factorize(n-i);
      //cout<<n-i<<" "<<ans<<endl;
      ways+=ans;
   }
   cout<<ways<<endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>

const long long int Z = 1000000007;
const long long int INF = 1 << 30;
int flag = 0;
using ll = long long;

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

}
 ll lcm(ll a, ll b) {
	 ll g = gcd(a, b);
	 return a / g * b;
 }

 int main() {
	 std::string s;
	 int a[27] = {0};
	 while (std::cin >> s) {
		 std::transform(s.begin(), s.end(), s.begin(), tolower);
		 for (int i = 0;i < s.size();i++) {
			 int num = s[i] - 'a';
			 a[num]++;
		 }
	 }
	 char c = 'a';
	 for (int i = 0;i < 26;i++) {
		 std::cout << c << ' ' << ':' << ' ' << a[i] << std::endl;
		 c++;
	 }
	return 0;
}


Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {

	static Scanner sc;
	static String input;

	public static void main(String[] args) {
		//初期化
		init();

		int ans = 0;
		//メインの処理
		//入力文字列を先頭から捜索
		for(int i=0; i<input.length(); i++) {
			//先頭からi番目の文字
			char c = input.charAt(i);
			//長さのカウントを開始
			if(c=='A' || c=='T'|| c=='G'|| c=='C') {
				int count = 0;
				for(int j=0; i+j<input.length(); j++) {
					c = input.charAt(i+j);
					if (c!='A' && c!='T'&& c!='G'&& c!='C') {
						count = j;
						break;
					}else if(i+j == input.length() - 1) {
						count = j+1;
						break;
					}
				}

				//最大長の更新
				if(ans < count) ans = count;
			}
		}

		System.out.println(ans);

		sc.close();
	}

	private static void init() {
		sc = new Scanner(System.in);
		input = sc.nextLine();
	}
}

Measured memory_bytes: 23892
// luogu-judger-enable-o2
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int l,r,ans;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>l>>r;
        ans+=r-l+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <climits>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    using i32 = int32_t; using u32 = uint32_t;
    using i64 = int64_t; using u64 = uint64_t;
    using f32 = float; using f64 = double;

    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int n; cin >> n;
    while (n--) {
        int a; cin >> a;
        if (!(a & 1)) {
            if (a % 3 && a % 5) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}



Measured memory_bytes: 3636
n, m = map(int,input().split())
h_list = list(map(int, input().split()))
good_list = [1 for i in range(n)]
for i in range(m):
  _a,_b = map(int, input().split())
  if h_list[_a-1] == h_list[_b-1]:
    good_list[_a-1] = 0
    good_list[_b-1] = 0
  elif h_list[_a-1] > h_list[_b-1]:
    good_list[_b-1] = 0
  else:
    good_list[_a-1] = 0
print(sum(good_list))

Measured memory_bytes: 20116
#include<iostream>
#include<vector>
#include<string>
#include<math.h>

using namespace std;

int main(void) {
	int a, b;
	string s;

	cin >> a >> s >> b;
	if (s == "+")cout << a + b;
	else cout << a - b;
	
}

class MYCP {
public:
	static void Print_Int(long number) {
		std::cout << number << std::endl;
	}

	static void Print_Ints(long* numbers, long count) {
		std::cout << numbers[0];
		for (int i = 1;i < count;i++) {
			std::cout << " " << numbers[i];
		}

		std::cout << std::endl;
	}

	static std::string* MyReadLineSplit(int n) {
		std::string *str = new std::string[n];
		for (int i = 0;i < n;i++) {
			std::cin >> (str)[i];
		}

		return str;
	}

	static int* ReadInts(long number) {
		int* a = new int[number];
		for (int i = 0;i < number;i++) {
			std::cin >> a[i];
		}

		return a;
	}

	//渡された自然数が素数ならtureを返す
	static bool PrimeCheck_Int(long number) {
		if (number < 2)return false;

		for (int i = 2;i*i <= number;i++) {
			if (number%i == 0)return false;
		}

		return true;
	}
};

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(){
    string S; cin >> S;

    if(S == "SUN"){
        cout << 7 << endl;
    }

    if(S == "MON"){
        cout << 6 << endl;
    }

    if(S == "TUE"){
        cout << 5 << endl;
    }

    if(S == "WED"){
        cout << 4 << endl;
    }

    if(S == "THU"){
        cout << 3 << endl;
    }

    if(S == "FRI"){
        cout << 2 << endl;
    }

    if(S == "SAT"){
        cout << 1 << endl;
    }

}

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

typedef long long ll;
typedef pair<ll,ll> P;

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


int main() {
  string s,t;
  cin>>s>>t;
  int n=s.size();
  vector<ll> v(26,-1);
  vector<ll> r(26,-1);
bool ok=true;
  rep(i,n){
    int s1=s[i]-'a';
    int t1=t[i]-'a';
    if (v[s1]>=0) {
      if (v[s1]!=t1){
        ok=false;
        break;
      }
     }
     if (r[t1]>=0) {
       if (r[t1]!=s1){
         ok=false;
         break;
       }
      }
      v[s1]=t1;
      r[t1]=s1;
}
if (ok==true)cout<<"Yes";
else cout<<"No";
}


Measured memory_bytes: 776
def main():
    while True:
        try:
            n = int(input())
            a = [True] * (n+1)
            a[0] = a[1] = False
            for i in range(2, int(n**0.5)+1):
                if a[i]:
                    for j in range(i**2, n+1, i):
                        a[j] = False
            print(a.count(True))
        except:
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 24140
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  
  int e=0;
  REP(i,n){
    if(i==0){
      continue;
    }else{
      if(s[i]=='E'){
        e++;
      }else{
        continue;
      }
    }
  }
  
  vector<int> l(n);
  int ans;
  REP(i,n){
    if(i==0){
      l[i]=e;
      ans = l[i];
    }else{
      l[i]=l[i-1];
      if(s[i-1]=='W' && s[i]=='W'){
        l[i]++;
      }else if(s[i-1]=='W' && s[i]=='E'){
        continue;
      }else if(s[i-1]=='E' && s[i]=='W'){
        continue;
      }else{
        l[i]--;
      }
      ans = min(ans,l[i]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1796
N, M, X = map(int, input().split())
A= []
for i in range(N):
  temp = list(map(int, input().split()))
  A.append(temp)

uds = [0]*M
cost = 0
ans = -1

for bit in range(2**N):
  for i in range(N):
    if (bit >> i) & 1:
      cost += A[i][0]
      for j in range(M):
        uds[j] += A[i][j+1]
  if min(uds) >= X:
    if ans == -1 or ans > cost:
      ans = cost
  cost = 0
  uds = [0]*M

print(ans)

Measured memory_bytes: 9148
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
const int Maxn = 1e9 + 10;
const int N = 1e5 + 10;
const int INF=(0x7fffffff)/2;
ll a[N], b[N];

int main(){
	ll n, l;
	while(cin >> n >> l){
		for(int i = 0; i < n; i++)
			cin >> a[i];
		int x = 0;
		for(int i = 0; i < n - 1; i++){
			if((a[i] + a[i + 1] >= l)){
				printf("Possible\n");
				for(int j = 0; j < i; j++)
					printf("%d\n", j + 1);
				for(int j = n - 2; j >= i + 1; j--)
					printf("%d\n", j+1);
				printf("%d\n", i + 1);
				return 0;
			}
		}
		printf("Impossible\n");
		return 0;
	}
}

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

using namespace std;

int main() {
    int A = 0;
    int B = 0;
    cin >> A;
    cin >> B;
    int z = A + B ;
    if(z >= 24){
       cout << z -24 << endl;
    }
    else{
     cout << z <<endl;
     
    }
    
                 
}

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

int main()
{
	stack<char> st;

	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='0' || s[i]=='1')
		{
			st.push(s[i]);
		}
		else
		{
			if(!st.empty())
			{
				st.pop();
			}
		}
	}
	string res="";
	while(!st.empty())
	{
		res=st.top()+res;
		st.pop();
	}
	cout<<res<<endl;
	return 0;
	
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll A, B, C, X, Y;
    ll mini = LONG_LONG_MAX;
    cin >> A >> B >> C >> X >> Y;
    for(ll i = 0;i <= 100000;i++) {
        ll temp = 2 * C * i + A * max(0LL, X - i) + B * max(0LL, Y - i);
        mini = min(temp, mini);
    }
    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>

namespace __temp_inbuilt{
	int read(void){
		int res = 0, sign = 1;
		char ch = std::getchar();
		while(!std::isdigit(ch)){
			if(ch == '-')
				sign = -1;
			ch = std::getchar();
		}
		while(std::isdigit(ch))
			res = res * 10 + ch - 48, ch = std::getchar();
		return sign * res;
	}
	
	template<class Tp>
		void write(const Tp &x){
			if(x > 9)
				write(x / 10);
			std::putchar(x % 10 + 48);
	}
}

using __temp_inbuilt::read;

template<class Tp>
	void writeln(const Tp &x){
		if(x < 0)
			std::putchar('-');
		__temp_inbuilt::write(x > 0 ? x : -x);
		std::putchar('\n');
	}

template<class Tp>
	void writesp(const Tp &x){
		if(x < 0)
			std::putchar('-');
		__temp_inbuilt::write(x > 0 ? x : -x);
		std::putchar(' ');
	}

template<class Tp>
	void write(const Tp &x){
		if(x < 0)
			std::putchar('-');
		__temp_inbuilt::write(x > 0 ? x : -x);
	}

typedef long long ll;
typedef unsigned long long ull;
typedef double rl;
typedef long double RL;

const rl PI = 3.1415926535898, E = 2.71828182845904;

namespace contest{
	int k;
	
	int main(){
		k = read();
		int mod = 7 % k, ans = 1;
		if(!mod){
			writeln(ans); return 0;
		}
		while(mod){
			++ans;
			mod = (mod * 10 + 7) % k;
			if(mod == 7 % k || ans >= 3e7){
				writeln(-1);return 0;
			}
		}
		writeln(ans);return 0;
		return 0;
	}
}

int main(){
	contest::main();
	return 0;
}

Measured memory_bytes: 3616
<?php
fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));
array_unshift($a, 0);
$a[] = 0;
// var_dump($a);
// exit;

$ans = 0;
for ($i = 0; $i <= $N; $i++) {
    $ans += abs($a[$i+1] - $a[$i]);
}
// echo $ans;
// exit;

for ($i = 1; $i <= $N; $i++) {
    // echo $i . "\n";
    if ($a[$i+1] >= $a[$i] && $a[$i] >= $a[$i-1]) {
        // echo "A ";
        $tmp = $ans;
    } elseif ($a[$i+1] <= $a[$i] && $a[$i] <= $a[$i-1]) {
        // echo "B ";
        $tmp = $ans;
    } else {
        // echo "C ";
        $x = abs($a[$i+1] - $a[$i]);
        $y = abs($a[$i] - $a[$i-1]);
        $z = abs($a[$i+1] - $a[$i-1]);
        
        $tmp = $ans - $x - $y + $z;
        // echo "{$ans} - {$x} - {$y} + {$z}\n";
    }
    echo $tmp . "\n";
}


Measured memory_bytes: 17140
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i, pi in enumerate(p[:-2]):
  if p[i] < p[i+1] and p[i+1] == p[i+2]: cnt += 1
  elif p[i] < p[i+1] and p[i+1] < p[i+2]: cnt += 1
  elif p[i+2] < p[i+1] and p[i+1] == p[i]: cnt += 1
  elif p[i+2] < p[i+1] and p[i+1] < p[i]: cnt += 1

print(cnt)

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True

def main():


    N = II()
    P = LMIIS()

    count = 0
    for i in range(N):
        if i+1 != P[i]:
            count += 1
    if count != 2 and count !=0:
        print('NO')
    else:
        print('YES')




    pass
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
# AGC 007: A – Shik and Stone
h, w = [int(s) for s in input().split()]
a = [input() for _ in range(h)]

the_number_of_stones = 0

for i in range(h):
    the_number_of_stones += a[i].count('#')

print('Possible' if the_number_of_stones == h + w - 1 else 'Impossible')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  if(S.at(0) == 'S' && S.at(1) == 'S' && S.at(2) == 'S') cout << 0 << endl;
  if(S.at(0) == 'S' && S.at(1) == 'S' && S.at(2) == 'R') cout << 1 << endl;
  if(S.at(0) == 'S' && S.at(1) == 'R' && S.at(2) == 'S') cout << 1 << endl;
  if(S.at(0) == 'S' && S.at(1) == 'R' && S.at(2) == 'R') cout << 2 << endl;
  if(S.at(0) == 'R' && S.at(1) == 'S' && S.at(2) == 'S') cout << 1 << endl;
  if(S.at(0) == 'R' && S.at(1) == 'S' && S.at(2) == 'R') cout << 1 << endl;
  if(S.at(0) == 'R' && S.at(1) == 'R' && S.at(2) == 'S') cout << 2 << endl;
  if(S.at(0) == 'R' && S.at(1) == 'R' && S.at(2) == 'R') cout << 3 << endl;
}

Measured memory_bytes: 3604
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int l; cin >> l;
	double lt = (double)l / 3;

	cout << fixed << setprecision(12) << lt*lt*lt << endl;

	
	return 0;
}

Measured memory_bytes: 256
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int f=0,a,b,ans=-1;
  cin >> a >> b;
  for(int i=1; i<=10000; i+=1.0) {
    if(floor(i*0.1)==b&&floor(i*0.08)==a) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)

int main() {
    int n;
    cin >> n;
    ll dp[n + 1][21];
    fill_n(*dp, (n + 1) * 21, 0);
    int a;
    cin >> a;
    dp[1][a] = 1;
    rep3(i, 1, n - 1) {
        cin >> a;
        rep(j, 21) {
            if (j - a >= 0) dp[i + 1][j - a] += dp[i][j];
            if (j + a > 20) continue;
            dp[i + 1][j + a] += dp[i][j];
        }
    }
    cin >> a;
    out(dp[n - 1][a]);
    // rep(i, n) { rep(j, 21) cout << dp[i][j] << " "; cout << endl; }
}



Measured memory_bytes: 3088
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
using namespace std;

int N, M, i;
long long A;
long long B;
vector<pair<long long, long long>> pairs;

int main() {
	cin >> N >> M;
	for (i = 0; i < N; i++) {
		cin >> A >> B;
		pairs.push_back(make_pair(A, B));
	}
	sort(pairs.begin(), pairs.end());

	long long ans = 0;
	int j = 0;
	while (M > 0) {
		int k = pairs[j].second;
		while (k > 0) {
			ans += pairs[j].first;
			M -= 1;
			k -= 1;
			if (M == 0) break;
		}
		j++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 2420
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
tt=0
for i in range(1,n+1):
  temp=min(b[i-1],a[i-1])
  b[i-1]-=temp
  a[i-1]-=temp
  tt+=temp
  temp=min(b[i-1],a[i])
  b[i-1]-=temp
  a[i]-=temp
  tt+=temp
print(tt)

Measured memory_bytes: 18624
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X, Y = map(str, input().split())
if ord(X) > ord(Y):
	print(">")
elif ord(X) < ord(Y):
	print("<")
else:
	print("=")

Measured memory_bytes: 5584
# -*- coding: utf-8 -*-
import numpy as np

n, k = map(int, input().split())
p = np.array(input().split(), dtype='int')

max_E = 0

e = (p - 1) * 0.5 + 1

first_E = 0
for i in range(k):
    first_E += e[i]

for i in range(n - k + 1):
    if i == 0:
        E = first_E
    else:
        E = E - e[i - 1] + e[i + k - 1]
    
    if E > max_E:
        max_E = E

print(max_E)

    

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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? " " : "");
    outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
    cout << head << (sizeof...(tail) ? "\n" : "");
    outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
    cout << head;
    outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> w(20), k(20);
    rep(i, 10) input(w[i]);
    rep(i, 10) input(k[i]);
    sort(all(w), greater<>());
    sort(all(k), greater<>());
    outs(w[0] + w[1] + w[2], k[0] + k[1] + k[2]);
    return 0;
}



Measured memory_bytes: 3124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
 
public class Main
{
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
 
    public static void main(String[] args)
    {
        FastReader in=new FastReader();
        int n = in.nextInt();
        int k = in.nextInt();
        int te=(int)(Math.log(k)/Math.log(2));
        long ans=1,te1=1,te2=1;
        if(te<n)
        {
        	for(int i=0; i<te; i++)
        	{
        		te1*=2;
        	}
        	te2=te1*2;
        	for(int i=0; i<n-te; i++)
        	{
        		te1+=k;
        		te2+=k;
        	}
        	te2-=k;
        	ans=Math.min(te1, te2);
        	System.out.println(ans);
        }
        else
        	System.out.println((long)Math.pow(2, n));
    }
}

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

int main() {
    int x, y;
    cin >> x >> y;
    while (true) {
        if (x == 0 && y == 0) break;
        if (x > y) {
            cout << y << " " << x << endl;
        } else {
            cout << x << " " << y << endl;
        }
        cin >> x >> y;
    }
}


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

int main() {
  int N, M; cin >> N >> M;
  int XMAX, YMIN; cin >> XMAX >> YMIN;
  for (int i = 0; i < N; ++i) {
    int x; cin >> x;
    XMAX = max(XMAX, x);
  }
  for (int i = 0; i < M; ++i) {
    int y; cin >> y;
    YMIN = min(YMIN, y);
  }
  cout << (XMAX < YMIN ? "No War" : "War") << endl;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		Map<Integer, Integer> a = new HashMap<Integer, Integer>();
		BigDecimal sum = new BigDecimal(0);

		int n = Integer.parseInt(sc.next());
		for (int i = 0; i < n; i++) {
			int m = Integer.parseInt(sc.next());

			if (a.containsKey(m))
				a.replace(m, a.get(m) + 1);
			else
				a.put(m, 1);

			sum = sum.add(new BigDecimal(m));
		}

		int b, c, b_num, c_num;
		int q = Integer.parseInt(sc.next());
		for (int i = 0; i < q; i++) {
			b = Integer.parseInt(sc.next());
			c = Integer.parseInt(sc.next());

			b_num = 0;
			if (a.containsKey(b)) {
				b_num = a.remove(b);
				BigDecimal diff = new BigDecimal((c - b) * b_num);

				c_num = b_num;
				if (a.containsKey(c)) {
					c_num += a.get(c);
					a.replace(c, c_num);
				} else {
					a.put(c, c_num);
				}

				sum = sum.add(diff);
			}
			System.out.println(sum);
		}
	}

}


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

int main(){
  int64_t N; cin >> N;
  int64_t a, b, c;
  a = N/3;
  b = N/5;
  c = N/15;
  int64_t k = a*(a+1)/2*3 + b*(b+1)/2*5 - c*(c+1)/2*15;
  int64_t ans = N*(N+1)/2 - k;
  cout << ans << endl;
}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

	int t[100010];
	int sum = 0;
	for(int i = 0;i < n;i++){
		cin >> t[i];
		sum += t[i];
	}

	int m;
	cin >> m;
	for(int i = 0;i < m;i++){
		int p, x;
		cin >> p >> x;
		cout << sum - (t[p-1]-x) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <numeric>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll HIGHINF = (ll)1e18;
const ll LOWINF = (ll)1e15;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
    int N; cin >> N;
    V<int> W(N);
    for(int i = 0; i < N; ++i){
        cin >> W[i];
    }
    int ans = 100000000;
    for(int i = 0; i < N; ++i){
        int S1 = 0, S2 = 0;
        for(int j = 0; j < N; ++j){
            if(j <= i) S1 += W[j];
            else S2 += W[j];
        }
        chmin(ans,abs(S1-S2));
    }
    cout << ans << endl;
    

    return 0;
}



Measured memory_bytes: 256
day = input()
aft = 0
if day == "SUN":
    print(7)
elif day == "MON":
    print(6)
elif day == "TUE":
    print(5)
elif day == "WED":
    print(4)
elif day == "THU":
    print(3)
elif day == "FRI":
    print(2)
elif day == "SAT":
    print(1)

Measured memory_bytes: 3060
N = int(input())
W = [input() for _ in range(N)]
word_dict = dict()

last_word = W[0]
word_dict[W[0]] = 1
for word in W[1:]:
    if last_word[-1] == word[0] and (not (word in word_dict)):
        last_word = word
        word_dict[word] = 1
    else:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 3060
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;



int32_t N,M;


#include <vector>

class union_find
{
private:
	std::vector<int>parent;
	std::vector<int>rank;
public:
	std::vector<int64_t>sum;
	std::vector<int64_t>edge_num;
	std::vector<int64_t>edge_oknum;

	union_find(int siz)
	{
		parent.resize(siz);
		rank.resize(siz);
		sum.resize(siz);
		edge_num.resize(siz);
		edge_oknum.resize(siz);
		for (int i = 0; i < siz; ++i)
		{
			parent[i] = i;
			rank[i] = 0;
		}
	}
	bool unite(int x, int y)
	{
		int xr = find(x);
		int yr = find(y);
		if (xr == yr) { return false; }
		if (rank[xr] > rank[yr])
		{
		}
		else if (rank[xr] > rank[yr])
		{
			std::swap(xr, yr);
		}
		else if (xr != yr)
		{
			++rank[xr];
		}

		parent[yr] = xr;
		sum[xr] += sum[yr];
		edge_num[xr] += edge_num[yr];
		edge_oknum[xr] += edge_oknum[yr];
		return true;
	}
	int find(int x)
	{
		if (parent[x] == x)
		{
			return x;
		}
		else
		{
			return parent[x] = find(parent[x]);
		}
	}
	bool check(int x, int y)
	{
		return find(x) == find(y);
	}
};



//struct edge {
//	int32_t to;
//	int64_t cost;
//	edge() {}
//	edge(int32_t to_, int64_t cost_)
//		:to(to_), cost(cost_) {}
//};
//std::vector<edge> graph[100000];

std::pair<int64_t, std::pair<int, int>> edges[100000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> M;

	union_find uf(N);
	for (size_t i = 0; i < N; i++)
	{
		in >> uf.sum[i];
	}

	for (size_t i = 0; i < M; i++)
	{
		int64_t a, b, c;
		in >> a >> b >> c; --a; --b;
		edges[i].first = c;
		edges[i].second.first = a;
		edges[i].second.second = b;
	}

	std::sort(edges, edges + M);

	int64_t oknum = 0;
	for (size_t EEE = 0; EEE < M; EEE++)
	{
		auto& e = edges[EEE];

		int a = uf.find(e.second.first);
		int b = uf.find(e.second.second);
		uf.unite(a, b);
		a = uf.find(e.second.first);
		uf.edge_num[a] += 1;
		if (uf.sum[a] >= e.first)
		{
			oknum -= uf.edge_oknum[a];
			uf.edge_oknum[a] = uf.edge_num[a];
			oknum += uf.edge_oknum[a];
		}
	}
	out << M-oknum << endl;

	return 0;
}
#endif


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

int main(){
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a.at(i);
  
  int alice = 0, bob = 0;
  for (;;) {
    int max = 0, index = 0;
    for (int i = 0; i < a.size(); i++) {
      if (a.at(i) > max) {
        max = a.at(i);
        index = i;
      }
    }
    alice += max;
    a.at(index) = a.at(a.size()-1);
    a.pop_back();
    if (a.size() == 0)
      break;
    
    max = 0;
    index = 0;
    for (int i = 0; i < a.size(); i++) {
      if (a.at(i) > max) {
        max = a.at(i);
        index = i;
      }
    }
    bob += max;
    a.at(index) = a.at(a.size()-1);
    a.pop_back();
    if (a.size() == 0)
      break;
  }
  cout << (alice - bob) << endl;
    
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using ll = long long;
using namespace std;
static const int INF = (1 << 29);

int main() {
    int n, m;
    int C[21];
    int T[50001];

    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        cin >> C[i];
    }

    for (int j = 0; j <= 50000; ++j) T[j] = INF;
    T[0] = 0;
    for (int i = 1; i <= m; ++i) {
        for (int j = 0; j + C[i] <= n; ++j) {
            T[j + C[i]] = min(T[j+C[i]], T[j]+1);
        }
    }

    cout << T[n] << "\n";
    return 0;
}



Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define double ld
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ifstream in("input.txt");ofstream out("output.txt");
const int inf=1e18;
const int mod=1e9+7;
int n;
vector<double> vec;
vector<vector<double> > dp;

void init()
{
    cin>>n;
    vec.resize(n);
    for(int i=0;i<n;i++)
        cin>>vec[i];
    dp.resize(n+1,vector<double>(n+1));
    dp[0][0]=1.;
    for(int lev=0;lev<n;lev++)
    {
        for(int j=0;j<=lev;j++)
        {
            int oth=lev-j;
            dp[j+1][oth]+=dp[j][oth]*vec[lev];
            dp[j][oth+1]+=dp[j][oth]*(1.-vec[lev]);
        }
    }
    double ans=0;
    for(int i=0;i<=n;i++)
    {
        int heads=i;
        int oth=n-heads;
        if(heads>oth)
            ans+=dp[heads][oth];
    }
    cout<<fixed<<setprecision(14)<<ans;
}

signed main()
{
    init();
    return 0;
}




Measured memory_bytes: 141056
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

class Point{
	int x, y, id;
	public Point(int X, int Y, int i) {
		x = X; y = Y; id = i;
	}
}
class edge implements Comparable <edge>{
	int from; int to; int cost;
	public edge(int x,int y,int c){
		this.from=x; this.to=y; this.cost=c;
	}
	public int compareTo(edge o) {
		return this.cost-o.cost;
	}
}
class UnionFind{
	int[] par;
	UnionFind(int n){
		par=new int[n];
		for(int i=0;i<n;i++)par[i]=i;
	}
	public int find(int x){
		if(par[x]==x)return x;
		return par[x]=find(par[x]);
	}
	public Boolean same(int x,int y){
		return find(x)==find(y);
	}
	public void unite(int x,int y){
		if(find(x)==find(y))return;
		par[find(x)]=find(y);
	}
}
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Point[] p = new Point[N];
		for(int i = 0; i < N; i++) p[i] = new Point(sc.nextInt(), sc.nextInt(), i);
		edge[] edges = new edge[2 * N - 2];
		/* sorting in x-axis */
		Arrays.sort(p, new Comparator<Point>() {
			public int compare(Point o1, Point o2) {
				return o1.x - o2.x;
			}
		});
		/* draw edge */
		for(int i = 0; i < N - 1; i++) {
			edges[i] = new edge(p[i].id, p[i + 1].id, Math.min(Math.abs(p[i].x - p[i + 1].x), Math.abs(p[i].y - p[i + 1].y)));
		}
		/* sorting in y-axis */
		Arrays.sort(p, new Comparator<Point>() {
			public int compare(Point o1, Point o2) {
				return o1.y - o2.y;
			}
		});
		/* draw edge */
		for(int j = 0; j < N - 1; j++){
			edges[j + N - 1] = new edge(p[j].id, p[j + 1].id, Math.min(Math.abs(p[j].x - p[j + 1].x), Math.abs(p[j].y - p[j + 1].y)));
		}
		Arrays.sort(edges);
		UnionFind uf = new UnionFind(N);
		long sum = 0;
		for(int i = 0; i < edges.length; i++) {
			if(!uf.same(edges[i].from, edges[i].to)) {
				sum += (long)edges[i].cost;
				uf.unite(edges[i].from, edges[i].to);
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 98900
"use strict";
    
const main = arg => {
    const N = arg.split("\n")[0];
    const K = parseInt(arg.split("\n")[1]);
    let number = 1;
    
    for(let i=0; i<N; i++) {
        if(number * 2 < number + K) {
            number  = number * 2;
        } else {
            number += K;

        }
    }
    
    console.log(number);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const int INF = +100100100;
typedef pair<int,int> P;
const ll MO = 1000000007;

struct Mon{
    int h,d;
};

int main(){
    Mon x,y;
    int a,b,c,d;
    cin>>a >> b >> c >> d;
    x.h=a;x.d=b;y.h=c;y.d=d;
    int i = 0;
    while(x.h>0 && y.h >0){
        if(i%2==1){
            x.h-=y.d;
        }else{
            y.h-=x.d;
        }
        ++i;
    }
    if(i%2==0)cout<<"No"<<endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3596
PROGRAM piyo
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      integer(p) :: i,ans, l
      character(2*10**5) :: s,t
      
      read*,s
      read*,t
      
      l = len_trim( s )
      
      ans = 0
      do i = 1,l
        if( s(i:i)/=t(i:i) )then
          ans = ans + 1
        end if
      end do
      
      print'(i0)',ans
      
      
      stop
      !debugg
      
      
      
      END PROGRAM

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

using namespace std;

int main() {
    string a;
    cin>>a;
    set <char> s;
    for (int i=0;i<a.length();i++)
        s.insert(a[i]);
    if (s.size()==2)
        cout<<"Yes"<<endl;

    else cout<<"No"<<endl;
    
    
    
}

Measured memory_bytes: 256
n, m = map(int, input().split())
A = list(map(int, input().split()))

s = sum(A) / (4 * m)

c = 0
for i in range(n):
    if (A[i] >= s):
        c = c + 1

if (c >= m):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE
ll find(ll n1,ll cur)
{
    if(n1==1)
    return 1;
    return 1+2*find(n1/2,2*cur);
    
}
signed main()
{   


      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
        
         ll n;
         cin>>n;
         cout<<find(n,1)<<endl;
         



      }
      
}






Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

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

llint n, m, L, Q;
llint G[305][305], dist[305][305];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m >> L;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			G[i][j] = inf;
			if(i == j) G[i][j] = 0;
		}
	}
	llint u, v, w;
	for(int i = 1; i <= m; i++){
		cin >> u >> v >> w;
		G[u][v] = G[v][u] = w;
	}
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			dist[i][j] = G[i][j];
		}
	}
	for(int k = 1; k <= n; k++){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
			}
		}
	}
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(dist[i][j] <= L) dist[i][j] = 1;
			else dist[i][j] = inf;
			if(i == j) dist[i][j] = 0;
		}
	}
	for(int k = 1; k <= n; k++){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
			}
		}
	}
	
	cin >> Q;
	llint s, t;
	for(int i = 1; i <= Q; i++){
		cin >> s >> t;
		if(dist[s][t] > inf/2) cout << -1 << endl;
		else cout << dist[s][t]-1 << endl;
	}
	
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1ll << 62)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){
  
  int n,t;
  cin >> n >> t;
  ll res = INF;
  REP(i,n){
    int c,tt;cin >> c >> tt;
    if(tt <= t)res = min(res,1ll*c);
  }
  res == INF ? cout << "TLE" << endl : cout << res << endl;
  


  

  return 0;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;


int main()
{
  int n[13]={0};

  for (int i=0; i<13; i++){
    if (i == 2) n[i] = 1;
    else if (i == 4 || i == 6 || i == 9 | i == 11) n[i] = 2;
    else n[i] = 3;
  }

  int x, y;

  cin >> x >> y;
  if (n[x] == n[y]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
str=input()
p_str=str.split(" ")
p=[int(tmp) for tmp in p_str]
count=0

for i in range (1 , n-1):
    if   p[i-1] < p[i] < p[i+1]:
        count+=1
    elif p[i-1] > p[i] > p[i+1]:
        count+=1

print(count)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){

int candid[50] = {0};
int n, p, i, mark;

while(1){
scanf("%d %d",&n,&p);
if(n == 0 && p == 0) break;

mark = p;

for(i =0;i <= 1000000;i++){
 if(p!=0){
  candid[i%n]++;
  p--;
}

else{
 if(candid[i%n] != 0){
  p=candid[i%n];
candid[i%n] = 0;
}
}

if(candid[i%n] == mark) break;
}

printf("%d\n",i%n);
candid[i%n] = 0;
}
return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;int r=0;cin>>s;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='0')r++;
  }
  int b=s.size()-r;
  cout<<2*min(r,b)<<endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long num = 100;
        int count = 0;
        while(num < x){
            count ++;
            double t = num * 1.01;
            num = (long)t;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 27080
import sys

argv = input().split()

X = int(argv[0])
Y = int(argv[1])
success = 0

for i in range(X+1):
  if ((2 * i) + (4 * (X - i))) == Y:
    success = 1

if success == 0:
  print ("No")
else:
  print ("Yes")

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll n,m;
char a[55][55],b[55][55];
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            cin>>b[i][j];
        }
    }
    for(int i=0;i<n-m+1;i++){
        for(int j=0;j<n-m+1;j++){
            bool x=true;
            for(int k=0;k<m;k++){
                for(int l=0;l<m;l++){
                    if(a[i+k][j+l]!=b[k][l]){
                        x=false;
                    }
                }
            }
            if(x){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    
}


Measured memory_bytes: 3584
import java.util.*;
public class Main{
    public static void main(String[] args) {
        int test;
        Scanner sc=new Scanner(System.in);
        //test=sc.nextInt();
     //   while(test-->0){
            int k;
            int a,b;
            k= sc.nextInt();
            a=sc.nextInt();
            b=sc.nextInt();
            if(a%k==0|| b%k==0){
                System.out.println("OK");
            }
            else {
                if((a/k)<(b/k)){
                    System.out.println("OK");
                }
                else{
                    System.out.println("NG");
                }
            }

       // }
    }
}

Measured memory_bytes: 35832
#include <iostream>

using namespace std;

long long how(long long h){
  if (h == 1) return 1;
  return 1 + 2 * how(h / 2);
}

int main() {
  ios_base::sync_with_stdio(false);
  long long h;
  cin >> h;
  cout << how(h) << endl;
}

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

int main(){
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  ll ans = 0;
  ans = min(k,a);
  if(k-a > 0){
    ans += min(k-a,b) * 0;
  }
  if(k-a-b > 0){
    ans += min(k-a-b,c) * -1;
  }
  cout << ans;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+7,mod=1e9+7;
int n,ans,c[N],f[N],lst[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&c[i]);
		if(c[i]==c[i-1])i--,n--;
	}
	f[0]=1;
	for(int i=1;i<=n;i++)
	{
		f[i]=f[i-1];
		if(lst[c[i]])f[i]=(f[i]+f[lst[c[i]]])%mod;
		lst[c[i]]=i;
	}
	printf("%d\n",f[n]);
}

Measured memory_bytes: 2560