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

const ll INF = 10010010010000;

vector<int> to[2505];
vector<ll> rto[2505];
bool reachableFrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachableFrom1[v]) return;
  reachableFrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector<tuple<int,int,int>> edges;
  rep(i,m) {
    ll a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    c = -c;
    edges.emplace_back(a,b,c);
    to[a].push_back(b);
    rto[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i] = reachableFrom1[i]&reachableToN[i];
  { // bellman-ford
    vector<ll> d(n,INF);
    d[0] = 0;
    bool upd = true;
    int step = 0;
    while (upd) {
      upd = false;
      rep(i,m) {
        int a, b, c;
        tie(a,b,c) = edges[i];
        if (!ok[a]) continue;
        if (!ok[b]) continue;
        ll newD = d[a]+c;
        if (newD < d[b]) {
          upd = true;
          d[b] = newD;
        }
      }
      step++;
      if (step > n) {
        puts("inf");
        return 0;
      }
    }
    ll ans = -d[n-1];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoders {
	class Program {
		static void Main(string[] args) {
	
			var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var C = inputArray[0].First();

			//答えの出力
			var ans = C+1;
			Console.WriteLine((char)ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}

Measured memory_bytes: 26128
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

int32_t main()
{
   IOS

    int TESTS=1;
    //cin >> TESTS;
    while (TESTS--)
    {
        string s;
        cin>>s ;

        reverse(all(s));
        ll n=sz(s);
        vi v(n);
        rep(i,0,n)
        {
            v[i]=((s[i]-'0')*modexp(10,i,2019))%2019;
            //what_is(v[i]);
        }
        vi pref(n);
        pref[0]=v[0];
        rep(i,1,n)
        {
            pref[i]=(pref[i-1]+v[i])%2019;
           // what_is(pref[i]);
        }
        ll ans=0;
        map<ll,ll>mp;
        rep(i,0,n)
        {
            if(pref[i]==0)
            {
               ans++;
            }
            ans+=mp[pref[i]];
            mp[pref[i]]++;
        }
        cout<< ans << endl;



    }
    return 0;
}


Measured memory_bytes: 6672
H, W = map(int, input().split())
N = int(input())
A = [int(x) for x in input().split()]
C = []
for i in range(N):
  C += [str(i + 1)] * A[i]
for j in range(H):
  out = C[:W]
  if j % 2:
    out.reverse()
  print(' '.join(out))
  C = C[W:]


Measured memory_bytes: 39792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int t=1;
    for(int i=k;i<n;i+=(k-1))t++;
    cout<<t<<endl;
    return 0;
}


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

int main() {
  vector<int> a(101);
  int b, c, d = 0;
  for (cin >> b; cin >> c; a.at(c)++);
  for (c = 100; b; c--) if (a.at(c)--) if (b-- % 2) d += c++;
  else d -= c++;
  if (d < 0) d *= -1;
  cout << d;
}


Measured memory_bytes: 3532
#ifdef LOCAL
    #define _GLIBCXX_DEBUG
    #define __clock__
#else
    #pragma GCC optimize("Ofast")
#endif
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;
using PII = pair<ll, ll>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())
#define MP make_pair

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

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

    // input
    string s,t;cin>>s>>t;
    cout << t << s << endl;
    
    return 0;
}

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

int main()
{
	int a,b,c,d,x,y;
	cin>>a>>b>>c>>d;
	x=a+b;
	y=c+d;
	if(x>y)
		cout<<"Left";
	if(x<y)
		cout<<"Right";
	if(x==y)
		cout<<"Balanced";
	return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builitin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end());
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
#define F first
#define S second
#define cauto (const auto &)
using P = pair<int, int>;
template <class A, class B>
using pii = vector<pair<A, B>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END
using Graph = vector<vector<P>>;
int N;
Graph G;

void dfs(int n, int par, int pac, vector<int> &res)
{
    int clr = 1;
    if (clr == pac)
        ++clr;
    for (auto x : G[n])
    {
        if (res[x.second] != -1)
            continue;
        res[x.second] = clr;
        dfs(x.first, n, clr, res);
        ++clr;
        if (clr == pac)
            ++clr;
    }
}

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

    cin >> N;
    G.assign(N, vector<P>());
    rep(i, 0, N - 1)
    {
        int a, b;
        cin >> a >> b;
        G[a - 1].emplace_back(b - 1, i);
        G[b - 1].emplace_back(a - 1, i);
    }

    int cnt = 0;
    rep(i, 0, N) chmax(cnt, int(G[i].size()));

    vector<int> res(N, -1);
    dfs(0, -1, -1, res);
    cout << cnt << '\n';
    rep(i, 0, N - 1) cout << res[i] << '\n';
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define ll long long

using namespace std;
ll a[100100],b[100100];

int main()
{
    ll n;  cin >> n;
    for(ll i = 1;i<=n;i++)  cin >> b[i];
    ll Res = 0;
    for(int i = n;i>=1;i--){
        Res+=((n - i) % 2 == 0 ? 1 : -1) * 2 * b[i];
    }
    a[1] = Res/2;
    for(ll i = 1;i<n;i++)  a[i + 1] = 2 * b[i] - a[i];
    for(ll i = 1;i<=n;i++)  cout << a[i] << " ";
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
#include <unordered_map>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
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; }

#define INF 21474836

int N;
int X[100];

int main() {

	cin >> N;
	
	double ave = 0;
	rep(i, N) {
		cin >> X[i];
		ave += X[i];
	}

	ave = ave / (double)N;

	if(ave - (int)ave >= 0.5f){
		ave = (int)ave + 1;
	}
	else {
		ave = (int)ave;
	}
	
	ll ans = 0;
	rep(i, N) {
		ans += pow((X[i] - ave), 2);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// D - Disjoint Set of Common Divisors
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll gcd(ll a, ll b){return b? gcd(b, a%b): a;}

ll p_count(ll n){
	ll count = 0;
	if((n&1) == 0) count++;
	while((n&1) == 0) n >>= 1;

	for(ll p=3; p*p<=n; p+=2){
		if(n%p) continue;
		count++;
		while(n%p == 0) n /= p;
	}

	if(n != 1) count++;
	return count;
}

int main(){
	ll A,B; cin>>A>>B;
	cout<< p_count(gcd(A,B)) + 1 <<endl;;
}

Measured memory_bytes: 384
{-# LANGUAGE BangPatterns, FlexibleContexts #-}

import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Array
import Data.Array.ST
import Data.List
import Debug.Trace (traceShow, traceShowM)
import qualified Data.IntMap.Strict as IM

-- 素数判定
isPrime :: Int -> Bool
isPrime n = all ((/= 0) . (n `mod`)) $ takeWhile ((<= n) . (^ 2)) (primes n)

-- n以下の素数
primes :: Int -> [Int]
primes n = 2 : 3 : filter isPrime xs
  where
    xs = takeWhile (<= n) [6 * i + j | i <- [1 ..], j <- [-1, 1]]

-- 素因数分解
primeFactor :: Int -> IM.IntMap Int
primeFactor n = go IM.empty n $ takeWhile ((<= n) . (^ 2)) (primes n)
  where
    go im 1  _  = im
    go im !k [] = IM.insertWith (+) k 1 im
    go im !k (p:ps)
        | r == 0    = go (IM.insertWith (+) p 1 im) q (p:ps)
        | otherwise = go im k ps
      where
        (q, r) = k `divMod` p

-- 約数の列挙
divisor :: Int -> [Int]
divisor n = foldr f [] $ takeWhile ((<= n) . (^ 2)) [1 .. n]
  where
    f x ds
        | r == 0, q /= x = x : q : ds
        | r == 0         = x : ds
        | otherwise      = ds
      where
        (q, r) = n `divMod` x

----------------------------------------

gen :: Int -> IM.IntMap Int
gen n = foldr (IM.unionWith (+)) IM.empty $ fmap primeFactor [2 .. n]

gen2 :: Int -> [Int]
gen2 n = IM.elems $ gen n

gen3 :: Int -> [Int]
gen3 n = filter (>= 3) $ fmap (+ 1) $ gen2 n

gen4 :: Int -> [[Int]]
gen4 n = do
    x <- gen3 n
    let ys = filter (<= x) $ fmap product $ sequence [[1,3],[1,5,25]]
    return ys

solve :: Int -> Int
solve n = length $ filter (== 75) $ fmap product $ sequence $ gen4 n

main :: IO ()
main = do
    n <- readLn :: IO Int
    print $ solve n
    return ()

Measured memory_bytes: 253180
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
ll ans;
vector<vector<pair<ll,bool>>> Graph(50);
vector<bool> seen(50,false);

void dfs(ll pos)
{
  seen[pos] = true;
  rep(i,sz(Graph[pos]))
  {
    if(Graph[pos][i].second && seen[Graph[pos][i].first] == false)
    {
      dfs(Graph[pos][i].first);
    }
  }

  return;

}
int main()
{
  ll n,m;
  cin >> n >> m;

  // グラフを作る
  rep(i,m)
  {
    ll a,b;cin >> a >> b;
    a--; b--;
    pair<ll,bool> buf;
    buf.first = b;
    buf.second = true;

    Graph[a].push_back(buf);
    buf.first = a;
    Graph[b].push_back(buf);
  }

  ll ans = 0;
  rep(i,n)
  {
    rep(j,sz(Graph[i]))
    {

      rep(k,n)
      rep(l,sz(Graph[k]))
      {
        Graph[k][l].second = true;
      }

      rep(k,50) seen[k] = false;

      Graph[i][j].second = false;
      dfs(0);

      rep(k,n)
      {
        if(seen[k] == false)
        {
          ans++;
          break;
        }
      }
      Graph[i][j].second = true;
    }
  }

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

int main(){
    string s;
    cin >> s;
    ll K;
    cin >> K;
    ll N = s.size();
    rep(i,N){
        if(s[i] == 'a')continue;
        ll manu = 'z'+1- s[i];
        if(manu<=K){
            K -= manu;
            s[i] = 'a';
        }else{
            continue;
        }
    }
    if(K > 0){
        s[N-1] += (K%26);
    }
    cout << s << endl;
}

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

int main(){


  string str;

  int cnt=0,cnt1=0;

  cin>>str;
  
  for(int i=0;i<str.length();i++){

    if(str[i]=='0'){
      cnt++;
    }else{
      cnt1++;
    }
  }

  cout<<min(cnt,cnt1)*2<<endl;
  
  return 0;
}


Measured memory_bytes: 512
n = int(input())
a_lst = list(map(int, input().split()))
lst = []
for i,a in enumerate(a_lst):
    lst.append([i+1,a])
ans = []
for l in sorted(lst, key=lambda x:x[1]):
    ans.append(l[0])
print(' '.join(map(str,ans)))

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

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main() {
	
	double a, b, c, ans;
	scanf("%lf%lf%lf", &a, &b, &c);
	if ((b / 2) * a * a <= c) {
		printdb(90.0 - (rad_to_deg(acot((2.0 * b / a) - (2.0 * c / a / a / a)))));
	}
	else {
		printdb(90.0 - rad_to_deg(atan(2.0 * c / a / b / b)));
	}
}

Measured memory_bytes: 888
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.ST                 as ST
import qualified Data.Array.Unboxed            as AU
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Foldable                 as DF
import           Data.Int
import qualified Data.IntMap                   as IM
import           Data.List
import qualified Data.Map                      as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Set                      as S
import qualified Data.Sequence                 as SQ
import           Data.Time
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
readInts n = replicateM n readInt
readString = map BS.unpack . BS.words <$> BS.getLine
readStrings n = replicateM n <$> readString
toPair [x, y] = (x, y)

main = do
  [n] <- readInt
  p   <- readInt
  q   <- readInt
  print $ fromJust $ solve n p q

solve n p q = do
  x <- a
  y <- b
  return $ abs $ x - y
 where
  s = V.fromList $ sort $ permutations [1, 2 .. n]
  a = V.elemIndex p s
  b = V.elemIndex q s




Measured memory_bytes: 20092
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
  int a,b;cin>>a>>b;
  int ans=-1;
  if(a>9||b>9)
    cout<<ans;
  else
    cout<<a*b;
}

Measured memory_bytes: 256
MOD=10**9+7

def powmod(a,p):
  if p==0:
    return 1
  elif p==1:
    return a
  elif p%2==0:
    powsq=powmod(a,p//2)
    return (powsq**2)%MOD
  elif p%2==1:
    powsq=powmod(a,p//2)
    return (a*powsq**2)%MOD

def invmod(a):
  return powmod(a,MOD-2)

X,Y=map(int,input().split())

if (X+Y)%3!=0:
  print(0)
else:
  u=(2*X-Y)//3
  v=(-X+2*Y)//3
  if u>=0 and v>=0:
    #print(int(u),int(v))
    ui=int(u)
    vi=int(v)

    bunshi=1
    for i in range(vi):
      bunshi*=ui+vi-i
      bunshi%=MOD
    bumbo=1
    for i in range(vi):
      bumbo*=vi-i
      bumbo%=MOD

    #calculate bunshi/bumbo%MOD as bunshi*bumbo^-1%MOD
    print(bunshi*invmod(bumbo)%MOD)
  else:
    print(0)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

type mymap map[int]int

type mapkey []int

func (m mymap) get(n int, def int) int {
	_, ok := m[n]
	if ok {
		return m[n]
	}
	return def
}

func (m mymap) keys() mapkey {
	k := make(mapkey, 0, len(m))
	for i := range m {
		k = append(k, i)
	}
	sort.Sort(k)
	return k
}

func (k mapkey) Len() int {
	return len(k)
}

func (k mapkey) Swap(i, j int) {
	k[i], k[j] = k[j], k[i]
}

func (k mapkey) Less(i, j int) bool {
	return k[i] > k[j]
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	//
	cards := make(mymap)
	for i := 0; i < n; i++ {
		var ai int
		fmt.Scan(&ai)
		cards[ai] = cards.get(ai, 0) + 1
	}
	//
	for i := 0; i < m; i++ {
		var bi, ci int
		fmt.Scan(&bi, &ci)
		cards[ci] = cards.get(ci, 0) + bi
	}
	//
	klist := cards.keys()
	var s int64 = int64(0)
	rest := n
	for _, k := range klist {
		nn := cards[k]
		if rest > nn {
			s += int64(k * nn)
			rest -= nn
		} else {
			s += int64(k * rest)
			break
		}
	}
	fmt.Println(s)
}


Measured memory_bytes: 14980
#include <bits/stdc++.h>
#define INT long long
#define oo 987654321
using namespace std;
INT n, m, k;
string s[110];
int main()
{
	ios::sync_with_stdio(false);
    cin>>n>>m>>k;
    for(int i = 0 ; i <= n ; i++ )
        for(int j = 0 ; j <= m ; j++ )
        {
            if( m*i+((n-i)*j)-(i*j) == k ) return cout<<"Yes"<<endl, 0;
        }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main() {
 	char s[5];
  	scanf(" %s", s);
  	if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) {
      	printf("Yes\n");
    } else {
      	printf("No\n");
    }
}

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

int main(){
	int a[101];
	int i,n;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];	
	}
	
	for(i=n;i>=1;i--){
		cout<<a[i];
		if(i!=1){
			cout<<" ";
		}
	}
	cout<<endl;
	
	
	return 0;
}

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

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

    int N, K;
    cin >> N >> K;

    vector<bool> c(N);

    for(int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for(int j = 0; j < d; j++) {
            int A;
            cin >> A;
            A--;
            c[A] = true;
        }
    }

    int ans = 0;

    for(int i = 0; i < N; i++) {
        if(c[i]) ans++;
    }

    cout << N - ans << endl;
}

Measured memory_bytes: 3656
import java.util.*;

public class Main{
  public static void main(String[] args) {
    try {
      Scanner scan = new Scanner(System.in);
      int a, b, x;
      a = Integer.parseInt(scan.next());
      b = Integer.parseInt(scan.next());
      x = Integer.parseInt(scan.next());

      if(a <= x && x-a <= b){
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
    }
    catch (Exception e) {

    }
  }
}


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

#define int long long

const int N = 1e2 + 10;
int n;

struct ms {
	string s;
	int x, indx;
	
	ms() {
		s.clear();
		x = indx = 0;
	}
	
	ms(string t, int a) {
		s = t;
		x = a;
	}
} ar[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		int x;
		cin >> s >> x;
		ar[i] = ms(s, x);
		ar[i].indx = i;
	}
	sort(ar, ar + n, [&] (ms a, ms b) {
		if (a.s != b.s)
			return a.s < b.s;
		return a.x > b.x;
	});
	
	for (int i = 0; i < n; i++)
		cout << ar[i].indx + 1 << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
   ll n, m; cin >> n >> m;
   ll k; cin >> k;
   vector<ll> a(n), b(m);
   rep(i, n) cin >> a.at(i);
   rep(i, m) cin >> b.at(i);

   vector<ll> c(n+1, 0);
   vector<ll> d(m+1, 0);
   rep(i, n){
      c.at(i+1) = c.at(i) + a.at(i); 
   }

   rep(i, m){
      d.at(i+1) = d.at(i) + b.at(i);
   }

   ll ans = 0;
   ll idc=0, idd=0;
   rep(i, n+1){
      ll tmp = k - c.at(i);
      if(tmp<0) break;

      vector<ll>::iterator pos;
      pos = upper_bound(d.begin(), d.end(), tmp);
      int idtmp;
      if(pos==d.end()){
         idtmp = m;
      }
      else{
         idtmp = distance(d.begin(), pos);
         if(pos!=d.begin()) idtmp--;
      }

      if(ans<i+idtmp){
         ans = i + idtmp;
         idc = i;
         idd = idtmp;
      }
   }

   cout << idc + idd << endl;

  return 0;
}


Measured memory_bytes: 9552
N,M,X,Y = map(int,input().split())
_x = list(map(int,input().split()))
_y = list(map(int,input().split()))
_x.sort()
_y.sort()

if max(_x) >= min(_y):
	print("War")
elif X >= min(_y):
	print("War")
elif Y <= max(_x):
	print("War")
else:
	print("No War")

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
   int r,d,x,i,j;
   scanf("%d %d %d",&r,&d,&x);
   for(j=1;j<=10;j++)
   {
       x=(r*x)-d;
       printf("%d\n",x);
   }
  return 0;
}


Measured memory_bytes: 128
# include <bits/stdc++.h>
using namespace std;
int main() {
  int X, A, B;
  cin >> X >> A >> B;
  
  if(B <= A){
    cout << "delicious" << endl;
  }else if(B - A <= X){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
mod=10**9+7
def nCr(n, r):
    mod=10**9+7
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

n,a,b=map(int,input().split())
w=pow(2, n, mod)-1

ans=w-nCr(n,a)-nCr(n,b)
while ans<0:
    ans+=mod
print(ans%mod)

Measured memory_bytes: 38512
N,Y = map(int, input().split())


a = -1
b = -1
c = -1

flag = 0

'''
    if flag == 1:
        break
    if  Y - 10000 * i  ==0 and i==N:
        a = i
        b = 0
        c = 0
        flag = 1
'''
#    if Y - 10000 * i > 0:
for i in range(N + 1):
    for j  in range(N+1- i):
        k = N - i -j
        if Y - 10000 * i - 5000 * j - 1000 * k == 0:
            a = i
            b = j
            c   = k
            flag = 1
            break


print(str(a) +' '+ str(b) +' '+ str(c))


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

#define DEBUG(C) cerr << #C << " = " << C << endl

using namespace std;
vector<string> split(const string &S, const char sep) {
  vector<string> res;
  string buf = "";
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == sep) {
      res.emplace_back(buf);
      buf.clear();
    } else {
      buf += S[i];
    }
  }
  if (!buf.empty()) {
    res.emplace_back(buf);
  }
  return res;
}

pair<string, vector<string>> parse(const string &S) {
  pair<string, vector<string>> res;
  int now = 0;
  string buf = "";
  for (; now < S.length(); now++) {
    if (S[now] == ':') {
      now++;
      break;
    } else {
      buf += S[now];
    }
  }
  res.first = buf;
  buf.clear();
  res.second = split(S.substr(now), ',');
  if (!res.second.empty()) {
    res.second.back().pop_back();
  }
  sort(res.second.begin(), res.second.end());
  res.second.erase(unique(res.second.begin(), res.second.end()), res.second.end());
  return res;
}

vector<pair<string, vector<string>>> input;
map<int, set<string>> se;

void dfs(int idx) {
  if (se.count(idx)) {
    return;
  }
  for (int i = 0; i < input[idx].second.size(); i++) {
    bool f = true;
    for (int j = 0; j < input.size(); j++) {
      if (input[idx].second[i] == input[j].first) {
        //DEBUG(idx);DEBUG(i);DEBUG(j);
        //DEBUG(input[idx].second[i]);
        f = false;
        dfs(j);
        se[idx].insert(se[j].begin(), se[j].end());
      }
    }
    if (f) {
      se[idx].insert(input[idx].second[i]);
    }
  }
  return;
}

void solve(int n) {
  se.clear();
  input.clear();
  input.resize(n);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    input[i] = parse(s);
    //if (89 <= i && i <= 91) DEBUG(s);
  }
  dfs(0);
  cout << se[0].size() << endl;
}

int main() {
  while (true) {
    int n;
    scanf("%d%d", &n);
    if (n == 0) {
      break;
    }
    solve(n);
  }
  return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll MOD = 1'000'000'007;
ll X, Y;

template <typename T>
std::tuple<T, T, T> extgcd(T a, T b){
    T s1 = 1, t1 = 0, s2 = 0, t2 = 1;
    while(b != 0){
        std::tie(s1, t1, s2, t2) = std::make_tuple(s2, t2, s1 - (a / b) * s2, t1 - (a / b) * t2);
        std::tie(a, b) = std::make_tuple(b, a % b);
    }
    return std::make_tuple(s1, t1, a);
}

// 注意: a と mod が互いに素である必要がある
template <typename T>
T mod_inverse(T a, T mod){
    T b;
    std::tie(b, std::ignore, std::ignore) = extgcd(a, mod);
    if(b < 0){b += mod;}
    return b;
}

template <typename T>
struct Combinatorics{
    T modulo;
    std::vector<T> fact, inv_fact;

    Combinatorics(T max, T modulo) : modulo(modulo), fact(max + 1), inv_fact(max + 1) {
        fact[0] = 1;
        for(T i=1;i<=max;++i){
            fact[i] = i * fact[i - 1] % modulo;
        }

        inv_fact[max] = mod_inverse(fact[max], modulo);
        for(T i=max;i>0;--i){
            inv_fact[i - 1] = i * inv_fact[i] % modulo;
        }
    }

    T nPk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[n - k] % modulo;
    }

    T nCk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[k] % modulo * inv_fact[n - k] % modulo;
    }

    T nHk(T n, T k){
        if(n == 0 && k == 0){return 1;}
        return nCk(n + k - 1, k);
    }
};

Combinatorics<ll> comb(1'001'000, MOD);

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

  std::cin >> X >> Y;

  ll res = 0;

  if((2ll * X - Y) % 3 == 0){
      ll m = (2ll * X - Y) / 3,
          n = X - 2ll * m;

      if(n >= 0 && m >= 0){
          res = comb.nCk(n + m, n);
      }
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define int long  long
#define N 400
using namespace std;
int sum[401] = {0}; 
int DP[401][401];
int a[401];

int sol(int L,int R)
{
    if(DP[L][R]!=-1)
    return DP[L][R];
    if(L==R)
    return 0;
    if(abs(R-L)==1)
    return (a[L] + a[R]);
    int best = 1e14;
    for(int i=L;i<R;i++)
    {
        best = min(best,(int)(sol(L,i) + sol(i+1,R) + sum[R] - sum[L-1]));
    }
    return DP[L][R] = best;
}

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

    memset(DP,-1,sizeof(DP));

    for(int i=1;i<n+1;i++)
    cin>>a[i];

    sum[1] = a[1];

    for(int i=2;i<=n;i++)
    sum[i] = sum[i-1] + a[i];
    cout<<sol(1,n);
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define nl '\n'
#define dbg(a) cout << #a << "=" << a << endl
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define ll long long
#define MX 600000
using namespace std;

ll t[4*MX];

int sum(int v, int tl, int tr, int l, int r) {
    if (l > r)
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return sum(v*2, tl, tm, l, min(r, tm))
           + sum(v*2+1, tm+1, tr, max(l, tm+1), r);
}

void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = t[v*2] + t[v*2+1];
    }
}


