akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())
    s = input()
    l = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
    ans = ""
    for i in list(s):
        ans = ans + l[(l.index(i)+n)%26]
    print(ans)
    
if __name__ == '__main__':
    main()

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

typedef long long ll;

const int INF = 100000000;

vector<int>a;

int main() {
    int N;
    cin >> N;
    vector<int>nums(N);
    for (int i = 1; i <= N; i++) {
        nums[i-1] = i;
    }

    vector<int>P(N);
    vector<int>Q(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> Q[i];
    }

    int cnt = 1;
    do {
        bool check1 = true;
        bool check2 = true;
        for (int i = 0; i < nums.size(); i++) {
            if (nums[i] != P[i]) {
                check1 = false;
            }
            if (nums[i] != Q[i]) {
                check2 = false;
            }
        }
        if (check1) {
            a.push_back(cnt);
        }
        if (check2) {
            a.push_back(cnt);
        }
        cnt++;
    } while (next_permutation(nums.begin(), nums.end()));
    cout << abs(a[0]-a[1]) << endl;
}


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

int main(){
  string s;
  cin >> s;
  rep(i,10){
    if(i == 3) cout << 8;
    else cout << s[i];
  }
  cout << endl;
}

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

int main()
{
  int n,m,l;

  cin >> n >> m >> l;

  int a[100][100] = {};
  int b[100][100] = {};

  for(int i =0;i < n;i++)
    {
      for(int j = 0;j < m;j++)
	{
	  cin >> a[i][j];
	}
    }
  for(int j =0;j < m;j++)
    {
      for(int k = 0;k < l;k++)
	{
	  cin >> b[j][k];
	}
    }

  long long c[100][100] = {};
  
  for(int i = 0;i < n;i++)
    {
      for(int j = 0;j < m;j++)
	{
	  for(int k = 0;k < l;k++)
	    {
	       c[i][k] += a[i][j]*b[j][k];
	    }
	}
    } 

  for(int i = 0;i < n;i++)
	{
	  for(int k = 0;k < l;k++)
	    {
	      if(k) cout << " ";
	      
	      cout << c[i][k];
	    }
	  cout << endl;
	}
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define x first
#define y second

using namespace std;

int solve()
{
	int in;
	for(int i=0;i<5;i++)
	{
		cin >> in;
		if(in ==0)
		{
			cout << i+1 << endl;
			return 0;
		}
	}
	return 0;
}
int main() 
{
	// freopen("a.in","r",stdin);
	solve();
	return 0;
}

Measured memory_bytes: 3584
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,k,c = map(int, input().split())
    s = input().rstrip()
    left = [0]*n
    day = 0
    temp = 1
    while day < n:
        if s[day] == 'o':
            left[day] = temp
            temp += 1
            day += c
        day += 1

    right = [0]*n
    day = n-1
    temp = k
    while 0 <= day:
        if s[day] == 'o':
            right[day] = temp
            temp -= 1
            day -= c
        day -= 1

    for i in range(n):
        if left[i] == right[i] and left[i] != 0:
            print(i+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 20984
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
max_a = A[-1]

dp = [0] * (K+1)

for a in A:
    dp[a] = 1

for i in range(1, K + 1):
    bl = False
    for a in A:
        if i - a < 0:
            break
        if dp[i - a] == 0:
            bl = True
            break
    dp[i] = 1 if bl else 0


ans = "First" if dp[K] else "Second"
print(ans)


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

int main(){
	int i,j;

	for(i = 1 ; i < 10 ; i++){
		for(j = 1 ; j < 10 ;j++){
			cout << i << 'x' << j << '=' << i*j << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 3076
#pragma gcc("OFast")
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds;
//template<typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define reunique(x) (x).resize(std::unique(all(x)) - (x).begin())
#define roflan ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ld long double
#define int long long

void SOLVE() {
	int n;
	cin >> n;
	if (n & 1) {
		cout << "0\n";
		return;
	}
	n /= 2;
	int res = 0;
	int cur = 5;
	while (cur <= n) {
		res += n / cur;
		cur *= 5;
	}
	cout << res << '\n';
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed;
	cout.precision(10);
	//freopen("longpath.in", "r", stdin);
	//freopen("longpath.out", "w", stdout);
	int Q = 1;
	//cin >> Q;
	while (Q--)
		SOLVE();

	return 0;
}
/*
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vll flag, D; vpll path;
//***********//
int main() { 
	cin >> N >> K;
	vl A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end());
	for (i = 0; i < K; i++) {
		ans += A[i];
	}
	cout << ans;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int n,m,k,x,y;
string S,T;
int main()
{
	scanf("%d%d%d%d%d",&n,&m,&k,&x,&y);
	cin>>S>>T;
	int tmpx=x,tmpy=y;
	for(int i=0;i<k;i++)
	{
		if(S[i]=='U') tmpx--;
		if(tmpx<1)
		{
			printf("NO");
			return 0;
		}
		if(T[i]=='D'&&tmpx!=n) tmpx++;
	}
	tmpx=x;
	for(int i=0;i<k;i++)
	{
		if(S[i]=='D') tmpx++;
		if(tmpx>n)
		{
			printf("NO");
			return 0;
		}
		if(T[i]=='U'&&tmpx!=1) tmpx--;
	}
	tmpx=x;
	for(int i=0;i<k;i++)
	{
		if(S[i]=='L') tmpy--;
		if(tmpy<1)
		{
			printf("NO");
			return 0;
		}
		if(T[i]=='R'&&tmpy!=m) tmpy++;
	}
	tmpy=y;
	for(int i=0;i<k;i++)
	{
		if(S[i]=='R') tmpy++;
		if(tmpy>m)
		{
			printf("NO");
			return 0;
		}
		if(T[i]=='L'&&tmpy!=1) tmpy--;
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 776
import java.util.*;


public class Main {
	public static int compute_max(int[] R) {
		int minprice = R[0];
	    int maxprofit = Integer.MIN_VALUE;
	    for (int i = 1; i < R.length; i++) {
	    	maxprofit = Math.max(maxprofit, R[i] - minprice);;
	    	minprice = Math.min(R[i],minprice);
	    	}
	    return maxprofit;
	    }

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] m = new int[n];
		for (int i = 0; i < n; i++) {
			m[i] = in.nextInt();
		}
		System.out.println(compute_max(m));
	}

}




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

using namespace std;

int N, X, Y, cnt = 0;
vector<int> AdjList[100005];
int dist[100005], onroute[100005];
vector<int> path, perm1, perm2;

void dfs(int x, int p){
	for (auto it : AdjList[x]){
		if (it == p) continue;
		dist[it] = dist[x] + 1;
		dfs(it,x);
	}
}

int route(int x, int t, int p){
	if (x == t) return 1;
	for (auto it : AdjList[x]){
		if (it == p) continue;
		if (route(it,t,x)){
			path.push_back(it);
			return 1;
		} 
	}
	return 0;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i < N; ++i){
		cin >> X >> Y;
		AdjList[X].push_back(Y);
		AdjList[Y].push_back(X);
	}
	dist[1] = 0;
	dfs(1,-1);
	int maxi1 = -1e9, maxdex1 = -1;
	for (int i = 1; i <= N; ++i){
		if (dist[i] > maxi1){
			maxi1 = dist[i];
			maxdex1 = i;
		}
		dist[i] = 0;
	}
	dfs(maxdex1,-1);
	int maxi2 = -1e9, maxdex2 = -1;
	for (int i = 1; i <= N; ++i){
		if (dist[i] > maxi2){
			maxi2 = dist[i];
			maxdex2 = i;
		}
	}
	route(maxdex1,maxdex2,-1);
	path.push_back(maxdex1);
	for (auto it : path) onroute[it] = 1;
	for (auto it : path){
		cnt++;
		for (auto ad : AdjList[it]){
			if (!onroute[ad]) cnt++;
		}
	}
	if (cnt != N){
		cout << -1 << '\n';
		return 0;
	}
	int p = 1, last = 1;
	for (int i = 0; i < path.size(); ++i){
		if (i == 0){
			perm1.push_back(1);
		}
		else{
			for (auto it : AdjList[path[i]]){
				if (!onroute[it]){
					p++;
					perm1.push_back(p);
				}
			}
			perm1.push_back(last);
		}
		p++;
		last = p;
	}
	reverse(path.begin(),path.end());
	p = 1, last = 1;
	for (int i = 0; i < path.size(); ++i){
		if (i == 0){
			perm2.push_back(1);
		}
		else{
			for (auto it : AdjList[path[i]]){
				if (!onroute[it]){
					p++;
					perm2.push_back(p);
				}
			}
			perm2.push_back(last);
		}
		p++;
		last = p;
	}
	if (perm1 > perm2) swap(perm1,perm2);
	for (auto it : perm1){
		cout << it << ' ';
	}
	cout << '\n';
}

Measured memory_bytes: 14584
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
  const ld pi = 3.14159265358979;
 ld r;
  cin>>r;
  cout<<fixed<<setprecision(16)<<2*r*pi;
	
}

Measured memory_bytes: 3740
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long 

int Mul(int a, int b) {
	return ((a % mod) * (b % mod)) % mod;
}

int square(int x) {
	return (x * x) % mod;
}

int power(int x, int y) {
	if (y == 0) return 1;
	else if (y == 1) return x % mod;
	else if (y % 2 == 0) return square(power(x, y / 2)) % mod;
	else return square(power(x, y / 2)) * x % mod;
}

int gcd(int a, int b) {
    if(a < b) return gcd(b, a);
    else if(b == 0) return a;
    else return gcd(b, a % b);
}
typedef pair<int, int> P;
map<P, int> mp;

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int A[200010], B[200010];
    int k = 0;
    rep(i, n) cin >> A[i] >> B[i];
    rep(i, n) {
        if(A[i] == 0 && B[i] == 0) {k++; continue;}
        if (B[i] < 0) {
            A[i] = -A[i];
            B[i] = -B[i];
        }
        int G = gcd(abs(A[i]), B[i]);
        if(A[i] < 0 && B[i] == 0) G *= -1;
        A[i] /= G;
        B[i] /= G;
        mp[{A[i], B[i]}]++;
        //cout << A[i] << " " << B[i] << endl;
    }
    int ans = 1;
    rep(i, n) {
        P p;
        if(A[i] <= 0) {
            p = make_pair(B[i], -A[i]);
        } else {
            p = make_pair(-B[i], A[i]);
        }
        int c1 = mp[{A[i], B[i]}], c2 = mp[p];
        if(c1 == 0 && c2 == 0) continue;
        int c = (power(2, c1) + power(2, c2) - 1 + mod) % mod;
        ans = Mul(ans, c);
        mp[{A[i], B[i]}] = 0;
        mp[p] = 0;

    }
    cout << (ans + mod - 1 + k) % mod << endl;




    return 0;
}
// {0, 1}, {1, 0}, {0, 0}
// {1, 0}, {0, 0}
// {0, 0}

Measured memory_bytes: 31700
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

/*
0のアスキー　"48"
*/

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

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

    char c = s.at(s.size()-1);
    if(c == 's')
        cout << s << "es" << endl;
    else
        cout << s << "s" << endl;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  vector<int> l(n);
  vector<int> target{a, b, c};
  for(int i = 0; i < n; ++i)
  {
    cin >> l[i];
  }

  sort(l.begin(), l.end());
  sort(target.begin(), target.end());

  int ans = 1 << 30;
  do
  {
    do
    {
      int ti = 0;
      int cost = 0;
      int now_len = 0;
      for(int li = 0; li < n; ++li)
      {
        if(ti >= 3) break;
        now_len += l[li];
        int guchoku_cost = abs(now_len - target[ti]);
        int gattai_cost = (li + 1 < n) ? abs(now_len + l[li + 1] - target[ti]) + 10 : 1000000;

        if (guchoku_cost < gattai_cost)
        {
          cost += guchoku_cost;
          now_len = 0;
          ti++;
        }
        else
        {
          cost += 10;
        }
      }
      if (ti >= 3)
      {
        ans = min(ans, cost);
      }
    } while(next_permutation(l.begin(), l.end()));
  } while(next_permutation(target.begin(), target.end()));
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(10) << ans << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

void Make(vector<int> &a,int x,int y){
    if(x==10){
        return;
    }
    int s = y * 10 + 3;
    int t = y * 10 + 5;
    int u = y * 10 + 7;
    a.push_back(s);
    a.push_back(t);
    a.push_back(u);
    Make(a,x+1,s);
    Make(a,x+1,t);
    Make(a,x+1,u);
}

int judge(int a){
    bool t = false;
    bool f = false;
    bool s = false;
    while(a != 0){
        int x = a%10;
        if(x==7){
            s = true;
        }
        if(x==5){
            f = true;
        }
        if(x==3){
            t = true;
        }
        a /= 10;
    }
    if(t&&f&&s){
        return 1;
    }
    else{
        return 0;
    }
}

signed main(){
    vector<int>a;
    Make(a,2,3);
    Make(a,2,5);
    Make(a,2,7);
    cin >> n;
    int ans = 0;
    REP(i,a.size()){
        if(a[i]<=n){
            if(judge(a[i]) == 1){
                //print(a[i])
                ans++;
            }
        }
    }
    print(ans);
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 640
while True:
    H,W = map(int,input().split())
    
    if H == W == 0:
        break
    
    for i in range(H):
        for j in range(W):

            if i%2 == 0:
                if j%2 == 0:
                    print("#",end="")
                else:
                    print(".",end="")
            else:
                if j%2 == 0:
                    print(".",end="")
                else:
                    print("#",end="")
                
        print()
    print()


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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int n, m, sum= 0;
    cin>> n >> m;

    int a[n];

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

    sort(a, a+n, greater<int>());

    cout <<(a[m-1] <  ( sum/(4.0*m)) ? "No\n" :"Yes\n");


            return 0;
}




Measured memory_bytes: 3620
n=int(input())
qi=0
for i in range(1000):
    if i*(i+1) ==n*2:
        qi=i
if qi==0 : 
    print("No")
    exit()
print("Yes")
print(qi+1)
from itertools import combinations as com
A=[[] for i in range(qi+1)]
now=1
for i,j in com([i for i in range(qi+1)],2):
    A[i].append(now) ; A[j].append(now)
    now+=1

for i in range(qi+1):
    print(qi, *A[i])

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

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

Measured memory_bytes: 3708
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] t = sc.nextLine().split("");
        int flag = 0;
        for(int i = 0;i<s.length();i++){            
            StringBuilder sb = new StringBuilder();
            for(int j = 0;j<s.length();j++){
                if(j-i<0){
                    sb.append(t[j-i+s.length()]);
                }else{
                    sb.append(t[j-i]);
                }
            }
            if(s.equals(sb.toString())){
                flag++;
                break;
            }
            sb.setLength(0);
        }
        if(flag == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int a,b;
    cin >> a >> b;
    cout << lcm(a,b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ulli unsigned long long int
#define ld long double  
using namespace std; 

void solve() {
    unsigned int a, b , c;
    
    cin >> a >> b >> c;
    if (a == b && b == c) {
        if (a & 1) cout << 0 << "\n";
        else cout << "-1\n";
        return;
    }

    int counter = 0;
    while (!(a & 1 || b & 1 || c & 1)) {
        unsigned int temp1 = a, temp2 = b, temp3 = c;
        a = temp2 / 2 + temp3 / 2;
        b = temp1 / 2 + temp3 / 2;
        c = temp1 / 2 + temp2 / 2;
        counter++;
    }
    cout << counter << "\n";
}

int main() 
{ 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
  
    int t = 1; 
    //cin >> t; 
    while (t--) { 
        solve(); 
    } 
  
    cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
    return 0; 
} 


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

void solve(void) {
	int n;
	cin >> n;
	vector<int> dp(3, 0);
	for(int i = 0; i < n; ++i) {
		vector<int> new_dp(3, 0);
		vector<int> happiness(3, 0);
		for(auto&t : happiness) cin >> t;
		for(int j = 0; j < 3; ++j) {
			for(int k = 0; k < 3; ++k) {
				if(j != k) {
					new_dp[k] = max(new_dp[k], dp[j]+happiness[k]);
				}
			}
		}
		dp = new_dp;
	}
	cout << max({dp[0], dp[1], dp[2]}) << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
	return 0;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    int a[n];
    int max1=0,max2=0;
    int flag=0;
    f1(i,0,n)
    {
    	cin>>a[i];
    	if(a[i]>max1)
    		max1=a[i];
    }

    f1(i,0,n)
    {
    	if(a[i]==max1)
    		flag++;
    }

    f1(i,0,n)
    {
    	if(a[i]>max2&&a[i]<max1)
    		max2=a[i];
    }
    if(flag>1)
    	max2=max1;
    f1(i,0,n)
    {
    	if(a[i]==max1)
    		cout<<max2<<endl;
    	else
    		cout<<max1<<endl;
    }
    return 0;
}

Measured memory_bytes: 3200
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum - *max_element(a.begin(), a.end()) <= k) {
    cout << sum << "\n";
    return 0;
  }
  vector<int> mq;
  for (int i = 1; i * i <= sum; i++) {
    if (sum % i == 0) {
      mq.push_back(i);
      mq.push_back(sum / i);
    }
  }
  sort(mq.rbegin(), mq.rend());
  for (auto &d : mq) {
    auto b = a;
    for (int i = 0; i < n; i++) {
      b[i] %= d;
    }
    sort(b.begin(), b.end());
    auto c = b;
    for (auto &el : c) {
      if (el != 0) el -= d;
    }
    for (int i = 1; i < n; i++) {
      b[i] += b[i - 1];
    }
    for (int i = n - 2; i >= 0; i--) {
      c[i] += c[i + 1];
    }
    int mn = 1e11;
    for (int i = 0; i < n - 1; i++) {
      if (b[i] + c[i + 1] == 0) {
        mn = b[i];
        break;
      }
    }
    if (mn <= k) {
      cout << d << "\n";
      return 0;
    }
  }
}



Measured memory_bytes: 256
<?php
# スペース区切りの整数の入力
fscanf(STDIN, "%s", $a);
$fscanf = preg_split("//u", $a, -1, PREG_SPLIT_NO_EMPTY);
$price = 700;

if ($fscanf[0] == 'o') {
  $price += 100;
} 
if($fscanf[1] == 'o') {
  $price += 100;
}
if($fscanf[2] == 'o') {
  $price += 100;
}

# 出力
echo ($price);
?>

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);

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

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, p;
    cin >> n >> p;
    vint a(n);
    rep(i, n) cin >> a[i];

    int o = 0;
    rep(i, n) if (a[i]&1) o++;

    ll ans = 1ll << (n-1);
    if (!o) {
        if (p) ans = 0;
        else ans *= 2;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int x, y, z;
    cin >> x >> y >> z;
    
    
    
    cout << z << " " << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
import math
mod=10**9+7
if abs(n-m)>=2:
    print(0)
elif n==m:
    print((2*(math.factorial(n)%mod)*(math.factorial(m)%mod))%mod)
else:
    print(((math.factorial(n)%mod)*(math.factorial(m)%mod))%mod)


Measured memory_bytes: 46960
N, A, *XS = $stdin.read.split.map(&:to_i)
X = (XS + [A]).max

dp = Array.new(N+1){ Array.new(2*N*X) }

(0..N).each do |j|
  (0..2*N*X).each do |t|
    yj = XS[j-1] - A
    dp[j][t] = 
      if j == 0 
        t == N*X ? 1 : 0
      else
        dp[j-1][t] + ((0 <= t-yj && t-yj <= 2*N*X) ? dp[j-1][t-yj] : 0)
      end
  end
end
p dp[N][N*X]-1


Measured memory_bytes: 4604
fun main(args: Array<String>) = IO().exec {
    val a = long()
    val b = long()
    println(Math.max(Math.max(a+b, a-b), a*b))
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 31276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    ll N,K;
    cin>>N>>K;
    if(N%K==0)cout<<0;
    else cout<<1;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}

int main(){
  ll n; cin >> n;
  
  //string ans = "Yes";
  //string ans = "No";
  //string ans = "YES";
  //string ans = "NO";
  ll ans = 0;
  
  //cout << ans << endl;
  cout << (n - n / 2) / (double)n << endl;
}

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

using namespace std;

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int s = c;
    for (int j = 0; j < m; j++) {
      int a;
      cin >> a;
      s += a * b[j];
    }
    if (s > 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn];
int main() {
	int n;cin>>n;
	int t=0;
	for(int i=1;i<=n;i++) cin>>pre[i],t^=pre[i];
	for(int i=1;i<=n;i++) cout<<(t^pre[i])<<' ';    
    return 0;
}

Measured memory_bytes: 4416
from collections import Counter
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = [list(map(int, input().split())) for _ in range(q)]

ans = sum(a)
a = Counter(a)
for b, c in bc:
    ans += (c - b) * a[b]
    a[c] += a[b]
    a[b] = 0
    print(ans)


Measured memory_bytes: 39184
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int count = 0;

		Integer Array[] = new Integer[N];
		for(int i = 0; i < N; i++){
			Array[i] = sc.nextInt();
		}
		Arrays.sort(Array);
		for(int i = 0; i < N-2; i++){
			for(int j = i+1; j < N-1; j++){
				for(int k = j+1; k < N; k++){
					if(Array[k]<Array[i]+Array[j]){
						count++;
					}
				}
			}
		}

		System.out.println(count);

		sc.close();
	}
};


