akhauriyash/Code-Regression huggingface dataset:
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str = Console.ReadLine().Split(' ');
      int a=int.Parse(str[0]);
      int b=int.Parse(str[1]);                      
       int c=int.Parse(str[2]);
   	int d=int.Parse(str[3]);
      if((Math.Abs(a-c))<=d){
        Console.WriteLine("Yes");
      }
       else if((Math.Abs(a-b))<=d &&(Math.Abs(b-c))<=d){
         Console.WriteLine("Yes");
      }
      else
      {
         Console.WriteLine("No");
      }
    }
    
  }

}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    n=n%1000;
    if(n==0)
    {
        cout<<0;
    }
    else
    {
        n=1000-n;
        cout<<n;
    }
    return 0;
}

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


long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main(){

ll n;
cin>>n;
ll a[n];
fori(n) cin>>a[i];
ll dp[n];
dp[0]=0;
dp[1]=abs(a[1]-a[0]);
fori(n-2){
dp[i+2]=min(dp[i]+abs(a[i]-a[i+2]),dp[i+1]+abs(a[i+1]-a[i+2]));
}
cout<<dp[n-1];

return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n;
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	string ans[10] = {"pon", "pon", "hon", "bon", "hon", "hon", "pon", "hon", "pon", "hon"};
	cout << ans[n%10] << endl;
	return 0;
}


Measured memory_bytes: 3652
n = int(input())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
c = [0] + list(map(int, input().split()))
res, pre = b[a[1]], a[1]
for i in range(2, n + 1):
	res += b[a[i]]
	if a[i] == pre + 1:
		res += c[pre]
	pre = a[i]
print(res)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		for (int i = 0; i < 4; i++) {
			int a = scanner.nextInt() - 1;
			int b = scanner.nextInt();
			System.out.println(ticket[a] * b);
		}
	}

	int[] ticket = { 6000, 4000, 3000, 2000, };
}

Measured memory_bytes: 17312
fun main(args: Array<String>) {
	val s = readLine() ?: return
	var count1 = 0
	var count2 = 0
	for (i in s.indices) {
		val cor = if (i % 2 == 0) '0' else '1'
		if (s[i] == cor) count1++
		else count2++
	}
	if (count1 <= count2) println(count1)
	else println(count2)
}

Measured memory_bytes: 34132
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define F(i, j, k) for(int i = j; i <= k; ++i)
#define pp pair<int, int>
#define mp make_pair
const int maxn = 2e5+5;
int n, m, x, y, z;
int read() {
    char ch = getchar();
    int x = 0,f = 1;
    while(!isdigit(ch)) {
	if(ch == '-') f = -1;
	ch = getchar();
    }
    while(isdigit(ch)) {
	x = x * 10 + ch - '0';
	ch = getchar();
    }
    return x * f;
}
int flag[maxn];
int main() {
#ifdef orz
    //freopen("input", "r", stdin);
#endif
    n = read();
    while(n--) {
	x = read();
	y = read();
	flag[x]++;
	flag[y+1]--;
    }
    int cnt = 0, fl = 0;
    for(int i = 1; i <= 100000; i++) {
	fl += flag[i];
	if(fl) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}


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

int main(){
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  int w,x,y,z;
  
  x=d+c-a;
  w=c-(d-b);
  
  y=a-(d-b);
  z=b+c-a;
  
  cout <<w << ' ' << x << ' ' << y <<' ' << z << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;

  if(v<=w)cout << "NO" <<endl;
  else if(abs(a-b)/(v-w)<t)cout << "YES" <<endl;
  else if(abs(a-b)==t*(v-w))cout << "YES" << endl;
  else cout << "NO" << endl;

}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

int main(){
    int a,b,h;
    cin>>a>>b>>h;
    int ans;
    ans = (a+b)*h/2;
    cout<<ans<<endl;
    }

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

#ifndef ONLINE_JUDGE 
const bool DEBUG = true;
#else
const bool DEBUG = false;
#endif

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

#define F first
#define S second
#define all(x) begin(x), end(x)

template <class T>
void read_vector(vector<T>& arr) {
	const int size = arr.size();
	for (int i = 0; i < size; ++i) cin >> arr[i];
}

//template <class T>
//vector<T> create_vector(int n) {
//	vector<T> v(n);
//	for (int i = 0; i < size; ++i) cin >> v[i];
//	return v;
//}





void exec()
{
	int n, w;
	cin >> n >> w;

	vector<pair<int, int>> pn(n);
	for (int i = 0; i < n; ++i) {
		int N, W;
		cin >> W >> N;
		pn[i] = make_pair(W, N);
	}

	vector<vector<ll>> dp(n+1, vector<ll>(w + 1, 0));
	
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= w; ++j) {
			if (j >= pn[i - 1].first)
				dp[i][j] = max(dp[i - 1][j], pn[i - 1].second + dp[i - 1][j - pn[i - 1].first]);
			else
				dp[i][j] = dp[i - 1][j];
		}
	}

	cout << dp[n][w] << endl;
}

