void solve()
{
    ll n, q;
    cin>>n>>q;
    vector<long long> v(n);
    for(auto &it:v) cin>>it;
    vector<pair<long long, long long> > qr[n+10];
    for(int i=0;i<q;i++)
    {
        ll l, r;
        cin>>l>>r;
        l--, r--;
        qr[r].push_back({i, l});
    }
    vector<int> prv(n+10), ans(q+10);
    prv.assign(n+10, -1);
    for(int i=0;i<n;i++){
        ll x=v[i];
        if(prv[x]==-1)
        {
            prv[x]=i;
            update(1, 0, n-1, i, 1);
        }
        else
        {
            update(1, 0, n-1, prv[x], 0);
            prv[x]=i;
            update(1, 0, n-1, i, 1);
        }
        // dbg(sum(1, 0, n-1, 0, 2));
        for(auto it:qr[i])
        {
            // dbg(it.first);
            // dbg(it.second);
            // dbg(i);
            ans[it.first]=sum(1, 0, n-1, it.second, i);
        }
        // dbg(t[1]);

    }
    for(int i=0;i<q;i++)
    {
        cout<<ans[i]<<endl;
    }

}

int main()
{
    fast;
    solve();

    return 0;
}


Measured memory_bytes: 44572
// revised submission of https://atcoder.jp/contests/abc176/submissions/16230212 @sabersann

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

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

