akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n,k;
	string s;
	cin>>n>>k>>s;

	vi a;
	int tmp=1;
	if(s[0]=='0') a.pb(0);

	rep(i,n-1){
		if(s[i+1]!=s[i]){
			a.pb(tmp);
			tmp=1;
		}else{
			tmp++;
		}
	}
	a.pb(tmp);

	if(s[n-1]=='0') a.pb(0);

	int m=a.size();

	// rep(i,m) cout<<a[i]<<' ';
	// cout<<endl;


	vi sum(m+1);
	sum[0]=0;
	rep(i,m) sum[i+1]=sum[i]+a[i];

	// rep(i,m+1) cout<<sum[i]<<' ';
	// cout<<endl;

	int ans=0;

	if(2*k+1>=m+1){
		k=m/2;
	}

	for(int i=0;i+2*k+1<m+1;i+=2){
		chmax(ans,sum[i+2*k+1]-sum[i]);
	}

	
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 4924
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BRGBBoxes solver = new BRGBBoxes();
        solver.solve(1, in, out);
        out.close();
    }

    static class BRGBBoxes {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int R = in.ni(), G = in.ni(), B = in.ni(), N = in.ni();
            int ans = 0;
            for (int r = 0; r * R <= N; r++) {
                for (int g = 0; g * G + r * R <= N; g++) {
                    if ((N - g * G - r * R) % B == 0)
                        ans++;
                }
            }
            out.println(ans);
        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

    }
}



Measured memory_bytes: 23380
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, k, a;

	cin >> n >> k;

	vector<ll> v;
	vector<ll> v1(n, 0);
	vector<ll> v2(2000, 0);
	ll sum1 = 0;
	ll sum2 = 0;

	REP(i, n) {
		cin >> a;
		v.push_back(a);
	}

	REP(i, n) {
		FOR(j, i, n) {
			if (v[i] > v[j]) {
				v1[i]++;
			}
		}
	}

	REP(i, n) {
		sum1 += v1[i];
	}

	REP(i, n) {
		REP(j, n) {
			if (i == j) {
				continue;
			}
			else {
				if (v[i] > v[j]) {
					sum2++;
				}
			}
		}
	}

	ll ans = sum1 * k;

	ll x = (k - 1) * k / 2;

	ans += (sum2 * (x % MOD)) % MOD;

	cout << ans % MOD << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
const string el = "\n";
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
int out(int a){cout << a << el; return 0;}
int out(string s = "NO"){cout << s << el; return 0;}
template <class T>
inline int out(vector<T>&v,string c = " "){
    for(int i = 0; i < v.size(); ++i){
        if(i) cout << c; cout << v[i];
    } cout << el;return 0;
}
#include <bits/stdc++.h>
template <class T>
class Cumulative2DSum {
    // query[sx,gx),[sy,gy)
public:
    vector<vector<T>>sum;
    T e;
    Cumulative2DSum(vector<vector<T>>&v,T e) {
        // W is x, H is y
        int W = v.front().size();
        int H = v.size();
        ++H , ++W;
        sum = vector<vector<T>>(H,vector<T>(W,e));
        
        for(int i = 0; i < v.size(); ++i){
            for(int j = 0; j < v[i].size(); ++j){
                sum[i + 1][j + 1] +=  v[i][j];
            }
        }
        for(int i = 1; i < sum.size(); ++i){
            for(int j = 1; j < sum[i].size();++j){
                sum[i][j] += sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1];
            }
        }
    }
    T query(int sx,int sy,int gx,int gy){
        return sum[gy][gx] - sum[sy][gx] - sum[gy][sx] + sum[sy][sx];
    }
};

signed main(){
    fast_io();
    int N,M,Q;
    cin >> N >> M >> Q;
    vector<vector<int>>grid(N + 1,vector<int>(N + 1,0LL));
    rep(i,M){
        int y,x; cin >> y >> x;
        --y,--x;
        grid[y][x]++;
    };
    auto csum = Cumulative2DSum<int>(grid,0LL);
    rep(_,Q){
        int l,r; cin >> l >> r;
        out(csum.query(l-1, l-1, r, r));
    }
}




Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 55,mo=1e9+7;
int n,f[N][N][N],C[N][N];
inline int getz(int x){return x>0?x:0;}
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
int main() {
	read(n);rep(i,0,n){
		C[i][0]=C[i][i]=1;
		rep(j,1,i-1)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	}
	f[0][1][0]=1;
	rep(x,0,n)rep(a,0,n)rep(b,0,n)if(f[x][a][b]&&x+a+b<=n&&a+b)rep(A,0,a+b){
		//if(!A)printf("%d %d %d:%d\n",x,a,b,f[x][a][b]);
		int B=a+b-A,aa=getz(a-A),bb=getz(A-a),t=1LL*f[x][a][b]*C[n-x][A]%mo*C[n-x-A][B]%mo;
		rep(k,0,n>>1)add(f[x+a+b][aa+k][bb+k],t);
	}
	printf("%d\n",f[n][0][0]);
	return 0;
}


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

