akhauriyash/Code-Regression huggingface dataset:
import bisect
from sys import stdin
A,B,Q = [int(x) for x in stdin.readline().rstrip().split()]
INF = 10**18
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]
for _ in range(Q):
    x = int(stdin.readline().rstrip())
    b = bisect.bisect_right(s,x)
    d = bisect.bisect_right(t,x)
    ans = INF
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1 = abs(S-x) + abs(T-S)
            d2 = abs(T-x) + abs(S-T)
            ans = min(ans,d1,d2)
    print(ans)

Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int N;
vector<int> L;
vector<int> A; 

int main() {
    cin >> N;
    A.resize(3);
    for (int i = 0; i < 3; ++i) cin >> A[i];
    L.resize(N);
    for (int i = 0; i < N; ++i) cin >> L[i];

    int res = 1<<29;
    vector<int> bit(3);
    for (bit[0] = 1; bit[0] < (1<<N); ++bit[0]) { 
        for (bit[1] = 1; bit[1] < (1<<N); ++bit[1]) { 

            if (bit[1] & bit[0]) continue;
            for (bit[2] = 1; bit[2] < (1<<N); ++bit[2]) { 

                if (bit[2] & bit[0]) continue;
                if (bit[2] & bit[1]) continue;
                vector<int> sums(3, 0), nums(3, 0);
                for (int i = 0; i < N; ++i) {
                    for (int j = 0; j < 3; ++j) {
                        if (bit[j] & (1<<i)) {
                            sums[j] += L[i];
                            nums[j]++;
                        }
                    }
                }
                int score = 0;
                for (int i = 0; i < 3; ++i) {
                    score += abs(sums[i] - A[i]); 
                    score += (nums[i] - 1) * 10; 
                }
                res = min(res, score);
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
  int a; int b; int c;
  cin >> a >> b >> c;
  int d = a % b;
  bool can = false;
  while(!can) {
    // c=0の時もケアしている
    if (d == c) {
      cout << "YES";
      can = true;
    }
    else {
	  d = (d + a) % b;
      // もし更新した結果、0になったら、今までの繰り返しになるので、d == cになることはない
      if (d == 0) {
     	cout << "NO";
        break;
      }
      // b（割る数）は100までなので最大100回繰り返せばループは終わる
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
  
int main(void){
  
  double x1,x2,y1,y2;
  double dis = 0;
  
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  dis = ((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2));
  dis = sqrt(dis);
  printf("%f\n",dis);
  return 0;
}

Measured memory_bytes: 652
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;

    cin >> a >> b >> c;
    int ans = 0;
    if (a == b && b == c) ans = 1;
    else if ((a == b && b != c) || 
            (a == c && c != b) ||
            (b == c && c != a)) ans = 2;
    else ans = 3;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

def dfs(v, color):
    colors[v] = color
    for to in g[v]:
        if colors[to] == color: return False
        if colors[to] == 0 and not dfs(to, -color):
            return False
    return True

def Washall_Floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])
    return d

n = int(input())
g = [[] for _ in range(n)]
f_inf =float('inf')
dist = [[f_inf]*n for _ in range(n)]
for i in range(n): dist[i][i]=0

for i in range(n):
    S = input()
    for j in range(n):
        if S[j] == '1':
            g[i].append(j)
            dist[i][j] = 1
            dist[j][i] = 1

colors = [0] * n
ans = -1
if not dfs(0, 1):
    print(ans)
else:
    Washall_Floyd(dist)
    for d in dist:
      tmp = max(d)
      ans = max(tmp, ans)
    print(ans+1)

Measured memory_bytes: 55388
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
  input += chunk;
});
process.stdin.on('end', function () {
  main(input.split('\n'));
});
function main(inputArr) {
  var i, temp, nGems, map, nMoves, moves;

  while ((nGems = +inputArr.shift()) !== 0) {
    map = new Array(21 * 21);
    moves = [];
    for (i = 0; i < 21 * 21; i++) {
      map[i] = 0;
    }

    i = 0;
    while (i < nGems) {
      temp = inputArr.shift().split(' ');
//      console.log(temp);
      map[(+temp[0]) + 21 * (+temp[1])] = 1;
//      {x: +temp[0], y: +temp[1]};
      i++;
    }
    nMoves = +inputArr.shift();
    i = 0;
    while (i < nMoves) {
      temp = inputArr.shift().split(' ');
      moves.push({d: temp[0], l: +temp[1]});
      i++;
    }
//    debug show map
//    for (i = 0; i < 21; i++) {
//      console.log(map.slice(i*21,i*21+21).join(' '));
//    }
    isAllGems(map, moves) ? console.log('Yes'):console.log('No');
//    for (i = 0; i < 21; i++) {
//      console.log(map.slice(i*21,i*21+21).join(' '));
//    }
  }
}
function isAllGems(map, moves) {
  var pos = 10 + 10 * 21, i, walk;
  moves.forEach(function (m) {
    switch (m.d) {
      case 'N':
        walk = 21;
        break;
      case 'W':
        walk = -1;
        break;
      case 'E':
        walk = 1;
        break;
      case 'S':
        walk = -21;
        break;
    }
    for (i = 0; i < m.l; i++) {
      pos += walk;
      map[pos] = 9;
    }
  });
  for (i = 0; i < 21 * 21; i++) {
     if(map[i] === 1){
       return false;
     }
  }
  return true;
}

Measured memory_bytes: 11080
#!/usr/bin/env python3
import sys
# input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    S,T = input().split()
    A,B = MAP()
    U = input()

    if S == U:
        print(A-1,B)
    else:
        print(A,B-1)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数leng
#define INF 9223372036854775807 //  巨大数INF
using namespace std;

signed main() {
  int N, T, A;
  cin >> N >> T >> A;
  T *= 1000;
  A *= 1000;
  vector<int> C(N);
  rep(i, N) {
    int h;
    cin >> h;
    C.at(i) = (T - (h * 6));
  }

  int mini = INF;
  int ans = -1;
  rep(i, N) {
    if (abs(A-mini) > abs(A-C[i])){
      ans = i;
      mini = C[i];
    }
  }
  cout << ans+1 << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<ll,ll> a,pair<ll,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

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

void f(ll rest,string s){
    if(rest==0){
        cout<<s<<endl;
    }else{
        for(char c='a';c<='c';c++){
            f(rest -1,s+c);
        }
    }
}


int main(){
    ll n,a[5];
    rep(i,5) a[i]=0;
    
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        if(s.at(0)=='M') a[0]++;
        else if(s.at(0)=='A') a[1]++;
        else if(s.at(0)=='R') a[2]++;
        else if(s.at(0)=='C') a[3]++;
        else if(s.at(0)=='H') a[4]++;
    }
    ll sum=0;
    rep(i,5){
        for(ll j=i+1;j<5;j++){
            for(ll k=j+1;k<5;k++){
                sum+=a[i]*a[j]*a[k];
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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

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

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];

long long d_p(int i,int k){
    if(i==0){
        return 0;
    }
    if(i<0){
        return INF;
    }

    if(dp[i]<INF){
        return dp[i];
    }
    long long res = INF;
    for(int j=1;j<=k;j++){
        chmin(res,d_p(i-j,k)+abs(h[i]-h[i-j]));
    }
    return dp[i] = res;
}

int main(){
    int n,k;
    cin>>n>>k;
    rep(i,n){
        cin>>h[i];
    }
    for (int i = 0; i < 100010; ++i) dp[i] = INF; 
    cout<<d_p(n-1,k)<<endl;
    return 0; 
}




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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int m;
    cin >> m;
    ll ans = -1;
    ll rest = 0;
    for (int i = 0; i < m; ++i) {
        int d;
        ll c;
        cin >> d >> c;
        ans += d * c / 9 + c;
        rest += d * c % 9;
    }
    ans += rest / 9;
    rest %= 9;
    if (rest == 0) ans--;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, K;
	cin >> N >> K;
	
	const ll mod = 1e9 + 7;
	vector<ll> dp(K + 1), dptmp(K + 1);
	dp[0] = 1;
	dptmp[0] = 1;

	rep(i, N) {
		int a;
		cin >> a;

		rep1(j, a) {
			dptmp[j] = (dptmp[j - 1] + dp[j]) % mod;
		}
		for (int j = a + 1; j <= K; j++) {
			dptmp[j] = (dptmp[j - 1] + dp[j] - dp[j - a - 1] + mod) % mod;
		}
		dp = dptmp;
	}

	co(dp[K]);


	Would you please return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
char a[50][50];
int c,d,b[55][55];
int main(){
    cin>>c>>d;
    for(int i=0;i<c;i++)
        cin>>a[i];
    for(int i=0;i<c;i++)
    for(int j=0;j<d;j++)
    if(a[i][j]=='#'){
        b[i][j]++,b[i][j+1]++,b[i][j+2]++,
        b[i+1][j]++,b[i+1][j+1]++,b[i+1][j+2]++,
        b[i+2][j]++,b[i+2][j+1]++,b[i+2][j+2]++;
    }
    for(int i=0;i<c;i++){
        for(int j=0;j<d;j++)
        if(a[i][j]=='#') cout<<'#';
        else cout<<b[i+1][j+1];
        cout<<endl;
    }

}

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

using namespace std;

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

	int* h = new int[N];
	long int* dp = new long int[N];

	//int h[100000];
	//long dp[100000];

	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		h[i] = x;
		dp[i] = LONG_MAX;
	}
	//cout << "-----\n";

	dp[0] = 0;
	
	//cout << h[0] << ' ' << dp[0] << '\n';

	for (int i = 1; i < N; i++) {
		int step1, step2;
		if (h[i] - h[i - 1] >= 0) {
			step1 = h[i] - h[i - 1];
		}
		else {
			step1 = h[i - 1] - h[i];
		}

		if (i == 1) {
			dp[i] = dp[i - 1] + step1;
			//cout << h[i] << ' ' << dp[i] << '\n';
			continue;
		}

		if (h[i] - h[i - 2] >= 0) {
			step2 = h[i] - h[i - 2];
		}
		else {
			step2 = h[i - 2] - h[i];
		}

		if (step1 + dp[i - 1] >= step2 + dp[i - 2]) {
			dp[i] = dp[i - 2] + step2;
		}
		else {
			dp[i] = dp[i - 1] + step1;
		}
		//cout <<i<<' '<< h[i] << ' ' << step1 << ' ' << step2 << ' ' << dp[i] << '\n';

	}

	cout << dp[N - 1] << endl;

	delete[] h;
	delete[] dp;

	return 0;
}

Measured memory_bytes: 1408
fun main(args:Array<String>) {
    val (a,b) = readLine()!!.split(" ").map{it.toInt()}
    switchCount = a
    lightCount = b

    switches.addAll((1..lightCount).map { readLine()!!.split(" ").map { it.toInt() - 1 }.drop(1).toMutableList() }.toMutableList())
    lightSetting.addAll(readLine()!!.split(" ").map { it.toInt() })
    val ans = getAns(0,0)
    println(ans)
}
var switchCount = 0
var lightCount = 0
val switches = mutableListOf<MutableList<Int>>()
val lightSetting = mutableListOf<Int>()

fun getAns(idx:Int, subtotal:Int):Int {
    if(idx >= switchCount) {
        var isAll = true
        for(i in lightSetting.indices) {
            var cnt = 0
            for(j in switches[i]) {
                val key = 1 shl j
                if((subtotal and key) != 0) {
                    cnt++
                }
            }
            if(cnt % 2 != lightSetting[i]) {
                isAll = false
            }
        }
        return if(isAll) 1 else 0
    }
    val tmp = (1 shl idx)
    val ans = getAns(idx + 1, subtotal) + getAns(idx + 1, subtotal + tmp)
    return ans
}

Measured memory_bytes: 38044
#include <stdio.h>

long gojo(long a, long b){
  if(a % b)
    gojo(b, a%b);
  else
    return b;
}

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

  long ans = b - a + 1;
  ans = ans - ((b/c) - (a-1)/c);
  ans = ans - ((b/d) - (a-1)/d);

  long g = c/gojo(c, d)*d;
  ans = ans + ((b/g) - (a-1)/g);

  printf("%ld\n", ans);

  return 0;
}


Measured memory_bytes: 1692
while True :
    n = int(input())
    if n == 0 :
        break
    
    S = 1
    for i in range(n) :
        S *= (i+1)
    
    a = 0
    while True :
        if S % 10 != 0 :
            break
        else :
            S = S // 10
            a += 1
    print(a)
        



Measured memory_bytes: 5624
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
const int maxn=2000000;
struct Edge
{
    int u,v,w;
}edge[maxn];
int n,cnt,ans[maxn],vis[maxn];
vector<int> g[maxn];
void addedge(int u,int v,int w)
{
    edge[++cnt].u=u;
    edge[cnt].v=v;
    edge[cnt].w=w;
    g[u].push_back(cnt);
}
void bfs()
{
	int i,x;
    queue<int>Q;
    Q.push(1);
    while(!Q.empty())
	{
        x=Q.front();
        Q.pop();
        if(vis[x]) 
			continue;
        vis[x]=1;
        for(i=0;i<g[x].size();i++)
		{
            int cur=g[x][i];
            if(!vis[edge[cur].v])
			{
                if(edge[cur].w %2==0)
                    ans[edge[cur].v]=ans[x];
                else
                    ans[edge[cur].v]=1-ans[x];
                Q.push(edge[cur].v);
            }
        }
    }
}
int main()
{
	int i;
    cin>>n;
    for(i=1;i<n;i++)
	{
        int u,v,w;
        cin>>u>>v>>w;
        addedge(u,v,w); 
		addedge(v,u,w);
    }
    bfs();
    for(i=1;i<=n;i++)
		cout<<ans[i]<<"\n";
    return 0;
}

Measured memory_bytes: 58880
import java.util.*;

public class Main{

    public static List<Integer> P;
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        ArrayList<int[]> a = new ArrayList<>();
        for(int i=0; i<N; i++){
            int[] in = new int[2];
            in[0] = i;
            in[1] = scanner.nextInt();
            a.add(in);
        }
        Collections.sort(
            a,
            new Comparator<int[]>(){
                @Override
                public int compare(int[] obj1, int[] obj2){
                    return obj2[1] - obj1[1];
                }
            }
        );

        long[][] dp = new long[N+1][N+1];
        for(int i=0;i<N; i++){
            long pos = a.get(i)[0];
            long A = a.get(i)[1];
            for(int j=0; j<=i; j++){
                dp[j+1][i-j] = Math.max(dp[j+1][i-j], dp[j][i-j] + A * Math.abs(pos-j) );
                dp[j][i-j+1] = Math.max(dp[j][i-j+1], dp[j][i-j] + A * Math.abs(pos-(N-(i-j+1))));
            }
        }
        long res = 0;
        for(int i=0; i<=N; i++){
            res = Math.max(res, dp[i][N-i]);
        }
        System.out.println(res);
    }
}

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

int main(){
   int S;
   int h;
   int m;
   int s;

   cin>>S;
   h=S/3600;
   m=(S-3600*h)/60;
   s=S-m*60-h*3600;
   cout<<h<<":"<<m<<":"<<s<<endl;
   
   return 0;
}



Measured memory_bytes: 3100
import Data.List
import Control.Monad

solve :: Int -> [Int] -> [Int]
solve n xs = map choiceMedian xs
  where sorted = sort xs
        n1 = n `div` 2
        n2 = n1 + 1
        median1 = sorted !! (n1 - 1)
        median2 = sorted !! (n2 - 1)
        choiceMedian n = if n <= median1 then median2 else median1

main :: IO ()
main = do
  n  <- readLn
  xs <- map read . words <$> getLine
  mapM_ print $ solve n xs

Measured memory_bytes: 102140
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


char str[105];
int main(int argc, char* argv[])
{
    scanf("%s", str);

    long cnt[30]={0};
    long i;
    for(i=0; i<strlen(str); i++) {
        cnt[str[i]-'a']++;
    }
    for(i=0; i<26; i++) {
        if(cnt[i]%2==1) {
            printf("No\n"); return 0;
        }
    }
    printf("Yes\n"); return 0;
    return 0;
}


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



int main(){
    int n,d;

    cin >>n>>d;
    int seeable = 2*d+1;
    if(n%seeable==0){
        cout << n/seeable << endl;
    }else{
        cout << n/seeable + 1 << endl;
    }

    return 0;


}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N;
  	scanf("%d",&N);
  
  	if((N%10) == 7){
      printf("Yes"); //1の位
    }else if(((N/10)%10) == 7){
      printf("Yes"); //10の位
    }else if((N/100) == 7) {
	  printf("Yes"); //100の位
    }else{
      printf("No");
    }
}

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

