akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = TEN(9) + 7;
inline void add(ll &x, ll y) { x += y; if (x >= MOD) x %= MOD; }

const int maxn = 5010;

int N;
V<int> g[maxn];
int sz[maxn], mc[maxn];
ll fac[maxn];
int par[maxn];
ll comb[maxn][maxn];

void dfs(int v, int p) {
	sz[v] = 1;
	par[v] = p;

	for (int to : g[v]) if (to != p) {
		dfs(to, v);
		sz[v] += sz[to];
		chmax(mc[v], sz[to]);
	}

	chmax(mc[v], N - sz[v]);
}

ll dp[maxn][maxn];

int main() {
	fac[0] = 1;
	rep(i, maxn - 1) {
		fac[i+1] = fac[i] * (i+1) % MOD;
	}

	rep(i, maxn) {
		comb[i][0] = comb[i][i] = 1;
		for (int j = 1; j < i; ++j) {
			comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % MOD;
		} 
	}

	cin >> N;

	rep(i, N-1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].pb(b);
		g[b].pb(a);
	}

	dfs(0, -1);

	int r = -1;

	rep(i, N) {
		if (r == -1 || mc[r] > mc[i]) {
			r = i;
		}
		if (sz[i] * 2 == N) {
			cout << fac[N/2] * fac[N/2] % MOD << endl;
			return 0;
		}
	}

	V<int> num;

	for (int to : g[r]) {
		if (to != par[r]) {
			num.pb(sz[to]);
		} else {
			num.pb(N-sz[r]);
		}
	}

	dp[0][0] = 1;

	int sz = num.size();
	rep(i, sz) {
		int x = num[i];
		rep(j, maxn) if (dp[i][j]) {
			for (int k = 0; k <= x; ++k) {
				ll coef = comb[x][k] * comb[x][k] % MOD * fac[k] % MOD;
				ll val = dp[i][j] * coef % MOD;
				if (k % 2 == 1) {
					val = (MOD - val) % MOD;
				}
				add(dp[i+1][j+k], val);
			}
		}
	}

	ll ans = 0;
	for (int i = 0; i <= N-1; ++i) {
		ll val = dp[sz][i] * fac[N - i] % MOD;
		add(ans, val);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 391040
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>
 
using namespace std;
 
/* template */
 
using ll = long long;
 
void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};
 
struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};
 
 
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;
 
template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}
 
template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
 
template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}
 
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;
	}
}
 
constexpr ll LNF = 1LL<<50;
 
constexpr int INF = 1e9+7;
 
const long double PI=3.14159265358979323846;
 
 
vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};
 
/* template */

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n>0){
        if(n&1) res = res *x%mod;
        x = x*x%mod;
        n>>=1;
    }
    return res;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,p; cin >> n >> p;
    string s; cin >> s;
    ll ans = 0;
    if(10%p==0){
        rep(i,0,n){
            if(ctoi(s[i])%p==0){
                ans += (i+1);
            }
        }
        cout << ans << endl;
        return 0;
    }
    vector<ll> c(p,0);
    ll tmp = 0;
    rrep(i,0,n){
        tmp += ctoi(s[i])*mod_pow(10ll,n-1-i,p);
        tmp %=p;
        ans += c[tmp];
        c[tmp]++;
        if(tmp==0) ans++;
    }
    cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair

using namespace std;

inline double Square(double x){
	return x*x;
}

struct Pos{
	double x,y;
};

pair<Pos,double> ComputeCircle(Pos p,Pos q,Pos r){
	double a=-2.0*(p.x-q.x);
	double b=-2.0*(p.y-q.y);
	double c=Square(p.x)+Square(p.y)-Square(q.x)-Square(q.y);
	double d=-2.0*(p.x-r.x);
	double e=-2.0*(p.y-r.y);
	double f=Square(p.x)+Square(p.y)-Square(r.x)-Square(r.y);
	double k=1.0/(b*d-a*e);
	double x=(c*e-f*b)*k;
	double y=-(c*d-f*a)*k;
	double rad=sqrt(Square(p.x-x)+Square(p.y-y));
	return MP(Pos{x,y},rad);
}

int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		Pos a,b,c;
		scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y);
		auto p=ComputeCircle(a,b,c);
		printf("%.3f %.3f %.3f\n",p.first.x,p.first.y,p.second);
	}
}

Measured memory_bytes: 3144
s = gets.chomp
t = gets.chomp
S = (s.unpack("C*")).sort
T = (t.unpack("C*")).sort{|a,b| b <=> a}