public class P
{
    public int x { get; set; }
    public int y { get; set; }
}

public class Q
{
    public int x { get; set; }
    public int y { get; set; }
    public int L { get; set; }
}

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var n = int.Parse(line[2]);
        var map = new int[h, w];
        var d = new Dictionary<int, P>();
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < w; j++)
            {
                if (s[j] == 'S') { d[0] = new P { x = i, y = j }; map[i, j] = -10; }
                else if (s[j] == 'X') map[i, j] = -1;
                else if (s[j] == '.') map[i, j] = -10;
                else
                {
                    var wt = int.Parse(s[j].ToString());
                    map[i, j] = -10;
                    d[wt] = new P { x = i, y = j };
                }
            }
        }
        var count = 0;
        var start = new P();
        var g = new P();
        for (int i = 1; i <= n; i++)
        {
            start.x = d[i - 1].x;   start.y = d[i - 1].y;
            g.x = d[i].x;   g.y = d[i].y;
            count += goBfs(map, start, g);
        }
        Console.WriteLine(count);
    }
    public static int goBfs(int[,] map, P s, P g)
    {
        var h = map.GetLength(0);
        var w = map.GetLength(1);
        var map2 = new bool[h, w];
        var dx = new int[] { 0, 1, 0, -1 };
        var dy = new int[] { 1, 0, -1, 0 };
        var q = new Queue<Q>();
        q.Enqueue(new Q { x = s.x, y = s.y, L = 0 });
        map2[s.x, s.y] = true;
        while (q.Count() > 0)
        {
            var t = q.Dequeue();
            if (t.x == g.x && t.y == g.y) return t.L;
            for (int i = 0; i < 4; i++)
            {
                var nx = t.x + dx[i];
                var ny = t.y + dy[i];
                if (nx >= 0 && nx < h && ny >= 0 && ny < w && map[nx, ny] == -10 && !map2[nx, ny] )
                { map2[nx, ny] = true; q.Enqueue(new Q { x = nx, y = ny, L = t.L + 1 }); }
            }
        }
        return 0;
    }
}






Measured memory_bytes: 20976
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());
        int k = 0;
        PrintWriter out = new PrintWriter(System.out);

        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= N - i; j++) {

                k = N - i - j;
                if (10000 * i + 5000 * j + 1000 * k == Y) {
                    out.println(i + " " + j + " " + k);
                    sc.close();
                    out.flush();
                    return;
                }
            }
        }

        out.println("-1 -1 -1");

        sc.close();
        out.flush();
    }
}

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


using namespace std;

int main(){
  long W, H, x, y;

  cin >> W >> H >> x >> y;

  long res = (W==2*x and H==2*y)? 1:0;

  double S = W*(H/2.0);
  cout << S << " " << res << endl;

  return 0;
}


Measured memory_bytes: 256
import math
def main(lines):
  n = len(lines)
  x = 0
  for i in range(n):
    x+=int(lines[i])
    
  if x//9 == math.ceil(x/9):
    print('Yes')
  else:
    print('No')

if __name__ == '__main__':
    lines = input()
    main(lines)

Measured memory_bytes: 9192
using System;
using System.Linq;
struct C
{
    public int X { get; set; }
    public int Y { get; set; }