int main(){
	string s ; cin >> s ;
	int n = s.size() ;
	vector<int> ans(n+1) ;
	ans.at(0) = 0 ;
	ans.at(1) = 1 ;
	if(s.at(0)==s.at(1)) ans.at(2) = 1 ;
	else ans.at(2) = 2 ;
	for(int i=3;i<=n;i++){
		if(s.at(i-1)==s.at(i-2)) ans.at(i) = ans.at(i-3)+2 ;
		else ans.at(i) = ans.at(i-1)+1 ;
	}
	cout << ans.at(n) << endl ;
}


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

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

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


int main()
{
    int n; cin >> n;
    int d[n][2];
    rep(i,n) cin >> d[i][0] >> d[i][1];
    bool f = false;
    for(int i = 0; i < n-2; i++){
        if(d[i][0] == d[i][1] && d[i+1][0] == d[i+1][1] && d[i+2][0] == d[i+2][1]) f = true;
    }
    if(f) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3628
k=int(input())
l=[i for i in range(1,10)]

for i in l:
    p=str(i)
    if 0<=int(p[-1])-1<10:
        l.append(int(str(i)+str(int(p[-1])-1)))
    l.append(int(str(i)+p[-1]))
    if 0<=int(p[-1])+1<10:
        l.append(int(str(i)+str(int(p[-1])+1)))
    if len(l)>10**5:
        break
print(l[k-1])

Measured memory_bytes: 46552
a, b, k = map(int, input().split())
out = []
for i in range(k):
    if a+i > b:
        continue
    out.append(a+i)
for i in range(k):
    if b-k+i+1 < a:
        continue
    if b-k+i+1 in out:
        continue
    else:
        out.append(b-k+i+1)
for i in out:
    print(i)


Measured memory_bytes: 3060
S=input()
num=0
ans=0
con=0
upcon=0
before="<"
for s in S:
  if s==before and s=="<":
    upcon+=1
    num+=1
    ans+=num
  if s==">":
    con+=1
    num-=1
    ans+=num
  if s=="<" and before==">":
    ans+=(-num)*(con+(con>upcon))
    con=0
    upcon=1
    num=1
    ans+=num
  before=s
if con!=0:
  ans+=(-num)*(con+(con>upcon))
print(ans)

Measured memory_bytes: 43464
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    ll h = 0, w = 0;
    cin >> h >> w;
    ll ans1 = 1e12, buf = 0;
    ll one = 0, two = 0, three = 0;
    for (int i=0; i<h; i++) {
        one = i*w;
        two = (h-i)/2*w;
        three = h*w - one - two;
        buf = max(abs(one-two), max(abs(two-three), abs(three-one)));
        ans1 = min(ans1, buf);
        two = w/2*(h-i);
        three = h*w - one - two;
        buf = max(abs(one-two), max(abs(two-three), abs(three-one)));
        ans1 = min(ans1, buf);
    }
    ll ans2 = 1e12;
    swap(h, w);
    for (int i=0; i<h; i++) {
        one = i*w;
        two = (h-i)/2*w;
        three = h*w - one - two;
        buf = max(abs(one-two), max(abs(two-three), abs(three-one)));
        ans2 = min(ans2, buf);
        two = w/2*(h-i);
        three = h*w - one - two;
        buf = max(abs(one-two), max(abs(two-three), abs(three-one)));
        ans2 = min(ans2, buf);
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = pow(10, 9) + 7;
//const int mod = 998244353;
//const int mod = ;
const int INF = 1LL << 60;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}

int r, D, x2000;

int x(int i)
{
  if (i == 2000) return x2000;
  return r * x(i - 1) - D;
}

signed main()
{
  cin >> r >> D >> x2000;
  
  for (int i = 2001; i <= 2010; i++)
  {
    cout << x(i) << endl;
  }
  
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

string tostring(LL x){
  stringstream ss;
  ss << x;
  string res;
  ss >> res;
  return res;
}

LL f(LL x){
  --x;
  LL ans = 0;
  LL p = 10, prv = 0, crt = 0, prv_35 = 0, crt_35 = 0;
  for(LL i=1;;++i){
	if(x < p) p = x;
	else --p;

	crt = p - (p/3 + p/5 - p/15) - prv;
	prv += crt;

	crt_35 = (p/3 + p/5) * 4 - prv_35;
	prv_35 += crt_35;

	ans += i*crt;
	ans += crt_35;
	if(x == p) break;

	++p;
	p *= 10;
  }

  return ans;
}

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

  LL s; cin >> s;
  --s;
  LL lb = 0;
  LL ub = 100000000000000000;
  // f(x) := x???????????????????????????
  while(ub-lb > 1){
	LL mid = (lb + ub) / 2;
	if(f(mid) <= s)
	  lb = mid;
	else
	  ub = mid;
  }
  //cout<< "lb: " << lb << ", f: " << f(lb) << endl;
  s -= f(lb);
  string ans;
  for(LL i=lb;i<lb+20;++i){
	if(i%3 && i%5) ans += tostring(i);
	if(i%3 == 0) ans += "Fizz";
	if(i%5 == 0) ans += "Buzz";
  }
  //  cout << ans << endl;
  cout << ans.substr(s, 20) << endl;

  return 0;
}

Measured memory_bytes: 1220
def compare(x, y):
    for i in range(6):
        order = [0, 0, 0]
        for j in range(3):
            if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:
                break
            if x[j] == y[z[i][j]]:
                order[j] = 1 
                if x[j] == x[-j-1]:
                    order[j] = 2 
        else:
            if 2 in order or z[i][3] == sum(order) % 2:
                return True
                break
    return False
 
n = int(input())
x = [[] for i in range(n)]
for i in range(n):
    x[i] = list(map(int, input().split()))
z = [[0, 1, 2, 1], [0, 2, 1, 0], [2, 1, 0, 0], [1, 0, 2, 0], [2, 0, 1, 1], [1, 2, 0, 1]]
different = True
for i in range(n):
    for j in range(i+1, n, 1): 
        if compare(x[i], x[j]):
            break
    else:
        continue
    print('No')
    break
else:
    print('Yes')

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

struct mint {
  ll x;
  mint(ll x=0) : x(x%mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x -= a.x) < 0) x += mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) {
    mint res(*this);
    return res*=a;
  }
};

