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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  long a, b, n;
  cin >> a >> b >> n;
  long res = (a * n) / b - a * (n / b); 
  n = min(n, b - 1); res = max(res, (a * n) / b - a * (n / b));
  cout << res;
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
#define mk make_pair
using namespace std;
#define int long long
int n,a,b,t[1000000];
bool ch(int x){
  int u=0;
  r(i,n)if(t[i]-x*b>0){
    int tt=t[i]-b*x;
    u+=tt/(a-b);
    if((tt)%(a-b))u++;
  }
  if(u<=x)return 1;
  else return 0;
}
main(){
  cin>>n>>a>>b;
  int l=0,rr=1000000000;
  r(i,n)cin>>t[i];
  while(l<rr){
    int mid=(rr+l)/2;
    if(ch(mid))rr=mid;
    else l=mid+1;
  }
  cout<<l<<endl;
}

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

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
int A[100010];
int B[100010];
map<int, int> sorted_poses;

int main(){

    fastStream();
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B, B + N);
    for(int i = 0; i < N; i++){
        sorted_poses[B[i]] = i;
    }
    
    int ans = 0;
    for(int i = 0; i < N; i+=2){
        if(sorted_poses[A[i]] % 2 == 1){
            ans++;
        }
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 5760
import Data.Array

nsolver::Int -> Array Int Int -> Int -> IO ()
nsolver _    _  0 = return ()
nsolver dflt ts n = do
  pxc<-getLine
  let p:x:[]=map read (words pxc)::[Int]
  print (dflt+(x-(ts!p)))
  nsolver dflt ts (n-1)

main::IO()
main =do
  nc<-getLine
  let n = read nc ::Int
  tc<-getLine
  let tarr = listArray (1,n) (map read (words tc)::[Int])
  let dflt = sum (map read (words tc)::[Int])
  mc<-getLine
  let m =read mc ::Int
  nsolver dflt tarr m


Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
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 long long INF = 1LL << 60;

int main() {
    string s;
    cin >> s;
    string t = "";
    
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '1') {
            t += '1';
        }else if(s[i] == '0') {
            t += '0';
        }else if(s[i] == 'B') {
            if(t != "") {
                t.erase(t.size()-1,t.size());
            }
        }
    }
    cout << t;
    return 0;
}

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

int main() {
  cout << fixed << setprecision(6);
  int64_t h, w, x, y;
  cin >> h >> w >> x >> y;
  double middle_h = h / 2.000;
  double middle_w = w / 2.000;

  cout << (h * w) / 2.00000 << " ";
  
  if (middle_h == x) {
    if (middle_w == y) {
      cout << '1' << endl;
    }
    else {
      cout << '0' << endl;
    }
  }
  else {
    cout << '0' << endl;
  }
  
}



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

using namespace std;

int main()
{
  int m;
  int f;
  int r;
  
  while(1)
  {
    cin >> m >> f >> r;
    if(m==-1 && f== -1 && r==-1)
      break;
    if(m==-1 || f==-1)
      {
        cout << "F\n";
        continue;
      }
      
    if(m+f>=80)
      cout << "A\n";
    if(m+f>=65 && m+f<80)
      cout <<"B\n";
    if(m+f>=50 && m+f<65)
      cout <<"C\n";
    if(m+f>=30 && m+f<50)
    {
      if(r>=50)
        cout <<"C\n";
      else
        cout <<"D\n";
    }
    if(m+f<30)
      cout <<"F\n";
  }
}

Measured memory_bytes: 1120
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > mat;

int main()
{
  ll s;
  cin >> s;
  ll sqe = sqrt(s);
  if (sqe < 1000000000)
  {
    sqe++;
    ll a = sqe * sqe - s;
    cout << 0 << " " << 0 << " " << sqe << " " << a << " " << 1 << " " << sqe << "\n";
  }
  else
  {
      cout << 0 << " " << 0 << " " << 1000000000 << " " << 1 << " " << 1000000000000000000-s << " " << 1000000000  << "\n";
  }
}

Measured memory_bytes: 256
import std.stdio;

const int MAX = 1000001;
bool[MAX] p;

void main(){
	p[] = true;
	foreach (i; 2..MAX) if (p[i]) for (int j = 2*i; j < MAX; j+=i) p[j] = false;
	int a, n;
	while (readf("%d\n", &n), n) {
		a = 0;
		foreach (i; 2..(n/2+1)) {
			if (p[i] && p[n-i]) a++;
		}
		writeln(a);
	}
}

