akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int n,ans,a[N],b[N];
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)b[a[i]=read()]++;
	for(int i=1;i<=n;i++)ans+=b[i]*(b[i]-1)/2;
	for(int i=1;i<=n;i++)
	{
		int x=ans;
		x-=b[a[i]]*(b[a[i]]-1)/2;
		b[a[i]]--;
		x+=b[a[i]]*(b[a[i]]-1)/2;
		b[a[i]]++;
		printf("%lld\n",x);
	}
	
}

Measured memory_bytes: 7296
s = list(input())


if s[0] == "A":
    if len([True for c in s[2:-1:] if c == "C"]) == 1:
        s.remove("A")
        s.remove("C")
        for c in s:
            if not c.islower():
                print("WA")
                exit()
        print("AC")
        exit()
print("WA")


Measured memory_bytes: 2940
n, k = map(int, input().split())
la = list(map(int, input().split()))
mod = pow(10,9)+7

c = 0
for i in range(n):
    for j in range(n-i-1):
        jj = j+1+i
        if la[i] > la[jj]:
            c += 1

c2 = 0
for i in range(n):
    for j in range(n):
        if la[i] > la[j]:
            c2 += 1

a = c*k
b = c2*((k*(k-1))//2)


print((a+b)%mod)


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>

using namespace std;
typedef long long ll;

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

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, now=1;
  cin>>N;
  REP(i,N){
    int a;
    cin>>a;
    if(a==now){
      now++;
    }
  }
  if(now==1){
    cout<<-1<<endl;
  }else{
    cout<<N-now+1<<endl;
  }
}


Measured memory_bytes: 256
N,M,C = (int(i) for i in input().split()) 
B = [int(i) for i in input().split()]

a = 0
ans = 0

for i in range(N):
	a = 0
	A = [int(i) for i in input().split()]
	for g in range(M):
		a += A[g]*B[g]
	if a+C>0:
		ans+=1
print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        
      long sum = 0;
        for (int i = 1; i <= n; i++) {
            if (i % 3 != 0 && i % 5 != 0) {
                sum += i;
            }
        }
        System.out.print(sum);
    }
}


Measured memory_bytes: 32472
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(const T arr[], int n){std::cout << "["; for(int i = 0; i < n; ++i){ std::cout << arr[i] << ", "; } std::cout << "]" << std::endl;}
template<typename T> void view(T e){std::cout << e << std::endl;}
using namespace std;
typedef long long ll;

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    ll na = a, nb = b;
    if(a >= k) na = a - k;
    else if(a + b >= k) na = 0, nb = b - (k - a);
    else na = nb = 0;
    cout << na << " " << nb << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int N;