const int MAX = 100'000 + 5;
ll fac[MAX], finv[MAX], inv[MAX];

void initComb() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  srep(i, 2, MAX) {
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = mod - inv[mod%i] * (mod / i) % mod;
    finv[i] = finv[i - 1] * inv[i] % mod;
  }
}
ll comb(ll n, ll k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int n, k;
vvi to;
mint ans;

void dfs(int v, int p=-1) {
  for (auto &u : to[v]) {
    if (u == p) continue;
    dfs(u, v);
  }
  int nk = (p==-1) ? k : k-2;
  int c = (p==-1) ? to[v].size()+1 : to[v].size()-1;
  ans *= comb(nk, c) * fac[c];
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  initComb();
  std::cin >> n >> k;
  to.resize(n);
  rep(i, n-1) {
    int a, b; std::cin >> a >> b;
    --a, --b;
    to[a].pb(b), to[b].pb(a);
  }
  ans = 1;
  dfs(0);
  std::cout << ans.x << "\n";
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long n;
    cin>>n;
    if (n%2!=0)
        cout<<"0";
    else
    {
    n=n/2;
    long long nb=0;
    for (long long i =5; n / i >=1; i *= 5)
        nb += n/i;
    cout<<nb;
    }
    return 0;
}


Measured memory_bytes: 256
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;
use std::thread;
use std::cmp::*;
fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let ma: usize = sc.ne();
    let mb: usize = sc.ne();
    let a: Vec<(usize, usize, i32)> = (0..n).map(|_| (sc.ne(), sc.ne(), sc.ne())).collect();
    let asum = a.iter().fold(0, |acc, x| acc + x.0) + 1;
    let bsum = a.iter().fold(0, |acc, x| acc + x.1) + 1;
    let an = asum as usize;
    let bn = bsum as usize;
    let inf = 1000000000i32;
    let mut dp = vec![vec![inf; bn]; an];
    dp[0][0] = 0;
    for x in a {
        let mut dp_ = dp.clone();
        for i in 0..an {
            for j in 0..bn {
                if dp[i][j] == inf {
                    continue;
                }
                dp_[i + x.0][j + x.1] = min(dp_[i + x.0][j + x.1], dp[i][j] + x.2);
            }
        }
        dp = dp_;
    }
    let mut ans = inf;
    for i in 1..an {
        for j in 1..bn {
            if i % ma != 0 {
                continue;
            }
            let k = i / ma;
            if j == k * mb {
                ans = min(ans, dp[i][j]);
            }
        }
    }
    if ans == inf {
        ans = -1;
    }
    println!("{}", ans);
}
const DEFAULT_STACK: usize = 16 * 1024 * 1024;
fn main() {
    let builder = thread::Builder::new();
    let th = builder.stack_size(DEFAULT_STACK);
    let handle = th.spawn(|| { exec(); }).unwrap();
    let _ = handle.join();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => return None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => panic!("parse error"),
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
//#include <algorithm>
#include<set>
#include <limits>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
ll pattern(ll num){
  switch(num){
    case 0:
    return 1;
    break;
    case 1:
    return 2;
    break;
    case 2:
    return 3;
    break;
    case 3:
    return 5;
    break;
    case 4:
    return 8;
    break;
    case 5:
    return 13;
    break;
    case 6:
    return 21;
    break;
  }
  return 0;
}
int main(void){
  int h,w,k;
  cin >> h>>w>>k;
  k--;
  vector<vector<ll>> dp(h+1,vector<ll>(w,0));
  dp[0][0]=1;
  ll p1,p2;
  rep(i,h){
    rep(j,w){
      if(j>0){
        p1=pattern(max(0,j-1-1));
        p2=pattern(max(0,w-1 - (j+1)));
        dp[i+1][j]+=(dp[i][j-1]*(p1*p2))%d9_7;
      }
      if(j<w-1){
        p1=pattern(max(0,j-1));
        p2=pattern(max(0,w-1 - (j+1+1)));
        dp[i+1][j]+=(dp[i][j+1]*(p1*p2))%d9_7;
      }
      p1=pattern(max(0,j-1));
      p2=pattern(max(0,w-1 - (j+1)));
      dp[i+1][j]+=(dp[i][j]*(p1*p2))%d9_7;
    }
    /*rep(j,w){
      cout << dp[i][j] << " ";
    }
    cout << endl;*/
  }
  cout << dp[h][k]%d9_7<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1e9 + 7;
//ll mod = 998244353;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	//t %= mod;
	if (n % 2 == 1)t *= a;
	return t /*% mod*/;
}

//const int INF = 1001001001;
const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

vector<pair<ll, ll>> prime_factorize(ll N) {
	vector<pair<ll, ll>> res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0;
		while (N % a == 0) {
			++ex;
			N /= a;
		}
		res.push_back({ a, ex });
	}
	if (N != 1) res.push_back({ N, 1 });
	return res;
}