    public double Dist (C other)
    {
        return Math.Sqrt((other.X - X) * (other.X - X) + (other.Y - Y) * (other.Y - Y));
    }
}
class A
{
    public static void Main(string[] args)
    {
        int t = 1;
        while (t > 0)
        {
            
            int n = int.Parse(Console.ReadLine());
            C[] points = new C[n];
            for(int i = 0; i < n; i++)
            {
                var arr = Console.ReadLine().Trim().Split().Select(x => int.Parse(x)).ToArray();
                points[i].X = arr[0];
                points[i].Y = arr[1];
            }
            var total = 0.0;
            for(int i = 0; i < n; i++)
            {
                for(int j = i + 1; j < n; j++)
                {
                    total += points[i].Dist(points[j]) * 2;
                }
            }
            Console.WriteLine(total / n);
            t--;
        }
    }

   
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,a) rng(i,0,a)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,a) gnr(i,0,a)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define print(x) cout<<(x)<<'\n'
using ll=long long;
using pl=pair<ll,ll>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vs=vector<string>;

void solve() {
    ll T;
    cin >> T;
    ll n,m,a,b;
    rep(i,T){
        cin >> n >> m >> a >> b;
        print(floor_sum(n,m,a,b));
    }

}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


Measured memory_bytes: 3700
#include <stdio.h>
#define mod 1000000007
#define m 256
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 0;
  scanf("%lld", &n);
  ll dp[n][m];
  bool flg[m];
  for(i = 0; i < n; ++i) for(j = 0; j < m; ++j) dp[i][j] = 0;
  if(n == 3) {
    printf("61");
    return 0;
  }
  for(i = 0; i < m; ++i) {
    if((i & 0x3F) == 0x9 || (i & 0x3F) == 0x6 || (i & 0x3F) == 0x21 || (i & 0xCF) == 0x9 || (i & 0xF3) == 0x21 || (i & 0xFC) == 0x24 || (i & 0xFC) == 0x18 || (i & 0xFC) == 0x84) flg[i] = false;
    else flg[i] = true;
  }
  for(i = 0; i < m; ++i) if(flg[i]) dp[3][i] = 1;
  for(i = 4; i < n; ++i) {
    for(j = 0; j < m; ++j) {
      if(flg[j]) for(k = 0; k < m; ++k) if(((k & 0x3F) << 2) == (j & 0xFC)) dp[i][j] += dp[i - 1][k], dp[i][j] %= mod;
    }
  }
  for(i = 0; i < m; ++i) ans += dp[n - 1][i], ans %= mod;
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
using namespace std;

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

//    cin >> a >> b;
//    cin >> int a >> int b;
    int d = a / b; 
    int r = a % b;
    double f = (double)a/b;
//　明示的型変換（キャスト）

//    double f = 1.00 * a / b; 
//    cout << d << endl;
//    cout << r << endl;
//    cout << f << endl;
    printf("%d ", d);
    printf("%d ", r);
    printf("%.6lf\n", f);

    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;

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


Measured memory_bytes: 3712
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMAX）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int lb(int l,int r,long long n,int *d){
  if(n>(1<<29))return r;
  while(l-r){
    int m=(l+r)/2;
    n<=d[m]?(r=m):(l=m+1);
  }
  return l;
}

int n,i,j,k,s=0,c,a[200010],b[200010],d[200010];
int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%lld",&a[i]);
  for(i=0;i<n;i++)scanf("%d",&b[i]);
  for(i=0;i<30;i++){
    R=C=1;
    k=(1<<i);//printf("%d\n",k);
    for(j=0;j<n;j++)hin((int)(b[j]&((2LL<<i)-1)));
    for(j=0;j<n;j++)d[j]=N[hout()];
    //for(j=0;j<n;j++)printf("%d ",d[j]);printf("\n");
    for(j=c=0;j<n;j++)c+=((lb(0,n,2*k-(a[j]&((2LL<<i)-1)),d)-
			   lb(0,n,1*k-(a[j]&((2LL<<i)-1)),d))%2+
			  (n-
			   lb(0,n,3LL*k-(a[j]&((2LL<<i)-1)),d))%2);
    s+=c%2*k;
    /*or(j=0;j<n;j++)printf("%d %d %d %d\n",s,
			   lb(0,n,2*k-(a[j]&((2<<i)-1)),d),
			   lb(0,n,1*k-(a[j]&((2<<i)-1)),d),
			   lb(0,n,3*k-(a[j]&((2<<i)-1)),d));//*/
  }
  printf("%d\n",s);
  return 0;
}


Measured memory_bytes: 8704
A = ["* = ****",
     "* =* ***",
     "* =** **",
     "* =*** *",
     "* =**** ",
     " *= ****",
     " *=* ***",
     " *=** **",
     " *=*** *",
     " *=**** "]