string n;
vector<string> V;
void dfs(string S) {
	//cout << S << endl;
	if (S.size() <= n.size()) {
		for (int i = 3; i <= 7; i += 2) {
			V.push_back(S + (char)(i + '0'));
			dfs(S + (char)(i + '0'));
		}
	}
}
int main()
{
	cin >> N;
	n = to_string(N);
	int ans = 0;
	dfs("");
	for (string S : V) {
		//cout << S << endl;
		ll num = 0;
		bool c3 = false, c5 = false, c7 = false;
		for (int i = 0; i < S.size(); i++) {
			if (S[i] == '3') c3 = true;
			if (S[i] == '5') c5 = true;
			if (S[i] == '7') c7 = true;
			num = num * 10 + S[i] - '0';
		}
		if (c3 && c5 && c7 && num <= N)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 7380
H,W=map(int,input().split())
S=[list(input()+'.') for i in range(H)]
S.append(['.']*(W+1))
a=[[0]*W for i in range(H)]
for y in range(H):
    for x in range(W):
        if S[y][x]=='.':
            a[y][x]=len([1 for i in range(-1,2) for j in range(-1,2) if S[i+y][j+x]=='#'])
        else: a[y][x]='#'
for i in a:print(''.join(list(map(str,i))))

Measured memory_bytes: 9172
#include <bits/stdc++.h>  // ver2.1.3
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define Pii pair<int,int>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int, vector<int>, greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a.back()<<endl
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n;
  cin >> n;
  vector<Vi> a(n,Vi(n-1));
  rep(i,0,n){
    rep(j,0,n-1){
      cin >> a[i][j];
      a[i][j]--;
    }
    reverse(ALL(a[i]));
  }
  queue<int> next,next2;
  
  rep(i,0,n){
    if(a[a[i].back()].back()==i) {
      next.push(i);
      next2.push(i);
    }
  }
  
  int day = 0,ct = 0,battle = 0,memo;
  
  
  while(ct < n*(n-1) ){
    set<int> kind;
    day++;
    battle = next.size();
    if(battle==0) {cout<<-1<<endl;return 0;}
    
    
    rep(i,0,battle){
      a[next.front()].pop_back();
      next.pop();
    }
    
    
    rep(i,0,battle){
      memo = next2.front();
      next2.pop();
      if(kind.count(memo)) continue;
      if(a[memo].size()==0 || a[a[memo].back()].size()==0) continue;
      if(a[a[memo].back()].back()==memo) {
        next.push(memo);
        next.push(a[memo].back());
        next2.push(memo);
        next2.push(a[memo].back());
        kind.insert(memo);
        kind.insert(a[memo].back());
      }

    }

    ct += battle;
  }
  
  
  cout << day << endl;
  
  /*Vout(a[0]);
  Vout(a[1]);
  Vout(a[2]);
  Vout(a[3]);
  
  while (!next2.empty()) {
    cout << next2.front() << endl;
    next2.pop();
  }*/

  
  return 0;
}


Measured memory_bytes: 8192
sy = gets.to_i

a_ary = gets.split(' ').map(&:to_i)
b_ary = gets.split(' ').map(&:to_i)
c_ary = gets.split(' ').map(&:to_i)

point = 0

sy.times do |n|
  i = a_ary[n] - 1

  point += b_ary[i]
  point += c_ary[i - 1].to_i if n != 0 && (a_ary[n] - 1) == a_ary[n - 1]
end

puts point


Measured memory_bytes: 3836
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

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

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N;
    cin >> N;
    VEC(int) A(N);
    READVEC(A);
    map<int, int> counter;
    for (int a : A)
        counter[a]++;

    lint maxArea = 0, maxSide = 0;
    for (auto pr : counter) {
        int side = pr.FIR, cnt = pr.SEC;
        if (cnt >= 4) {
            maxArea = max(maxArea, side * 1LL * side);
        }

        if (cnt >= 2) {
            maxArea = max(maxArea, maxSide * 1LL * side);
            maxSide = side;
        }
    }

    cout << maxArea << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 5376
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    ll n, k; cin >> n  >> k;
    vector<ll> da(n);
    rip(i,n,0) cin >> da[i];
    ll ok = 2000000000, ng = 0;
    while(ok-ng > 1) {
        ll cnt = 0;
        ll now = (ok + ng) /2;
        rip(i,n,0) {
            cnt += (da[i]+now-1)/now-1;
        }
        // cout << cnt MM now MM ok MM ng << '\n';
        if(cnt > k) {
            ng = now;
        }
        else {
            ok = now;
        }
    }
    cout << ok << endl;
}

Measured memory_bytes: 4788
#include <iostream>
#define mxn 100010
#define inf 10001
using namespace std;

int ar[mxn], dp[mxn];