int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll res = 0;
	ll max = a[0];
	for (int i = 0; i < n; i++) {
		if (a[i] < max) {
			res += max - a[i];
		}
		else {
			max = a[i];
		}
	}
	cout << res << endl;
	return 0;
}


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

using namespace std;

int main()
{
    int bx,ex,by,ey;
    scanf("%d%d%d%d",&bx,&by,&ex,&ey);
    int nx = bx,ny = by;
    while(nx < ex)
    {
        printf("R");
        nx ++;
    }
    while(ny < ey)
    {
        printf("U");
        ny ++;
    }
    nx = ex,ny = ey;
    while(nx > bx)
    {
        printf("L");
        nx --;
    }
    while(ny > by)
    {
        printf("D");
        ny --;
    }
    nx = bx,ny = by;
    printf("D");
    ny --;
    while(nx < ex + 1)
    {
        printf("R");
        nx ++;
    }
    while(ny < ey)
    {
        printf("U");
        ny ++;
    }
    printf("L");
    nx = ex,ny = ey;
    printf("U");
    ny ++;
    while(nx > bx - 1)
    {
        printf("L");
        nx --;
    }
    while(ny > by)
    {
        printf("D");
        ny --;
    }
    printf("R");
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int U[2003][2003];

int main() {
    ll A[4];
    rep(i,1){
        cin >> A[i];
    }
    cout << (A[0]%2==0 ? A[0]*A[0]/4 : A[0]/2*(A[0]+1)/2) << endl;
}

Measured memory_bytes: 380
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
const int inf=1e8;
using namespace std;
int main(){
  int a,b,n;
  while(cin>>a>>b,a||b){
    cin>>n;
    vector<vector<int> >out(a+1,vector<int>(b+1));
    rep(i,n){
      int x,y;cin>>x>>y;
      out[x][y]=-inf;
    }
    out[0][1]=1;
    loop(i,1,1+a)loop(j,1,1+b){
      if(out[i][j]<0)continue;
      int sum=0;
      if(out[i-1][j]>=0)sum+=out[i-1][j];
      if(out[i][j-1]>=0)sum+=out[i][j-1];
      out[i][j]=sum;
    }
    /*rep(i,a+1){
      rep(j,b+1)cout<<" "<<out[i][j];
      cout<<endl;
    }*/
    cout<<out[a][b]<<endl;
  }
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1_000_000_007
#define INF 10*10
#define EPS 1e-9

//----***パーツ***----
#define fr first
#define se second

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

int N,M,K;
string S;

signed main(){
  cin>>N;
  print((2*N*3.1415926535))

}


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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for(int i=0; i<N; i++) cin >> H[i];
    vector<int> ok(N, 1);
    while(M--){
        int a, b;
        cin >> a >> b;
        a--; b--;
        if(H[a] <= H[b]) ok[a] = 0;
        if(H[a] >= H[b]) ok[b] = 0;
    }
    int ans = accumulate(ok.begin(), ok.end(), 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4048
import sys
s = input()
n = len(s)

for bit in range(2**(n-1)):
    f = ["-"]*(n-1)
    for i in range(n-1):
        if ((bit>>i) & 1):
            f[i] = "+"
    formula = ""
    for pn,po in zip(s, f + [""]):
        formula += (pn + po)
    if eval(formula) == 7:
        print(formula + "=7")
        sys.exit()

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

int main(){
    int num1, num2;
    scanf("%d %d",&num1,&num2);
    int div1, div2;
    if ( num1 > num2 ){ 
            div1 = num1;
            div2 = num2;
    }else{  div1 = num2;
            div2 = num1;
    }
    for( ; ; ){
        int remainder = div1%div2;
        
        div1 = div2;
        div2 = remainder;
        if (div2 == 0) break;
    }
    printf("%d\n",div1);
    
    return EXIT_SUCCESS;
}


Measured memory_bytes: 2124
x = int(input())

def prime(c):
    import math
    if c == 1:
        return False
    for i in range(2, round(math.sqrt(c)) + 1):
        if c % i == 0:
            return False
        else:
            continue
    return True

i = x
while True:
    if prime(i):
        print(i)
        break
    else:
        i += 1


Measured memory_bytes: 2940
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
#define accum(x) accumulate((x).begin(), (x).end(), 0)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  int n, tot = 0;
  cin >> n;
  vector<int> v(n);
  rep(i, 0, n) {
    cin >> v[i];
    tot += v[i];
  }

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

  sort(v.begin(), v.end());
  rep(i, 0, n) {
    int tmp = tot - v[i];
    if (tmp % 10 != 0) {
      cout << tmp << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template <typename T>
vector<T> Dijkstra(int s, vector<vector<pair<int, T>>>& g) {
    priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>>
        que;
    int n = sz(g);
    vector<T> d(n);
    rep(i, n) d[i] = INF;
    d[s] = 0;
    que.push(make_pair(0, s));
    while (!que.empty()) {
        pair<T, int> p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (auto e : g[v]) {
            if (chmin(d[e.first], d[v] + e.second)) {
                que.push(make_pair(d[e.first], e.first));
            }
        }
    }
    return d;
}
int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> g(n);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b, 1);
        g[b].emplace_back(a, 1);
    }

    auto df = Dijkstra<int>(0, g);
    auto ds = Dijkstra<int>(n - 1, g);

    int fn = 0, sn = 0;
    rep(i, n) {
        if (df[i] <= ds[i])
            fn++;
        else
            sn++;
    }
    cout << (fn <= sn ? "Snuke" : "Fennec") << endl;
}

Measured memory_bytes: 7408
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void AnsYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void AnsYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}







//ここまでライブラリ
//ここから本文





int main() {
	int a, b ,c;
	cin >> a >> b >> c;
	if (a - b >= c) cout << 0 << endl;
	else cout << c - (a - b) << endl;
}


Measured memory_bytes: 256
use std::io;

fn get_input() -> String {
    let mut word = String::new();
    io::stdin().read_line(&mut word).ok();
    return word.trim().to_string();
}

fn main() {
    let a: i32 = get_input().parse().unwrap();

    println!("{}", a+a*a+a*a*a);
}

Measured memory_bytes: 2160
//差分
#include <bits/stdc++.h>
using namespace std;
const int M=2e5+10;
typedef long long ll;
struct node{
	ll x,h;
}a[M];
ll c[M];

bool cmp(node a,node b){
	return a.x<b.x;
}

int main(int argc, char const *argv[])
{
	int N,D,A;
	cin>>N>>D>>A;
	for(int i=0;i<N;i++)scanf("%lld%lld",&a[i].x,&a[i].h);
	sort(a,a+N,cmp);
	
	ll ans=0;
	for(int i=0,j=0;i<N;i++){
		while(j<N&&a[j].x<=a[i].x+2*D)j++;
		ll tmp=max((a[i].h-c[i]*A+A-1)/A,0ll);
		c[i]+=tmp;
		c[j]-=tmp;//保证攻击i点的时候，j点没有攻击
		ans+=tmp;
		c[i+1]+=c[i];
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string data;
    while(cin>>data)
    {
        int ans=0;
        for(int i=0; i<data.length(); i++)
        {
            if(i==0) ans++;
            else if(data[i]!=data[i-1]) ans++;
        }
        cout<<ans-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const ll mod=1000000007;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> s(n);
  rep(_i,n-1){
    int i=n-_i-2;
    s[i] = (s[i+1]+a[i+1])%mod;
  }
  ll ans = 0;
  rep(i,n) ans = (ans+a[i]*s[i])%mod;
  cout << ans << endl;
}


Measured memory_bytes: 6336
#include <iostream>
#include <algorithm>
#include <vector>

constexpr int INF = 1 << 30;

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;

    int ans = INF;
    for (int p = 0; p <= 100; ++p) {
        int sum = 0;
        for (auto x : xs) {
            sum += (p - x) * (p - x);
        }
        ans = std::min(ans, sum);
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 256