b = 0
i = 0
while b == 0 
    if i != s.length  && i != t.length
        if S[i] < T[i]
        b += 1
        puts 'Yes'
        elsif S[i] > T[i]
        b += 1
        puts 'No'
        elsif S[i] == T[i] 
        i += 1
        end
    elsif i == s.length && i == t.length
        b += 1
        puts 'No'
    elsif i  == s.length 
        b += 1
        puts 'Yes'
    elsif i == t.length
        b += 1
        puts 'No'
    end

end

Measured memory_bytes: 3836
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define min(a, b) ((a) < (b) ? (a) : (b))

int main(void)
{
    int n, l;
    int ans = 0, del = 100100100;
    scanf("%d%d", &n, &l);
    rep(i, n)
    {
        ans += l + i;
        del = min(abs(l + i), del);
    }

    if (ans >= 0)
        ans -= del;
    else
        ans += del;
    printf("%d\n", ans);
    return 0;
}

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

string tbl = "abcdefghijklmnopqrstuvwxyz.?! ";

int main() {
    string s;
    while (cin >> s) {
        int n = s.size();
        if (n % 2 == 1) {
            cout << "NA" << endl;
        } else {
            string ans = "";
            for (int i=0; i+1<n; i+=2) {
                int a = s[i] - '0';
                int b = s[i+1] - '0';
                if (1 <= a && a <= 6 && 1 <= b && b <= 5) {
                    ans = ans + tbl[(a-1) * 5 + (b-1)];
                } else {
                    ans = "NA";
                    break;
                }
            }
            cout << ans << endl;
        }
    }
    return 0;
}

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

#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 VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

const int max_n = 55;
const int mod = 1e9 + 7;

struct matrix {
  int A[max_n][max_n];
	int n;

  matrix(int x = 0,int _n = 0) {
		n = _n;
    memset(A, 0, sizeof A);
    FOR(i,0,n) A[i][i] = x;
  }

  friend matrix operator*(const matrix &a, const matrix &b) {
    lint mod2 = mod*1LL*mod;
    matrix res(0,a.n);
    FOR(i,0,a.n) FOR(j,0,a.n) {
      lint act = 0;
      FOR(k,0,a.n) {
        act+=a.A[i][k]*1LL*b.A[k][j];
        if(act>=mod2) act-=mod2;
      }
      res.A[i][j]=act%mod;
    }
    return res;
  }

	friend VI operator*(const matrix &a, const VI & v){
		VI res;
		FOR(i,0,a.n){
			lint act = 0;
			FOR(k,0,a.n){
				act+= a.A[i][k] * 1LL * v[k];
				act%= mod;
			}
			res.pb(act);
		}
		return res;
	}
};



matrix power(matrix a, lint b) {
  matrix res(1,a.n);
  for (; b; b >>= 1LL, a = a * a)
    if (b & 1LL) res = res * a;
  return res;
}



int main () {
	make(n);
	lint k; scanf("%lld", &k);
	matrix m;
	m.n = n;
	FOR(i,0,n) {
		FOR(j,0,n) {
			make(a);
			m.A[i][j] = a;
		}
	}
	matrix res = power(m, k);
	lint ans = 0;
	FOR(i,0,n) FOR(j,0,n) ans += res.A[i][j];
	printf("%lld\n", ans % mod);
}	





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define endl '\n'
#define mod 998244353
#define pi 3.14159265358979323846
#define rep(i,a,b) for(int i=a;i<b;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define inf INT_MAX
#define maxx 2*100000 + 5

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

    string str;
    cin >> str;
    if(str[2] == str[3] && str[4] == str[5]) cout << "Yes";
    else cout << "No";
    return 0;
}

 