const int INF = 1001001001;

int main(){
    int H, W; cin >> H >> W;
    int ch, cw; cin >> ch >> cw;
    int dh, dw; cin >> dh >> dw;
    ch--, cw--, dh--, dw--;

    vector<string> s(H);
    vector<vector<int>> dist(H, vector<int>(W, INF));
    rep(i,H) cin >> s[i];
    deque<P> q;

    q.push_back(P(ch, cw));
    dist[ch][cw] = 0;

    while(!q.empty()){
        P p = q.front();
        q.pop_front();
        int x = p.first;
        int y = p.second;
        int tmp = dist[x][y];

        for(int i = 0; i < 4; i++){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if(s[nx][ny] == '#') continue;
            if(dist[nx][ny] <= tmp) continue;

            q.push_front(P(nx, ny));
            dist[nx][ny] = min(dist[nx][ny], tmp);
        }
        for(int j = -2; j <= 2; j++){
            for(int k = -2; k <= 2; k++){
                int nx = x + j;
                int ny = y + k;

                if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
                if(s[nx][ny] == '#') continue;
                if(dist[nx][ny] <= tmp + 1) continue;

                q.push_back(P(nx, ny));
                dist[nx][ny] = min(dist[nx][ny], tmp + 1);
            }
        }
    }
    /*
    rep(i,H){
        rep(j,H) {
            cout << cnt[i][j];
        }
        cout << endl;
    }
    */
    if(dist[dh][dw] == INF) cout << -1 << endl;
    else cout << dist[dh][dw] << endl;
}

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