int main()
{
	exec();

	return 0;
}

Measured memory_bytes: 80256
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    int a; scan(a);
    string s = readln.chomp;
    writeln(a < 3200 ? "red" : s);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn = 105;

int a[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  for(int i=0;i<5;i++)cin>>a[i];
  int mi = -1;
  for(int i=0;i<5;i++){
    if(a[i]%10!=0){
      if(mi==-1||mi>a[i]%10)mi=a[i]%10;
    }
  }
  int ret = 0;
  for(int i=0;i<5;i++){
    if(a[i]%10==0)ret+=a[i];
    else ret+=a[i]+(10-a[i]%10);
  }
  if(mi!=-1)ret-=(10-mi);
  cout<<ret<<endl;
  return 0;
}

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

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

int main() {
    vector<int> sum(1000);
    int a, b;

    cin >> a >> b;
    sum.at(0) = 0;

    for (int i = 1; i < 1000; i++) {
        sum.at(i) = sum.at(i - 1) + i;
    }

    int i;
    for (i = 1; i < 1000; i++) {
        if ((b - a) == (sum.at(i) - sum.at(i - 1)))
            break;
    }

    cout << sum.at(i - 1) - a << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int h = in.nextInt();
		int m = in.nextInt();
		double h_ang = (h*30) + (m*0.5);
		double m_ang = m*6;
		double tmp = 0;
		if(h>m){
			tmp = h_ang - m_ang;
		}else{
			tmp = m_ang - h_ang;
		}
		if(tmp>180){
			tmp-=360;
		}
		double cos = Math.cos(Math.toRadians(tmp));
		double result = (a*a) + (b*b) - (2*a*b*cos);
		System.out.println(Math.sqrt(result));
	}
}


Measured memory_bytes: 36040
import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n = int(input())
h = readints()
h.append(-1)

# def func(n, h):
#    if n == 0:
#        return 0
#    if n == 1:
#        return abs(h[1]-h[0])
#    return min(abs(h[n]-h[n-1])+func(n-1, h), abs(h[n]-h[n-2])+func(n-2, h))

dp = [10**9]*(2*n)
dp[0] = 0
for i in range(0, n-1):
    dp[i+1] = min(abs(h[i+1]-h[i])+dp[i], dp[i+1])
    dp[i+2] = min(abs(h[i+2]-h[i])+dp[i], dp[i+2])


print(dp[n-1])


Measured memory_bytes: 14744
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int n;
int a, b;
int data[100010];
int vis[100010];
struct node
{
	int id, a, b;
//	bool operator <(const node& x)
//	{
//		return (a - b) == (x.a - x.b) ? a > x.a : (a - b) < (x.a - x.b); 
//	}
} seg[100010], tag[100010];
//int vis[100010];
bool cmp1(node x, node y)
{
	return x.a + x.b > y.a + y.b;
}
bool cmp2(node x, node y)
{
	return (x.b - y.a) == (y.b - x.a) ? x.b > y.b : (x.b - y.a) < (y.b - x.a);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a >> b;
		seg[i] = tag[i] = (node){i, a, b};
	}
	sort(seg + 1, seg + n + 1, cmp1);
	sort(tag + 1, tag + n + 1, cmp2);
	int l1 = 1, l2 = 1;
	long long sum1 = 0, sum2 = 0;
	for (int i = 1;  i <= n; ++i)
	{
		if (i & 1)
		{
			sum1 += seg[i].a;
		}
		else
		{
			sum2 += seg[i].b;
		}
	}
	cout << sum1 - sum2;
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  vector<int64_t> vec(3);
  rep(i,3) cin >> vec.at(i);
  sort(all(vec));
  int64_t ans = INFL;
  rep(i,3){
    int64_t a=vec[i]/2,b=vec[i]-a;
    a*=vec[(i+1)%3]*vec[(i+2)%3];
    b*=vec[(i+1)%3]*vec[(i+2)%3];
    ans = min(ans,abs(a-b));
  }

  cout << ans <<endl;

}


Measured memory_bytes: 256
# 2020/01/26
# AtCoder Beginner Contest 153 - D

# Input
h = int(input())

# Calc
wk_h = h
div_cnt = 0
while(wk_h >= 1):
    div_cnt = div_cnt + 1
    wk_h = wk_h // 2

at_cnt = 0
for i in range(div_cnt):
    at_cnt = at_cnt + 2 ** i
    
# Output
print(at_cnt)


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

int main(int argc, char const* argv[]) {
	int H, W;
	scanf("%d %d", &H, &W);
	string C[100];
	for (int i = 0; i < H; i++) {
		cin >> C[i];
	}
	for (int i = 0; i < H; i++) {
		cout << C[i] << "\n";
		cout << C[i] << "\n";
	}

	return 0;
}


Measured memory_bytes: 3672
abc = list(map(int, input().split()))

abc.sort()

count = 0

if ((abc[2]-abc[1]) + (abc[2]-abc[0]))%2 == 0:
    count += abc[2] - abc[1]
    count += ((abc[2] - (abc[2] - abc[1])) - abc[0])/2