Measured memory_bytes: 1968
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define rall(n) std::rbegin(n), std::rend(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	Int N, M, X; std::cin >> N >> M >> X;
	std::vector<Int> C(N);
	std::vector<std::vector<Int>> A(N, std::vector<Int>(M));

	rep(i, N) {
		std::cin >> C[i];
		rep(j, M) {
			std::cin >> A[i][j];
		}
	}

	Int ans = INF;
	std::vector<Int> num(M, 0);

	rep(bit, 1 << N) {
		Int price = 0;
		rep(i, N) {
			if (bit & (1 << i)) {
				rep(j, M) {
					num[j] += A[i][j];
				}
				price += C[i];
			}
		}
		bool flag = true;
		rep(i, M) {
			if (num[i] < X)flag = false;
		}
		if (!flag) {
			rep(i, M)num[i] = 0;
			continue;
		}
		ans = std::min(ans, price);
		rep(i, M)num[i] = 0;
	}
	if (ans == INF) {
		std::cout << -1;
		return;
	}
	std::cout << ans;

}


int main() {

	init();
	calc();

	return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    int n, d;
    cin >> n >> d;
    int tmp = 1 + 2 * d;
    int ans = n / tmp;
    if (n % tmp != 0)
        ans++;
    cout << ans << endl;
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

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

	int n;
	cin >> n;
	vector<pair<int, int>> a(n);
	for (auto &i : a) cin >> i.F >> i.S;
	sort(a.begin(), a.end());

	vector<int> dp(n);
	set<pair<int, int>> s;

	int mx = 0;
	for (int i = 0; i < n; ++i)
	{
		while (!s.empty() && s.begin()->F <= a[i].F - a[i].S)
		{
			mx = max(mx, dp[s.begin()->S]);
			s.erase(s.begin());
		}

		dp[i] = mx + 1;
		s.insert({ a[i].F + a[i].S, i });
	}

	cout << *max_element(dp.begin(), dp.end()) << "\n";

	return 0;
}


Measured memory_bytes: 3840
// ABC 144-B
// 2019.10.27 bal4u

#include <stdio.h>