Measured memory_bytes: 27860
import sys
sys.setrecursionlimit(10 ** 8)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    H, W, D = ZZ()
    A = [ZZ() for _ in range(H)]
    Q = Z()
    query = [ZZ() for _ in range(Q)]

    pos = [(-1, -1) for _ in range(H*W+1)]
    for i in range(H):
        for j in range(W): pos[A[i][j]] = (i, j)
    cost = [0] * (H*W+1)

    def calc(now, c):
        cost[now] = c
        if now+D > H*W: return
        x, y = pos[now]
        nx, ny = pos[now+D]
        nc = abs(nx-x) + abs(ny-y) + c
        calc(now + D, nc)

    for n in range(1, D+1): calc(n, 0)

    for l, r in query: print(cost[r] - cost[l])

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 131916
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
using namespace std;

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

	int n;
	cin >> n;
	vector<int>height(n);
	for(int& i:height) cin >> i;

	vector<int>dp(n+1,INT_MAX);

	dp[0] = 0;
	for(int i=0;i<n;i++){
		for(int j=1;j<=2;j++){
			if(j+i < n) dp[j+i] = min(dp[j+i],dp[i] + abs(height[i]-height[i+j]));
		}
	}

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

	return 0;
}


Measured memory_bytes: 4028
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
static const double pi=3.141592653589793238462643383279;

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 r,d,x;
    cin >> r >> d >> x;
    for(int i=0;i<10;i++){
        int ans=r*x-d;
        cout << ans << endl;
        x=ans;
    }
}

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