int main() {
    int n, k; cin >> n >> k;
    fill(dp, dp+mxn, -1);
    for(int i=1; i<=n; ++i) cin >> ar[i];

    dp[1] = 0;

    for(int i = 2; i <= n; ++i) {
        dp[i] = (1 << 30);
        for(int j=1; j<=k && (i-j) > 0; ++j) {
            dp[i] = min(dp[i], dp[i-j] + abs(ar[i] - ar[i-j]));
        }
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    int a,b,m;
    cin>>a>>b;
    if(a>9||b>9)
    {
        cout<<-1;
        return 0;
    }
    else
    {
        m=a*b;
        cout<<m;
    }
    return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }

const int MAX_N = 500;
ll n,k;
ll a[MAX_N];
ll total;

int main()
{
  cin >> n >> k;
  forn(i,n) {
    cin >> a[i];
    total += a[i];
  }

  vl d;
  for (ll i = 1; i*i <= total; i++) {
    if (total % i == 0) {
      d.push_back(i);
      if (i != total/i) d.push_back(total/i);
    }
  }

  sort(d.begin(),d.end(),greater<ll>());

  ll res = 1;
  for (ll v : d) {
    vector<pli> inc; vl dec;
    ll total_dec = 0;
    forn(i,n) {
      ll x = a[i]/v*v;
      ll y = x+v;
      ll c1 = a[i]-x, c2 = y-a[i];
      inc.push_back(mp(c2,i));
      dec.push_back(c1);
      total_dec += c1;
    }

    sort(inc.begin(),inc.end());
    inc.push_back(mp(0,0));

    ll temp = LLONG_MAX;
    ll total_inc = 0;
    forn(i,n+1) {
      chmin(temp, total_inc+max(total_dec-total_inc,0LL));
      total_inc += inc[i].fst;
      total_dec -= dec[inc[i].snd];
    }

    if (temp <= k) {
      res = v;
      break;
    }
  }

  cout << res << endl;

  return 0;
}


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

int field, hand[50];

int main()
{
	int n, p;
	while (scanf("%d %d", &n, &p), n + p){
		field = p;
		memset(hand, 0, sizeof(hand));
		
		int now = 0;
		int res = 0;
		while (true){
			if (field > 0){
				field--;
				hand[now]++;
				
				if (field == 0 && hand[now] == p){
					res = now;
					break;
				}
			}
			else {
				field += hand[now];
				hand[now] = 0;
			}
			
			now = (now + 1) % n;
		}
		
		printf("%d\n", now);
	}
	
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

long min(long a, long b, long c) {
    return min(a, min(b, c));
}

int main() {
    long a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << min(a * b, b * c, c * a) << endl;
}


Measured memory_bytes: 256
M, D = gets.split.map(&:to_i)

ans = 0

(1..M).each do |m|
  (1..D).each do |d|
    d1, d10 = ("%02d" % d).chars.map(&:to_i)

    if d1 >= 2 && d10 >= 2 && m == d1 * d10
      ans += 1
    end
  end
end

puts ans


Measured memory_bytes: 1788
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect
INF = 10**18

if __name__ == "__main__":
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    preA = [0]
    for i in range(n):
        preA.append(preA[i] + a[i])
    preB = [0]
    for i in range(m):
        preB.append(preB[i]+b[i])
    ans = 0
    for i in range(n+1):
        if preA[i] <= k:
            find = bisect.bisect_right(preB,k-preA[i])
            ans = max(ans,find+i-1)
    print(ans)

Measured memory_bytes: 47848
#include<iostream>
#include<stdio.h>
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()

int main(void){
    int a, b;
    int add, sub, mul;
    int max;

    std::cin >> a >> b;

    add = a+b;
    sub = a-b;
    mul = a*b;

    if(add >= sub && add >= mul) max = add;
    else if(sub > add && sub > mul) max = sub;
    else if(mul > add && mul >sub) max = mul;

    std::cout << max << std::endl;
    return 0;

}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int64_t combination(const int64_t n, const int64_t k) {
  int64_t ans = 1;
  for (int64_t i = 0; i < k; i++) {
    ans *= n - i;
    ans /= i + 1;
  }
  return ans;
}

class combination_cache {
 private:
  explicit combination_cache(const int64_t p)
      : mod(p), max(1), fac(2, 1), finv(2, 1), inv(2, 1) {}
  ~combination_cache() = default;
  const int64_t mod;
  int64_t max;

 public:
  combination_cache(const combination_cache &) = delete;
  combination_cache &operator=(const combination_cache &) = delete;
  combination_cache(combination_cache &&) = delete;
  combination_cache &operator=(combination_cache &&) = delete;

  std::vector<int64_t> fac;
  std::vector<int64_t> finv;
  std::vector<int64_t> inv;

  static const combination_cache &get(const int64_t n, const int64_t p) {
    static combination_cache instance(p);

    assert(p == instance.mod);
    if (instance.max < n) {
      instance.fac.reserve(n + 1);
      instance.finv.reserve(n + 1);
      instance.inv.reserve(n + 1);
      for (int64_t i = instance.max + 1; i <= n; i++) {
        instance.fac.push_back(instance.fac[i - 1] * i % p);
        instance.inv.push_back(p - instance.inv[p % i] * (p / i) % p);
        instance.finv.push_back(instance.finv[i - 1] * instance.inv[i] % p);
      }
      instance.max = n;
    }
    return instance;
  }
};

int64_t combination(const int64_t n, const int64_t k, const int64_t p) {
  if (n < k || n < 0 || k < 0) {
    return 0;
  }
  const auto &cache = combination_cache::get(n, p);
  return cache.fac[n] * (cache.finv[k] * cache.finv[n - k] % p) % p;
}

int main() {
  int64_t n, k;
  std::cin >> n >> k;
  constexpr int64_t p = 1000000007;
  combination(n, 1, p);

  for (int64_t i = 0; i < k; i++) {
    auto v = combination(n - k + 1, i + 1, p) * combination(k - 1, i, p);
    std::cout << v % p << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    //input
    int x1, x2, y1, y2;
    int x3, x4, y3, y4;
    std::cin >> x1 >> y1 >> x2 >> y2;
    
    int dx = x2 - x1;
    int dy = y2 - y1;
    
    x3 = x2 - dy;
    y3 = y2 + dx;
    
    dx = x3 - x2;
    dy = y3 - y2;
    
    x4 = x3 - dy;
    y4 = y3 + dx;
    
    std::cout << x3 << " " << y3 << " " << x4 << " " << y4 << std::endl;
}

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

int main()
{
  string s; cin>>s;
  cout<< s[0] << s.size()-2 << s[s.size()-1] << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.ArrayDeque
import kotlin.math.min

data class Train(val dest: Int, val fee: Int, val time: Long)
data class Exchange(val currency: Int, val time: Long)
data class State(val city: Int, val money: Int, val time: Long)

fun main() {
    val pw = PrintWriter(System.out)

    val upper = 2500

    val (n, m, s) = readInputLine().split(" ").map { it.toInt() }

    val cost = Array(n) { LongArray(upper + 1) { Long.MAX_VALUE } }

    val edges = Array(n) { mutableListOf<Train>() }

    repeat(m) {
        val input = readInputLine().split(" ")
        val u = input[0].toInt() - 1
        val v = input[1].toInt() - 1
        val a = input[2].toInt()
        val b = input[3].toLong()
        edges[u].add(Train(v, a, b))
        edges[v].add(Train(u, a, b))
    }

    val exchange = Array(n) {
        val input = readInputLine().split(" ")
        Exchange(input[0].toInt(), input[1].toLong())
    }

    cost[0][min(upper, s)] = 0L

    val queue = ArrayDeque<State>()

    queue.add(State(0, min(upper, s), 0L))

    while (queue.isNotEmpty()) {
        val state = queue.poll()!!

        for (e in edges[state.city]) {
            if (state.money >= e.fee) {
                if (cost[e.dest][state.money - e.fee] > state.time + e.time) {
                    cost[e.dest][state.money - e.fee] = state.time + e.time
                    queue.add(State(e.dest, state.money - e.fee, state.time + e.time))
                }
            }
        }

        val ex = exchange[state.city]

        if (cost[state.city][min(upper, state.money + ex.currency)] > state.time + ex.time) {
            cost[state.city][min(upper, state.money + ex.currency)] = state.time + ex.time
            queue.add(State(state.city, min(upper, state.money + ex.currency), state.time + ex.time))
        }
    }

    for (i in 1 until n) {
        pw.println(cost[i].min())
    }

    pw.flush()
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 67256
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1]%d7 + C[i - 1][j]%d7)%d7;}}}
    return C[n][k]%d7;
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
// code now
   
    
    ll n,k;
    ll m;
    cin>>n>>m>>k;
    if(k>m+n){
        ll jj=k-m-n;
        if(jj*jj>4*n*m){cout<<"Yes";}
        else{cout<<"No";}
    }else{cout<<"No";}
    