Measured memory_bytes: 256
#include<iostream>
#include<string>
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] - '0';
	}
	cout << (n % sum == 0 ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
count = 0
outs = []
max_a = max(a)
max_index = a.index(max(a))
min_a = min(a)
min_index = a.index(min(a))
flag = -1
if 0 <= min_a:
  flag = 0
elif max_a <= 0:
  flag = n
elif max_a > -1 * min_a:
  flag = 0
  for i in range(0,n):
    if a[i] < 0:
      a[i] += max_a
      outs.append(str(max_index + 1) + " " + str(i + 1))
      count += 1
elif max_a <= -1 * min_a:
  flag = n
  for i in range(0,n):
    if a[i] > 0:
      a[i] += min_a
      outs.append(str(min_index + 1) + " " + str(i + 1))
      count += 1

if flag == 0:
  for i in range(0, n-1):
    a[i+1] += a[i]
    outs.append(str(i + 1) + " " + str(i + 1 + 1))
    count += 1
elif flag == n:
  for i in range(1, n):
    a[n-i-1] += a[n-i]
    outs.append(str(n - i + 1) + " " + str(n - i - 1 + 1))
    count += 1
    
print(count)
for out in outs:
  print(out)

Measured memory_bytes: 3064
n,t = map(int,input().split())
tl = list(map(int,input().split()))
ans = 0
for i in range(1,n):
    if tl[i] >= t and tl[i] - tl[i-1] >= t:
        ans+=t
    else:
        ans+=tl[i] - tl[i-1]
print(ans+t)

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

int main() {
  long long N, K;
  
  cin >> N >> K;
  
  long long p[N];
  long long q[N], r[N-K];
  
  for (int i=0; i<N; i++){
    cin >> p[i];
    q[i]=(p[i]+1)*5;    
  }
  
  r[0] = 0;
    
  for (int i=0; i<K; i++){
    r[0] += q[i];
  }
  
  for (int i=0; i<N-K; i++){
    r[i+1] = q[K+i] - q[i] + r[i];
  }
  
  sort (r, r+N-K+1, greater<long long>());
  
  cout << fixed << setprecision(15);
  cout << (double)r[0]/10 << endl;

}



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

int main(){
	string s;
	cin >> s;
	if(s == "SUN") cout << 7 << endl;
	if(s == "MON") cout << 6 << endl;
	if(s == "TUE") cout << 5 << endl;
	if(s == "WED") cout << 4 << endl;
	if(s == "THU") cout << 3 << endl;
	if(s == "FRI") cout << 2 << endl;
	if(s == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 3628
ls = list(map(int, input().split()))
a = ls[0]
b = ls[1]
c = ls[2]
d = ls[3]

k = [x for x in range(0, 101) if a <= x <= b and c <= x <= d]

if not k:
    print(0)
else:
    print(max(k) - min(k))


Measured memory_bytes: 3060
import itertools
#TLE

N,M,R = map(int,input().split())
rs = list(map(lambda x:int(x)-1,input().split()))
cost=[[10**9]*N for i in range(N)]
for i in range(M):
    a,b,c = map(int,input().split())
    cost[a-1][b-1] = c
    cost[b-1][a-1] = c

for k in range(N):
    for i in range(N):
        for j in range(i):  # j<i
            cost[i][j] =  min(cost[i][j],cost[i][k] + cost[k][j])
            cost[j][i] = cost[i][j]

ans = 10**9
for roads in itertools.permutations(rs):
    co = 0
    p = roads[0]
    for r in roads[1:]:
        co += cost[p][r]
        p = r
    ans = min(ans,co)
print(ans)


Measured memory_bytes: 49244
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

x=ii()

ans=1

for i in range(1,x+1):
    for j in range(2,11):
        if i**j<=x:
            ans=max(ans,i**j)
print(ans)


Measured memory_bytes: 65516
using System;

namespace QuestionB
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            var result = 0;
            for(int i = 0 ; i <= (s.Length - t.Length) ; i++)
            {
                var sliced = s.Substring(i,t.Length);
                var sameCharNum = CountSameChar(sliced,t);
                if(sameCharNum > result)
                {
                    result = sameCharNum;
                }
            }

            Console.WriteLine(t.Length - result);
        }

        static int CountSameChar(string a, string b)
        {
            var count = 0;
            for(int i=0; i < a.Length; i++)
            {
                if(a[i] == b[i])
                {
                    count++;
                }
            }
            return count;
        }
    }
}


Measured memory_bytes: 26096
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int MAXX = 100000;

int tab[MAXX + 5], NP[MAXX + 5], P[MAXX + 5], n, i, indP1, indP2, indNP1, indNP2, r;

int get(int a, int b) {
	int res = 0;
	for (int i=0;i<n;i++) {
		if (i%2 && tab[i] != b) res++;
		if (!(i%2) && tab[i] != a) res++;
	}
	return res;
}

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) {
	scanf("%d", &tab[i]);
	if (i%2) NP[tab[i]]++; else P[tab[i]]++;
}
indP1 = indP2 = indNP1 = indNP2 = -1;
for (i=1;i<=MAXX;i++) {
	if (indP1 == -1 || P[i] > P[indP1]) {
		indP2 = indP1;
		indP1 = i;
	} else if (indP2 == -1 || P[i] > P[indP2]) {
		indP2 = i;
	}
	if (indNP1 == -1 || NP[i] > NP[indNP1]) {
		indNP2 = indNP1;
		indNP1 = i;
	} else if (indNP2 == -1 || NP[i] > NP[indNP2]) {
		indNP2 = i;
	}
}
r = INF;
if (indP1 != indNP1) r = min(r, get(indP1, indNP1));
if (indP2 != -1) r = min(r, get(indP2, indNP1));
if (indNP2 != -1) r = min(r, get(indP1, indNP2));
if (r == INF) r = n / 2;
printf("%d\n", r);	
return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
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)