int main() {
    int x[3];
    scanf("%d %d %d", &x[0], &x[1], &x[2]);
    for(int i=2; i>0; i--) {
        for(int j=0; j<i; j++){
            if(x[j] > x[j+1]) std::swap(x[j], x[j+1]);
        }
    }
    printf("%d %d %d\n", x[0], x[1], x[2]);
}


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

int main() {
  int a, b, c, d;
  int F;
  cin >> a >> b >> c >> d;
  int OOTJNY;
  OOTJNY = 0;
  int KYR;
  int YABAI;
    
  if(a > d || a == d){
    cout << d << endl;
  }
  else{
    KYR = a;
    F = a + b;
    if(F > d || KYR + b == d){
    cout << KYR << endl;
  }
  else{
    OOTJNY = KYR + b;
    YABAI = d - OOTJNY;
    KYR -= YABAI;
    cout << KYR << endl;
    //cout << "@" << OOTJNY << endl;
  }
    //cout << "@" << KYR << endl;
  }
  
  
  
  //cout << YABAI << endl;
  //cout << OOTJNY << endl;
    
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int N;
int ans;

int main()
{
	int x;
	int i,j;
	
	scanf("%d",&N);
	for(i=1; i<=N; i++)
	{
		scanf("%d",&x);
		while(x%2==0)
		{
			x/=2;
			ans++;
		}
	}
	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import numpy as np

A = np.zeros([3, 3], dtype=int)
M = np.zeros([3, 3], dtype=int)

for i in range(3):
    A[i] = list(map(int, input().split()))
B = list(int(input()) for _ in range(int(input())))

for b in B:
    M[A == b] = 1

if np.any(np.all(M==1, axis=0) == True) or np.any(np.all(M==1, axis=1) == True):
    print('Yes')
elif M[0,0]*M[1,1]*M[2,2]:
    print('Yes')
elif M[0,2]*M[1,1]*M[2,0]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 12428
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main(){
  string s;
  cin >> s;
  int n = s.length();
  s += "<";
  vector<long long> t(n+1,0);
  long long ans = 0;
  for(int i = 0; i < n; ++i){
    if(s[i] == '<') t[i+1] = t[i]+1;
  }
  for(int i = n-1; i >= 0; --i){
    if(s[i] == '>') t[i] = max(t[i],t[i+1]+1);
  }
  for(int i = 0; i <= n; ++i)
    ans += t[i];
  cout << ans << endl;
}


Measured memory_bytes: 4740
int main(void){
    int Num = 0, point = 0;
    double Distance = 0;
    scanf("%d %lf",&Num,&Distance);

    double x = 0, y=0;
    double D;

    for(int i = 0; i < Num; i++){
        scanf("%lf %lf",&x,&y);
        D = sqrt(x*x + y*y);
        if(D <= Distance)
            point++;
    }

    printf("%d",point);

    return 0;
}

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

#define int long long int 
#define endl "\n"
typedef long double ld ;


int32_t main() 
{
   
  /* #ifndef ONLINE_JUDGE 
   freopen("input.txt","r",stdin) ;
   freopen("output.txt","w",stdout);
   #endif */

   int A , B , C ;
   cin >> A >> B >> C ;
   cout<<min(C,B/A)<<endl;
   return 0 ;
  
}


Measured memory_bytes: 256
from collections import defaultdict
dd = defaultdict(int)
a=int(input())
li =[]
for i in range(a):
    b=input()
    li.append(b)
for b in li:
    dd[b] += 1
M = 1
l=[]
for i in dd.keys():
    if dd[i] > M:
        M = dd[i]
        l = []
        l.append(i)
    elif dd[i] == M:
        l.append(i)
    else:
        continue
l.sort()
for i in range(len(l)):
    print(l[i])

Measured memory_bytes: 35572
#include<stdio.h>
int main(void) {
	int n,count;
	count = 0;
	char s[50];
	if (scanf("%d%s", &n, s) == 1);

	for (int i = 0; i < n-2; i++) {
		if (s[i] == 'A'&&s[i + 1] == 'B'&&s[i + 2] == 'C') {
			count++;
		}
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}
  
int main() {
  int s, w;
  cin >> s >> w;
  if (s > w) {
    cout << "safe"  <<endl;
  }
  else {
    cout << "unsafe" <<endl;
  }
} 


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define endl '\n'  
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <mypair, vector<mypair>, greater<mypair> > min_heap;
const ll mod=1e9+7;
const ll inf=1e16;
const ll N=1e5+10;

int main()
{
	boost;
	string a,b;
	cin>>a>>b;
	int ans=0;
	for(int i=0;i<3;i++) if(a[i]==b[i]) ans++;
	cout<<ans;	

	return 0;
}

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

int main(int argc, char const *argv[]) {
    std::string S;
    long long K;
    std::cin >> S;
    std::cin >> K;
    bool flag = true;
    for (size_t i = 0; i < S.size(); i++) {
        if (S[i] != '1') {
            if (K < i + 1) {
                std::cout << 1 << '\n';
            } else {
                std::cout << S[i] << '\n';
            }
            flag = false;
            break;
        }
    }
    if (flag) {
        std::cout << 1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  string s; cin>>s;
  ll n = s.size();
  ll k; cin>>k;

  for (int i=0; i<n; i++) {
    if (s[i] == 'a') continue;
    int t = 26 - (s[i] - 'a');
    if (t <= k) {
      s[i] = 'a';
      k -= t;
    }
  }
  k %= 26;
  s[n-1] += k;
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define M 200005
#define ll long long
using namespace std;
const int P=1e9+7;
int n,s[M],B[M],m=0;
ll pr[M],dp[M];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d",&s[i]);
	for(int i=1;i<=n;i++)
		if(s[i]!=s[i-1])B[++m]=s[i];
	n=m;
	dp[0]=1;
	for(int i=1;i<=n;i++){
		dp[i]=(dp[i-1]+pr[B[i]])%P;
		pr[B[i]]=(pr[B[i]]+dp[i-1])%P;
	}
	printf("%d\n",dp[n]);
	return 0;
}


Measured memory_bytes: 4992
n,m=map(int,input().split())
a_list=list(map(int,input().split()))
a_sum=[0]
for i in range(n):
    Sum=(a_sum[i]+a_list[i])%m
    a_sum.append(Sum)
a_dict={}
for i in a_sum:
    if i in a_dict:
        a_dict[i]=a_dict[i]+1
    else:
        a_dict[i]=1
ans=0
for i in a_dict.values():
    ans=ans+i*(i-1)//2
print(ans)


Measured memory_bytes: 63256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,x,ans;
	cin>>a>>b>>c>>x;
	for(int i1=0;i1<=a;i1++)
	{
		for(int i2=0;i2<=b;i2++)
		{
			for(int i3=0;i3<=c;i3++)
			{
				if(i1*500+i2*100+i3*50==x)ans++;	
			} 
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N, A[20], B[20], C[20];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i], A[i]--;
    rep(i, 0, N) cin >> B[i];
    rep(i, 0, N - 1) cin >> C[i];

    int ans = 0;
    int pre = -2;
    rep(i, 0, N) {
        int eat = A[i];
        ans += B[eat];
        if(pre + 1 == eat) ans += C[eat - 1];
        pre = eat;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <fstream>
#include <cmath>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define ITER(c) __typeof((c).begin())
#define PB(e) push_back(e)
#define FOREACH(i, c) for(ITER(c) i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define PARITY(n) ((n) & 1)

typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

void shift(int &a, int &b, int &c, int &d){
  int tmp = a;
  a = b;
  b = c;
  c = d;
  d = tmp;
}

void rotx(vector<int> &v){
  shift(v[0], v[1], v[2], v[3]);
  shift(v[4], v[5], v[6], v[7]);
}

void roty(vector<int> &v){
  shift(v[0], v[1], v[5], v[4]);
  shift(v[6], v[7], v[3], v[2]);
}

void rotz(vector<int> &v){
  shift(v[0], v[4], v[7], v[3]);
  shift(v[1], v[2], v[6], v[5]);
}

vector<int> normalize(vector<int> v){
  vector<int> res = v;
  REP(i, 4){
    REP(j, 4){
      REP(k, 4){
        res = min(res, v);
        rotx(v);
      }
      roty(v);
    }
    rotx(v);
  }
  return res;
}

int main(){
  string line;
  while(getline(cin, line)){
    string tmp;
    istringstream in(line);

    int cc = 0;
    map<string, int> color;
    vector<int> v;
    
    while(in >> tmp){
      if(color.find(tmp) == color.end()) color[tmp] = cc++;
      v.push_back(color[tmp]);
    }
    
    vector<int> p(7);
    REP(i, 7) p[i] = i;

    set<vector<int > > oct_set;
    
    do{
      vector<int> oct(8);
      oct[7] = v[7];
      REP(i, 7) oct[p[i]] = v[i];
      oct_set.insert(normalize(oct));
    }while(next_permutation(ALL(p)));
    cout << oct_set.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 1356