typedef long long ll;

int N;
ll arr[200001];

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

    ll ret = INT_MAX;
    int left=0;
    int mid=1;
    int right=2;
    for(;mid<N-2;mid++){

        while(abs(arr[left]-(arr[mid]-arr[left])) >= abs(arr[left+1]-(arr[mid]-arr[left+1])))
            left++;

        while(abs((arr[N-1]-arr[right])-(arr[right]-arr[mid])) >= abs((arr[N-1]-arr[right+1])-(arr[right+1]-arr[mid])))
            right++;

        
        ll l1 = arr[left];
        ll l2 = arr[mid]-arr[left];
        ll r1 = arr[right]-arr[mid];
        ll r2 = arr[N-1]-arr[right];

        ll minval = min(min(l1,l2),min(r1,r2));
        ll maxval = max(max(l1,l2),max(r1,r2));

        ret = min(ret, maxval-minval);
    }
    cout<<ret;
    
}

Measured memory_bytes: 1920
#16
n = int(input())
s = [int(input()) for i in range(n)]

Max = sum(s)
s.sort()

if Max%10 ==0:
    for i in range(n):
        if s[i]%10 != 0:
            Max -= s[i]
        if Max%10 !=0:
            break
if Max%10 == 0:
    Max = 0
    
print(Max)