typedef long long ll;

int h, w, ans;
int dx[4] = {1,-1,0,0} , dy[4] = {0,0,1,-1};

bool isok(int i, int j){
    return i>=0 && i<h && j>=0 && j<w;
}

int dfs(int i, int j, int s, vector<vector<int> > a){
    if (s>10) return 0;
    REP(k,4){
        int x = i+dx[k] , y = j+dy[k];
        if (!isok(x,y) || a[x][y]==1)
            continue;
        while (isok(x,y)){
            if (a[x][y]==3){
                ans = min(ans,s);
                break;
            }
            if (a[x][y]==1){
                a[x][y] = 0;
                x -= dx[k];
                y -= dy[k];
                dfs(x,y,s+1,a);
                a[x+dx[k]][y+dy[k]] = 1;
                break;
            }
            x += dx[k];
            y += dy[k];
        }
    }
    return 0;
}

int main(void) {
    while (cin >> w >> h && w){
        vector<vector<int> > a(h,vector<int> (w));
        int x,y;
        REP(i,h){
            REP(j,w){
                cin >> a[i][j];
                if (a[i][j]==2){
                    x=i;
                    y=j;
                    a[i][j] = 0;
                }
            }
        }
        ans = 11;
        dfs(x,y,1,a);

        if (ans>10)
            cout << -1 << endl;
        else
            cout << ans << endl;
    }

    return 0;
}

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

int main(){
  int n,m,tmp1,tmp2;
  cin >> n >> m;
  vector<int> town(n);
  for(int i=0;i<m;i++){
    cin >> tmp1 >> tmp2;
    town.at(tmp1-1)++;
    town.at(tmp2-1)++;
  }
  for(int i=0;i<n;i++){
    cout << town.at(i) << endl;
  }
}

Measured memory_bytes: 3564
#include <stdio.h>