n = map(int,list(raw_input()))
while True:
    n = [0]*(5-len(n)) + n
    print "\n".join("".join(s) for s in zip(*[A[i] for i in n]))
    try:
        n=map(int,list(raw_input()))
    except EOFError:
        break
    print

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    set<string> sets;
    int n;
    cin >> n;
    REP(i, n) {
        string s;
        cin >> s;
        sets.insert(s);
    } 
    cout << sets.size() << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 19216
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        long N = sc.nextLong();
        long K = sc.nextLong();

        System.out.println(solve(N, K));
    }

    private static long solve(long N, long K) {
        return Math.min(N%K, Math.abs(K - N%K));
    }
}

Measured memory_bytes: 22996
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
using namespace std;
#define INF 100000
#define MAX 100000
#define MOD 1000000007n
typedef long long ll;
typedef pair<int,int> P;
//typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)


int main(){
    int N;
    multiset<int> S;
    int p[110000];
    vector<P> V;
    
    cin>>N;
    for(int i=0;i<2;i++){
        S.insert(0);
        S.insert(N+1);
    }

    for(int i=0;i<N;i++){
        cin>>p[i+1];
        V.push_back(P(p[i+1],i+1));
    }
    sort(V.begin(),V.end());
    reverse(V.begin(),V.end());
    ll ret=0;
    for(int i=0;i<N;i++){
        P v=V[i];
        ll num=v.first;
        int id=v.second;
        auto it=S.lower_bound(id);
        int R1=*it++;
        int R2=*it--;
        it--;
        int L1=*it--;
        int L2=*it;
        ret+=num*(R2-R1)*(id-L1);
        ret+=num*(L1-L2)*(R1-id);
        S.insert(id);
    }
    cout<<ret<<endl;
}



Measured memory_bytes: 6132
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = sum(B)
for i in range(N - 1):
    if A[i] + 1 == A[i + 1]:
        ans += C[A[i] - 1]
print(ans)

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define print(x) cout << x << endl

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

ll MOD = 1000000007;


int main()
{
    ll K;
    cin >> K;
    vector<ll> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    print(vec[K - 1]);
    return 0;
}


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



int main(){

	int n, m;
	cin >> n >> m;
	vector<int> graph[100005];

	int x, y, z;
	for(int i = 0; i < m; i++){
		cin >> x >> y >> z;
		graph[x-1].push_back(y-1);
		graph[y-1].push_back(x-1);
	}

	bool visited[100005] = {};
	int ans = 0;
	for(int i=0; i<n; i++){
		if(visited[i]) continue;
		ans++;
		queue<int> q;
		q.push(i);
		visited[i] = true;
		while(!q.empty()){
			for(int j=0; j<graph[q.front()].size(); j++){
				int v = graph[q.front()][j];
				if(!visited[v]) q.push(v);
				visited[v] = true;
			}
			q.pop();
		}
	}

	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6648
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= c && c <= b) cout << "Yes" << endl;
    else if (b <= c && c <= a) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
from collections import defaultdict
from math import gcd
def GCD(a,b):
    gc = gcd(a,b)
    a//=gc
    b//=gc
    return a,b

zero = 0
First_quadrant = defaultdict(int)
Second_quadrant = defaultdict(int)
n = int(input())
for i in range(n):
    a,b = map(int, input().split())
    if a == 0 and b == 0:
        zero +=1
    elif a*b >= 0 and b != 0:
        First_quadrant[(GCD(abs(a),abs(b)))] +=1
    else:
        Second_quadrant[(GCD(abs(b), abs(a)))] +=1
        First_quadrant[(GCD(abs(b), abs(a)))] +=0

ans = 1
for key1, val in  First_quadrant.items():

    v2 = Second_quadrant[key1]
    ans *= (2**val + 2**v2 -1)
    ans %= (10**9+7)
ans  = ans + zero -1
ans %= (10**9+7)
print(ans)


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