int main()
{
	int A, B, N;
	
	scanf("%d", &N);
	for (A = 1; A <= 9; ++A) {
		for (B = 1; B <= 9; ++B) {
			if (A*B == N) { puts("Yes"); return 0; }
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265
int main()
{
    double a,b,h,m,ans,res;
    cin>>a>>b>>h>>m;
    ans=(double)abs((11.0*(double)m)/2.0-30.0*(double)h);
   
    if(ans>180.0)
     ans=360.0-ans;
     
    res=(double)sqrt(a*a+b*b-2*a*b*cos(ans*(M_PI/180.0)));
    
    printf("%.20lf",res);
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

int main()
{
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<ll> a(x);
    for(auto &u : a)
        cin >> u;
    vector<ll> b(y);
    for(auto &u : b)
        cin >> u;
    vector<ll> c(z);
    for(auto &u : c)
        cin >> u;

    sort(rall(c));

    priority_queue<pair<ll, int>> pq;

    for(int i = 0; i < x; ++i)
    {
        for(int j = 0; j < y; ++j)
        {
            pq.push({a[i]+b[j]+c[0], 0});
        }
    }

    for(int i = 0; i < k; ++i)
    {
        auto top = pq.top();
        pq.pop();

        cout << top.fi << '\n';

        if(top.se == z-1)
            continue;

        pq.push({top.fi - c[top.se] + c[top.se+1], top.se+1});
    }

    return 0;
}


Measured memory_bytes: 18540
import bisect
import sys
input = sys.stdin.readline


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

edges = [[] for _ in range(n+1)]
for _ in range(n-1):
    from_, to = map(int, input().split())
    edges[from_].append(to)
    edges[to].append(from_)


DP = [10**9+7] * (n+1)
limit = 10**9 + 1
DP[0] = 0
olds = [None] * (n+1)
ans = [0] * n

todo = [1]
while todo:
    node = todo.pop()
    if node > 0:
        num = A[node-1]
        update_idx = bisect.bisect_left(DP, num)
        old = DP[update_idx]
        olds[node] = (old, update_idx)
        DP[update_idx] = num
        lis = bisect.bisect_left(DP, limit) - 1
        ans[node-1] = lis

        todo.append(-node)
        for to in edges[node]:
            if ans[to-1]:
                continue
            todo.append(to)

    else:
        node = -node
        old, update_idx = olds[node]
        DP[update_idx] = old

for res in ans:
    print(res)


Measured memory_bytes: 82012
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int n,sum,res,c;
int main(){
	scanf("%d",&n);
	while(sum<n)++res,sum+=res;
	fp(i,1,res)if(i!=sum-n)printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 256
/* ex5_4
   saitomo  */
#include <stdio.h>

int main(void){
    int max=0,count=0;//maxは最大値、countは連続出現回数を
    char str[11],*ptr; //ptrはstrの各要素へのポインタ
    scanf("%s",str);
    ptr=str;
    while(*ptr){//ポインタをヌルまで一つずつ動かしていく
        if(*ptr=='A'||*ptr=='T'||*ptr=='G'||*ptr=='C'){
        // ATGCのいずれかなら一つカウント、ポインタを動かす
            count+=1;
            ptr+=1;
        }else{
            //異なる場合は最大値判定をしてからcountを0に
            if(count>max){
                max=count;
            }
            count=0;
            ptr+=1;
        }
        if(*(ptr+1)=='\0'){
            //ヌル文字の前のみ場合わけ
            if(count>max){
                max=count;
            }
        }
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;cin>>n;
  string s[n];
  int p[n];
  vector<tuple<string,int,int>> P;
  for(int i=0;i<n;i++){
    cin>>s[i]>>p[i];
   P.emplace_back(s[i],100-p[i],i+1);
  }
  sort(begin(P),end(P));
  
  for(int i=0;i<n;i++){
    cout<<get<2>(P[i])<<endl;
  }
}

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

int main() {
    
    string s;
    cin>>s;
    deque<char> dq;
    for(LL i=0;i<s.length();i++){
        dq.push_back(s[i]);
    }
    LL q;
    cin>>q;
    int toggle=1;
    for(LL i=0;i<q;i++){
        LL x;
        cin>>x;
        if(x==1){
            toggle=1-toggle;
        }
        else if(x==2){
            LL y;
            char ch;
            cin>>y>>ch;
            if(y==1){
                if(toggle){
                    dq.push_front(ch);
                }
                else{
                    dq.push_back(ch);
                }
            }
            else if(y==2){
                if(toggle){
                    dq.push_back(ch);
                }
                else{
                    dq.push_front(ch);
                }
            }
        }
    }
    if(toggle){
        for(auto it:dq){
            cout<<it;
        }
        cout<<endl;
    }
    else{
        for(auto it=dq.rbegin();it!=dq.rend();it++){
            cout<<*it;
        }
        cout<<endl;
    }
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  ll A, B, C, X, Y; scanf("%lld %lld %lld %lld %lld", &A, &B, &C, &X, &Y);
  ll ans = A * X + B * Y;
  ans = min(ans, 2 * X * C + B * max(Y - X, 0LL));
  ans = min(ans, 2 * Y * C + A * max(X - Y, 0LL));
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

bool a[1<<10];
int main(){
    int n,m,ai;
    cin>>n>>m;
    rep(i,m){
        cin>>ai;
        a[n+ai]=true;
    }
    int cnt=0;
    for(int i=2*n-1;i>1;i-=2){
        if(!a[i]&&!a[i-1]) ++cnt;
        a[i/2]=a[i]&&a[i-1];
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3084
from bisect import *
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans=0
for b in B:
    ans+=(n-bisect(C,b))*bisect_left(A,b)
print(ans)

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    ll ans = 0;
    cin >> n >> a >> b;
    vector<ll> x(n);
    rep (i, n) {
        cin >> x[i];
    }
    sort(x.begin(), x.end());
    FOR (i, 1, n) {
        if ((x[i] - x[i - 1]) * a < b) {
            ans += (x[i] - x[i - 1]) * a;
        } else {
            ans += b;
        }
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)

int main() {
	vector<string> S(3);

	cin >> S[0] >> S[1] >> S[2];

	int turn = 0;
	int index[3] = {};
	for (;;) {
		if (index[turn] + 1 == S[turn].size()) {
			break;
		}
		index[turn]++;
		turn = S[turn][index[turn]-1] - 'a';
		
	}
	char ans = 'A' + turn;
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const N = +lines[0];
	console.log(N%2?(N-1)/2:N/2-1);
});

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

#define fast ios_base::sync_with_stdio; cin.tie(0); cout.tie(0)
#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
//#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

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

int main()
{fast;
 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 #endif
 int t=1,n;
 //cin>>t;
 while(t--)
 {cin>>n;
  string s;
  map<string,int> m;
  rep(i,0,n){
    cin>>s;
    m[s]++;
  }
  cout<<"AC x "<<m["AC"]<<endl;
  cout<<"WA x "<<m["WA"]<<endl;
  cout<<"TLE x "<<m["TLE"]<<endl;
  cout<<"RE x "<<m["RE"]<<endl;
 }
 return 0;
}


Measured memory_bytes: 3628
# -*- coding: utf-8 -*-

import math

MAX = 1000000007

def ans(m,n):
    if ( abs(m - n) > 1 ):
        print(0);
        return 0

    if ( abs(m - n) == 1 ):
        print((math.factorial(m)*math.factorial(n))%MAX);
        return 0
    
    if ( abs(m - n) == 0 ):
        print((2*(math.factorial(m)*math.factorial(n)))%MAX);
        return 0

m,n = [int(i) for i in input().split()]
ans(m,n)


Measured memory_bytes: 5184
import java.util.*;

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

        char[] sdash = sc.next().toCharArray();
        char[] T = sc.next().toCharArray();
        List<String> ansCandidates = new ArrayList<>();

        for (int i = 0; i < sdash.length - T.length + 1; i++) {
            boolean isMatch = true;
            char[] ansCandidate = new char[sdash.length];

            for (int j = 0; j < T.length; j++) {
                char sChar = sdash[i + j];
                if (sChar != '?' && sChar != T[j]) {
                    isMatch = false;
                }
            }

            if (isMatch) {
                for (int j = 0; j < sdash.length; j++) {
                    ansCandidate[j] = sdash[j];
                }
                for (int j = i; j < i + T.length; j++) {
                    ansCandidate[j] = T[j - i];
                }
                for (int j = 0; j < ansCandidate.length; j++) {
                    if (ansCandidate[j] == '?') {
                        ansCandidate[j] = 'a';
                    }
                }
                ansCandidates.add(String.valueOf(ansCandidate));
            }
        }

        if (ansCandidates.size() == 0) {
            System.out.println("UNRESTORABLE");
        } else {
            Collections.sort(ansCandidates);
            System.out.println(ansCandidates.get(0));
        }
    }
}

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

int main()
 {
  int n;
  cin>>n;
  int a[n],ans=10e5;
  for(int i=0;i<n;i++)
    cin >> a[i];
  sort(a,a+n);
  for (int i=a[0];i<=a[n-1];i++)
  {
    int sum=0;
    for (int j=0;j<n;j++)
    {
      sum=sum+(a[j]-i)*(a[j]-i);
    }
    ans = min(sum,ans);
  }

  cout<<ans<< endl;
}


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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long
#define vi vector<int>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())

int main(){
	string s;
	cin>>s;
	if(s[0]==s[1]&&s[1]==s[2])
		cout<<"Yes\n";
	else if(s[1]==s[2]&&s[2]==s[3])
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

// const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}



// TODO: write
int main() { 
  int h,w;cin>>h>>w;
  vector<string> s(h);rep(i,h)cin>>s[i];
  
  vector<vector<int>> a(h,vector<int>(w,0));
  queue<pair<int,int>> q;

  q.push(mp(0,0));
  a[0][0] = 1;
  while(q.size()){
    auto crt = q.front();q.pop();
    if(crt.fi == h-1 && crt.se == w-1)break;
    for(int i = 0;i < 4;++i){
      auto now = crt;
      now.fi += dx[i];
      now.se += dy[i];
      if(now.fi < 0 || now.se < 0 || now.fi >= h || now.se >= w)continue;
      if(a[now.fi][now.se] != 0)continue;
      if(s[now.fi][now.se] =='#')continue;
      
      a[now.fi][now.se] = a[crt.fi][crt.se]+1;
      q.push(now);
    }
  }
  int tmp = 0;
  rep(i,h)rep(j,w)if(s[i][j] == '.')tmp++;
  int ans = tmp - a[h-1][w-1];
  if(a[h-1][w-1] == 0)print(-1);
  else print(ans);
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    string first = "", second = "";
    for (int i = 0; i < b; i++)
        first += to_string(a);
    for (int i = 0; i < a; i++)
        second += to_string(b);
    cout << min(first, second) << endl;
}

Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    //vector<ll> X(N);
    //string s;
    //in >> s;
    //vector<string> s;
    //s.resize(N);
    ll N;
    in >> N;
    ll A,B;
    in >> A>>B;
    ll ans=0;
    

    for(ll i=A;i<=B;i++){
        if(i%N==0){
            ans=1;
            break;
        }
    }

    if(ans==1){
        out<<"OK"<<endl;
    }else{
        out<<"NG"<<endl;
    }
    
}

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

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

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

    ll N,M; cin >> N >> M;

    if(N == M) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, k, n) for (int i = k; i < n; ++i)

using namespace std;

template<class T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
const long long INF = 1LL << 60;

int main(){
  // input
  int N, V = 100100;
  long long W;
  cin >> N >> W;
  vector<vector<long long>> dp(N + 1, vector<long long>(V, INF));
  dp[0][0] = 0;

  // dp
  rep(i, 0, N){
    long long v, w;
    cin >> w >> v;
    rep(j, 0, V) {
      if (j - v >= 0) chmin(dp[i + 1][j], dp[i][j - v] + w);
      chmin(dp[i + 1][j], dp[i][j]);
    }
  }

  // output
  int ans = 0;
  rep(i, 0, V) if (dp[N][i] <= W) ans = i;
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back

typedef vector<int> vint;
typedef long long ll;


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

    int n;
    cin >> n;
    n %= 10;
    n %= 10;
    switch(n){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            return 0;

        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            return 0;

        case 3:
            cout << "bon" << endl;
            return 0;
    }
}


Measured memory_bytes: 3656
#include <stdio.h>

int main() {
  int x, a, b;
  scanf("%d %d %d", &x, &a, &b);

  int c = a - x;
  int d = b - x;

  if(c < 0) {
    c *= -1;
  }
  if(d < 0) {
    d *= -1;
  }
  if(c < d) {
    puts("A");
  }
  else {
    puts("B");
  }
  
  return 0;
}

Measured memory_bytes: 1636
#include <iostream>
using namespace std;
int main(void){    
    int c;
    while(cin >> c){
        int num=c % 39;
        if(num == 0) cout << "3C39" << endl;
        else if(num >= 1 && num <= 9) cout << "3C0" << c % 39 << endl;
        else cout << "3C" << c % 39 << endl;
    }
     
}



Measured memory_bytes: 3044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;
char s[10];
void solve(){
	
} 
int main(){  
	cin.tie(0);
    ios::sync_with_stdio(false);
	//solve();
	scanf("%s",s);
	if(s[2]==s[3]&&s[4]==s[5]) printf("Yes");
	else printf("No");

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define double long double
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int N=4e5+10;
const double pi=acos(-1);
typedef long long ll;
typedef pair<int,int> pii;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int c[N],st[N],tp=0,f[N];
void modify(int p,int v) {
    while(p<=tp) c[p]=max(c[p],v),p+=p&-p;
}
int query(int p) {
    int ret=-1e9;
    while(p) ret=max(ret,c[p]),p-=p&-p;
    return ret;
}
pii a[N];
int main() {
    int n,x1,y1,x2,y2;
    x1=gi(),y1=gi(),x2=gi(),y2=gi(),n=gi();
    for(int i=1;i<=n;i++) a[i].fi=gi(),a[i].se=gi();
    if(x1>x2) {
        x1=-x1,x2=-x2;
        for(int i=1;i<=n;i++) a[i].fi=-a[i].fi;
    }
    if(y1>y2) {
        y1=-y1,y2=-y2;
        for(int i=1;i<=n;i++) a[i].se=-a[i].se;
    }
    memset(c,0xc0,sizeof(c));
    a[++n]=mp(x1,y1),a[++n]=mp(x2,y2);
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++) st[++tp]=a[i].se;
    sort(st+1,st+tp+1);
    tp=unique(st+1,st+tp+1)-st-1;
    for(int i=1;i<=n;i++) a[i].se=lower_bound(st+1,st+tp+1,a[i].se)-st;
    double ans=x2-x1+y2-y1;
    ans*=100.0;
    int mn=min(x2-x1+1,y2-y1+1);
    y1=lower_bound(st+1,st+tp+1,y1)-st;
    y2=lower_bound(st+1,st+tp+1,y2)-st;
    int cnt=0;
    for(int i=1;i<=n;i++) {
        f[i]=query(a[i].se)+1;
        if(a[i]==mp(x1,y1)) f[i]=0;
        else if(a[i]==mp(x2,y2)) cnt=f[i]-1;
        modify(a[i].se,f[i]);
    }
    ans+=(pi-4)*5*cnt;
    if(cnt==mn) ans+=pi*5;
    printf("%.20Lf\n",ans);
    return 0;
}


Measured memory_bytes: 7424
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    long debt = 100000;
    for (int i = 0; i < n; i++) {
      debt = (long) (debt * 1.05);
      if (debt % 1000 > 0) {
        debt = (debt / 1000 + 1) * 1000;
      }
    }
    System.out.println(debt);
  }
}



Measured memory_bytes: 26148
#include <stdio.h>

#define MAX_H 500000

int H;
int A[MAX_H];

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void maxHeapify(int idx) {
  int l = 2*idx+1;
  int r = 2*idx+2;
  int largest = idx;
  if(l < H && A[largest] < A[l]) largest = l;
  if(r < H && A[largest] < A[r]) largest = r;
  
  if(largest != idx) {
    swap(A+idx, A+largest);
    maxHeapify(largest);
  }
}

void buildMaxHeap() {
  int i;
  for(i = H/2; i >= 0; i--) maxHeapify(i);
}

int main() {
  int i;
  scanf("%d", &H);  
  for(i = 0; i < H; i++) scanf("%d", A+i);

  buildMaxHeap();

  for(i = 0; i < H; i++) printf(" %d", A[i]);
  puts("");
  
  return 0;
}

Measured memory_bytes: 2560
#A
S = str(input())
if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
elif S == "SAT":
    print(1)


Measured memory_bytes: 2940
N,A,B = map(int,input().split())
X = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if (X[i+1] - X[i])*A < B:
        ans += (X[i+1] - X[i])*A
    else:
        ans += B
print(ans)

Measured memory_bytes: 19936
h,w=map(int,input().split())
s=[input() for _ in range(h)]
for i in range(h):
    l = ''
    for j in range(w):
        if s[i][j] == '#':
            l += '#'
        else:
            l += str(sum([t[max(0,j-1):min(w,j+2)].count('#') for t in s[max(0,i-1):min(h,i+2)]]))
    print(l)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
double PI=acos(-1.0);
signed main(){
    string t;cin>>t;
    ll ans=0;
    rep(i,t.size()){
        if(t[i]=='?')cout<<'D';
        else cout<<t[i];
    }
    cout<<endl;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<functional>
#include<algorithm>
#include<queue>
#include<map>
#include<string>
#include<numeric>


#define FOR(i, a, b) for(int i=a; i<b; i++)
#define rep(i, n) for(int i=0; i<n; i++)
#define COUT(a) cout << a << endl;
#define PB push_back

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


P game(ll T, ll W,ll K, bool t){
    if (K == 0) {
        return P(T, W);
    }
    if (t){
        if (T % 2 == 0){
            return game(T/2, W + T/2, K-1, false);
        }else{
            return game((T-1)/2, W + (T-1)/2, K-1, false);
        }
    }else{
        if (W % 2 == 0){
            return game(T + W/2, W/2, K-1, true);
        }else{
            return game( T + (W-1)/2, (W-1)/2, K-1, true);
        }
    }
}

int main() {

    ll A, B, K;
    cin >> A >> B >> K;

    ll a, b;
    tie(a, b) = game(A, B, K, true);

    COUT(a << " " << b);
    

}

Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    string s;
    in1(s);

    if (s.back() == 's')
    {
        outl(s + "es");
    }
    else
    {
        outl(s + "s");
    }

    return 0;
}


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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,s;
    cin >> a >> b;
    s = a*500;
    if(s>=b)
    {
        cout << "Yes" <<endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;

    return 0;
}


Measured memory_bytes: 3628
import itertools

N, M, Q = map(int, input().split())

seisu_list = []

for i in range(Q):
    seisu = list(map(int, input().split()))
    seisu_list.append(seisu)

M_list = [i for i in range(1,M+1)]
A_list = list(itertools.combinations_with_replacement(M_list,N))
#print(A_list)
ans = 0

for i in range(len(A_list)):
    ans_temp = 0
    for j in range(Q):
        if A_list[i][seisu_list[j][1]-1] - A_list[i][seisu_list[j][0]-1] == seisu_list[j][2]:
            ans_temp += seisu_list[j][3]
            ans = max(ans, ans_temp)
print(ans)

Measured memory_bytes: 21456
#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 MAX_HW = 105;
char s[MAX_HW][MAX_HW];
int dp[MAX_HW][MAX_HW];

int f(char c)
{
	if (c == '.') return 1;
	else return 0;
}

int main()
{
	int H,W;
	cin >> H >> W;
	rep(i,H)
	{
		rep(j,W)
		{
			cin >> s[i][j];
		}
	}
	if (s[0][0] == '#') dp[0][0] = 1;
	rep(i,W-1)
	{
		if (s[0][i] == '.' && s[0][i+1] == '#') dp[0][i+1] = dp[0][i] + 1;
		else dp[0][i+1] = dp[0][i];
	}
	rep(i,H-1)
	{
		if (s[i][0] == '.' && s[i+1][0] == '#') dp[i+1][0] = dp[i][0] + 1;
		else dp[i+1][0] = dp[i][0];
	}
	rep(i,H-1)
	{
		rep(j,W-1)
		{
			if (s[i+1][j+1] == '#') dp[i+1][j+1] = min(dp[i+1][j] + f(s[i+1][j]), dp[i][j+1] + f(s[i][j+1]));
			else dp[i+1][j+1] = min(dp[i+1][j],dp[i][j+1]);
		}
	}
	cout << dp[H-1][W-1] << endl;
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    if(n == 1) cout << 1 << endl;
    else if(n<4) cout << 2 << endl;
    else if(n<8) cout << 4 << endl;
    else if(n<16) cout << 8 << endl;
    else if(n<32) cout << 16 << endl;
    else if(n<64) cout << 32 << endl;
    else cout << 64 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
const int INF = 1e9;
const double PI = acos(-1.0);

int main() {
	int n;
	cin >> n;
	vector<int> s(n);
	rep(i, n)cin >> s[i];
	int sum = accumulate(s.begin(), s.end(), 0);
	sort(s.begin(), s.end());

	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}

	rep(i, n) {
		if (s[i] % 10 != 0) {
			sum -= s[i];
			break;
		}
		if (i == n - 1)sum = 0;
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split(" ") )


def sum_up_to(i,j) :
    MOD = int(1e9+7)
    return (( (i+j)*(j-i+1) )//2 ) % MOD

ans = 0
for i in range(K, N+2) :
    ans += ( sum_up_to(N-i+1, N) - sum_up_to(0,i-1) + 1  )

MOD = int(1e9+7)
print(ans%MOD)

Measured memory_bytes: 9204
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
from collections import deque
def resolve():
    N,M=pin()
    edge=dict()
    for i in range(M):
        a,b=pin()
        #non-directed
        edge.setdefault(a,[])
        edge.setdefault(b,[])
        edge[a].append(b)
        edge[b].append(a)
    #print(edge)
    milestones=[0]*(N+1)#1-index
    milestones[1]=1
    c=deque([1])
    #print(c)
    while(1):
        if len(c)==0:
            break
        t=c.popleft()
        #print(t)
        for to in edge[t]:
            #print(f"to={to}")
            if milestones[to]==0:
                milestones[to]=t
                c.append(to)
        #print(c)
        ##print(f"milestones={milestones}")
        ##print(f"endt={t}")
    print("Yes")
    print(*milestones[2:],sep="\n")
        
#%%submit!
resolve()

Measured memory_bytes: 105744
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;

    int arr[n];
    for(int i=0; i<n; i++){
        cin >> arr[i];
    }
    for(int i=n-1; i>=0; i--){
        cout << arr[i];
        if (i!=0) cout << ' ';
        else cout << endl;
    }
}


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>>m(0,vector<char>(W));
  for(int i=0;i<H;i++){
    int k=0;
    vector<char>a(W);
    for(int j=0;j<W;j++){
      cin >> a.at(j);
      if(a.at(j)=='.')
        k++;
    }
    if(k!=W){
      m.push_back(a);
    }//##.# ##.# .#.#
  }
  vector<vector<char>>mm(0,vector<char>(m.size()));//0,3
  for(int i=0;i<W;i++){
    int k=0;
    vector<char>a(m.size());
    for(int j=0;j<m.size();j++){
      a.at(j)=m.at(j).at(i);
      if(a.at(j)=='.')
        k++;
    }
    if(k!=m.size()){
      mm.push_back(a);
    }
  }
  vector<vector<char>>e(mm.at(0).size(),vector<char>(mm.size()));
  for(int i=0;i<mm.at(0).size();i++){
    for(int j=0;j<mm.size();j++){
      e.at(i).at(j)=mm.at(j).at(i);
    }
  }
  for(int i=0;i<e.size();i++){
    for(int j=0;j<e.at(0).size();j++){
      cout << e.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
x, y = map(int, input().split())

def f(x, y):
  ans = [x]
  i = 0
  while True:
    temp = ans[i] * 2
    if temp <= y:
      ans.append(temp)
    else:
      break
    i += 1
  return len(ans)

print(f(x, y))

Measured memory_bytes: 3060
n=int(input())
T=0
H=0
for i in range(n):
    card_t,card_h=input().split()
    if card_t==card_h:
        T+=1
        H+=1
    else:
        if card_h>card_t:
            H+=3
        else:
            T+=3
print(T,H)


Measured memory_bytes: 5600
n, k = gets.split(' ').map{|a|a.to_i}
s = gets.to_s.chomp

# que に "0が連続する数", "1が連続する数" を格納
#   s: 累積和を格納
#   f: 0 or 1 を格納
list_01 = [{s: 0, f: nil}]
counter = ''
s.chars.each do | c |
  if counter == ''
    counter = c
    next
  end
  if counter[0] == c
    counter = counter + c
  else
    list_01 << {s: counter.size + list_01[-1][:s], f: counter[0].to_i}
    counter = c
  end
end
list_01 << {s: counter.size + list_01[-1][:s], f: counter[0].to_i} if counter.size > 0

# 累積和からMaxを算出する
#   起点の f: 0 or 1 により index の start, width が変わる.
max = 0
1.upto(list_01.size-1) do | ind |
  sum, st, wi = 0, 0, 0
  if list_01[ind][:f] == 0
    st = ind
    wi = 2*k
    if ind > 1
      st -= 1
    else
      wi -= 1
    end
  else # == 1
    st = ind
    wi = 2*k
  end
  if st + wi > list_01.size-1
    wi = list_01.size-1-st
  end
  sum = list_01[st+wi][:s] - list_01[st-1][:s]
  max = sum if sum > max
end
p max

Measured memory_bytes: 83280
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};


// D - Equals
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> P(N);
    UnionFind uf(N);

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

    vector<int> X(M), Y(M);
    for(int i=0;i<M;++i){
        cin >> X[i] >> Y[i];
        --X[i];
        --Y[i];
        uf.unionSet(X[i], Y[i]);
    }

    int ans=0;
    for(int i=0;i<N;++i){
        if(uf.findSet(i, P[i])) ++ans;
    }
    cout << ans << endl;
    
    return 0;
}




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

int main() {
  string a, b;
  cin >> a >> b;
  int ab = stoi(a + b);

  int t = sqrt(ab);
  if (pow(t, 2) == ab) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#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() {
  int N, K;
  cin >> N >> K;
  vector<int> snuke(N, 1);
  rep(i, K) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      a--;
      snuke[a] = 0;
    }
  }
  
  int ans = 0;
  rep(i, N) if(snuke[i]) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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

  int n; cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);

  rep(i, n) {
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
  }

  int dp[n][3];
  rep(i, n) {
    rep(j, 3) {
      dp[i][j] = 0;
    }
  }

  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];

  for(int i=1; i<n; i++) {
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
    dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b[i];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
  }

  int ans = max(dp[n-1][0], dp[n-1][1]);
  ans = max(ans, dp[n-1][2]);


  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	ans += min(k, a);
	k = max(k-a, 0);
	k = max(k-b, 0);
	ans -= min(k, c);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
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;
}
ll MOD=1000000000000000000;
int main(){
    ll N;cin>>N;
    vector<ll>A(N);
    rep(i,N){
        cin>>A[i];
    }
    sort(A.begin(),A.end());
    ll ans=1;
    rep(i,N){
        if(A[i!=0]){
            if(ans>MOD/A[i]){
                ans=-1;
                break;
            }
        }
        ans=ans*A[i];
        if(ans==0){
            break;
        }
        if(ans>MOD){
            ans=-1;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4048