int n, a[100];

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) { scanf("%d", &a[i]); }
	
	int min = 4000001;
	for(int i = -100; i <= 100; i++) { int sum = 0;
	for(int j =    0; j <    n; j++) {
		sum += (a[j] - i) * (a[j] - i);
	} if(sum < min) { min = sum; }
	}
	
	printf("%d\n", min);
	
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main
{
	public static void main( String args[] )
	{
		Scanner input = new Scanner(System.in);
		int h, w;
		while(true)
		{
			h=input.nextInt();
			w=input.nextInt();
			if(h == 0 && w == 0)
				break;
			else {
				for(int i = 0; i < h; i++)
				{
					for(int k = 0; k < w; k++)
					{
						System.out.print("#");
					}
					System.out.println();
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 37940
#include<stdio.h>
int main(){
    int i,x,y;
    for(i=1;;i++){
        scanf("%d %d",&x,&y);
        if(x==0 && y==0)break;
        if(x<y){
            printf("%d %d\n",x,y);
        }else{
            printf("%d %d\n",y,x);
        }
    }
}


Measured memory_bytes: 2048
import std;
void main () {
	long n, p;
	while (readf !(" %s") (n) > 0) {
		for (p = 26, n -= 1; p <= n; p *= 26) {
			n -= p;
		}
		for (p /= 26; p > 0; n %= p, p /= 26) {
			write (cast (char) (n / p + 'a'));
		}
		writeln;
	}
}


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

int main(){
		string s1,s2,p;
		int judge = 0;
		cin >> s1 >> p;
		s2 = s1 + s1;
		for(int i = 0;i < s1.size();i++){
				if( p == s2.substr(i, p.size())){
						judge = 1;
						break ;
				}
		}
		if(judge == 1) {
				cout << "Yes" << endl;
		}else{
				cout << "No" << endl;
		}
		return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(void){
  char S[3];
  char T[3];
  scanf("%s", S);
  scanf("%s", T);

  int ans = 0;

  if (S[0] == T[0]) {
    ans++;
  }
  if (S[1] == T[1]) {
    ans++;
  }
  if (S[2] == T[2]) {
    ans++;
  }
  printf("%d", ans);


}


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

int main()
{
	ll n; cin >> n;
	int ans = 0;
	for (ll i = 2, m = n; i*i <= m; ++i)
	{
		ll k = i;
		while (n % k == 0) 
		{
			ans++;
			n /= k;
			k *= i;
		}
		while (n % i == 0) 
			n /= i;
	}
	cout << ans + (n != 1) << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long int
using namespace std;

struct activity{
	int A, B, C;
};

int solve(vector<activity> ar,int n){
	int dp[n+1][3];
	
	dp[1][0] = ar[1].A;
	dp[1][1] = ar[1].B;
	dp[1][2] = ar[1].C;
 	
	for(int i=2;i<=n;i++){
		dp[i][0] = ar[i].A + max(dp[i-1][1],dp[i-1][2]); 
		dp[i][1] = ar[i].B + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = ar[i].C + max(dp[i-1][0],dp[i-1][1]);
	}	
	return max(dp[n][0],max(dp[n][1],dp[n][2]));
}

int32_t main() {
	
	int n;
	cin >> n;
	vector<activity>ar(n+1);
	for(int i=1;i<=n;i++){
		cin >> ar[i].A;
		cin >> ar[i].B;
		cin >> ar[i].C;
	} 
	
	cout << solve(ar,n) << endl;
	return 0;
}


Measured memory_bytes: 10284
N = gets.to_i
data = N.times.map { gets.split.map(&:to_i) }

t = 1
a = 1
n = 1

data.each do |x, y|
  n = [
    t % x == 0 ? t / x : t / x + 1,
    a % y == 0 ? a / y : a / y + 1
  ].max
  t = n * x
  a = n * y
end

puts a + t


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse
// struct Edge {
//   int to, id;
//   Edge(int a, int b): to(a), id(b) {}
// };

string field[1010];

ll dp[1010][1010];

int main () {

	int h,w;cin>>h>>w;

	rep(i,h) cin>>field[i];

	dp[0][0]=1;

	rep(i,h) {
		rep(j,w) {
			if (field[i+1][j]=='#') dp[i+1][j]=0;
			else dp[i+1][j]=(dp[i][j]+dp[i+1][j])%MOD;
			if (field[i][j+1]=='#') dp[i][j+1]=0;
			else dp[i][j+1]=(dp[i][j+1]+dp[i][j])%MOD;
		}
	}

	cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  string T=S.substr(0,(S.size()-1)/2),U=S.substr((S.size()+3)/2-1);
  for(int i=0;i<S.size()/2;i++)
    if(S[i]!=S[S.size()-1-i]){
      puts("No");
      return 0;
    }
  for(int i=0;i<T.size()/2;i++)
    if(T[i]!=T[T.size()-1-i]){
      puts("No");
      return 0;
    }
  for(int i=0;i<U.size()/2;i++)
    if(U[i]!=U[U.size()-1-i]){
      puts("No");
      return 0;
    }
  puts("Yes");
}

Measured memory_bytes: 3604
#include<stdio.h>

int main()
{
	int base, num, answer;
	int a, b, c,n=0;
	while (1)
	{
		answer = 0;
		scanf("%d%d", &base, &num);
		if (base == 0 && num == 0) break;
		for (a = 1; a <= base; a++)
		{
			for (b = a + 1; b <= base; b++)
			{
				for (c = b + 1; c <= base; c++)
				{
					if ((a + b + c) == num)
						answer = answer + 1;
				}
			}
		}
		printf("%d\n", answer);
	}
	

	return 0;
}

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

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 998244353;
int a[3005];
int dp2[3005][3005];

int dp[3005][3005];
int n, s;
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}

int solve(int id, int sum, int selected) {
    // debug(id, sum, selected);
    if(id == n and sum == 0) {
        // debug("here", id, sum, selected);
        // return power(2, n - selected);
        return 1;
    }
    else if(id == n)
        return 0;
    if(dp2[id][sum] != -1)
        return dp2[id][sum];
    int ans = 0;
    if(a[id] > sum) {
        ans = (1LL * 2 * solve(id + 1, sum, selected)) % mod;
    }
    else {
        ans += solve(id + 1, sum - a[id], selected + 1);
        ans %= mod;
        ans += (1LL * 2 * solve(id + 1, sum, selected)) % mod;
        ans %= mod;
    }

    return dp2[id][sum] = ans;
}
int main() {
    input;
    
    cin >> n >> s;
    for(int i = 0; i < n; i++)
        cin >> a[i];

    dp[0][0] = 1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= s; j++) {
            dp[i + 1][j] += (1LL * 2 * dp[i][j]) % mod;
            dp[i + 1][j] %= mod; 
            if(j + a[i] <= s) {
                dp[i + 1][j + a[i]] += dp[i][j];
                dp[i + 1][j + a[i]] %= mod;
            }
        }
    }
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= s; j++) {
            // cout << dp[i][j] << ' ';
        }
        // cout << endl;
    }
    cout << dp[n][s] << endl;
    // memset(dp2, -1, sizeof dp2);
    // cout << solve(0, s, 0);
}


Measured memory_bytes: 38800
import * as fs from 'fs'
import {debug} from '../../../util'

const input = fs.readFileSync('/dev/stdin', 'utf8').trim()

const output = (x: string | number | boolean): void => console.log(x)
const splitLine = (string: string): string[] => string.split('\n')
const splitBlank = (string: string): string[] => string.split(' ')
const toNumbers = (array: string[]): number[] => array.map(v => Number(v))
const range = (end: number, start: number = 0): number[] => [...Array(end - start)].map((v, i) => i + start)

// debug(input)

/* ここから */
const [X, N] = toNumbers(splitBlank(splitLine(input)[0]))
if (N === 0) {
	console.log(X)
} else {
	const p = toNumbers(splitBlank(splitLine(input)[1]))

	const absoluteValues = p.map(n => Math.abs(X - n))
	const index = Array(100).fill(-1)

	absoluteValues.map(n => {
		index[n] += 1
	})

	const result = index.findIndex((v, i) => {
		if (i === 0 && v === -1) {
			return true
		}
		if ((v === -1 || v === 0) && i !== 0) {
			return true
		}
	})

	const a = X - result
	const b = X + result
	if (p.find(v => v === a)) {
		console.log(b)
	} else {
		console.log(a)
	}
}


Measured memory_bytes: 29628
#include<bits/stdc++.h>
using namespace std;
int main() {
    int H,W;cin>>H>>W;
    vector<vector <char>> a(H,vector<char>(W));

    for(int i=0;i<H;i++){//入力
        for(int j=0;j<W;j++){//入力
            cin>>a.at(i).at(j);
        }
    }

    vector<bool> row(H,false),column(W,false);

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++) {
            if (a[i][j] == '#') {
                row[i]=true;
                column[j]=true;
            }
        }
    }

    for(int i=0;i<H;i++) {
        if (row[i] == true) {
            for (int j = 0; j < W; j++) {
                if (column[j] == true) {
                    cout << a[i][j];
                }
            }
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
def ceil_time(t)
  (t * 0.1).ceil * 10
end

cooking_minutes = STDIN.read.split(/\s+/).map(&:to_i)
ceiled_cooking_minutes = cooking_minutes.map { |t| ceil_time(t) }

max_item = -1
max_dt = -1
cooking_minutes.each.with_index { |t, i|
  dt = ceiled_cooking_minutes[i] - t
  if dt > max_dt
    max_dt = dt
    max_item = i
  end
}
ceiled_cooking_minutes.delete_at(max_item)
puts ceiled_cooking_minutes.reduce(0) { |a, x| a + x } + cooking_minutes[max_item]


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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define dupli(a)     unique(all(a)),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define f first
#define s second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e7+5;
int min_prime[lmt];

void seive(){
	loop(i,lmt)min_prime[i]=i;

	for(int ll i=2; i<lmt; i++){
		if(min_prime[i]==i){
			for(ll j=i*i; j<lmt; j+=i) min_prime[j]=i;
		}
	}
}

ll count(ll n){
	// return 0;
	ll ans=1;
	while(n>1){
		ll mp = min_prime[n];
		int cnt=1;
		while(n%mp==0){
			n /= mp; cnt++;
		}
		 ans = (cnt*ans);
	}
	return ans;
}

int main(){

 //    #ifndef ONLINE_JUDGE
 //    freopen("../input.txt", "r", stdin);
 //    freopen("../output.txt", "w", stdout);
	// #endif
    fast
    
    // pt("jdbshfjk");
    seive();

  	ll n;
  	cin>>n;

  	ll sum=0;
  	loop1(i,n){
  		sum+=i*count(i);
  	}

  	pt(sum);
}


/*

// 

*/

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,x;
ll s[201];
ll dp[201][e5];

ll factorial(ll n,ll mod = mod){
  static ll dp[100001];
  if(dp[n]) return dp[n];
  if(n == 0) return dp[n] = 1;
  return dp[n] = (n*factorial(n-1))%mod;
}

ll powl(ll x,ll r,ll mod = mod){
  ll ret = 1;
  for(;r != 0;r >>= 1){
    if(r&1 != 0) ret *= x,ret %= mod;
    x *= x,x %= mod;
  }
  return ret;
}

ll inverse(ll x,ll mod = mod){
  static ll dp[100001];
  if(dp[x]) return dp[x];
  return dp[x] = powl(x,mod-2,mod);
}

ll ans = 0;


int main(){
  cin >> n >> x;
  for(ll i = 0;i < n;i++) cin >> s[i];
  sort(s,s+n,greater<ll>());
  dp[0][x] = 1;
  for(ll i = 1;i <= n;i++){
    ll mem = 0;
    for(ll j = 0;j <= x;j++){
      dp[i-1][j] %= mod;
      dp[i][j] += ((dp[i-1][j] * (n-i) % mod) * inverse(n-i+1))%mod;
      dp[i][j] %= mod;
      dp[i][j%s[i-1]] += (dp[i-1][j] * inverse(n-i+1))%mod;
      dp[i][j%s[i-1]] %= mod;
      mem += dp[i-1][j];
    }
    if((mem%mod) != 1) return 1;
  }
  for(ll j = 0;j <= x;j++){
    ans += (dp[n][j]*j)%mod;
    ans %= mod;
  }
  cout << ((ans*factorial(n))%mod) << endl;

}


Measured memory_bytes: 410624
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
// #define endl "\n"

int main(void) {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    ll n;
    cin >> n;
    vector<double> dp (n+1, 0.0);

    dp[0] = 1;

    for (ll i = 0; i < n; i++) {
        double ph;
        cin >> ph;
        double pt = 1-ph;

        for (ll j = i+1; j >= 0; j--) {
            dp[j] = (j == 0 ? 0 : dp[j-1] * ph) + dp[j] * pt;
        }
    }
    
    double sum = 0;
    for (ll i = n/2 + 1; i < n+1; i++) {
        sum = sum + dp[i];
    }
    cout << setprecision(10) <<  sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	double x,y,x1,x2,y1,y2,d,distance;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	x=x2-x1;
	x=pow(x,2.0);
	y=y2-y1;
	y=pow(y,2.0);
	d=x+y;
	distance=sqrt(d);
	printf("%lf\n",distance);
	return 0;

	
}

Measured memory_bytes: 652
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  int a[30][30];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> a[i][j];
    }
  }

  static int dp[30][bit(22)];
  m0(dp);
  dp[0][0] = 1;

  for (int i = 0; i < N; i++) {
    for (int bit = 0; bit < bit(N); bit++) {
      if (i == bitcount(bit)) {
        for (int j = 0; j < N; j++) {
          if (a[i][j] == 1 && !bitcheck(bit, j)) {
            dp[i + 1][bit | bit(j)] += dp[i][bit] % MOD;
            dp[i + 1][bit | bit(j)] %= MOD;
          }
        }
      }
    }
  }

  cout << dp[N][bit(N) - 1] << endl;
  return 0;
}