else:
    count += abc[2] - abc[1]
    count += (((abc[2]+1) - (abc[2] - abc[1])) - abc[0])/2
    count += 1

print(int(count))

Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int hash[3];
	if(s[0]=='S')
	hash[0] = 0;
	else
	hash[0] = 1;
	for(int i=1;i<3;i++)
	{
		if(s[i]=='R')
		hash[i] = hash[i-1] + 1;
		else
		hash[i] = 0;
	}
	cout<<max(hash[0],max(hash[1],hash[2]));
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;

int main(){

  int n,ten=0,rui=0,j,i;
  char str[2000];

  scanf("%d",&n);

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

      scanf("%s",str);

      if(strcmp(str,"HIT")==0){
	rui++;
      }
      else if(strcmp(str,"HOMERUN")==0){
	ten+=1+rui;
	rui=0;
      }
      else {
	j++;
      }
      if(rui==4){
	ten++;
	rui=3;
      }
    }
    printf("%d\n",ten);
    ten=0;
    rui=0;
  }

  return 0;
}

Measured memory_bytes: 1188
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
pair < int , int > a[1000 * 100 + 5];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, ans = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i].f;
		a[i].s = i;
	}
	sort(a , a + n);
	for(int i = 0; i < n; i++)
		if(a[i].s % 2 != i % 2)
			ans++;
	cout << ans / 2 << endl;
	return 0;
}


Measured memory_bytes: 1792
class Rational
  def my_to_f(digit = -1)
    n = numerator()
    d = denominator()
    res = ""
    m = digit != -1 ? digit : 1000000
    m.times{|i|
      res += (n / d).to_s
      n = n % d * 10
      break if digit == -1 && n == 0 && i >= 1
      res += "." if i == 0
    }
    res
  end
end