using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 4; i++) {
        if (s[i] == '+')
            ans++;
        else 
            ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * jfen
 */
public class Main {

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

		while (sc.hasNext()) {

			String S = sc.nextLine();
			if (S.equals("#")) break;

			int a, b, c, d;
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();
			d = sc.nextInt();
			sc.nextLine();

			char[][] board = unpack(S);
			board[a - 1][b - 1] = '.';
			board[c - 1][d - 1] = 'b';

			System.out.println(pack(board));

		}

	} //end main


	static char[][] unpack(String s) {

		String[] lines = s.split("/");

		char[][] board = new char[lines.length][];

		for (int i = 0; i < lines.length; i++) {
			String row = "";
			int sp = 0;
			for (int j = 0; j < lines[i].length(); j++) {
				char c = lines[i].charAt(j);
				if ('0' <= c && c <= '9') {
					sp *= 10;
					sp += c - '0';
				} else {
					for (int k = 0; k < sp; k++) {
						row += '.';
					}
					row += 'b';
					sp = 0;
				}
			}
			for (int k = 0; k < sp; k++) {
				row += '.';
			}
			board[i] = row.toCharArray();
		}
		return board;
	}

	static String pack(char[][] board) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < board.length; i++) {
			String row = "";
			int sp = 0;
			for (int j = 0; j < board[i].length; j++) {
				char c = board[i][j];
				if (c == '.') {
					sp++;
				} else {
					if (sp > 0) {
						row += String.valueOf(sp);
					}
					row += 'b';
					sp = 0;
				}
			}
			if (sp > 0) {
				row += String.valueOf(sp);
			}
			if (0 < i) {
				sb.append('/');
			}
			sb.append(row);
		}
		return sb.toString();
	}
}

Measured memory_bytes: 27068
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == '1') cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
const ll MAX_V=100005;
vector<bool> visited(2*MAX_V);
vector<ll> edge[2*MAX_V];
ll cntx,cnty;
// x:1~MAX_V
// y:(MAX_V+1)~

void dfs(ll x){
    visited[x]=true;
    if(x<=MAX_V) cntx++;
    else cnty++;
    
    rep(i,sz(edge[x])){
        if(!visited[edge[x][i]]){
            dfs(edge[x][i]);
        }
    }
}

int main(){
    ll N; cin>>N;
    ll ans=0;
    rep(i,N){
        ll x,y; cin>>x>>y;
        edge[x].pb(y+MAX_V);
        edge[y+MAX_V].pb(x);
    }
    
    rep1(i,MAX_V){
        if(!visited[i]){
            cntx=0;
            cnty=0;
            dfs(i);
            
            ans+=cntx*cnty;
        }
    }
    
    cout<<ans-N<<endl;
}



Measured memory_bytes: 13384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back

int ncr(int n,int r){ int res=1; if(r>n-r)r=n-r; for(int i=0;i<r;i++) {  res*=n-i;  res/=i+1; } return res; }

int gcd(int a,int b){
    if(b==0) return a;
    else return gcd(b,a%b);
}
vector<int>v;
bool isPresent(int n){
    for(int i=0;i<v.size();i++){
        if(v[i]==n) return true;
    }
    return false;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    int sum=0;
    while(t--){
        int n;
        cin>>n;
        v.pb(n);
        if(n%2==0) n=n/2;
        else n=3*n+1;
        while(isPresent(n)==false){
            v.pb(n);
            if(n%2==0) n=n/2;
            else n=3*n+1;
        }
        cout<<v.size()+1<<endl;
    }
}
    

Measured memory_bytes: 256
import sys
import numpy as np

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    N, H = inl()
    a = [None] * N
    b = [None] * N
    mi = None
    ma, mb = 0, 0
    for i in range(N):
        a[i], b[i] = inl()
        if a[i] > ma:
            mi = i
            ma = a[i]

    bm = max(b[mi], a[mi])
    am = a[mi]

    bb = []
    for i in range(N):
        bb.append((b[i], i))
    bb.sort(reverse=True)

    cnt = 0
    for i in range(N):
        if H <= 0:
            break
        x, j = bb[i]
        debug(H, x, j)
        if x < am:
            break
        H -= x
        cnt += 1
    if H > 0:
        k = (H + am - 1) // am
        cnt += k
        H -= k * am
        assert H <= 0

    return cnt


print(solve())


Measured memory_bytes: 45128
num = list(input())
num = list(map(int, num))
length = len(num)

ans = 0

# isspecial = True
# # 9が１子以上続いたあとに5
# if num[-1] == 5:
#     for i in reversed(range(length - 1)):
#         if num[i] != 9:
#             isspecial = False
#             break
# else:
#     isspecial = False
# if isspecial:
#     print(6)
#     exit()    

for i in reversed(range(1, length)):
    digit = num[i]
    if digit < 5:
        ans += digit
    elif i > 0 and digit == 5 and num[i-1] < 5:
        ans += digit
    else:
        ans += (10 - digit)
        if i > 0:
            num[i-1] += 1
        else:
            ans += 1