Measured memory_bytes: 9188
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

constexpr ll MOD = 1e9 + 7;

vector<int> get_countinuous(vector<ll>& S, ll diff) {
    const int N = S.size();
    vector<int> imos(N, 0);
    rep(i, N - 1)imos[i] = S[i + 1] - S[i] >= diff ? 1 : 0;
    rep(i, N - 1)imos[i + 1] += imos[i];
    return imos;
}

bool isall(vector<int>& imos, int l, int r) {
    if (l == r)return true;
    int vl = l == 0 ? 0 : imos[l - 1];
    int vr = imos[r - 1];
    return vr - vl == r - l;
}

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> S(N);
    rep(i, N)cin >> S[i];

    auto contA = get_countinuous(S, A);
    auto contB = get_countinuous(S, B);

    vector<vector<ll>> dp(N, vector<ll>(2, 0));
    dp[0][0] = dp[0][1] = 1;

    rep(i, N - 1) {
        // same row
        if (S[i] + A <= S[i + 1])(dp[i + 1][0] += dp[i][0]) %= MOD;
        if (S[i] + B <= S[i + 1])(dp[i + 1][1] += dp[i][1]) %= MOD;

        // diff row
        int L1 = upper_bound(S.begin(), S.begin() + i, S[i + 1] - B) - S.begin();
        int L2 = upper_bound(S.begin(), S.begin() + i, S[i + 1] - A) - S.begin();

        if (isall(contA, L1, i))(dp[i + 1][1] += dp[L1][0]) % MOD;
        if (isall(contB, L2, i))(dp[i + 1][0] += dp[L2][1]) % MOD;
    }

    cout << (dp.back()[0] + dp.back()[1]) % MOD << endl;
    return 0;
}


