akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    string S;
    map<char,int> m;
    cin >> S;
    if(S.length()!=4){
        cout << "No" << endl;
        return 0;
    }
    rep(i,4){
        m[S[i]]++;
    }
    rep(i,4){
        if(m[S[i]]!=2){
            cout << "No" << endl;
        return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
while 1:
  n=int(input())
  if not n:break
  f=1
  L={}
  for a,b,c in [input().split() for i in range(n)]:
    d=int(b)*int(c)
    if a in L:
      if L[a]>=1e6:continue
      L[a]+=d
    else:L[a]=d
    if L[a]>=1e6:
      print(a)
      f=0
  if f:print('NA')

Measured memory_bytes: 8204
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define int long long
#define fori(j,n) for(int i=j;i<n;i++)
#define forb(n,j) for(int i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define PI 3.141592653589793
#define M 1000000007
using namespace std;
int fast(int a,int b)
{
    int ans=1;
    a=a%M;
    if(a==0)
        return 0;
    while(b>0)
    {
        if(b&1)
        {
            ans=(ans*a)%M;
        }
        b>>=1;
        a=(a*a)%M;
    }
    return ans;
}

int32_t main()
{
   	int a[5];
   	fori(0,5)
        cin>>a[i];
    fori(0,5)
    {
        if(a[i]==0)
        {
            cout<<i+1;
            break;
        }
    }
    return 0;
}


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

int main() {
  int  N,ans;
  cin>>N ;
  vector<int> d(N);
  for(int i=0;i<N;i++) {cin>>d.at(i);}
  sort(d.begin(),d.end());
  if (d.at(N/2)==d.at(N/2-1))ans=0;
  else ans=d.at(N/2)-d.at(N/2-1);
  cout<<ans<<endl;
}


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

p = [(x+1)/2 for x in map(int, input().split())]

ans = sum(p[0:k])
prev = ans

for i in range(1, n - k + 1):
    prev = prev - p[i - 1] + p[i + k - 1]
    if ans < prev:
        ans = prev

print(ans)

Measured memory_bytes: 71792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<ll, ll>;
constexpr int MX = 200005;
int n,d,a,x,h;
long long ans,ac;
queue<P> qu;
P p[MX];
int main(){
	scanf("%d%d%d", &n, &d, &a);
	rep(i,n){
		scanf("%d%d", &x, &h);
		p[i] = P{x,h};
	}
	sort(p,p+n);
	rep(i,n){
		while(!qu.empty() && qu.front().first < p[i].first){
			ac -= qu.front().second;
			qu.pop();
		}
		if(ac < p[i].second){
			ll t = (p[i].second - ac - 1) / a + 1;
			ans += t;
			ac += a * t;
			qu.push(P{p[i].first+d*2,a*t});
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  int a,b,m; cin >> a >> b >> m;
  int alpha[a], beta[b];
  int mina = 1001001001;
  int minb = 1001001001;
  FOR(i,0,a-1) {
    cin >> alpha[i];
    chmin(mina,alpha[i]);
  }
  FOR(i,0,b-1) {
    cin >> beta[i];
    chmin(minb,beta[i]);
  }
  int ans = mina + minb;
  FOR(i,0,m-1){
    int x,y,c; cin >> x >> y >> c;
    chmin(ans,alpha[x-1] + beta[y-1] - c);
  }
  cout << ans << endl;


}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int info[505][505], raw[200005][2], quest[200005][2], ans[200005];
int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    for ( int i = 0; i <= m-1; i++ )
    {
        cin >> raw[i][0] >> raw[i][1];
        info[raw[i][0]][raw[i][1]]++;
    }
    for ( int i = 1; i <= n; i++ )
    {
        for ( int j = 1; j <= n; j++ )
        {
            info[i][j] = info[i][j] + info[i][j-1];
        }
    }
    for ( int i = 0; i <= q-1; i++ )
    {
        cin >> quest[i][0] >> quest[i][1];
        for ( int j = quest[i][0]; j <= quest[i][1]; j++ )
        {
            ans[i] = ans[i] + info[j][quest[i][1]] - info[j][quest[i][0]-1];
        }
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n)-1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a)-1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using Vec = vector<T>;
template<class T> using VVec = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i-1)*10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}

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

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

int N;
int A[200005];

bool kaburi(int now, int val, int i) {
	if ((now & 1 << i) && (val & 1 << i)) return true;
	return false;
}

void Add_bit(int &now, int val) {
	rep (i, 25) if (val & 1 << i) now |= 1 << i;
}

void Remove_bit(int &now, int val) {
	rep (i, 25) if (val & 1 << i) now &= ~(1 << i);
}

void solve() {
	int now = 0; 
	int right = 0;
	ll ans = 0;
	rep (left, N) {
		if (left != 0) Remove_bit(now, A[left - 1]);
		bool ok = true;
		while (right < N && ok) {
			rep (i, 25) if (kaburi(now, A[right], i)) ok = false;
			if (ok) {
				Add_bit(now, A[right]);
				right++;
			}
			
		}
		ans += right - left;
	}
	cout << ans << endl;
}

int main() {
	cin >> N;
	rep (i, N) cin >> A[i];
	solve();
	
	return 0;
}

Measured memory_bytes: 4396
def f(x,y):
    count_x, count_y = 1, 1
    while x/10>=1:
        x = x//10
        count_x += 1
    while y/10>=1:
        y = y//10
        count_y += 1
    return max(count_x, count_y)

pf = []
m = int(input())

for i in range(1,int(m**0.5)+1):
    if m%i == 0:
        pf.append(i)

print(f(pf[-1], m/pf[-1]))

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

class Program
{
    static void Main(string[] args)
    {
        // 入力
        string[] input = Console.ReadLine().Split(' ');
        var n = long.Parse(input[0]);
        var k = long.Parse(input[1]);
        var q = long.Parse(input[2]);

        //初期化
        long[] tmp = new long[n];
        for (int i = 0; i < n; i++)
        {
            tmp[i] = -1 * q;
        }

        //計算
        for (int i = 0; i < q; i++)
        {   
            int j = int.Parse(Console.ReadLine());
            tmp[j-1] += 1;
        }

        //出力
        for (int i = 0; i < n; i++)
        {
            if (tmp[i] > k * -1)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 17592
s=input()
n=len(s)
ans=0

for i in range(1<<(n-1)):
  f=s[0]
  for j in range(n-1):
    if i&(1<<j):
      f += "+"
    f+= s[j+1]
  ans += sum(map(int, f.split("+")))
  
print(ans)



Measured memory_bytes: 41452
n=int(input())
c=[int(input())for i in range(n)]
a=[0]
a.extend(c)
x=a[1]
a[1]=-1
cnt=1
for i in range(n):
    if x==2:
        print(cnt)
        exit()
    cnt+=1

    y=a[x]
    a[x]=-1
    x=y
    if x==-1:
        print(-1)
        exit()


Measured memory_bytes: 7852
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=list(list(map(int,input().split())) for  _ in range(M))#リストの表記が違う
BC.sort(key=lambda x: x[1],reverse=True)#リバースと-1の違い

for b,c in BC:
    A.extend([c]*b)
    if len(A)>N*2:
        break
A.sort(reverse=True)
print(sum(A[:N]))

Measured memory_bytes: 35400
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = -1;
	int tmp;
	int n; 
	cin >> n;
	vector<int> a(n+1);
	REP1(i, n) cin >> a[i];
	int now = 1;
	REP1(i, 100000){
		now = a[now];
		if(now == 2){
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import math


def resolve():
    n, m = map(int, input().split())
    mod = 10 ** 9 + 7
    if n == m:
        print(math.factorial(n) * math.factorial(m) * 2 % mod)
    elif n - 1 == m or m - 1 == n:
        print(math.factorial(n) * math.factorial(m) % mod)
    else:
        print(0)


if __name__ == "__main__":
    resolve()


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



double calc_density( int water, int sugar ){
	return 100.0 * (double)sugar / (double)( water + sugar );
}



int main(){
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	
	// memo: w * 100 = water
	vector<int> possible_w(31);
	for ( int a = 0; a <= 30; a++ ){
		for ( int b = 0; b <= 30; b++ ){
			int w = a*A+b*B;
			if ( 0 < w && w <= 30 )
				possible_w[w] = 1;
		}
	}
	
	
	double best_density = -1.0;
	int best_water;
	int best_sugar;
	
	for ( int w = 0; w <= 30; w++ ){
		if ( !possible_w[w] )
			continue;
		int water = w*100;
		int max_sugar = min( w * E, F - water );
		
		for ( int c = 0; c*C <= max_sugar; c++ ){
			int d = (max_sugar - c*C)/D;
			int sugar = c*C+d*D;
			double density = calc_density( water, sugar );
			if ( best_density < density ){
				best_water = water;
				best_sugar = sugar;
				best_density = density;
			}
		}
		
		
	}
	
	cout << (best_water+best_sugar) << " " << best_sugar << endl;
	
	return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

const int V = 300002;

struct E { int t; LL c; int r; };
vector<E> g[V];
bool used[V];
const LL INF = 1e12;

void add(int f, int t, LL c) {
	int gt = g[t].size();
	int gf = g[f].size();
	g[f].PB({ t, c, gt });
	g[t].PB({ f, 0, gf });
}

LL dfs(int v, int t, LL f) {
	if(v == t) { return f; }
	
	used[v] = true;
	inc(i, g[v].size()) {
		E & e = g[v][i];
		if(! used[e.t] && e.c > 0) {
			LL d = dfs(e.t, t, min(f, e.c));
			if(d > 0) {
				e.c -= d;
				g[e.t][e.r].c += d;
				return d;
			}
		}
	}
	
	return 0;
}

LL flow(int S, int T) {
	LL ans = 0;
	while(true) {
		inc(i, V) { used[i] = false; }
		LL f = dfs(S, T, INF);
		ans += f;
		if(f == 0) { break; }
	}
	return ans;
}

// ----

LL n, a[101];

int main() {
	cin >> n;
	inc1(i, n) { cin >> a[i]; }
	
	int S = 0;
	int T = 1;
	inc1(i, n) {
		add(S, i * 3 - 1, INF);
		add(i * 3 - 1, i * 3 + 0, max(a[i], 0LL) - a[i]);
		add(i * 3 + 0, i * 3 + 1, max(a[i], 0LL) -  0LL);
		add(i * 3 + 1, T, INF);
	}
	inc1(i, n) {
		for(int j = i * 2; j <= n; j += i) { add(i * 3, j * 3, INF); }
	}
	
	LL ans = -flow(S, T);
	
	inc1(i, n) { ans += max(a[i], 0LL); }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 7680
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Integer[] a = new Integer[n];
        int votes = 0;
        
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            votes += a[i];
        }
        
        Arrays.sort(a, Collections.reverseOrder());
        
        for(int j=0; j<m; j++){
            if(a[j] < votes*((double)1/(4*m))){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 35688
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,cnt=0;
  cin>>a>>b>>c>>x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
	if(500*i+100*j+50*k==x){
	  cnt++;
	}
      }
    }
  }
  cout<<cnt<<endl;
}
  


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[m];
		int[] d = new int[m];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for (int i = 0; i < m; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		int[] minDistance = new int[n];
		for (int i = 0; i < n; i++) {
			minDistance[i] = 1000000000;
		}
		int[] minIndex = new int[n];
		for (int i = 0; i < n; i++) {
			minIndex[i] = -1;
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				int distance = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
				if (distance < minDistance[i]) {
					minDistance[i] = distance;
					minIndex[i] = j;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.println(minIndex[i] + 1);
		}
	}
}

Measured memory_bytes: 21588
#include <iostream>
using namespace std;
static const int MAX=2000001;

int H,A[MAX];

void maxHeapify(int i) {
  int l,r,largest;
  l=2*i;
  r=2*i+1;
  if (l<=H and A[l]>A[i]) {
    largest=l;
  }
  else largest=i;
  if (r<=H and A[r]>A[largest]) {
    largest=r;
  }
  if (largest!=i) {
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}
int main() {
  cin>>H;
  for (int i=1; i<=H; i++) {
    cin>>A[i];
  }
  for (int i=H/2; i>=1; i--) {
    maxHeapify(i);
  }
  for (int i=1; i<=H; i++) {
    cout<<" "<<A[i]<<flush;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 5040
#include<iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define point complex<double>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int N = 2e5 + 10, mod = 998244353;
int n;

ll a[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   string s1,s2;
   cin>>s1>>s2;
   if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0]){
    cout<<"YES";
   }else cout<<"NO";
    return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli dp[100100];
bool vis[100100];
map<lli,vector<lli>> d;

lli dfs(lli now){
	if(vis[now])return dp[now];
	vis[now]=true;

	lli ret=0;
	for(auto e:d[now]){
		ret = max(ret,dfs(e)+1);
	}
	return dp[now]=ret;
}

signed main(){

	lli n,m;
	cin>>n>>m;

	REP(i,0,m){
		lli x,y;
		cin>>x>>y;
		x--,y--;
		d[x].push_back(y);
	}

	lli ans=0;
	REP(i,0,n){
		ans = max(ans,dfs(i));
	}

	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15488
#include <iostream>

using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if ((A == 7 && B == 5 && C == 5) || (A == 5 && B == 7 && C == 5) ||
	    (A == 5 && B == 5 && C == 7)) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}


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

int main(void){
  int a, b, c;
  cin >> a >> b >> c;

  for(int i = 1; i <= b; i ++){
    if(a * i % b == c){
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	//freopen("in.txt","r",stdin);
	ll n;
	cin>>n;
	ll q,w;
	cin>>q>>w;
	ll x = 0;
	for(ll i=2;i<n;i++){
		ll tmp;
		cin>>tmp;
		x ^= tmp;
	}
	ll d = (q+w-x)  / 2;
	if(d<0 or d>q or (d&x) or (q+w-x)%2==1){
		cout<<-1<<endl;
		exit(0);
	}
	for(ll i=56;i>=0;i--){
		if(x>>i&1LL){
			if(d+(1LL<<i) <= q){
				d += (1LL<<i);
			}
		}
	}
	if(d==0) cout<<-1<<endl;
	else cout<<q-d<<endl;
	return 0;
}

Measured memory_bytes: 3548
use std::io::stdin;
use std::vec::Vec;

mod utils {
    use std::io::BufRead;
    use std::str::{self, FromStr};

    pub struct StdinReader<R: BufRead> {
        reader: R,
        buf: Vec<u8>,
    }

    impl<R: BufRead> StdinReader<R> {
        pub fn new(reader: R) -> StdinReader<R> {
            StdinReader {
                reader: reader,
                buf: Vec::new(),
            }
        }

        #[allow(unused)]
        #[inline]
        pub fn reads<T: FromStr>(&mut self) -> T {
            self.read_until(b' ')
        }

        #[allow(unused)]
        #[inline]
        pub fn readl<T: FromStr>(&mut self) -> T {
            self.read_until(b'\n')
        }

        #[allow(unused)]
        #[inline]
        pub fn read_vec<T: FromStr>(&mut self) -> Vec<T> {
            return self.read_until::<String>(b'\n').trim().split_whitespace().map(|c| c.parse().ok().unwrap()).collect();
        }

        #[inline]
        pub fn read_until<T: FromStr>(&mut self, delim: u8) -> T {
            loop {
                self.buf.clear();
                let len = self.reader
                    .read_until(delim, &mut self.buf)
                    .expect("failed reading bytes");
                match len {
                    0 => panic!("early eof"),
                    1 if self.buf[0] == delim => (),
                    _ => {
                        if self.buf[len - 1] == delim {
                            self.buf.truncate(len - 1);
                        }
                        break;
                    }
                }
            }

            let elem = unsafe { str::from_utf8_unchecked(&self.buf) };
            elem.parse().unwrap_or_else(|_| panic!(format!("failed parsing: {}", elem)))
         }
    }
}


fn main(){
    let stdin = stdin();
    let mut r = utils::StdinReader::new(stdin.lock());
    let a:i32 = r.readl();
    let b:i32 = r.readl();
    let c:i32 = r.readl();
    let sum:i32 = r.readl();

    let mut res = 0;

    for x in 0..(a + 1) {
        for y in 0..(b + 1) {
            for z in 0..(c+1) {
                if(x * 500 + y * 100 + z * 50 == sum) {
                    res += 1;
                }
            }
        }
    }

    println!("{}",res);
}


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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

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

    int n;
    cin >> n;

    vi dp(3, 0);
    rep(i, 0, n) {
        int a, b, c;
        cin >> a >> b >> c;
        int ai = a + max(dp[1], dp[2]);
        int bi = b + max(dp[2], dp[0]);
        int ci = c + max(dp[0], dp[1]);
        dp[0] = ai;
        dp[1] = bi;
        dp[2] = ci;
    }

    cout << max(dp[0], max(dp[1], dp[2])) << endl;
    return 0;
}

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


int main() {
	
	int N;
	cin >> N;
	vector<int> h(N);
	for(auto &i:h) cin >> i;
	if(N==1) cout << "Yes" << endl;
		else{
		for(int i=N-2; i>=0; i--){
			if(h.at(i)>h.at(i+1)+1){
				cout << "No" << endl;
				break;
			}
			else if(h.at(i)==h.at(i+1)+1) h.at(i)--;
			if(i==0) cout << "Yes" << endl;
		}
	}
	
	return 0;
}

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

using namespace std;

int main(){
	int N; cin >> N;
	string s = to_string(N);
	int sum = 0;
	for(int i = 0; i < s.size(); ++i){
		sum += s[i] - 48;
	}
	if(N%sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

const int red = 1, green = 2, blue = 4;

ll sum[10][4010];

int main(){
	int n; cin >> n;
	string s; cin >> s;
	vector<int> seq;
	for( char c : s ){
		if( c == 'R' ) seq.push_back(red);
		if( c == 'G' ) seq.push_back(green);
		if( c == 'B' ) seq.push_back(blue);
	}
	for( int i = 0; i < n; ++i ){
		sum[red][i+1] = sum[red][i];
		sum[green][i+1] = sum[green][i];
		sum[blue][i+1] = sum[blue][i];
		sum[seq[i]][i+1] += 1;
	}
	ll ans = 0;
	for( int left = 0; left < n-2; ++left ){
		for( int right = left+2; right < n; ++right ){
			if( seq[left] == seq[right] ) continue;
			int needed_c = 7 - seq[left] - seq[right];
			ans += ( sum[needed_c][right] - sum[needed_c][left+1] );
			if( (right-left)%2 == 0 ){
				int mid = (right+left)/2;
				if( left < mid and mid < right and seq[mid] == needed_c ) ans -= 1;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3772
#include <complex>
#include <cmath>
#include <vector>
#include <cstdio>
#include <iostream>
using namespace std;

typedef complex<double> xy_t;

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }

const double eps = 1e-11;
// (|a|+|b|+|c|+|d|)*epsilon??¨(10-5)^2???????????°

int main(){
  int n;
  cin >> n;
  for(int i=0; i<n; ++i){
    xy_t P[4];
    double x, y;
    for(int j=0; j<4; ++j){
      cin >> x >> y;
      P[j] = xy_t(x, y);
    }
    bool p = abs(cross_product(P[1]-P[0], P[3]-P[2])) < eps;
    cout << (p ? "YES" : "NO") << endl;
  }
}

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

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--)
#define INF (ll)2e9
#define MOD ((ll)1e9+7)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define bit(n) (1LL<<(n))

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;
}

template<class InputIterator>
InputIterator adv(InputIterator x, typename std::iterator_traits<InputIterator>::difference_type n) {
    advance(x, n);
    return x;
}

class mod {
    static ll fact[];
public:

    template<class... A>
    static ll mul(A... args) {
        ll res = 1;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res * i) % MOD;
        }
        return res;
    }

    static ll power(ll base, ll exp) {
        if (exp == 0) return 1;
        if (exp & 1) {
            return mul(base, power(base, exp - 1));
        } else {
            ll p = power(base, exp / 2);
            return mul(p, p);
        }
    }

    static ll factorial(int n) {
        if (fact[n] != 0) return fact[n];
        if (n == 0) return 1;
        return fact[n] = mul(n, factorial(n - 1));
    }

    static ll inverse(int n) {
        return power(n, MOD - 2);
    }

    static ll comb(int n, int r) {
        if (r < 0 || r > n) return 0;
        return mul(factorial(n), inverse(factorial(n - r)), inverse(factorial(r)));
    }

    template<class... A>
    static ll div(ll dividend, A... args) {
        ll res = dividend;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = mul(res, inverse(i));
        }
        return res;
    }

    template<class... A>
    static ll add(A... args) {
        ll res = 0;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res + i) % MOD;
        }
        return res;
    }

    template<class... A>
    static ll sub(ll l, A... args) {
        ll res = l;
        for (ll i : std::initializer_list < ll > {args...}) {
            res = (res - i + MOD) % MOD;
        }
        return res;
    }
};

ll mod::fact[(int) 1e6 + 1];

int ni() {
    int i;
    cin >> i;
    return i;
}

ll nll() {
    ll l;
    cin >> l;
    return l;
}

int main() {
    int N = ni();
    ll count[1010] = {};

    FOR(i, 2, N+1) {
        int temp = i;
        FOR(j, 2, N+1) {
            if (temp % j == 0) {
                count[j]++;
                temp /= j;
                j--;
            }
            if (temp == 1) break;
        }
    }

    ll ans = 1;
    REP(i, N+1)  {
        ans = mod::mul(ans, count[i]+1);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def solve():
    sx, sy, tx, ty = map(int, input().split())
    ans = ""
    ans += "R"*(tx-sx)+"U"*(ty-sy)
    ans += "L"*(tx-sx)+"D"*(ty-sy)
    ans += "D"+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L"
    ans += "U"+"L"*(tx-sx+1)+"D"*(ty-sy+1)+"R"
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 9184
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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

    vector<vector<int>> dp(N+5, vector<int>(N+5));

    for(int i=N-1; i>=0; --i)
        for(int j=N-1; j>=0; --j) {
            if(S[i] == S[j])
                dp[i][j] = dp[i+1][j+1] + 1;
        }

    int ans = 0;
    for(int i=0; i<N; i++)
        for(int j=0; j<N; j++) {
            if(i>=j) continue;
            if(ans < dp[i][j] && j-i >= dp[i][j]) ans = dp[i][j];
        }

    cout << ans << endl;
    return 0;
}

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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int N;
    cin >> N;
    vector<int> d(N);
    for (int i=0; i<N; ++i) cin >> d[i];

    sort(d.begin(), d.end());

    if (d[N/2-1] == d[N/2]) {
        cout << 0 << endl;
        return 0;
    }

    cout << d[N/2] - d[N/2-1] << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using P = pair<int, int>;
using ll = long long;

int main()
{
    int p,q,r;
    cin >> p >> q >> r;
    int ans = min(min(p+q,q+r),p+r);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<vector>

using namespace std;
#define ll long long 

int  main(){
    int a,b;
    string s,t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    if(s < t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}    

Measured memory_bytes: 256
lst = []
while True:
    a = list(map(int, input().split()))
    if a[0] == a[1] == 0:
        break
    else:
        lst.append(a)
for i in range(len(lst)):
    for y in range(lst[i][0]):
        for x in range(lst[i][1]):
            if (y + x) % 2 == 0:
                print("#", end = "")
            else:
                print(".", end = "")
        print()
    print()


Measured memory_bytes: 7004
#include <iostream>
using namespace std;
long long a[200013],n,ans,j,h;
int main()
{
	cin>>n;
	for(int i = 0;i < n;i++)
		cin>>a[i];

	for(int i = 0;i < n;i++)
	{
		for(;j < n;j++)
			if((h | a[j]) != h + a[j])
				break;
			else
				h = h + a[j],
		ans = ans + j - i + 1;
		h -= a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>

using namespace std;

const int MAX_N = 10000;
const int V = 10000;

vector<int> G[MAX_N];
vector<int> rG[MAX_N];
vector<int> vs; //??°?????????????????????
bool used[MAX_N]; //?????§????????????????????????
int cmp[MAX_N];	//?±????????????£????????????????????????????????????

void add_edge(int from,int to)
{
	G[from].push_back(to);
	rG[to].push_back(from);
}

void dfs(int v)
{
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		if(!used[G[v][i]]){
			dfs(G[v][i]);
		}
	}
	vs.push_back(v);
}

void rdfs(int v,int k)
{
	used[v] = true;
	cmp[v] = k;
	for(int i=0;i<rG[v].size();i++){
		if(!used[rG[v][i]]){
			rdfs(rG[v][i],k);
		}
	}
}

int scc()	//?????£??????????????°?????????
{
	memset(used,0,sizeof(used));
	vs.clear();
	for(int v=0;v<V;v++){
		if(!used[v]){
			dfs(v);
		}
	}
	memset(used,0,sizeof(used));
	int k=0;
	for(int i=vs.size()-1;i>=0;i--){
		if(!used[vs[i]]){
			rdfs(vs[i],k++);
		}
	}
	return k;
}

int main()
{
	int n,m,from,to,k,l,u,v;
	cin >> n >> m;
	for(int i=0;i<m;i++){
		cin >> from >> to;
		add_edge(from,to);
	}
	k = scc();	
	cin >> l;
	for(int i=0;i<l;i++){
		cin >> u >> v;
		printf("%d\n",(cmp[u] == cmp[v]));
	}
}

Measured memory_bytes: 4796
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,n) for(int i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;

    ll ans = 0;

    for(int bit = 0; bit < (1<<s.size()-1); bit++){
        vector<int> S;

        ll tmp = 0;
        ll tmp2 = 0;
        tmp = s[0]-'0';
        for (int i = 0; i < s.size()-1; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S.push_back(i);
                tmp2 += tmp;
                tmp = 0;
            }
                tmp = tmp * 10 + s[i+1]-'0';       
            
        }

        tmp2 += tmp;
        ans += tmp2;



        for(int i = 0; i < s.size(); i++){
            for(int j = 0; j < (int)S.size(); ++j){
                
            }
        }

    }

    cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
void solve(int N, vector<string>& S)
{
    vector<string> T(N);
    vector<vector<int>> G(N+1);
    vector<int> items = {0};
    for (int i = 0; i < N; i++) {
        int level = 0;
        while (S[i][level] == '.') level++;
        while (items.size() > level + 1) items.pop_back();
        G[items.back()].push_back(i+1);
        items.push_back(i+1);
        T[i] = S[i].substr(level);
    }
    function<void(int, string)> recur = [&](int id, string acc) {
        if (id != 0) {
            if (acc.size() == 1) {
                cout << T[id-1] << '\n';
            } else {
                for (int j = 1; j < acc.size()-1; j++) {
                    cout << acc[j];
                }
                cout << '+' << T[id-1] << '\n';
            }
        }
        for (int i = 0; i < G[id].size(); i++) {
            if (i + 1 < G[id].size()) {
                recur(G[id][i], acc + '|');
            } else {
                recur(G[id][i], acc + ' ');
            }
        }
    };
    recur(0, "");
}

int main()
{
    int N;
    for (;;) {
        cin >> N;
        if (N == 0) break;
        vector<string> S(N); for (auto &s : S) cin >> s;
        solve(N, S);
    }
    return 0;
}


Measured memory_bytes: 5048
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;
}
#endif 


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

    string S; cin >> S;
    int N = S.size();
    int X, Y; cin >> X >> Y;

    vs v = split(S, 'T');
    vi dx, dy;
    bool odd = true;
    for (string s : v) {
        if (odd) dx.push_back(s.size());
        else dy.push_back(s.size());
        odd = !odd;
    }

    int dxL = dx.size();
    int dyL = dy.size();
    if (dxL == 0 && dyL == 0) {
        if (X == 0 && Y == 0) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }

    auto dpx = vvb(N, vb(N * 2 + 1, false));
    auto dpy = vvb(N, vb(N * 2 + 1, false));

    if (dxL > 0) {
        dpx[0][N + dx[0]] = true;
        for (int i = 1; i < dxL; i++) {
            for (int x = -N; x <= N; x++) {
                if (dpx[i - 1][N + x]) {
                    dpx[i][N + x + dx[i]] = true;
                    dpx[i][N + x - dx[i]] = true;
                }
            }
        }
    }

    if (dyL > 0) {
        dpy[0][N + dy[0]] = true;
        dpy[0][N - dy[0]] = true;
        for (int i = 1; i < dyL; i++) {
            for (int y = -N; y <= N; y++) {
                if (dpy[i - 1][N + y]) {
                    dpy[i][N + y + dy[i]] = true;
                    dpy[i][N + y - dy[i]] = true;
                }
            }
        }
    }

    string ans = "No";
    if (dpx[dxL - 1][N + X]) {
        if (dyL == 0 || dpy[dyL - 1][N + Y]) ans = "Yes";
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    int K;
    string S;
    cin >> K;
    cin >> S;
    if (S.length() > K){
        for (int i=0; i<K; i++){
            printf("%c", S[i]);
        }
        printf("...\n");
    } else{
        cout << S << endl;
    }
    return 0;
}

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


#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define fr(i,a,b) for(int i = a ; i < b ; ++i)
#define backfr(i,a,b) for(int i = a ; i > b ;--i)
#define all(v) v.begin() , v.end()
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define show(x) cout << #x <<" = " << x << endl
#define fastio ios_base::sync_with_stdio(0)

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

int main()
{
	fastio;cin.tie(0);cout.tie(0);
	long long int h,n,sum=0;
	cin>>h>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>=h)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const int H_MAX = 100;
const int W_MAX = 100;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    char tile[H_MAX][W_MAX];
    cin >> a >> b;

    REP(i, H_MAX)REP(j, W_MAX)
        tile[i][j] = j < W_MAX / 2 ? '#' : '.';

    REP(i, a - 1) tile[i * 2 / (W_MAX / 2) * 2][i * 2 % (W_MAX / 2)] = '.';
    REP(i, b - 1) tile[i * 2 / (W_MAX / 2) * 2][W_MAX / 2 + i * 2 % (W_MAX / 2) + 1] = '#';

    cout << H_MAX << " " << W_MAX << endl;
    REP(i, H_MAX) {
        REP(j, W_MAX) cout << tile[i][j];
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<memory.h>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3,greater<int>());
  ll x=a[0]-a[2],y=a[1]-a[2];
  if(x==0 && y==0){
    if(a[0]%2==0 && a[1]%2==0 && a[2]%2==0){
      cout << -1 << endl;
      return 0;
    }else{
      cout << 0 << endl;
      return 0;
    }
  }
  ll cnt=0;
  while(x%2==0 && y%2==0){
    ll nx=max(x,y)/2;
    ll ny=abs(x-y)/2;
    x=nx;
    y=ny;
    cnt++;
  }
  cout << cnt << endl;
return 0;}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
// #define DEBUG_MODE
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(x) fprintf(stderr, "[%s = %d]\n", #x, x)
#else
	#define errp(...)
	#define dbg(x) 
#endif

int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int a, b, t;
	scanf("%d%d%d", &a, &b, &t);
	printf("%d\n", b * (t / a));
}

Measured memory_bytes: 128
N,K=map(int,input().split())
L=list(map(int,input().split()))
ans=float("inf")
for i in range(N-K+1):
	ans=min(ans,(abs(0-L[i])+abs(L[i]-L[i+K-1])),(abs(0-L[i+K-1])+abs(L[i]-L[i+K-1])))
print(ans)

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


#define ll long long

ll cnt = 0;
void swap(int& a, int& b){
	int tmp = a;
	a = b;
	b = tmp;
}

void insertionSort(int A[], int n, int g) {
	for(int i=g;i<n;i++){
		int v = A[i];
		int j = i - g;
		// cout << "g=" << g << "i=" << i << "j=" << j << endl;
		while( j>= 0 && A[j] > v) {
			// cout << "g=" << g << "i=" << i << "j=" << j << endl;
			A[j + g] = A[j];
			j -= g;
			cnt++;
			// cout <<" cnt=" << cnt << endl;
		}
		A[j + g] = v;
	}
}

// void shellSort(int A[], int n, vector<int> G[]){
//
// }


int main(){
	int N; cin >> N;
	int a[N];
	vector<int> G;
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	int h = 1;
	while(h<=N){
		G.push_back(h);
		h = 3 * h + 1;
	}
	cout << G.size() << endl;
	for(int i=G.size()-1;i>=0;i--){
		cout << G[i];
		if(i) cout << " ";
	}
	cout << endl;
	for(int i = G.size()-1;i>=0;i--){
		insertionSort(a, N, G[i]);
	}
	cout << cnt << endl;
	for(int k=0;k<N;k++){
		cout << a[k] << endl;
	}
	return 0;
}



Measured memory_bytes: 7000
//
//  main.cpp
//  CP-C++
//
//  Created by ALOK KUMAR THAKUR on 05/05/20.
//  Copyright © 2020 ALOK KUMAR THAKUR. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define tc() ll T;cin>>T;while(T--)
#define pb push_back
#define Max3(a,b,c) max(a,max(b,c))
#define Min3(a,b,c) min(a,min(b,c))
#define all(v) v.begin(),v.end()

struct cmp {
    bool operator() (const ll& a, const ll& b){
        return a < b;
    }
};

int main() {
    
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    /*-----------------Code Begins Here------------------*/
    
    ll n; cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++) cin>>a[i];
    ll maxi = a[0], ans = 0;
    for(ll i=0;i<n;i++){
        if(a[i] > maxi) maxi = a[i];
        else ans += (maxi-a[i]);
    }
    cout<<ans;

    /*------------------Code Ends Here-------------------*/
    
    return 0;
}


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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
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;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5;

int n;
vi p, q;
int pp = 0, pq = 0;

int fact(int n)
{
    if (n == 0)
    {
        return 1;
    }
    return fact(n - 1) * n;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    p.resize(n);
    q.resize(n);
    for0(i, n)
    {
        cin >> p[i];
    }
    for0(i, n)
    {
        cin >> q[i];
    }
    vi cur(n);
    iota(all(cur), 1);
    for0(i, fact(n))
    {
        if (cur == p)
        {
            pp = i;
        }
        if (cur == q)
        {
            pq = i;
        }
        next_permutation(all(cur));
    }
    cout << abs(pp - pq);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,a,b) for(int i = (a); i < (b); i++)
 
bool take[310][310];
int dp[310][310];
 
signed main() {
    int n;
    while(cin >> n, n) {
        int w[310];
        rep(i,0,n) cin >> w[i];
        memset(take, false, sizeof(take));
        memset(dp, 0, sizeof(dp));
 
        rep(i,0,n) {
            rep(j,0,n-i) {
                int len = i+1;
                int s = j, t = j+i;
                rep(k,s,t) {
                    if(take[s][k] && take[k+1][t]) take[s][t] = true;
                }
                if(len == 2) {
                    if(abs(w[s] - w[t]) < 2) {
                        take[s][t] = true;
                    }
                }
                if(take[s][t]) {
                    int x = s-1, y = t+1;
                    while(1) {
                        if(x < 0 || x >= n || y < 0 || y >= n) break;
                        if(abs(w[x] - w[y]) >= 2) break;
                        take[x][y] = true;
                        x--; y++;
                    }
                }
            }
        }
 
        rep(i,0,n) rep(j,i+1,n) {
            if(take[i][j]) dp[i][j] = j-i+1;
        }
 
        rep(i,0,n) rep(j,i,n) rep(k,i,j) {
            dp[i][j] = max(dp[i][j], dp[i][k] + dp[k+1][j]);
        }
        cout << dp[0][n-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

ll fac[202020];

int main(){
  
  fac[0]=1;
  rep(i,200002) fac[i+1]=fac[i]*2%MOD;
  
  int N; cin>>N;
  ll C[N]; rep(i,N) cin>>C[i];
  sort(C,C+N);
  reverse(C,C+N);
  
  ll ans=0;
  rep(i,N){
    ll mul=fac[i];
    if(i) mul=(mul+i*fac[i-1])%MOD;
    mul=(mul*C[i])%MOD*fac[N-1-i]%MOD;
    ans=(ans+mul)%MOD;
  }
  cout<<ans*fac[N]%MOD<<endl;
  return 0;
}

Measured memory_bytes: 3328
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int[] A = new int[N];
        for(int i=0;i<N;i++){
            A[i] = int.Parse(str[i]);
        }
        int[] B = new int[N];
        int rest = N;
        int p = N;
        bool b = true;
        for(int i=N-1;i>=0;i--){
            if(b){
                p -= rest;
            }
            else{
                p += rest;
            }
            b = !b;
            B[p] = A[i];
            rest--;
        }
        for(int i=0;i<N;i++){
            sb.Append(B[i]);
            if(i != N-1){
                sb.Append(" ");
            }
            else{
                sb.Append("\n");
            }
        }
    }
}

Measured memory_bytes: 44600
#include <stdio.h>
int main(void){
    int cards[128][14] = {{0}};
    int i, n, num;
    char c;
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
    scanf("%c", &c);
    scanf("%c %d", &c, &num);
    cards[c][num] = 1;

  }
    for(i = 1; i <= 13; i++) {
        if(cards['S'][i] == 0) {
            printf("S %d\n", i);
        }
    }
    for(i = 1; i <= 13; i++) {
        if(cards['H'][i] == 0) {
            printf("H %d\n", i);
        }
    }
    for(i = 1; i <= 13; i++) {
        if(cards['C'][i] == 0) {
            printf("C %d\n", i);
        }
    }
    for(i = 1; i <= 13; i++) {
        if(cards['D'][i] == 0) {
            printf("D %d\n", i);
        }
    }
}


Measured memory_bytes: 2064