Measured memory_bytes: 983424
#include <bits/stdc++.h>
using namespace std;
int main(){
   long a,b;
   cin >> a >> b;
   if(b-a+1 >= 2300)cout << 0 << endl;
   else{
       long min = 3000;
       for(long i=a;i<b;i++){
           for(long j=i+1;j<b+1;j++){
               long x = i%2019, y = j%2019;
               if((x*y)%2019 < min)min = x*y%2019;
           }
       }
       cout << min << endl;
   }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(NULL); cin.tie(NULL);

using namespace std;

long long n;
bool flag = false;

int main()
{
    fastIO
    cin>>n;
    
    long long tmp = 100;
    long long cnt = 0;
    
    while (tmp < n)
    {
        tmp = tmp + (tmp * 1/100);
        ++cnt;        
    }
    
    cout<<cnt;
}

Measured memory_bytes: 3644
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    vector<int> v(n), w(n);
    rep(i, n) cin >> v[i] >> w[i];

    vector<vector<int>> dp(n+1, vector<int>(W+1, -1));
    rep(i, W+1){
        dp[0][i] = 0;
    }
    for(int i = 1; i <= n; i++){
        for(int j = W; j >= 0; j--){
            if(j < w[i-1]){
                dp[i][j] = dp[i-1][j];
                continue;
            }
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
        }
    }
    cout << dp[n][W] << endl;

    return 0;
}