Measured memory_bytes: 10364
data = input().split(" ")
N, K, C = int(data[0]), int(data[1]), int(data[2])
S = input()

point = 0
work_start = [0] * (K + 1)
for i in range(1, K + 1):
  point = S.find("o", point, N)
  work_start[i] = point + 1
  point += (C + 1)

point = N
work_end = [0] * (K + 1)
for i in range(K, 0, -1):
  point = S.rfind("o", 0, point)
  work_end[i] = point + 1
  point -= C

for i in range(1, K + 1):
  if work_start[i] == work_end[i]:
    print(work_start[i])

Measured memory_bytes: 20604
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

  int size_s = (int)(s.length());
  int size_t = (int)(t.length());

  // cout << size_s << ',' << size_t << endl;

  int counter = 1;
  bool flag = 0;
  int start = -1;

  // size_tだけ，？｜｜tの対応部分と一致すればその中で最後のものにtを挿入．
  for (int i = 0; i < size_s - size_t + 1; i++){
    flag = false;
    for (int j = 0; j < size_t; j++){
      if(s[i+j] != t[j] && s[i+j] != '?') flag = true;
    }
    if(!flag) start = i;
  }

  // cout << start << endl;
  if(start >= 0){
    for(int i = 0; i < size_t; i++){
      s[i+start] = t[i];
    }
    for(int i = 0; i < size_s; i++){
      if(s[i] == '?') s[i] = 'a';
    }

    cout << s << endl;
  }else cout << "UNRESTORABLE" << endl;

  return 0;
}

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