//code ends
    return 0;
}


Measured memory_bytes: 256
def bubblesort(A):
    N = len(A)
    cnt = 0
    for i in range(N):
        for j in range(N-1):
            if A[j] > A[j+1]:
                A[j],A[j+1] = A[j+1],A[j]
                cnt += 1
    print(*A)
    print(cnt)
            

def main():
    N = int(input())
    A = list(map(int,input().split()))
    bubblesort(A)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,h;
    long long d;
    vector<int> vec;
    cin >> a;
    for(int e=0;e < a;e++){
        cin >> h;
        vec.push_back(h);
    }
    b = c = vec.at(0);
    d =0;
    for(int f=0;f < a;f++){
        b = min(b,vec.at(f));
        c = max(c,vec.at(f));
        d = d + vec.at(f);
    }
    cout << b <<" "<< c <<" "<< (long long)d <<endl;
    
}


Measured memory_bytes: 3260
h, w = map(int, input().split())
g = []
ans = []
for _ in range(h):
    s = [c for c in input()]
    g.append(s)
del_col = []
for j in range(w):
    col = [r[j] for r in g]
    if all([x == '.' for x in col]) :
        del_col.append(j)
del_col.sort(reverse=True)

for i in range(h):
    if not all([x == '.' for x in g[i]]):
        for d in del_col:
            g[i].pop(d)
        ans.append(g[i])
for r in ans:
    print(''.join(r))

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
	int N;
	int x[1009],y[1009];
	int h[1009];
	cin>>N;
	for(int i=0;i<N;i++)cin>>x[i]>>y[i]>>h[i];
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			int H;
			for(int k=0;k<N;k++){
				if(h[k]>0)H=h[k]+abs(x[k]-i)+abs(y[k]-j);
			}
			bool flag=true;
			for(int k=0;k<N;k++){
			   	if(h[k]!=max(H-abs(x[k]-i)-abs(y[k]-j),0))flag=false;
			}
			if(flag==true){
				cout<<i<<" "<<j<<" "<<H<<endl;
				return 0;
			}
		}
	}
}

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

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

Measured memory_bytes: 3708
n=int(input())
arr=[input() for _ in range(n)]
dic={}
for i in range(n): #各単語の出現回数を数える
 if arr[i] not in dic:
   dic[arr[i]]=1
 else:
   dic[arr[i]]+=1