digit = num[0]
if digit <= 5:
    ans += digit
else:
    ans += (11 - digit)

print(ans)


Measured memory_bytes: 21348
#include<stdio.h>
#include<string.h>

int i, j, k, n, x, m, menu[30], dp[1000000],prime[1000001], ans;
int main(){
  for(i = 2;i <= 1000;i++){
    if(prime[i] == 1)continue;
    for(j = i * i;j < 1000000;j += i){
      prime[j] = 1;
    }
  }
  while(1){
    scanf("%d%d", &n, &x);
    if(n == 0 && x == 0)return 0;
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    for(i = 0;i < n;i++){
      scanf("%d", menu + i);
    }
    ans = 0;
    for(i = 1;i <= x;i++){
      for(j = 0;j < n;j++){
	if(i - menu[j] >= 0 && dp[i - menu[j]] == 1)
	  dp[i] = 1;
      }
      if(dp[i] == 1 && prime[i] == 0){
	ans = i;
      }
    }
    if(ans == 0)
      puts("NA");
    else
      printf("%d\n", ans);
  }
}

Measured memory_bytes: 8432
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,d,k;
    cin>>a>>d>>k;
    if(a==7&&d==5&&k==5)cout<<"YES"<<endl;
    else if(a==5&&d==7&&k==5)cout<<"YES"<<endl;
    else if(a==5&&d==5&&k==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}
  


Measured memory_bytes: 256
#include<stdio.h>
void swap(int* a,int* b){
	int p;
	p=*a;
	*a=*b;
	*b=p;
}
int main(){
	int n,a[100],count=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<n;i++){
		for(int j=n-1;j>i;j--){
			if(a[j]<a[j-1]){
				swap(&a[j],&a[j-1]);
				count++;
				}
		}
	}
	for(int i=0;i<n;i++)
		printf("%d%s",a[i],i!=n-1?" ":"\n");
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 2100
N = int(input())

A = [int(z) for z in input().split()]
B = [int(w) for w in input().split()]

defeat = 0

for i in range(N):
    if A[i] >= B[i]:
        defeat += B[i]
    elif A[i] + A[i+1] >= B[i]:
        defeat += B[i]
        A[i+1]= A[i] + A[i+1] - B[i]
    else:
        defeat += A[i]+A[i+1]
        A[i+1] = 0
    
    
print(defeat)

Measured memory_bytes: 19648
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {
    ll mod = 1000000007;
    ll N,K;
    cin >> N >> K;
    ll A[N];
    rep(i,N) cin >> A[i];
    ll S = 0;
    rep(i,N){
        for(ll j=i+1;j<N;j++){
            if(A[i]>A[j]) S++;
        }
    }
    ll out = (S*K)%mod;
    ll T = 0;
    rep(i,N){
        rep(j,N){
            if(A[i]>A[j]) T++;
        }
    }
    out = (out+((K*(K-1))/2)%mod*T)%mod;
    cout << out << endl;
    return 0;
}


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

using namespace std;

bool flag;
int cnt;

void printArr(int A[], int n) {
    for (int i = 0; i < n; ++i) {
        cout << A[i];
        if (i < n-1)
            cout << ' ';
    }
    cout << endl;
}

void bubbleSort(int A[], int N) {
    flag = true;
    int i = 0; // 未ソート部分列の先頭インデックス
    while (flag) {
        flag = false;
        for (int j = N-1; j > i; --j) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                ++cnt;
                flag = true;
            }
        }
        ++i;
    }
}

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

    int n;
    cin >> n;

    int arr[n];
    for (int i = 0; i < n; ++i) cin >> arr[i];

    bubbleSort(arr, n);
    printArr(arr, n);
    cout << cnt << endl;
}


Measured memory_bytes: 3224
using System;