Measured memory_bytes: 10752
a = list(input())
b = list(input())
c = list(input())

nxt = a.pop(0)
while True:
    try:
        if nxt == 'a': nxt = a.pop(0)
        elif nxt == 'b': nxt = b.pop(0)
        else: nxt = c.pop(0)
    except:
        break
print(nxt.upper())

Measured memory_bytes: 3060
#include <iostream>
#include<stdio.h>
#include<string.h>

using namespace std;


int main(void){
    // Your code here!
    
    int d,t,s;
    
    scanf("%d %d %d",&d,&t,&s);
    
    if(  (double)d/s<=t ) puts("Yes");
    else puts("No");
    
    return 0;
}


Measured memory_bytes: 3760
n = int(input())
A = list(map(int, input().split()))
k = sum(A) / (n * (n + 1) // 2)
d = [a2 - a1 - k for a1, a2 in zip(A, A[1:] + A[0:1])]
for di in d:
    if di > 0 or di % n:
        print('NO')
        break
else:
    print('YES')

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int A, B; cin >> A >> B;
	int ans = -1;

	for (int i = 1; i < 10000; ++i) {
		int x = i * 8 / 100;
		int y = i * 10 / 100;
		if (x == A && y == B) {
			ans = i;
			break;
		}
	}

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


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int N;
    cin>>N;
    int L[N];
    for(int i=0;i<N;++i)cin>>L[i];

    int count=0;
    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            for(int k=j+1;k<N;++k){
                if(L[i]+L[j]>L[k]&&L[i]+L[k]>L[j]&&L[j]+L[k]>L[i]){
                    if(L[i]!=L[j]&&L[i]!=L[k]&&L[j]!=L[k]){
                        count++;
                    }
                }
            }
        }
    }
