akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


vector<int> es[200010];

ll d[200010];

int main(){
	int n, m;
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		es[a-1].pb(b-1);
		es[b-1].pb(a-1);
	}
	rep(i, 200010) d[i] = 1e18;
	d[0] = 0LL;
	{
		typedef pll P;
		priority_queue<P,vector<P>,greater<P> > q;
		P p;
		q.push({0LL, 0});
		while(!q.empty()) {
			p = q.top(); q.pop();
			ll cost = p.fi;
			ll prv = p.se;
			if(cost > d[prv]) continue;
			for(auto& nxt : es[prv]) {
				ll ncost = cost + 1;
				if(ncost < d[nxt]) {
					d[nxt] = ncost;
					q.push({d[nxt], nxt});
				}
			}
		}
	}
	if(d[n-1] == 2) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	dump(d[n-1]);
	rep(i, n) dump(d[i]);
}


Measured memory_bytes: 15724
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define sort(a,b) sort(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
 
int main() {
  string a,b;
  ci(a>>b);
  string c=a+b;
  ll d=0;
  for(i,0,c.size())
    d+=(c[i]-'0')*pow(10,c.size()-i-1);
  string e="No";
  for(i,1,d)
    if(i==sqrt(d)){
      e="Yes";
      break;
    }
  co(e);
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int[] a = new int[n];
		for (int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int r = 0;
		for (int i=0;i<k;i++) {
			r += a[i];
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 38720
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

#define x first
#define y second

signed main(){
	cout<<fixed<<setprecision(10);
	
	int xmax = -INF, xmin = INF;
	int ymax = -INF, ymin = INF;
	vector<pair<int,int>> in;
	int N;
	int ans = 0;
	
	cin>>N;
	
	in.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>in[i].x>>in[i].y;
		int X = in[i].x;
		int Y = in[i].y;
		in[i].x = X - Y;
		in[i].y = X + Y;
		
		xmax = max(xmax, in[i].x);
		xmin = min(xmin, in[i].x);
		
		ymax = max(ymax, in[i].y);
		ymin = min(ymin, in[i].y);
	}
	
	
	for(int i = 0; i < N; i++){
		ans = max(ans, abs(xmax - in[i].x));
		ans = max(ans, abs(xmin - in[i].x));
		
		ans = max(ans, abs(ymax - in[i].y));
		ans = max(ans, abs(ymin - in[i].y));
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 6268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N, K;
    cin >> N >> K;
    //cout << min(N % K, abs(N % K - K))<< "\n";
    ll t = N / K;
    cout << min(N - t * K, (t + 1) * K - N) << "\n";
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1); vector<int> B(N+1); vector<int> C(N);
  rep(i,N)
    cin >> A.at(i);
  rep(i,N)
    cin >> B.at(i);
  rep(i,N-1)
    cin >> C.at(i);
  int sum=0;
  rep(i,N)
    sum+=B.at(A.at(i)-1);
  rep(i,N-1)
    if(A.at(i)+1==A.at(i+1))
      sum+=C.at(A.at(i)-1);
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
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; }


/*  PrimeFact
    init(N): 初期化。O(N log log N)
    get(n): クエリ。素因数分解を求める。O(log n)
 */
template <typename T>
struct PrimeFact {
    vector<T> spf;
    PrimeFact(T N) { init(N); }
    void init(T N) { // 前処理。spf を求める
        spf.assign(N + 1, 0);
        for (T i = 0; i <= N; i++) spf[i] = i;
        for (T i = 2; i * i <= N; i++) {
            if (spf[i] == i) {
                for (T j = i * i; j <= N; j += i) {
                    if (spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }
    map<T, T> get(T n) { // nの素因数分解を求める
        map<T, T> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        return m;
    }
    // nの約数の個数を求める
    T get_num(T n) {
        map<T, T> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        T res = 1;
        for(auto k : m){
            res *= (k.second + 1);
        }
        return res;
    }
};


int main(){
    int n;
    ll ans = 0;
    cin >> n;
    PrimeFact<ll> p(n);
    rep2(i, 1, n+1) {
        ans += p.get_num(i) * i;
    }
    cout << ans << endl;
}

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


int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int left,cnt;
  left=0;
  cnt=0;
  for(int i=0;i<s.size();++i){
    if(s[i]=='(') ++cnt;
    else{
      if(cnt==0) ++left;
      else --cnt;
    }
  }
  int right=cnt;
  string ans="";
  for(int i=0;i<left;++i) ans+='(';
  ans+=s;
  for(int i=0;i<right;++i) ans+=')';

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


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#define ll long long
#define ull unsigned long long
#define LLMax LLONG_MAX
#define LLMin LLONG_MIN
#define Max INT_MAX
#define Min INT_MIN
#define FOR1(i,a,b) for(int i=(a);i<(b);i++)
#define FOR2(i,a,b) for(int i=(a);i<=(b);i++)
#define DWN(j,b,a) for(int j=(b);j>=(a);j--) 
#define SET0(a) memset(a,0,sizeof(a))
#define SETN1(a) memset(a,-1,sizeof(a))
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
//#define int long long
const int INF=0x3f3f3f3f;
const int NINF=-INF-1;
const double PI=acos(-1); 
const int mod=1e9+7;
const int maxn=5e5+50;
using namespace std;
int main() {
	//IOS;
	int m,n,sum=0;
	cin>>m>>n;
	FOR2(i,1,n) {
		int temp;
		cin>>temp;
		sum+=temp;
	}
	if(m>=sum) 
		cout<<m-sum<<'\n';
	else
		cout<<-1<<'\n';
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int dfs(int node,vector<vector<int> >&adj,vector<int>&visited)
{
    int cnt=1;
    for(auto var : adj[node])
    {
        if(!visited[var]){
            visited[var]=1;
            cnt+=dfs(var,adj,visited);
        }
    }
    return cnt;
}
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n,m;
    cin>>n>>m;
    vector<vector<int> >adj(n+1);
    vector<int>visited(n+1);
    for(int i=0; i<m; i++){
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    vector<int>grp;
    for(int i=1; i<=n; i++){
        if(visited[i])
            continue;
        visited[i]=1;
        int var=dfs(i,adj,visited);
        grp.push_back(var);
    }
    int ans=*max_element(grp.begin(),grp.end());
    cout<<ans;
    return 0;

}

Measured memory_bytes: 24376
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 100000+5
using namespace std;
char s[100],t[100];
int main(){
  cin>>s>>t;
  int l1=strlen(s),l2=strlen(t);
  if(l2>l1){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }bool f=1;
  int l;
  for(int i=l1-l2;i>=0&&f;i--){

    int j,k;
    for(j=i,k=0;k<l2;k++,j++){
        if(s[j]=='?')
            continue;
        else if(s[j]==t[k])
            continue;
        else break;
    }
    if(k>=l2){
        f=0;
        l=i;
        break;
    }
  }
  if(f==1){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }


  for(int i=0;i<l;i++){
    if(s[i]=='?')
        cout<<"a";
    else cout<<s[i];
  }

  for(int i=1,j=l;i<=l2;i++,j++)
    cout<<t[i-1];

  for(int k=l+l2;k<l1;k++){
     if(s[k]=='?')
        cout<<"a";
    else cout<<s[k];
  }
  cout<<endl;
}


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

const int N = 200010;

string s;
int n;
int f[N][26], nxt[N][26];
int a[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> s; n = s.size(); s = ' ' + s;

	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < 26; ++j) f[i][j] = f[i - 1][j];
		f[i][s[i] - 'a'] = i;
	}

	for (int j = 0; j < 26; ++j) nxt[n + 1][j] = n + 1;

	for (int i = n; i >= 1; --i) {
		for (int j = 0; j < 26; ++j) nxt[i][j] = nxt[i + 1][j];
		nxt[i][s[i] - 'a'] = i;
	}

	int len = 0;
	int lst = n + 1;
	while(1) {
		a[len] = --lst; 
		//cerr << len << ' ' << a[len] << endl;
		++len;
		int mn = lst;
		bool ok = 1;
		for (int j = 0; j < 26; ++j) {
			if (f[lst][j] == 0) {
				ok = 0; break; 
			}
			else mn = min(mn, f[lst][j]);
		}
		if (!ok) break;
		lst = mn;
	}

	int nw = 0;
	string ans = "";
	for (int t = 0; t < len; ++t) {
		++nw;
		for (int j = 0; j < 26; ++j) {
			int k = nxt[nw][j];
			if (k <= a[len - 1 - t]) continue;
			else {
				ans += (char)(j + 'a');  
				nw = k;
				break;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 41296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  
  // 読み込み
  vector<vector<char>> grid(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> grid.at(i).at(j);
    }
  }
  
  // 省略する行と列の判定
  vector<bool> row(H, false); // 行に#が含まれるか
  vector<bool> col(W, false); // 列に#が含まれるか
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (grid.at(i).at(j) == '#'){
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  
  // 出力
  for (int i = 0; i < H; i++) {
    if (!row.at(i)) continue;
    for (int j = 0; j < W; j++) {
      if (!col.at(j)) continue;
      cout << grid.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            var tmp = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            Console.WriteLine(tmp[0] + tmp[1] >= tmp[2] ? "Yes" : "No");
        }
    }
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int used[200010];
vector<int> edge[200010];

void dfs(int v) {
  used[v] = 1;
  for (int c : edge[v]) {
    if (not used[c]) dfs(c);
  }
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M; cin >> N >> M;
  REP(i, N) {
    int K; cin >> K;
    REP(j, K) {
      int l; cin >> l; l--;
      edge[i].push_back(N+l);
      edge[N+l].push_back(i);
    }
  }

  dfs(0);
  REP(i, N) {
    if (not used[i]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    vector<int> H(N); for (auto &h : H) cin >> h;
    H[0]--;
    bool fail = false;
    for (int i = 1; i < N; i++) {
        if (H[i-1] < H[i]) H[i]--;
        if (H[i-1] > H[i]) fail = true;
    }
    cout << (fail ? "No" : "Yes") << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>

int top,S[1000];

void push(int x){
	S[++top]=x;
}
int pop(){
	top--;
	return S[top+1];
}
int main(){
	int a,b;
	top=0;
	char s[100];
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

int leftcost[100005];
int rightcost[100005];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin >> n >> k;
	vi arr(n);
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	int mn = MOD;
	for(int i = 0; i+k <= n; i++) {
		if(arr[i+k-1] <= 0) {
			mn = min(mn,-arr[i]);
		} else if(arr[i] >= 0) {
			mn = min(mn,arr[i+k-1]);
		} else {
			mn = min(mn,min(2*max(arr[i+k-1],0)-min(0,arr[i]),max(arr[i+k-1],0)-2*min(0,arr[i])));
		}
	}
	cout << mn;
	return 0;
}



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

using namespace std;

pair<int,pair<int,int>> dp[3001][3001];

int main(){
  string s,t;
  cin >> s >> t;
  for(int i = 0; i < s.length(); i++){
    for(int j = 0; j < t.length(); j++){
      if(s[i]==t[j] && dp[i+1][j+1].first < dp[i][j].first+1){
          dp[i+1][j+1] = make_pair(dp[i][j].first+1,make_pair(i,j));
      }
      if(dp[i][j].first>dp[i+1][j].first)
        dp[i+1][j] = dp[i][j];
      if(dp[i][j].first>dp[i][j+1].first)
        dp[i][j+1] = dp[i][j];
    }
  }
  string ans = "";
  pair<int,pair<int,int>> val = dp[0][0];
  for(int i = s.length(); i>=0; i--)
    for(int j = t.length(); j>=0; j--)
      val = max(val,dp[i][j]);
  while(val.first > 0){
    ans += s[val.second.first];
    val = dp[val.second.first][val.second.second];
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 105728
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=2e5+5;

#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back()
#define se second
#define fi first
#define test(t) int t;cin>>t;while(t--)
#define debug(x) cerr<<"=>"<<#x<<" = "<<x<<endl

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp);
    if(b%2){
        temp=(temp*a);
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference, debug statements can also cause TLE.
//priority_queue implements max heap by default

bool check(vl &a,int mx,ll k){
    ll used = 0;
    forn(i,0,a.size()){
        if(a[i]>mx){
            used += a[i]/mx;
        }
    }
    return used<=k;
}

int main(){
    fastio;
    // think about edge cases like n=1(especially graph questions).
    ll n,k;
    cin>>n>>k;
    vl a(n);
    for(auto &x:a){
        cin>>x;
    }
    sort(a.begin(),a.end());
    int lo = 1,hi = 1e9,best = a[n-1];
    while(lo<=hi){
        int mid = (lo+hi)/2;
        // debug(mid);
        if(check(a,mid,k)){
            best = mid;
            hi = mid-1;
        }
        else{
            lo = mid+1;
        }
    }
    cout<<best;
    return 0;
}

Measured memory_bytes: 4776
-- 参考: @matonix https://atcoder.jp/contests/aising2020/submissions/15176826
import Data.Bits
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt = fst . fromJust . BS.readInt

getInt = readInt <$> BS.getLine

getVU n = VU.reverse . VU.unfoldrN n BS.uncons <$> BS.getLine

createBits :: VU.Vector Char -> Integer
createBits = VU.ifoldl' (\bit index value -> if value == '1' then setBit bit index else bit) zeroBits

simulate :: Integer -> Integer -> Integer
simulate count 0 = count
simulate count x = simulate (count + 1) (x `mod` (fromIntegral (popCount x)))

main = do
  n <- getInt
  x <- getVU n
  let x' = createBits x
  let xs = [complementBit x' i | i <- reverse [0 .. n -1]]
  mapM_ (print . (simulate 0)) xs


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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++)
        cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < i; j++)
        {
            for (int k = 0; k < j; k++)
            {
                if (l[k] != l[j] and l[i] != l[j] and l[k] + l[j] > l[i])
                {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >>n;
  vi d(n);
  rep(i,n) cin>>d[i];
  ll ans =0;
  rep(i,n) for (int j=i+1; j<n; j++) {
    ans += d[i]*d[j];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	x := nextInt64()
	y := nextInt64()

	v := x
	cnt := int64(0)
	for v <= y {
		cnt++
		v = pow(2, cnt-1) * x
	}

	fmt.Println(cnt - 1)

}
func pow(a, b int64) int64 {
	var ret int64 = 1
	for b > 0 {
		if (b & 1) == 1 {
			ret *= a
		}
		a *= a
		b >>= 1
	}
	return ret
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
int main(){
  int l,r,d;cin >> l >> r >> d;
  int ans = 0;
  for(int i=l;i<=r;i++){
    if(i % d == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n){
    cin >> h[i];
  }
  int highest=0;
  int sea=0;
  for(int i=0;i<n;i++){
    if(h[i]>=highest){
      highest = h[i];
      //cout << highest << endl;
      sea+=1;
    }
  }
    cout << sea << endl;
}

Measured memory_bytes: 256
/**
 * Title: E - This Message Will Self-Destruct in 5s
 * Url: https://atcoder.jp/contests/abc166/tasks/abc166_e
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    map<ll, ll> Li, Ri;
    for(int i=0; i<n; i++) {
        Li[i+1-a[i]]++;
        Ri[i+1+a[i]]++;
    }
    ll ans = 0;
    for(auto li:Li) {
        if(Ri.count(li.first)!=0) {
            ans += li.second * Ri[li.first];
        } 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 28004
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int x, y, z;
  cin >> x >> y >> z;
  cout << (x-z) / (y+z) << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#define MAX 26

using namespace std;

int main(void)
{
  int counter[MAX] = {0},num;
  char ch;
  while(cin >> ch)
  {
    if('a' <= ch && ch <= 'z')num = ch - 'a';
    else if('A' <= ch && ch <= 'Z')num = ch - 'A';
    else continue;
    counter[num]++;
  }
  for(int i = 0 ; i < MAX ; i++)
  {
    cout << (char)('a' + i) << " : " << counter[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
    char ch;
    while (1)
    {
        scanf("%c",&ch);
        if(islower(ch)){printf ("%c",toupper(ch));
        }else if(isupper(ch)){printf ("%c",tolower(ch));
        }else if (ch){printf ("%c",ch);}
        if (ch == '\n')break;
    }
return 0;
}


Measured memory_bytes: 2620
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/*************************************/
int ok(int a, int b, int c) {
  return a < b + c && b < a + c && c < a + b;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n;
  cin >> n;
  const int nax = 1e3 + 42;
  vector<int> a(n), b(nax);
  for (int &z : a) cin >> z, b[z]++;
  vector<int> p = b;
  for (int i = 1; i < nax; ++i) {
    p[i] += p[i - 1];
  }
  i64 ans = 0;
  for (int i = 1; i < nax; ++i) {
    for (int j = i + 1; j < nax; ++j) {
      int up = i + j - 1;
      uin(up, nax - 1);
      ans += (i64) b[i] * b[j] * (p[up] - p[j]); 
      if (ok(i, j, j)) {
        ans += (i64) b[i] * b[j] * (b[j] - 1) / 2;
      }
      if (ok(i, i, j)) {
        ans += (i64) b[j] * b[i] * (b[i] - 1) / 2;
      }
    }
    ans += (i64) b[i] * (b[i] - 1) * (b[i] - 2) / 6;
  }
  kek(ans);
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

vector<int> G[MAX_N];
vector<int> ord;
int depth[MAX_N];
int id[MAX_N];
bool flag[MAX_N];

//?????????????????????0?§???????
//????°????????±???????????????°??????(RMQ)
const int N = 1 << 18;	//10^5?¨????

//?????°???????????¨???????????°??????????????????

int n_;
int dat[2*N-1];
int idx[2*N-1];

//?????????
//n_???x??\??????????°????2????????????
void init(int x)
{
	//?°????????????????????´???°???2???????????????
	n_=1;
	while(n_<x){
		n_*=2;
	}
	rep(i,2*n_-1){
		dat[i] = INF;
        idx[i] = -1;
	}
}

//k???????????????a????????´??????
void update(int k,int a)
{
	//????????????
	k += n_-1;
	dat[k] = a;
    idx[k] = k - (n_-1);
	//?????????????????´??°
	while(k>0){
		k = (k-1)/2;
		if(dat[2*k+1] < dat[2*k+2]){
            dat[k] = dat[2*k+1];
            idx[k] = idx[2*k+1];
        }else{
            dat[k] = dat[2*k+2];
            idx[k] = idx[2*k+2];
        }
	}
}

P query(int a,int b,int k=0,int l=0,int r=n_)
{
	if(r <= a || b <= l){
		return P(INF,-1);
	}
	if(a <= l && r <= b){
		return P(dat[k],idx[k]);
	}else{
		P vl = query(a,b,2*k+1,l,(l+r)/2);
		P vr = query(a,b,2*k+2,(l+r)/2,r);
		return min(vl,vr);
	}
}

void dfs(int u,int k)
{
    id[u] = ord.size();
    ord.pb(u);
    flag[u] = true;
    depth[u] = k;
    rep(i,G[u].size()){
        if(!flag[G[u][i]]){
            dfs(G[u][i],k+1);
            ord.pb(u);
        }
    }
}

int main()
{
    int n;
    cin >> n;
    rep(i,n){
        int m;
        scanf("%d",&m);
        rep(j,m){
            int x;
            scanf("%d",&x);
            G[i].pb(x);
        }
    }
    dfs(0,0);
    init(ord.size());
    rep(i,ord.size()){
        update(i,depth[ord[i]]);
    }
    int q;
    cin >> q;
    rep(i,q){
        int u,v;
        scanf("%d%d",&u,&v);
        printf("%d\n",ord[query(min(id[u],id[v]),max(id[u],id[v])+1).se]);
    }
    return 0;
}

Measured memory_bytes: 18840
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int a1 = a;
        int b1 = b;
        while (a1 != b1){
            if(a1 > b1)a1 -= b1;
            else b1 -= a1;
        }
        a /= a1;
        b /= a1;
        System.out.println(sc.nextInt() * a * b);
    }



}



Measured memory_bytes: 26228
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976
const double PI = 3.1415926535897932;

int main()
{
    ll a,b,c,k; cin >> a >> b >> c >> k;
    ll sum = 0;
    sum += min(a,k);
    k -= a;
    if(k > 0) k -= b;
    if(k > 0){
        sum -= k;
    }
    cout << sum;
    
}

Measured memory_bytes: 3636
#include <iostream>
#include <limits>
#include <algorithm>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, r, min_r, max_p = numeric_limits<int>::min();
    cin >> n >> min_r;
    for (int i = 1; i < n; i++) {
        cin >> r;
        max_p = max(max_p, r - min_r);
        min_r = min(min_r, r);
    }
    cout << max_p << endl;
    return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
#include <set> 
using namespace std;

typedef long long ll;
typedef pair<ll, int> P;
typedef pair<pair<int, int>, int> PP;

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

const int MAX = 510000;
const int MOD = 1000000007;

ll c[3000][3000];

int main(void) {
	int N, K; cin >> N >> K;

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

	for (int i = 2; i < N + 10; i++) {
		for (int j = 1; j < i; j++) {
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD;
		}
	}

	for (int i = 1; i <= K; i++) {
		cout << (c[N - K + 1][i] * c[K - 1][i - 1]) % MOD << endl;
	}
	
}


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




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

    int n, m,s=0,t=0;
    cin >> n >> m;
    vector<ll> a(n), b(m);
    ll mod = 1e9 + 7,ans=1;

    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    for (int i = n * m; i > 0;i--){
        int x=-1, y=-1;
        rep(j,n)if(a[j]==i){
            if(x!=-1)
                ans = 0;
            x = j;
            s++;
        }
        rep(j, m) if (b[j] == i){
            if (y != -1)
                ans = 0;
            y = j;
            t++;
        }

        if(x==-1&&y==-1){
            ans *= (s * t - m * n +i);
            ans %= mod;
        }
        else if(x==-1&&y!=-1){
            ans *= s;
            ans %= mod;
        }
        else if(y==-1&&x!=-1){
            ans *= t;
            ans %= mod;
        }

    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main () {
	long input , n;
	long max = -10000001 , min = 10000001 , sum = 0;
	long i;
	scanf("%ld" , &n);
	for(i = 0; i < n; i++) {
		scanf("%ld" , &input);
		sum += input;
		if (input < min) {
			min = input;
		}
		if (max < input) {
			max = input;
		}
	} 
	printf("%ld %ld %ld\n" , min , max , sum);
	return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

string S, T;
int cnts[int(1e5+5)], cntt[int(1e5+5)];

int main(){
  cin >> S >> T;
  int N = S.length();
  for (int i = 1; i <= N; i++){
    if (S[i-1] == 'A') cnts[i] = 1;
    else cnts[i] = 2;

    if (T[i-1] == 'A') cntt[i] = 1;
    else cntt[i] = 2;
  }

  for (int i = 1; i <= N; i++){
    cnts[i] += cnts[i-1];
    cntt[i] += cntt[i-1];
  }

  int Q; cin >> Q;
  for (int i = 0; i < Q; i++){
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int s = cnts[B] - cnts[A-1];
    int t = cntt[D] - cntt[C-1];

    if ((s-t) % 3 == 0) YES();
    else NO();
  }

  return 0;
}


Measured memory_bytes: 4524
/*
 * Author : anaksoleh
 * 8 September 2019
 *
 */

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

int N;
int arr[105];

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

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

	int s1 = 0;
	int s2 = 0;
	vector<int> v;
	for(int T = 1 ; T < N ; T++){
		s1 = accumulate(arr+1,arr+T+1,0);
		s2 = accumulate(arr+T+1,arr+N+1,0);
		v.push_back(abs(s1-s2));
	}
	sort(v.begin(),v.end());
	cout << v[0] << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
bool ac[100006];
int wa[100006];
int ans0,ans1;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int k;
		string t;
		cin>>k>>t;
		if(ac[k])
		{
			continue;
		}
		if(t=="WA")
		{
			wa[k]++;
		}
		else
		{
			ac[k]=true;
			ans1+=wa[k];
			ans0++;
		}
	}
	cout<<ans0<<" "<<ans1;
}

Measured memory_bytes: 768
import java.util.Scanner;

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

        int x = sc.nextInt();

        System.out.println(solve(x));

        sc.close();
    }

    static String solve(int x) {
        return (x < 1200) ? "ABC" : "ARC";
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    double a,sum=0.0;
    rep(i,n){
        cin>>a;
        sum+=1.0/a;
    }
    sum=1.0/sum;
    cout<<setprecision(6)<<sum;
}

Measured memory_bytes: 3756
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define int 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; }
    const int MAX =1002;
const int MOD =1000000007;

  
  
signed main(){
int n,m,q;
cin>>n>>m>>q;
int a[q];
for(int i=0;i<q;i++)cin>>a[i];
int x[m],y[m]={};
vector<int> v,w;
fill(x,x+m,MOD);
for(int i=0;i<q;i++){
  if(x[a[q-1-i]-1]==MOD){
    x[a[q-1-i]-1]=v.size();
    v.push_back(0);
    w.push_back(a[q-1-i]-1);
  }
  if(x[a[q-1-i]-1]==0||v[x[a[q-1-i]-1]]<v[x[a[q-1-i]-1]-1])v[x[a[q-1-i]-1]]++;
}
for(int i=0;i<m;i++)if(x[i]==MOD)w.push_back(i);
int k=0;
while(k<v.size()&&v[k]>=n)k++;
for(int i=k;i<w.size()-1;i++)if(w[i]>=w[i+1]){
  cout<<"No"<<endl;
  return 0;
}
cout<<"Yes"<<endl;
return 0;

}

Measured memory_bytes: 7372
#include <stdio.h>

int main(void)
{
   int n, x, i, j, k;
   int wa = 0;
   while (1) {
      scanf("%d %d", &n, &x);

      if ( n == 0 && x == 0 )
         break;

      wa = 0;

      for ( i = 1; i < n-1; i++ ) {
         for ( j = i+1; j < n; j++ )
            for ( k = j+1; k <= n; k++ )
               if ( i+j+k == x ) {
                  wa = wa+1;
               }
      }
   printf("%d\n", wa);
   }
   return 0;
}

Measured memory_bytes: 1844
#include<stdio.h>


int main(){
    
    int i,j,temp,n,k,p[1000],result=0;
    
    scanf("%d %d",&n,&k);
    
    for(i=0;i<n;i++){
    	scanf("%d",&p[i]);
	}
    
    for(i=0;i<n;i++){
    	for(j=0;j<n;j++){
    		if(p[i]<p[j]){
    			temp=p[i];
    			p[i]=p[j];
    			p[j]=temp;
			}
		}
	}
    
   /* for(i=0;i<n;i++){
    	printf("%d ",p[i]);
	}*/
	
	for(i=0;i<k;i++){
		result+=p[i];
	}
	
	printf("%d",result);
    
	return 0;	
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  char C;
  cin >> C;
  cout << (char) (C + 1) << endl;
}

Measured memory_bytes: 256
import heapq

def dijkstra(N,start, goal, E):
    """最短距離,経路を返すプログラム"""
    dist = [float('inf')] * N          #dist[i]:始点からの距離
    path = [tuple() for n in range(N)] #path[i]:(start,...,i)までの経路をカンマで区切ったもの
    dist[start] = 0
    path[start] = (start, )            
    pq = [(0, path[start])]

    while pq:
        di, pathi = heapq.heappop(pq)
        v = pathi[-1]

        if v == goal:
            return di

        #辺を全部見る
        for vertex, weight in E[v].items():
            new_di = di + weight
            if (new_di < dist[vertex]) or (new_di == dist[vertex] and pathi + (vertex, ) < path[vertex]):
                dist[vertex] = new_di
                path[vertex] = pathi + (vertex, )
                heapq.heappush(pq, (new_di, path[vertex]))



N = 10
H,W = map(int, input().split())
E = [dict() for i in range(10)]
ans = 0

tank = [0] * 10
for i in range(10):
    tmp = list(map(int,input().split(" ")))
    for j in range(10):
        E[i][j] = tmp[j]

for i in range(H):
    A = list(map(int,input().split(" ")))
    for j in range(W):
        if abs(A[j]) != 1:
            if tank[A[j]] == 0: 
                tank[A[j]] = dijkstra(N,A[j],1,E)

            ans += tank[A[j]]

print(ans)



Measured memory_bytes: 3188
#include<iostream>
#include<string>
using namespace std;
 
int main()
{
    string str, com, p;
    int q, a, b;
 
    cin >> str >> q;
 
    for (int i = 0; i < q; i++) {
        cin >> com >> a >> b;
        if (com == "print") {
            cout << str.substr(a, b - a + 1) << endl;
        }
        else if (com == "reverse") {
            string tmp = str.substr(a, b - a + 1);
            int n = tmp.size();
            for (int j = 0; j < n; j++)str[j + a] = tmp[n - j - 1];
        }
        else if(com=="replace"){
            cin >> p;
            str = str.replace(a, b - a + 1, p);
        }
    }
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi; 

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


    //keep it simple stupid 

Measured memory_bytes: 19276
#include<stdio.h>
 
int main(void){
  int i;
  int n;
  int m;
  int a;
  scanf("%d%d",&n, &m);
  for(i = 0; i < m; i++){
    scanf("%d", &a);
    n -= a;
  }
  if (n < 0)
    printf("-1\n");
  else
    printf("%d\n",n);
}

Measured memory_bytes: 1732
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime)
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(999999, prime);

	for(;;){
		int a, d, n;
		cin >> a >> d >> n;;
		if(a == 0 && d == 0 && n == 0)
			break;

        a -= d;
        while(n > 0){
            a += d;
            if(prime[a])
                -- n;
        }
        cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
    int a,b,c,d;
    scanf("%d%d%d",&a,&b,&c);
    d=a*100+b*10+c;
    if(d%4==0){
        printf("YES");
    }
    else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <bitset>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = long long;

int main(){
    
    int N,Q;
    scanf ("%d %d",&N,&Q);
    vector<ll> a(N);
    rep(i,0,N) scanf("%lld" , &a[i]);
    fenwick_tree<ll> bit(N);
    rep(i,0,N) bit.add(i,a[i]);

    rep(i,0,Q){

        ll x,y,z;
        scanf ("%lld %lld %lld" , &x , &y , &z );

        if (x == 0) {
            bit.add(y,z);
        }else{
            printf("%lld\n" , bit.sum(y,z));
        }
    }
}

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

using namespace std;

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

  int n, a, b;
  cin >> n >> a >> b;

  vector < int > v(n);
  for(int &x : v) cin >> x;
  
  auto inRange = [&](const int &l, const int &r) {
    int w = lower_bound(v.begin(), v.end(), l) - v.begin();
    int h = upper_bound(v.begin(), v.end(), r) - v.begin();
    return h - w;
  };
  sort(v.begin(), v.end());

  cout << min(min(inRange(0, a), inRange(a + 1, b)), inRange(b + 1, 100));

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define TAKA 1
#define AO 0

int main(void){
    int taka, ao;
    int k;
    scanf("%d %d %d", &taka, &ao, &k);

    int pass_person = TAKA;
    for(int loop = 0; loop < k; loop++){
        int taka_half = taka / 2;
        int ao_half = ao / 2;
        
        if(pass_person == TAKA){
            if(taka % 2 == 1) taka--;
            taka -= taka_half;
            ao += taka_half;
            pass_person = AO;
        }else{
            if(ao % 2 == 1) ao--;
            ao -= ao_half;
            taka += ao_half;
            pass_person = TAKA;
        }
    }

    printf("%d %d\n", taka, ao);
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  for( int i = 0; i < n; i++ ){
    int point = 0,runner = 0,out = 0;
    while(1){
      if(out == 3 ){
	out = 0;
	break;
      }
   
      string str;  cin >> str;
    
      if( str == "HIT" ){
	runner++;
	if( runner == 4){
	  point +=1;
	  runner--;
	}
      }else if( str == "HOMERUN" ){
	point += runner+1;
	runner = 0;
      }else if( str == "OUT"){
	out++;
	if( out == 3 ){
	  cout << point << endl; 
	}
      }
 
    }
  }
  return 0;
}

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

using namespace std;

int main()
{
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
        if (i % 15 == 0 && i > 0)
            ans += 600;
        else
            ans += 800;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys


def solve(N: int, P: "List[int]"):
    smallest = 2 * 10**6
    count = 0
    for p in P:
        if p <= smallest:
            count += 1
            smallest = p
    print(count)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P)

if __name__ == '__main__':
    main()


Measured memory_bytes: 25984
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	int x=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		x=x^(a[i]);
	}
	for(int i=0;i<n;i++)
	{
		cout<<int(a[i]^x)<<" ";
	}
	
}

Measured memory_bytes: 4304
//+-----------------+//
//|😈_Anonymous06_😈|//
//+-----------------+//
#include <bits/stdc++.h>
#define ll/*////////*/long long
#define gcd()/*////////*/___gcd()
#define pi/*////////*/3.141592653
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//------Enter your code here.------
	int n,k,ans=0;cin>>n>>k;int ar[n];for(int i=0;i<n;i++){cin>>ar[i];}sort(ar,ar+n);
	for(int i=0;i<k;i++){ans+=ar[i];}
	cout<<ans<<"\n";
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
typedef long long LL;
const int N = 1e5;
using namespace std;
 
 
int main(){
	
	LL n,m,res;
	cin>>n>>m;
	if(m==1 && n==1) res = 1;
	else if(n==1)res = n*(m-2);
      else if(m==1)res=(n-2)*m;
  else res = (n-2)*(m-2);
	cout<<res;
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll gcd(ll a, ll b) { 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    ll i,j,k,n,r,a,b;

    cin>>a>>b;

    r=(a*b)/gcd(a,b);
    cout<<r<<"\n";




    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
	int main(void) {
		int a, b, x, r;
		scanf("%d %d %d", &x, &a, &b);
		if(a<1 || a>1000000000 || b<1 || b>1000000000 || x<1 || x>1000000000){
			return 1;
		}
		r = a-b;
		if(r>=0){
			printf("delicious");
		}
		else{
			if(-r<=x){
				printf("safe");
			}
			else{
				printf("dangerous");
			}
		}
	}

Measured memory_bytes: 128