public class Test
{
	public static void Main()
	{
		int a, b, k;
		string[] s = Console.ReadLine().Split(' ');
		a = int.Parse(s[0]);
		b = int.Parse(s[1]);
		k = int.Parse(s[2]);
		
		for(int i=a;i<=b;i++)
		{
			if(i<a+k||i>b-k)
			{
				Console.WriteLine(i);
			}
		}
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
int main() 
{
    buff();
    long long cur_amm = 100;
    int y = 0;
    long long want; cin >> want;
    while(cur_amm < want) {
        long long xtra = cur_amm / 100;
        cur_amm += xtra;
        y++;
    }
    cout << y << '\n';
    return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const int N=100005;

int main(){
    long long a[N],x=2,y=2,z,w;
    int k;
//    bool ok=1;
    cin>>k;
    for(int i=0;i<k;i++){
        cin>>a[i];
    }
    for(int i=k-1;i>=0;i--){
        z=(x/a[i]+(x%a[i]!=0))*a[i];
        w=(y/a[i])*a[i];
//        cout<<z<<' '<<w<<'\n';
//        if((z<x||y<z){
//            ok=0;
//            break;
//        }
        x=z;
        y=w+a[i]-1;
//        cout<<x<<' '<<y<<'\n';
    }
    if(x<y){
        cout<<x<<' '<<y<<'\n';
    }else{
        cout<<"-1\n";
    }
}
//6 8
//4 7
//3 5
//2 3
//2 2


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

using namespace std;

long int f(long int n, long int x){
    if(0 <= n){
      return n / x + 1;
    }else{
      return 0;
    }
}

int main(){
  long int a, b, x, ans;

  cin >> a >> b >> x;

  ans = f(b, x) - f(a-1, x);

  cout << ans << endl;

  return 0;

}


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

int main() {
  string S, SR;
  cin >> S;
  
  int A = S.find("A");
  int Z = S.rfind("Z");
  
//  cout << A << endl;
//  cout << Z << endl;
  cout << Z - A + 1 ;
}
  

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a >= 13) {
        cout << b << endl;
    } else if (6 <= a && a <= 12) {
        cout << b/2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


N = a_int()
A = ints()
ma = -1
ans = 0
for a in A:
    ma = max(ma, a)
    ans += ma - a
print(ans)


Measured memory_bytes: 89896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;


int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<bool>> path(n, vector<bool>(n, false));

	rep(i, m) {
		int a, b;
		cin >> a >> b;
		path[a - 1][b - 1] = true;
		path[b - 1][a - 1] = true;
	}

	vi p = {};
	rep(i, n)p.push_back(i);
	int ans = 0;

	do{
		bool can = true;

		rep(i, p.size()-1) {
			if (path[p[i]][p[i + 1]] == false)can = false;
		}

		if (can)ans++;
	
	} while (next_permutation(p.begin()+1,p.end()));

	cout << ans << endl;

}

Measured memory_bytes: 256
S=str(input())
T=str(input())
ls=len(S)
lt=len(T)

ans=''
loc=None
for i in range(ls-lt,-1,-1):
  flag=0
  for j in range(lt):
    if not (S[i+j] == T[j] or S[i+j] == '?'):
      flag=1
      break
  if flag==0:
    loc=i
    break

if loc == None:
  print('UNRESTORABLE')
else:
  i=0
  while i<ls:
    if i==loc:
      ans += T
      i += lt
    elif S[i] == '?':
      ans += 'a'
      i += 1
    else:
      ans += S[i]
      i += 1
  print(ans)


Measured memory_bytes: 9136
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  n = ni()
  s = [ni() for _ in range(n)]
  s.sort()

  ans = sum(s)
  if ans % 10 == 0:
    change = False
    for e in s:
      if e % 10 != 0:
        ans -= e
        change = True
        break
    if change:
      print(ans)
    else:
      print(0)
  else:
    print(ans)

main()

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int main()
{
    double a,b,c,d,e,f;
    scanf("%lf%lf%lf",&a,&b,&c);
    c=M_PI*c/180;
    f=b*sin(c);
    d=a*b*0.5*sin(c);
    e=a+b+(sqrt(a*a+b*b-2*a*b*cos(c)));
    printf("%lf\n",d);
    printf("%lf\n",e);
    printf("%lf\n",f);
    return 0;
}

Measured memory_bytes: 648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll a;long double b;cin>>a>>b;
    ll bb=round(b*100);
    ll res=a*bb;
    res/=100;
    cout<<res<<endl;
}


Measured memory_bytes: 3744
n = int(input())
area = [list(map(int,input().split())) for i in range(2)]

max_v=0

for i in range(n):
  max_v = max(max_v,sum(area[0][0:i+1])+sum(area[1][i:n]))

# print(sum(area[0][0:max_i+1])+sum(area[1][max_i:n+1]))

print(max_v)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] S = new String[H];
        for (int i=0; i<H; i++) {
            S[i] = sc.next();
        }

        String[] ans = solve(H, W, S);
        for (int i=0; i<H; i++) {
            System.out.println(ans[i]);
        }
    }

    private static String[] solve(int H, int W, String[] S) {
        String[] ans = new String[H];

        for (int h=0; h<H; h++) {
            ans[h] = "";
            for (int w=0; w<W; w++) {
                if (S[h].charAt(w) == '#') {
                    ans[h] = ans[h] + S[h].charAt(w);
                } else {
                    ans[h] = ans[h] + count(h, w, H, W, S);
                }
            }
        }

        return ans;
    }

    private static int count(int h, int w, int H, int W, String[] S) {
        int count = 0;

        for (int i=h-1; i<=h+1; i++) {
            for (int j=w-1; j<=w+1; j++) {
                if (i < 0 || j < 0 || i >= H || j >= W) continue;

                if (S[i].charAt(j) == '#') count++;
            }
        }

        return count;
    }
}


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