gets.to_i.times{
  s = gets.strip
  bit = []
  s.each_char{|c|
    x = c.to_i(16)
    4.times{|i|
      bit.push((x >> (3-i) & 1) == 1 ? 1 : 0)
    }
  }
  res = Rational(0,1)
  t = Rational(1,1)
  24.downto(1){|i|
    res += t if bit[i] == 1
    t *= 2
  }
  t = Rational(1,2)
  25.upto(31){|i|
    res += t if bit[i] == 1
    t /= 2
  }
  print bit[0] == 1 ? "-" : ""
  puts res.my_to_f
}

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
using P = pair<long double, long double>;
long double dist(P a, P b) {
  return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
}
int main() {
  int n;
  cin >> n;
  vector<P> point(n);
  P O;
  O.first = 0;
  O.second = 0;
  for(int i=0;i<n;i++) cin >> point[i].first >> point[i].second;
  if(n == 2) {
    cout << setprecision(20) << sqrtl(dist(point[0], point[1])) / 2 << endl;
    return 0;
  }
  long double from = 1e-5;
  long double to = 2000;
  for(int i=0;i<50;i++) {
    long double r = (from + to) / 2;
    bool yes = false;
    for(int i=0;i<n;i++) {
      for(int j=i+1;j<n;j++) {
        P A = point[i];
        P B = point[j];
        if(r + r < sqrtl(dist(A, B))) continue;
        P MID;
        MID.first = (A.first + B.first) / 2;
        MID.second = (A.second + B.second) / 2;
        long double h = sqrtl(r * r - dist(A, MID));
        P normalVector;
        normalVector.first = A.second - B.second;
        normalVector.second = B.first - A.first;
        long double l = sqrtl(dist(normalVector, O));
        P L, R;
        L.first = MID.first + normalVector.first / l * h;
        L.second + MID.second + normalVector.second / l * h;
        R.first = MID.first - normalVector.first / l * h;
        R.second = MID.second - normalVector.second / l * h;
        bool Lincluded = true;
        bool Rincluded = true;
        for(int k=0;k<n;k++) {
          if(k == i || k == j) continue;
          if(sqrtl(dist(point[k], L)) > r) Lincluded = false;
          if(sqrtl(dist(point[k], R)) > r) Rincluded = false;
        }
        if(Lincluded || Rincluded) {
          yes = true;
          break;
        }
      }
      if(yes) break;
    }
    if(yes) to = r;
    else from = r;
  }
  cout << setprecision(20) << (to + from) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define pb push_back
#define pp(a, b) pair <a, b>
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define itr iterator
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
 
 
using namespace __gnu_pbds;
using namespace std;
 
template <class T> T printr(T p){ cout << p << '\n'; return 0; }
template <class T> T printe(T p){ cout << p << '\n'; exit(0); }
template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
 
 
//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set;  
 
#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif
 
ll power(ll x, ll y, ll p){ 
   ll res = 1;
   x = x % p;  
   while (y > 0) {
      if (y & 1) 
         res = (res * x) % p; 
      y = y >> 1;
      x = (x * x) % p; 
   }
   return res;
}
 
const ll INF = (ll)(8e18);
const ll MOD = (ll)(1e9 + 7);
const ll HMOD = (ll)4222234727;
const ll hashprime = (ll)31;
 
const int maxn = 200010;


int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ll h,a; cin >> h >> a;
    cout << (h + a - 1LL) / a << '\n';
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


int main(){

    string S,T;
    cin >> S >> T;

    cout << T+S;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define INF 1100000000
#define MP make_pair
#define FI first
#define SE second
#define PB push_back

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll dist[110][110];
int main()
{
  REP(i, 110) REP(j, 110) dist[i][j] = (i == j ? 0 : INF);
  int N, M;
  cin >> N >> M;
  vector<pair<P, ll>> edge;
  REP(i, M) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    edge.PB(MP(MP(a, b), c));
    dist[a][b] = c;
    dist[b][a] = c;
  }
  REP(k, N) {
    REP(i, N) {
      REP(j, N) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = 0;
  for (auto e : edge) {
    ll a = e.FI.FI;
    ll b = e.FI.SE;
    ll c = e.SE;
    if (dist[a][b] < c) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 1000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.14159265358979323
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"

ll dp[2005];

int main() 
{
    FAST;
    ll n,x,y;
    cin>>n>>x>>y;
    for(ll i=1;i<=n;i++)
        for(ll j=i+1;j<=n;j++)
        {
            ll a=min(j-i,abs(j-y)+abs(i-x)+1ll);
            dp[a]++;
        }
    for(int i=1;i<n;i++)
        cout<<dp[i]<<'\n';
    subt;   
    return 0;
}

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

#define ll long long int 
ll mod=1e9+7;

// vector<int> g[200005];
// int vis[200005];
// queue<int> q;
// int level[200005];

// void dfs(int i)
// {
//     vis[i] = 1;
//     for(int j=0;j<g[i].size();j++)
//     {
//         int child = g[i][j];
//         if(vis[child] == 0)
//         {
//             dfs(child);
//         }
//     }
// }

// void bfs(int i)
// {
//     vis[i] = 1;
//     while(!q.empty())
//     {
//         int top = q.front();
//         int len_adj = g[top].size();
//         int j;
//         for(j=0;j<len_adj;j++)
//         {
//             int v = g[top][j];
//             if(vis[v]==0)
//             {
//                 vis[v]=1;
//                 q.push(v);
//                 level[v] = level[top] + 1;
//             }
//         }   
//         q.pop();
//     }
// }

ll modular_exponentiation(ll base, ll power)
{
    ll ans = 1;
    base = base % mod;
    while (power > 0)
    {
        if (power & 1)
        {
            ans = (ans * base) % mod;
        }

        power /= 2;
        base = (base * base) % mod;
    }
    return ans;
}

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    int t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j;
        // cin >> n;
        string s;
        // ll arr[n];
        cin >> s;
        int flag = 0;

        for(i=0;i<s.size();i++)
        {
            if(s[i] == '7')
            {
                flag = 1;
                cout << "Yes\n";
                break;
            }
            else
            {
                continue;
            }
            
        }

        if(flag == 0)
        {
            cout << "No\n";
        }
    }

    
    
}

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

int main(){
  string s, t;
  cin >> s >> t;
  int n1 = s.size(), n2 = t.size();
  int ans = 100000;
  for(int i=0; i<=n1-n2; ++i){
    int cnt = 0;
    for(int j=0; j<n2; ++j){
      if(s[i+j] != t[j]) ++cnt;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

n = int(input())

cnt = 0

for i in range(n):
    i +=1
    for j in range(n):
        j +=1
        for k in range(n):
            k +=1

            cnt += gcd(i,j,k)

print(cnt)


Measured memory_bytes: 69668
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>

using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;

int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll m1,d1,m2,d2;
	cin >> m1 >> d1 >> m2 >> d2;

	ll arr[]= {31,28,31,30,31,30,31,31,30,31,30,31};
	if(arr[m1-1] == d1) cout << 1 << endl;else cout << 0 << endl;

		
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n; cin >> n;
    vector<int> A(n + 2);
    A[0] = A[n + 1] = 0;
    int sum = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> A[i];
    }
    vector<int> diff;
    for(int i = 0; i <= n; i++)
    {
        sum += abs(A[i] - A[i + 1]);
        diff.push_back(abs(A[i] - A[i + 1]));
    }
    for(int i = 1; i <= n; i++)
    {
        int ans = sum;
        int a = A[i - 1];
        int b = A[i + 1];
        int d = abs(a - b);
        ans -= diff[i - 1] + diff[i] - d;
        cout << ans << endl;
    }
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

void max_heapify(vector<int> &a, int i) {
    int h = a.size() - 1;
    int l = 2 * i;
    int r = l + 1;
    int largest = i;
    if (r <= h) {
        if (a[i] < max(a[l], a[r])) {
            if (a[l] < a[r]) largest = r;
            else largest = l;
        }
    } else if (l <= h) {
        if (a[i] < a[l]) largest = l;
    }
    if (largest != i) {
        swap(a[i], a[largest]);
        max_heapify(a, largest);
    }
}

void biuld_max_heap(vector<int> &a) {
    int h = a.size() - 1;
    for (int i = h / 2; i >= 1; i--) {
        max_heapify(a, i);
    }
}

int main() {
    int h;
    scanf("%d", &h);
    vector<int> a(h+1, 0);
    for (int i = 1; i <= h; i++) {
        scanf("%d", &a[i]);
    }
    biuld_max_heap(a);
    for (int i = 1; i <= h; i++) {
        printf(" %d", a[i]);
    }
    printf("\n");
}


Measured memory_bytes: 4624
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, m;
multiset<int> st;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		st.insert(a);
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		int a; cin >> a;
		if (st.lower_bound(a) == st.upper_bound(a)) {
			cout << "NO" << endl;
			return 0;
		}
		st.erase(st.lower_bound(a));
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 12948
x,n = map(int,input().split())

arr = []

if n == 0:
    print(x)
else:
    tmp = input()
    num = tmp.split(' ')
    num_li = [int(i) for i in num]
    arr.extend(num_li)

    for i in range(10000):

        if x - i not in arr:
            print(x - i)
            break

        if x + i not in arr:
            print(x + i)
            break

Measured memory_bytes: 9200
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
using namespace std;
const int MAXN=55;
const int MAXM=110;
const int P=1E9+7;
struct Edge
{
	int from, to;
	Edge(int u, int v): from(u), to(v) {}
};
int n, m, k, cnt, t1, t2, tot;
int c[2*MAXM][MAXM], f[MAXM];
int dfn[MAXN], low[MAXN];
int s1[MAXN], s2[MAXM];
int c1[MAXM], c2[MAXM];
bool ins[MAXN];
vector<Edge> edges;
vector<int> g[MAXN];
int gcd(int a, int b)
{
	if (b==0) return a;
	return gcd(b, a%b);
}
int exgcd(int a, int b, int& x, int& y)
{
	if (b==0) x=1, y=0;
	else exgcd(b, a%b, y, x), y-=a/b*x;
}
int qpow(int a, int b)
{
	int r=1;
	while (b)
	{
		if (b&1) r=1ll*r*a%P;
		a=1ll*a*a%P; b>>=1;
	}
	return r;
}
int inv(int a)
{
	int x, y;
	exgcd(a, P, x, y);
	return (x%P+P)%P;
}
void init()
{
	memset(c, 0, sizeof c);
	c[0][0]=1;
	for (int i=1; i<=m+k; i++)
	{
		c[i][0]=1;
		for (int j=1; j<=i&&j<=m; j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%P;
	}
	memset(f, 0, sizeof f);
	for (int i=1; i<=m; i++)
	{
		for (int j=1; j<=i; j++)
			f[i]=(f[i]+qpow(k, gcd(i, j)))%P;
		f[i]=1ll*f[i]*inv(i)%P;
	}
	edges.clear();
	for (int i=1; i<=n; i++) g[i].clear();
	memset(dfn, 0, sizeof dfn);
	memset(ins, 0, sizeof ins);
	cnt=tot=t1=t2=0;
}
inline void addEdge(int u, int v)
{
	edges.push_back(Edge(u, v));
	edges.push_back(Edge(v, u));
	g[u].push_back(edges.size()-2);
	g[v].push_back(edges.size()-1);
}
void tarjan(int u, int f)
{
	low[u]=dfn[u]=++cnt; ins[u]=1;
	for (int i=0; i<g[u].size(); i++)
	{
		int v=edges[g[u][i]].to;
		if (!dfn[v]||v!=f&&ins[v])
		{
			s2[++t2]=g[u][i];
			if (!dfn[v])
			{
				s1[++t1]=v;
				tarjan(v, u);
				low[u]=min(low[u], low[v]);
				if (low[v]>=dfn[u])
				{
					c1[++tot]=1; c2[tot]=0;
	                do c1[tot]++; while (s1[t1--]!=v);
	                do c2[tot]++; while (s2[t2--]!=g[u][i]);
				}
			}
			else low[u]=min(low[u], dfn[v]);
		}
	}
	ins[u]=0;
}
int main()
{
//	freopen("A.in", "r", stdin);
//	freopen("A.out", "w", stdout);
	scanf("%d%d%d", &n, &m, &k);
	init();
	for (int i=1; i<=m; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		addEdge(u, v);
	}
	for (int i=1; i<=n; i++)
		if (!dfn[i]) tarjan(i, 0);
	int ans=1;
	for (int i=1; i<=tot; i++)
	{
		if (c1[i]==c2[i]) ans=1ll*ans*f[c2[i]]%P;
		else if (c1[i]<c2[i]) ans=1ll*ans*c[c2[i]+k-1][c2[i]]%P;
		else ans=1ll*ans*k%P;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  int l[100];
  int n;

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

  sort(l,l+n);
  int max = l[n-1];
  int sum;
  for(int i=0; i<n-1;i++){
    sum += l[i];
  }
  if(sum > max)
    cout << "Yes";
  else
    cout << "No";

      return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ans := float64(0)
	for i := 1; i <= n; i++ {
		bnb := n
		sum := i
		for sum < k {
			bnb *= 2
			sum *= 2
		}
		ans += float64(1) / float64(bnb)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.Scanner;

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

		while(true){
			int n=sc.nextInt(),r=sc.nextInt();
			if(n==0) break;

			int[] card=new int[n];
			for(int i=0;i<n;i++) card[i]=n-i;
			for(int i=0;i<r;i++){
				int p=sc.nextInt()-1;
				int c=sc.nextInt();
				int[] next=new int[n];
				for(int j= p ;j<p+c;j++) next[j-p]=card[j];
				for(int j= 0 ;j< p ;j++) next[c+j]=card[j];
				for(int j=p+c;j< n ;j++) next[ j ]=card[j];
				card=next;
			}
			System.out.println(card[0]);
		}

		return;
	}
}

Measured memory_bytes: 30228
n=int(input())
l=list(map(int,input().split()))
lmax=0
for i in range(n):
    if lmax<l[i]:
        lmax=l[i]
sumlist=[]
for i in range(lmax):
    sumlist.append(0)
total=0
for i in range(lmax):
    for j in range(n):
        t=(l[j]-(i+1))*(l[j]-(i+1))
        total+=t
    sumlist[i]=total
    total=0
min=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
for i in range(lmax):
    if min>sumlist[i]:
        min=sumlist[i]
print(min)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

int const N_MAX = 100000;

ll N, H;

ll a[N_MAX + 1], b[N_MAX + 1];

int main() {
  scanf("%lld %lld", &N, &H);
  ll strongest_a = 0;
  rep(i, N) {
    scanf("%lld %lld", &a[i], &b[i]);
    strongest_a = max(a[i], strongest_a);
  }

  sort(b, b + N, greater<ll>());

  int count = 0;
  rep(i, N) {
    ll x = b[i];
    if (x < strongest_a) break;

    H -= x;
    count++;
    if (H <= 0) {
      printf("%d\n", count);
      return 0;
    }
  }
  if (H % strongest_a == 0) {
    count += H / strongest_a;
  } else {
    count += H / strongest_a + 1;
  }
  printf("%d\n", count);
}


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String inputStr = in.next();
            int counter = 0;
            for (int i = 0; i < inputStr.length(); i++) {
                if (inputStr.charAt(i) == 'o') {
                    counter++;
                }
            }

            if (counter + 15 - inputStr.length() >= 8) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }
}



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

struct Node {
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
	Node *cur = nil ->next;
	while(cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList() {
	Node *cur = nil->next;
	int isf = 0;
	while(1) {
		if(cur == nil) break;
		if(isf++>0) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t) {
	if(t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void insert(int key) {
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main() {
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for(i = 0; i < n; i++) {
		scanf("%s%d", com, &key);
			if(com[0] == 'i') {insert(key); np++; size++;}
		else if(com[0] == 'd') {
			if (strlen(com) > 6) {
				if(com[6] == 'F') deleteFirst();
				else if(com[6] == 'L') deleteLast();
			}else{
				deleteKey(key); nd++;
			}
			size--;
		}
	}
	
	printList();
	
	return 0;
}

Measured memory_bytes: 33876
#include<stdio.h>
int main(void){
  int x;
  int a,b,c;
  scanf("%d",&x);
  a=x/3600;
  b=(x-a*3600)/60;
  c=(x-a*3600-b*60);
    printf("%d:%d:%d\n",a,b,c);



  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;
 
int main() {
  ll n,m;
  cin >> n >> m;
  vec x(n);
  vec y(n);
  vec z(n);
  for(ll i=0;i<n;i++) {
    cin >> x[i] >> y[i] >> z[i];
  }
  vec modx={1,1,1,1,-1,-1,-1,-1};
  vec mody={1,-1,1,-1,1,-1,1,-1};
  vec modz={1,1,-1,-1,1,1,-1,-1};
  ll ans=0;
  for(ll i=0;i<8;i++) {
    ll tans=0;
    vec p(n);
    for(ll j=0;j<n;j++) {
      p[j]=modx[i]*x[j]+mody[i]*y[j]+modz[i]*z[j];
    }
    sort(p.rbegin(),p.rend());
    for(ll j=0;j<m;j++) {
      tans+=p[j];
    }
    ans=max(ans,tans);
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  cin>>N;
  vector<vector<int>>p(3,vector<int>(N-1));
  for(int i=0;i<N-1;i++){
    cin>>p.at(0).at(i)>>p.at(1).at(i)>>p.at(2).at(i);
  }
  for(int i=0;i<N;i++){
    int Z=0;
    for(int j=i;j<N-1;j++){
      Z=max(p.at(1).at(j),((Z-1)/p.at(2).at(j)+1)*p.at(2).at(j))+p.at(0).at(j);
    }
    cout<<Z<<endl;
  }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define re(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int
struct Union{
  vector<int> par;
  Union(int a){
  par=vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(int a,int b){
    return (find(a)==find(b));
  }
  int size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    int c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
int main(void){
    long long a;
    cin >> a;
    cout << (a+1)/2;
}


Measured memory_bytes: 256
def read_input():
    n, a = map(int, input().split())
    xlist = list(map(int, input().split()))
    return n, a, xlist


def make_matrix():
    dp = [
        [
            [0] * ((n + 1) * max(max(xlist), a)) for _ in range(n + 1)
        ] for _ in range(n + 1)
    ]



def submit():
    n, a, xlist = read_input()

    dp = [
        [
            [0] * ((n + 1) * max(max(xlist), a)) for _ in range(n + 1)
        ] for _ in range(n + 1)
    ]

#   dp[j][k][s] : j枚目までのカードでk枚選び、合計sにする方法の数
#         (1) dp[0][0][0] : 1枚も選ばずに合計0にする方法は1種類
#               j = k = s = 0のとき
#         (2) dp[j][k][s] = dp[j - 1][k][s] if xj > s : j枚目のカードがsより大きいとき、sを作りようがないのでj-1枚目までの手法と一緒
#               j > 0, xj > sのとき
#         (3) dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - xj]
#               : xj <= sのとき、j-1枚目まででsを作る方法と、j-1枚目まででs-xjをつくり、j枚目を選んでk枚にする
#               j > 0, k > 0, s >= xjのとき
#         (4) dp上記以外は無理なので0

    dp[0][0][0] = 1

    for j in range(n + 1):
        for k in range(n + 1):
            for s in range((n + 1) * max(xlist)):
                if j > 0 and xlist[j - 1] > s:
                    dp[j][k][s] = dp[j - 1][k][s]
                elif j > 0 and k > 0 and xlist[j - 1] <= s:
                    dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - xlist[j - 1]]

    methods = 0
    for i in range(1, n + 1):
        methods += dp[n][i][i * a]

    print(int(methods))


if __name__ == '__main__':
    submit()


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

int main(){
  long long n,k,r,s,p,i,cop,cor,cos;
  cin >> n >> k;
  cin >> r >> s >> p;
  string t,ha(n,'x');
  cin >> t;
  long long ans=0;
  cop=0;
  cos=0;
  cor=0;
  for(i=0;i<n;++i){
    if(i<k){
      if(t[i]=='r'){
        cop++;
        ha[i]='p';
      }else if(t[i]=='s'){
        cor++;
        ha[i]='r';
      }else if(t[i]=='p'){
        cos++;
        ha[i]='s';
      }
    }else if(i>=k){
      if(t[i]=='r'){
        if(ha[i-k]=='p'){
          ha[i]='x';
        }else{
          cop++;
          ha[i]='p';
        }
      }else if(t[i]=='s'){
        if(ha[i-k]=='r'){
          ha[i]='x';
        }else{
          cor++;
          ha[i]='r';
        }
      }else if(t[i]=='p'){
        if(ha[i-k]=='s'){
          ha[i]='x';
        }else{
          cos++;
          ha[i]='s';
        }
      }
    }
  }
  ans=cop*p;
  ans+=cos*s;
  ans+=cor*r;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
bool f [100001];
int c [100002];
int N ,L , R ;
int main (){
    for ( int i =2; i <=100000; i ++) if (! f [ i ]) for ( int j = i + i ;j <=100000; j += i )
        f[j]= true ;
        for ( int i =3; i <=100000; i +=2) if (!f[i]&&!f[(i+1)/2])c[i]++;
        for ( int i =3; i <=100000; i ++) c[i]+=c[i-1];
        scanf ("%d " ,& N );
        while (N--)
        {
            scanf ("%d %d " ,&L ,& R );
            printf ("%d \n " , c[R] - c[L-1]);
        }
}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int k,n,a,b,s[100001],acnt,wcnt;
string c;
int main(void){
    cin>>k>>n;
    for(int i=0;i<n;i++){
        cin>>a>>c;
        if(s[a]<=0){
            if(c=="AC"){
                acnt++;
                wcnt+=-s[a];
                s[a]=1;
            }
            if(c=="WA"){
                s[a]--;
            }
        }
    }
    cout<<acnt<<" "<<wcnt<<endl;
}


Measured memory_bytes: 640
def main():
    n,m,q = map(int,input().split())
    a = [list(map(int, input().split())) for _ in range(q)]
    #a = sorted(a, key=lambda x:-x[3])
    ans = 0
    from itertools import combinations_with_replacement
    for dp in combinations_with_replacement(range(1,m+1),n):
        res = 0
        for j in range(q):
            if dp[a[j][1]-1] - dp[a[j][0]-1] == a[j][2]:
                res += a[j][3]
        ans = max(res,ans)
    print(ans)
    
if __name__ == '__main__':
    main()



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

bool deltaCheck(int a,int b,int c){
  bool dekiru=false;
  if( a<b+c && b<c+a && c<a+b)dekiru = true;
  return dekiru;
}
int binary_Search(vector<int> A,int key){
  int ng=-1,ok=(int)(A.size());

  while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (key <= A[mid]) ok = mid;
        else ng = mid;
    }
  return ok;
}

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i,N){cin >> L.at(i);}

  sort(L.begin(),L.end());
  
  int ans = 0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      int large_L= binary_Search(L,L[i]+L[j]);
      //cout << large_L<<endl;
      ans += max(0,large_L - j-1);
      /*for(int k=j+1;k<large_L; k++){
        if(deltaCheck(L[i],L[j],L[k]))ans++;
      }*/
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;




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

	int n, d, x, i, j, k, ans;
	cin >> n >> d >> x;
	ans = x;
	for (i = 0; i < n; i++) {
		cin >> x;
		ans += (d - 1) / x + 1;
	}
	cout << ans << "\n";

	return 0;
}


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

typedef long long ll;

using namespace std;

int main() {
    ll h, w;
    cin >> h >> w;
    ll p = (h + 1) / 3, q = (w + 1) / 3;
    cout << min({h * bool(w % 3), w * bool(h % 3), max(p * w, (w + 1) / 2 * (h - p)) - min(p * w, w / 2 * (h - p)), max(q * h, (h + 1) / 2 * (w - q)) - min(q * h, h / 2 * (w - q))}) << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	A := make([]int, N+1)

	for i := 0; i < N+1; i++ {
		A[i] = nextInt()
	}

	c := 0

	for i := 0; i < N; i++ {
		B := nextInt()

		if A[i] > B {
			c += B
			A[i] -= B
		} else {
			c += A[i]

			d := B - A[i]
			A[i] = 0

			if A[i+1] < d {
				c += A[i+1]
				A[i+1] = 0
			} else {
				c += d
				A[i+1] -= d
			}
		}
	}

	fmt.Println(c)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)

	return i
}


Measured memory_bytes: 4992
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

class Node {
    constructor(n) {
        this.value = n;
        this.prev = null;
        this.next = null;
    }
}

class List {
    constructor() {
        this.size = 0;
        this.head = null;
        this.tail = null;
    }

    insert(n) {
        const newNode = new Node(n);
        if (this.size === 0) {
            this.head = newNode;
            this.tail = newNode;
        } else {
            newNode.next = this.head;
            this.head.prev = newNode;
            this.head = newNode;
        }
        this.size++;
    }

    del(n) {
        let delNode = this.head;
        while(delNode.value !== n) {
            delNode = delNode.next;
            if (delNode === null) return;
        }
        if (delNode.prev !== null) delNode.prev.next = delNode.next;
        else this.head = delNode.next;
        if (delNode.next !== null) delNode.next.prev = delNode.prev;
        else this.tail = delNode.prev;
        
        this.size--;
    }

    deleteFirst() {
        this.head = this.head.next;
        if (this.head !== null) this.head.prev = null;
        this.size--;
    }

    deleteLast() {
        this.tail = this.tail.prev;
        if (this.tail !== null) this.tail.next = null;
        this.size--;
    }

    toArray() {
        let currentNode = this.head;
        const arr = [];
        while(currentNode !== null) {
            arr.push(currentNode.value);
            currentNode = currentNode.next;
        }

        return arr;
    }
}


const cmds = line.slice(1);
const ans = cmds.reduce((acc, x) => {
    const cmd = x.split(' ');
    switch (cmd[0]) {
        case 'insert':
            acc.insert(parseInt(cmd[1]));
            break;
        case 'delete':
            acc.del(parseInt(cmd[1]));
            break;
        case 'deleteFirst':
            acc.deleteFirst();
            break;
        case 'deleteLast':
            acc.deleteLast();
            break;
    }

    return acc;
}, new List()).toArray().map(x => x.toString()).join(' ');

console.log(ans);



Measured memory_bytes: 265440
#! /usr/bin/env python3

D = 10**9+7
N = int(input())
A = list(map(int, input().split()))
M = N%2>0
b = 1
C = [0] * (N//2+1)
if M:
    for i in A:
        if i%2 < 1:
            C[i//2] += 1 
    b = (N//2) == sum(1 for x in C[1:] if x == 2) and C[0] == 1
    
else:
    for i in A:
        if i%2 > 0:
            C[i//2] += 1 
    b = (N//2) == sum(1 for x in C if x == 2)

print((2**(N//2))%D if b else 0)

Measured memory_bytes: 14008
#include<cstdio>
using namespace std;
typedef long long LL;
const int maxn=200005;
int n,A[maxn],p=1,len,idx[maxn];LL K;
inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=getchar();}
	return ret*f;
}
int main()
{
	n=read();scanf("%lld",&K);
	for(int i=1;i<=n;i++) A[i]=read();
	while(!idx[p]&&K){idx[p]=++len;K--;p=A[p];}
	K%=(len+1-idx[p]);
	for(int i=1;i<=K;i++) p=A[p];
	printf("%d\n",p);
	return 0;
}

Measured memory_bytes: 3256