int main () {
    int n;
    std::cin >> n;
    int x = n;
    int f = 0;
    while(n > 0) {
        f += n % 10;
        n /= 10;
    }

    std::string ans = (x % f == 0) ? "Yes" : "No";
    std::cout << ans << "\n";
}

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll X,N;
  cin >> X >> N;
  vector<ll> P(N);
  rep(i,N) cin >> P.at(i);
  sort(all(P));
  ll t=0,m=INF,ans;
  rep(i,102){
    if(t<N&&P.at(t)==i){
      t++;
    }else{
      if(abs(X-i)<m){
        m=abs(X-i);
        ans=i;
      }
    }
  }cout << ans << endl;
  
}

Measured memory_bytes: 3624
N,M  = map(int, input().split())
balls = [1]*(N+1)
reds = [False]*(N+1)
reds[0] = True
for i in range(M):
    x,y = map(int, input().split())
    x -= 1
    y -= 1
    balls[x] -= 1
    balls[y] += 1
    if reds[x]:
        reds[y] = True
    if balls[x] == 0:
        reds[x] = False

print(sum(reds))

Measured memory_bytes: 4596
#include "stdio.h"
#include "stdlib.h"

int main(int argc, char const *argv[]) {
  int S;
  scanf("%d", &S);
  if (S==22) {
    printf("Christmas Eve Eve Eve");
  }
  if (S==23) {
    printf("Christmas Eve Eve");
  }
  if (S==24) {
    printf("Christmas Eve");
  }
  if (S==25) {
    printf("Christmas");
  }
  return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  string s;
  map<char,int> mp;
  cin >> s;
  bool flag = true;
  for(auto au : s){
    if(mp[au] > 0)flag = false;
    else mp[au]++;
  }
  if(flag)cout << "yes" << endl;
  else cout << "no" << endl;







  return 0;
}


Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc119/tasks/abc119_d
// binary search
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int a, b, q;
    cin >> a >> b >> q;

    vector<long> s(a), t(b);

    for(int i = 0; i < a; ++i)
        cin >> s[i];

    for(int i = 0; i < b; ++i)
        cin >> t[i];

    for(int i = 0; i < q; ++i) {
        long x;
        cin >> x;

        long shrine = lower_bound(s.begin(), s.end(), x) - s.begin();
        long temple = lower_bound(t.begin(), t.end(), x) - t.begin();

        long ans = 1L << 60;
        for(int j = 0; j <= 1; ++j) {
            for(int k = 0; k <= 1; ++k) {
                int idx1 = shrine - j;
                int idx2 = temple - k;
                if(idx1 < 0 or idx2 < 0 or idx1 > a or idx2 > b) continue;
                ans = min(ans, abs(x - s[idx1]) + abs(s[idx1] - t[idx2]));
                ans = min(ans, abs(x - t[idx2]) + abs(s[idx1] - t[idx2]));
            }
        }
        cout << ans << endl;
    }

    return 0;
}



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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  const string cols = "RGB";

  int N; cin >> N;
  vector<pair<int, int>> vs(N);
  rep(i, N) {
    cin >> vs[i].first >> vs[i].second;
  }

  vector<string> G(4);
  rep(i, 4) cin >> G[i];

  static int dist[1<<16];
  minus(dist);
  dist[0] = 0;

  queue<int> q;
  q.push(0);

  while(!q.empty()) {
    if(~dist[(1<<16)-1]) break;

    int curr = q.front(); q.pop();

    for(auto hw: vs) {
      int h = hw.first, w = hw.second;

      for(auto col: cols)
      REP(i, -h + 1, 4) REP(j, -w + 1, 4) {
        int next = curr;
        REP(y, max(0, i), min(i + h, 4)) REP(x, max(0, j), min(j + w, 4)) {
          if(G[y][x] == col) next |= 1<<(y * 4 + x);
          else next &= ~(1<<(y * 4 + x));
        }
        if(dist[next] < 0) {
          dist[next] = dist[curr] + 1;
          q.push(next);
        }
      }
    }
  }

  cout << dist[(1<<16)-1] << endl;
    
  return 0;
}

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

int main() {
    string s,p,x;
    cin>>s>>p;
    x = s + s;
    //cout<<x<<endl;
    int begin = -1;
    bool flag = false;
    while ((begin= static_cast<int>(x.find(p, static_cast<unsigned long long int>(begin + 1)))) != string::npos)
    {
        flag = true;
    }
    if (flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3216
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
b=[["."]*w for _ in range(h)]
b[0][0]="#"
now=[0,0]
for i in range(h+w):
    if now[1]<w-1:
        if a[now[0]][now[1]+1]=="#":
            now[1]+=1
            b[now[0]][now[1]]="#"
    if now[0]<h-1:         
        if a[now[0]+1][now[1]]=="#":
            now[0]+=1
            b[now[0]][now[1]]="#"
            
print("Impossible" if a!=b else "Possible")  

Measured memory_bytes: 3064