public class Main {

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();

        int [] point = new int [n];
        Arrays.fill(point, k - q);

        for(int i = 0; i < q; i++) {
        	int a = sc.nextInt();
        	point[a-1]++;
        }

        for(int tmp : point) {
        	if(tmp <= 0) {
        		System.out.println("No");
        	} else {
        		System.out.println("Yes");
        	}
        }
	}
}

Measured memory_bytes: 55284
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val list = mutableListOf<Int>()
    for(i in 0..n-1){
        list.add(scanner.nextInt())
    }
    val list2 = mutableListOf<Int>()
    list2.addAll(list)
    list2.sortDescending()
    val max = list2.get(0)
    val max2 = list2.get(1)
    for(i in 0..n-1) {
        if(list.get(i) === max){
            println(max2)
        }
        else println(max)
    }
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong R, C, K;
  vector<vector<llong>> area;

  cin >> R >> C >> K;
  area.resize(R, vector<llong>(C, 0));
  for (int i = 0; i < K; i++) {
    llong r, c, v;
    cin >> r >> c >> v;
    area[r-1][c-1] = v;
  }

  vector<vector<vector<llong>>> dp(R, vector<vector<llong>>(C, vector<llong>(4, 0)));
  for (int r = 0; r < R; r++) {
    for (int c = 0; c < C; c++) {
      if (r > 0) {
        dp[r][c][0] = max({dp[r-1][c][1], dp[r-1][c][2], dp[r-1][c][3]});
      }
      dp[r][c][1] = dp[r][c][0] + area[r][c];
      if (c > 0) {
        for (int i = 3; i >= 1; i--) {
          dp[r][c][i] = max({dp[r][c][i], dp[r][c-1][i], dp[r][c-1][i-1] + area[r][c]});
        }
      }
    }
  }

  cout << max({dp[R-1][C-1][3], dp[R-1][C-1][2], dp[R-1][C-1][1]}) << endl;

  return 0;
}

Measured memory_bytes: 706676
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int[][] cardlist=new int[4][13];
        String m="";
        int n,mn=0;
        int a=scan.nextInt();
        
            for(int i=0; i<a; i++){
                m=scan.next();
                n=scan.nextInt();
                switch(m){
                    case "S":mn=0;break;
                    case "H":mn=1;break;
                    case "C":mn=2;break;
                    case "D":mn=3;break;
                }
                cardlist[mn][n-1]=1;
            }
        for(int i=0; i<4; i++){
            for(int j=0; j<13; j++){
                if(cardlist[i][j]==1)continue;
                switch(i){
                    case 0:m="S";break;
                    case 1:m="H";break;
                    case 2:m="C";break;
                    case 3:m="D";break;
                }
                System.out.println(m+" "+(j+1));
            }
        }
    }
}


Measured memory_bytes: 26336
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
#define MAXN 1000000007
 
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll a,b,s,p,m;
	cin>>a>>b;
	s=a+b;
	p=a*b;
	m=a-b;
	cout<<max(max(s,p),m);
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int main()
{

    char s[11],t[12];
    scanf("%s %s",s,t);

    int n;
    n=strlen(s);

    int flag=0;

    for(int i=0;i<n;i++)
    {
        if(s[i]!=t[i])
        {
            flag=1;
        }
    }

    if(flag==0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }


    return 0;
}

Measured memory_bytes: 1660