cout<<count;

}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
const int maxn=123456;
int n,m;
int l[maxn],r[maxn];
int a[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>m;
    rep(i,1,m)
    {
        cin>>l[i]>>r[i];
        a[l[i]]++;
        a[r[i]+1]--;
    }
    int sum=0,coun=0;
    rep(i,1,n)
    {
        sum+=a[i];
        if(sum==m)
        {
            coun++;
        }
    }
    cout<<coun<<"\n";


    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
using namespace std;
const long NMAX = 1000000;

int main(){
  int n, k;
  cin >> n >> k;
  
  vector<long> h(n+1);
  for(int i=1; i<=n; i++){
    cin >> h.at(i);
  }
  
  vector<long> dp(n+1);
  dp[1] = 0;
  
  for(int i=2; i<=n; i++){
    dp[i] = 1e13;

    for(int j=max(1, i-k); j<i; j++){
      dp[i] = min(dp[i], dp[j] + abs(h.at(j)-h.at(i)));
    }
  }

  cout << dp[n] << endl;
  
  return 0;
}


Measured memory_bytes: 1792
####################
####################
####################
####################
from heapq import*
i=input
for s in[0]*int(i()):
 n,x,*y=int(i()),[]
 for _ in'_'*n:
  k,l,r=map(int,i().split())
  if l>=r:s+=r;x+=[[k,r-l]]
  else:s+=l;y+=[[n-k,l-r]]*(k<n)
 for x in x,y:
  x.sort();h=[]
  for k,d in x:
   heappush(h,-d)
   if len(h)>k:heappop(h)
  for d in h:s+=d
 print(s)

Measured memory_bytes: 41904
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
using namespace std;
vector<long> memo;

int dp(vector<int>& vc,int num)
{
    if(memo[num] != -1) return memo[num];
    else{
        memo[num] =  min(dp(vc,num-1)+abs(vc[num]-vc[num-1]),dp(vc,num-2)+abs(vc[num]-vc[num-2]));
        return memo[num];
    }
}


int main()
{
    int N;
    cin >> N;
   
    int temp;
    vector<int> vc;
    for (int i = 0; i < N; i++)
    {
        cin >> temp;
        vc.push_back(temp);
        memo.push_back(-1);
    }
    
    memo[0]=0;
    memo[1] = abs(vc[0]-vc[1]);

    cout << dp(vc,N-1) << endl;
    
}

Measured memory_bytes: 4720
/*
Author: CNYALI_LK
LANG: C++
PROG: Cf2017C_A.cpp
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef long long ll;
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
char s[100];
int main(){
#ifdef cnyali_lk
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	scanf("%s",s);
	for(int i=0;i+1<strlen(s);++i)if(s[i]=='A'&&s[i+1]=='C'){
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;
}



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

// #define multitest 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;

void solve()
{
	int k, x;
	cin >> k >> x;
	set<int> S;
	for (int i = x - k + 1; i < x + k; ++i)
		cout << i << ' ';
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef WIN32
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> X(N, pair<int, int>(0, 0));
    for (int i = 0; i < N; i++)
    {
        cin >> X[i].first;
        X[i].second = i;
    }
    sort(X.begin(), X.end());
    int a = X[N / 2 - 1].first, b = X[N / 2].first;
    vector<int> ans(N, 0);
    for (int i = 0; i < N; i++)
    {
        if (i < N / 2)
        {
            ans[X[i].second] = b;
        }
        else
        {
            ans[X[i].second] = a;
        }
    }
    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4480
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/
 

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

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ppl                      pair < int , pll>           
#define    sp(x)                    setprecision(x)

int32_t main()
{       
    
    int n,k,sum=0;
    cin>>n>>k;
    int a[n+5];
    f(i,0,n-1)
        cin>>a[i];
    sort(a,a+n);
    if(k>=n)
        cout<<"0";
    else
    {
        for(int i=0;i<=n-k-1;i++)
            sum+=a[i];
        
        cout<<sum;
    }
    
}


Measured memory_bytes: 1792