largest=max(dic.values()) #最大の出現回数を求める
ans=[]
for keys in dic.keys():
 if dic[keys]==largest: #出現回数が最も多い単語を集計する
   ans.append(keys)
ans=sorted(ans) #単語を辞書順に並べ替えて出力する
for words in ans:
 print(words)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	int L=S.size();
	
	ll ret=0;
	for(int mask=0;mask<1<<(L-1);mask++) {
		ll cur=S[0]-'0';
		FOR(i,L-1) {
			if(mask&(1<<i)) {
				ret+=cur;
				cur=0;
			}
			cur=cur*10+(S[i+1]-'0');
		}
		ret+=cur;
	}
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
signed main()
{
  int h,w; cin >> h >> w;
  vector<string> v(h);
  for(int i=0; i<h; ++i){
    cin >> v[i];
  }

  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      int sum = 0;
      if(v[i][j]=='#') {cout << '#'; continue;}

      if(i!=0 && j!=0) {if(v[i-1][j-1]=='#') ++sum;}
      if(i!=0) {if(v[i-1][j]=='#') ++sum;}
      if(i!=0 && j!=w-1) {if(v[i-1][j+1]=='#') ++sum;}

      if(j!=0) {if(v[i][j-1]=='#') ++sum;}
      if(j!=w-1) {if(v[i][j+1]=='#') ++sum;}

      if(i!=h-1 && j!=0) {if(v[i+1][j-1]=='#') ++sum;}
      if(i!=h-1) {if(v[i+1][j]=='#') ++sum;}
      if(i!=h-1 && j!=w-1) {if(v[i+1][j+1]=='#') ++sum;}

      cout << sum;
    }
    cout << "\n";
  }
}

Measured memory_bytes: 3552
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import itertools as ite
import math
import random
import sys
import codecs
from collections import defaultdict

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

n, m = map(int, input().split())
c = list(map(int, input().split()))
DP = [0] + [n] * n
for i in range(m):
    for j in range(c[i], n + 1):
        DP[j] = min(DP[j], DP[j - c[i]] + 1)
print(DP[n])



Measured memory_bytes: 10072
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n;
    while(cin >> n){
        bool prime[1000000] = {false};
        // false??§?????????
        prime[1] = true;
        prime[2] = false;
        int count = 0;
        
        // ??¨??????????????????????????????
        for(int j = 2; j * j <= n ; j++){
            if(!prime[j]){
                for (int k = 2; k*j <= n;k++){
                   prime[j*k] = true;
                }
            }
        }
        // false?????¨?´???°
        for(int i = 1;i<=n;i++){
            if(!prime[i]) count = count +1;
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 4032
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int N;
  cin >> N;
  int ans = INF;
  for(int i=0; i<N; ++i){
    int v;
    cin >> v;
    int count =0;
    while(v > 0 && v % 2 == 0){
      v /= 2;
      count++;
    }
    ans = min(ans, count);

  }
  cout << ans << endl;

}


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

using namespace std;
string s, c;
int q, T, F;

int main(){
    cin >> s;
    cin >> q;
    int st = 0;
    string bg = "", ed = "";
    for (int i = 0; i < q; i++){
        cin >> T;
        if (T == 1) st = st^1;
        else {
            cin >> F >> c;
            F--;
            if (F^st == 0) bg = bg + c;
            else ed = ed + c;
        }
    }
    if (st){
        reverse(ed.begin(), ed.end());
        reverse(s.begin(), s.end());
        cout << ed << s << bg;
    }
    else {
        reverse(bg.begin(), bg.end());
        cout << bg << s << ed;
    }
}


Measured memory_bytes: 1456
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int a[100001];
	int tmp = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(abs(a[tmp]) < abs(a[i])) tmp = i;
	}
	cout << 2 * n - 2 << endl;
	for(int i = 0; i < n; i++){
		if(i != tmp) cout << tmp + 1 << " " << i + 1 << endl;
	}
	if(a[tmp] > 0){
		for(int i = 1; i < n; i++){
			cout << i << " " << i + 1 << endl;
		}
	} else {
		for(int i = n; i > 1; i--){
			cout << i << " " << i - 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[20];
ll dp[20][110];
ll dfs(ll pos,ll lim,ll sta,ll lead){
    if(pos==-1)return sta==105;
    ll up=lim?a[pos]:9;
    ll tmp=0;
    if(dp[pos][sta]!=-1)return dp[pos][sta];
    if(sta!=105||lim){
    for(ll i=lead?0:3;i<=7&&i<=up;i+=(i==0?3:2)){
        if(i==0)
        tmp+=dfs(pos-1,lim&&i==a[pos],1,lead&&i==0);
        else
        tmp+=dfs(pos-1,lim&&i==a[pos],sta%i?sta*i:sta,lead&&i==0);
    }
    }
    else tmp+=3*dfs(pos-1,0,sta,0);
    if(lead)
    dp[pos][sta]=tmp;
    return tmp;
}
ll sol(ll x){
    ll tot=0;
    while(x){
    a[tot++]=x%10;
    x/=10;
    }
    return dfs(tot-1,1,1,1);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin>>x;
    memset(dp,-1,sizeof(dp));
    cout<<sol(x)<<endl;
}


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

using namespace std;

int MOD = 1e9 +7;


//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int perm(int n){
	int ans = 1;
	while(n){
		ans *= n;
		ans %= MOD;
		n--;
	}
	return ans;
}



int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int s; cin >> s;
	vector<int> dp(s + 1, 1);
	if(s <= 3) {
		if(s == 3) cout << 1;
		else cout << 0 ;
	}
	else{
		dp[0] = 0; dp[1] = 0; dp[2] = 0;
		for(int i = 4; i <= s; i++){
			for(int j = 3; j <= s; j++){
					if(i - j > j){
						dp[i] += dp[i - j] + dp[j];
						dp[i] %= MOD;
					}
					if(i-j == j) {dp[i] += dp[j]; dp[i]%=MOD;}
			}
		}
		cout << dp[s];
	}



		


	#ifdef LOCAL
	cerr << "\n";
	#endif
	return 0;
}


Measured memory_bytes: 3664
#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;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int dp[3];

int main(){
	int n,K;cin>>n>>K;
	int r,s,p;cin>>r>>s>>p;
	string T;cin>>T;
	int ans=0;
	for(int i=0;i<K;i++){
		memset(dp,0,sizeof(dp));
		for(int j=i;j<n;j+=K){
			int nx[3]{};
			rep(k,3)rep(t,3){
				if(k==t)continue;
				int score=0;
				if(T[j]=='r'&&t==0)score+=p;
				if(T[j]=='s'&&t==1)score+=r;
				if(T[j]=='p'&&t==2)score+=s;
				nx[t]=max(nx[t],dp[k]+score);
			}
			rep(k,3)dp[k]=nx[k];
		}
		ans+=max({dp[0],dp[1],dp[2]});
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    priority_queue<int> q;
    rep(i,n){
        int a;
        cin>>a;
        q.push(a);
    }
    rep(i,m){
        int tmp=q.top();
        q.pop();
        tmp/=2;
        q.push(tmp);
    }
    ll ans=0;
    rep(i,n){
        ans+=q.top(); q.pop();
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 892
n, d = gets.split.map(&:to_i)
points = n.times.map do
  gets.split.map(&:to_i)
end

require 'prime'

ans = points.combination(2).map do |x, y|
  x.zip(y).map {|i, j| (i-j)**2 }.inject(:+).prime_division.map(&:last).all?(&:even?)
end.count(true)

puts ans


Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstring>
int main()
{
	int K;
	std::cin >> K;
	int num = 7;
	int col = 1;
	std::vector<bool> modset(K, false);
	while (true) {
		const int mod = num % K;
		if (mod == 0) {
			break;
		}
		if (modset[mod]) {
			std::cout << "-1" << std::endl;
			return 0;
		}
		modset[mod] = true;
		num = mod * 10 + 7;
		++col;
	}
	std::cout << col << std::endl;

	/*int N, Q;
	std::cin >> N >> Q;
	std::vector<int> c(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> c[i];
	}
	std::vector<int> count(N);
	std::set<int> set;
	for (int i = N - 1; i >= 0; --i) {
		set.insert(c[i]);
		count[i] = (int)set.size();
	}
	std::vector<int> ans;
	for (int i = 0; i < Q; ++i) {
		int l, r;
		std::cin >> l >> r;
		int c = count[l - 1];
		if (r < N && count[r]!=c) {
			c -= count[r];
		}
		ans.push_back(c);
	}
	for (int i = 0; i < Q; ++i) {
		std::cout << ans[i] << std::endl;
	}*/
	return 0;
}

Measured memory_bytes: 3708
import heapq

def calc(N, M, A):
    if (N == 1):
        return A[0] // (2 ** M)
    H = []
    for a in A:
        heapq.heappush(H, -a)
    for _ in range(M):
        a = (-heapq.heappop(H)) // 2
        heapq.heappush(H, -a)
    return -sum(H)


(N, M) = tuple([int(s) for s in input().split(' ')])
A = [int(s) for s in input().split()]
print(calc(N, M, A))

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

int main() {
    int x, y;
    cin >> x >> y;
    if (y % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    if (x * 2 <= y && y <= x * 4) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3592
import numpy as np

n = list(map(int, input().split()))

a = []

for i in range(n[2]):
    a.append(int(input()))

if n[1] > n[2]:
    for c in range(n[0]):
            print('Yes')

else:
    m = [n[1]]*n[0]

    x = np.array(m)
    x -= n[2]
    for j in range(n[2]):
        x[a[j]-1] += 1

    for num in range(n[0]):
        if x[num] <= 0:
            print('No')
        else:
            print('Yes')



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

int main()
{
	int A;
	int B;
	cin >> A;
	cin >> B;
	
	if (A <= 5)
		std::cout << "0" << std::endl;
	else if (A <= 12)
		std::cout << (B >> 1) << std::endl;
	else
		std::cout << B << std::endl;
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
int T;
int n, k, a[N];
int tree[N * 4];

void change(int i, int l, int r, int pos, int val) {
    if (l == r) {
        tree[i] = val;
        return;
    }
    int mid = l + r >> 1;
    if (pos <= mid)change(i << 1, l, mid, pos, val);
    else change(i << 1 | 1, mid + 1, r, pos, val);
    tree[i] = max(tree[i << 1], tree[i << 1 | 1]);
}

int ask(int i, int l, int r, int L, int R) {
    if (L <= l && r <= R) { return tree[i]; }
    int mid = l + r >> 1;
    int ans = -1;
    if (L <= mid)ans = max(ans, ask(i << 1, l, mid, L, R));
    if (R > mid)ans = max(ans, ask(i << 1 | 1, mid + 1, r, L, R));
    return ans;
}

int dp[N];

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)cin >> a[i], a[i]++;
    int maxx = *max_element(a + 1, a + n + 1);
    dp[1] = 1;
    change(1, 1, maxx, a[1], 1);
    for (int i = 2; i <= n; i++) {
        int ans = ask(1, 1, maxx, max(1, a[i] - k), min(maxx, a[i] + k));
        dp[i] = ans + 1;
        change(1, 1, maxx, a[i], dp[i]);
    }
    cout << *max_element(dp + 1, dp + n + 1);
    return 0;
}


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

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

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

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

	char t;
	cin >> t;

	if(t> 96)
		cout << 'a' << endl;
	else
		cout << 'A' << endl;
}

Measured memory_bytes: 3636
N, K = map(int, input().split())
X = list(map(int, input().split()))

lft, rgt = 0, K - 1
ans = float('inf')

while True:
    if rgt == N:
        break
    ans = min(ans, min(abs(X[lft]) + abs(X[lft] - X[rgt]),
                       abs(X[rgt]) + abs(X[rgt] - X[lft])))
    lft += 1
    rgt += 1
print(ans)


Measured memory_bytes: 14224
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    int F[50];
    F[0] = F[1] = 1;
    for(int i = 2; i <= n; i++)F[i] = F[i -1] + F[i - 2];
        cout << F[n] << endl;
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin>>a[i];
        a[i]=INT_MAX-a[i];
    }
    vector<int> dp;
    for(int aa : a){
        auto it=upper_bound(dp.begin(),dp.end(),aa);
        if(it==dp.end()) dp.push_back(aa);
        else *it=aa;
    }
    cout<<dp.size();

    return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool ok = true;
  vector<int> t(N + 1), x(N + 1), y(N + 1);
  t.at(0) = 0;
  x.at(0) = 0;
  y.at(0) = 0;
  for (int i = 1; i < (N + 1); i++) {
    cin >> t.at(i) >> x.at(i) >> y.at(i);
    if (abs(abs(x.at(i) - x.at(i - 1)) + abs(y.at(i) - y.at(i - 1))) > (t.at(i) - t.at(i - 1))) {
      ok = false;
      break;
    }
    if (((t.at(i) - t.at(i - 1)) - abs(abs(x.at(i) - x.at(i - 1)) + abs(y.at(i) - y.at(i - 1)))) % 2 == 1) {
      ok = false;
      break;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 4260
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
	int N;
	cin >> N;
	cout << 800*N - (N/15)*200;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 9223372036854775807ll;
const int nax = 200005;
int n,k,a[nax];
void solve()
  {
   cin>>n>>k;
   loop(i,1,n+1)
    cin>>a[i];
   loop(i,k+1,n+1)
    {
      if(a[i]>a[i-k])
         cout<<"Yes"<<END;
      else
         cout<<"No"<<END;      
    }
  }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
     /*int t;
     cin>>t;
     while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 5208
#include<iostream>
#include<math.h>

using namespace std;

int main(void){

    int n, ans = 0;
    
    cin >> n;

    int count = 0;
    for(int i = 1;i <= n;i += 2){
        for(int j = 1;j < sqrt(i)+1;j++){
            if(i%j == 0) count += 2;
        }
        if(count == 8) ans++;
        count = 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
X, Y = map(int, input().split())

answer = 0
if X == 1:
    answer += 300000
elif X == 2:
    answer += 200000
elif X == 3:
    answer += 100000

if Y == 1:
    answer += 300000
elif Y == 2:
    answer += 200000
elif Y == 3:
    answer += 100000

if X == Y == 1:
    answer += 400000

print(answer)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define mod 1000000007
 
#define p(x) cout<<x<<" ";
#define p2(x,y) cout<<x<<" "<<y<<" "
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<" "
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
 
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define pi pair<ll,ll>
#define ppi pair<ll,pi>
#define pb push_back
#define all(v) v.begin(), v.end() 

int n,m;// n rows  m column
 int mat[1005][1005];
 int dp[1005][1005];


int solve(int i,int j){
  if(mat[i][j]==0||i<0||j<0)
    return 0;
  if(i==0&&j==0)
    return 1;
  if(dp[i][j]!=-1)
    return dp[i][j];
   dp[i][j]=solve(i-1,j)+solve(i,j-1);
   dp[i][j]%=mod;
   return dp[i][j];
}

int main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout<<fixed<<setprecision(6);

// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
  
    ll t=1;
    //cin>>t;
    
    while(t--)
    {
      cin>>n>>m;
      F(i,0,n-1){
        string s;
        cin>>s;
        F(j,0,m-1){
          s[j]=='.'?mat[i][j]=1:mat[i][j]=0;
        }
      }
      memset(dp,-1,sizeof(dp));
      cout<<solve(n-1,m-1);

      
    }
        
}

Measured memory_bytes: 8192
w = input()

s = "abcdefghijklmnopqrstuvwxyz"

dic = {}

for o in s:
    dic[o] = 0

for o in w:
    dic[o] += 1

for num in dic.values():
    if num % 2 == 1:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 9048
#include <iostream>
#include <cmath>

#define MAX 1000000

using namespace std;

bool prime[MAX+1];
int T[MAX];

void eratos(int n) {
  for(int i = 0; i < n; i++) prime[i] = false;
  for(int i = 3; i <=n; i+=2)prime[i] = true;
  prime[2] = true;
  for(int i = 3, limit = (int)sqrt(n); i <= limit; i += 2) {
    if(!prime[i]) continue;
    for(int j = i*i, k = i*2; j <= n; j += k) prime[j] = false;
  }
}

void init() {
  eratos(MAX);

  for(int i = 0; i < MAX; i++) {
    T[i] = T[i-1];
    if(prime[i]) T[i]++;
  }
}

int main(void) {
  init();
  int n;
  
  while(cin >> n) cout << T[n] << endl;
  return 0;
}

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

int n, x[200005], y[200005], a[200005], b[200005];

int main(){
    scanf("%d", &n);
    for (int i = 0; i < n; ++i){
        scanf("%d%d", &x[i], &y[i]);
    }
    for (int i = 0; i < n; ++i){
        a[i] = x[i] + y[i];
        b[i] = x[i] - y[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    int ans = max(a[n - 1] - a[0], b[n - 1] - b[0]);
    printf("%d", ans);
}


Measured memory_bytes: 6920
#include<iostream>
#include<cstdio>
using namespace std;
int record[100005][2];
int res[100005];
int n, a[3];
int main(){
	scanf("%d%d%d%d",&n,&a[0],&a[1],&a[2]);
	for(int i=0;i<n;i++){
		char s[3];
		scanf("%s",s);
		record[i][0]=s[0]-'A';
		record[i][1]=s[1]-'A';
	}

	for(int i=0;i<n;i++){
		int op1=record[i][0], op2=record[i][1];
		if(!a[op1]&&!a[op2]){
		        printf("No\n");
			return 0;
		}
		else if(!a[op1]) {
                       	res[i]=op1;
	                a[op1]++;
	                a[op2]--;
                    }
		else if(!a[op2]){
                      	res[i]=op2;
	                 a[op2]++;
	                a[op1]--;
                 }
		else{
			if(i!=n-1&&op1==3-record[i+1][0]-record[i+1][1]){
                      	res[i]=op2;
	                a[op2]++;
	                a[op1]--;
                          }
			else  {
                       	res[i]=op1;
	                a[op1]++;
	                a[op2]--;
                    }
		}
	}
	printf("Yes\n");
	for(int i=0;i<n;i++)
              printf("%c\n",res[i]+'A');
}

Measured memory_bytes: 4988