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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

static const ll INF = 1e15;

static const ll mod= 1e9 + 7;


int main() {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	//各文字処理時において、前の文字より大きい文字がどれだけ残っているかわかればよい。
	//dp[i][j]...i番目の文字において、i-1番目の文字より大きい文字がj個残っているときの場合の数
	vector<vector<ll>> dp(n, vector<ll>(n, 0));
	vector<vector<ll>> sums(n, vector<ll>(n+1, 0));
	rep(i, n) {
		//任意の数なので1とする
		dp[0][i] = 1;
		sums[0][i + 1] = sums[0][i] + dp[0][i];
	}
	for (int i = 0; i < n-1; i++) {
		char c = s[i];
		if (c == '<') {
			for (int j = 0; j < n-i-1; j++) {
				//j==0...0個
				//dp[i + 1][0] = dp[i][1] + dp[i][2] + ... + dp[i][n - i - 1];
				//j==1...
				//dp[i + 1][1] = dp[i][2] + dp[i][3] + ... + dp[i][n - i - 1];
				//dp[i + 1][n - i - 2] = dp[i][n - 1 - i];

				dp[i + 1][j] = sums[i][n - i] - sums[i][j+1] + mod;
				dp[i + 1][j] %= mod;
			}
		}
		else {
			for (int j = 0; j < n-i; j++) {
				//j==0...0個
				//dp[i + 1][0] = dp[i][0];
				//j==1...
				//dp[i + 1][1] = dp[i][0] + dp[i][1];
				//j==2...
				//dp[i + 1][2] = dp[i][0] + dp[i][1] + dp[i][2];
				dp[i + 1][j] = sums[i][j+1] - sums[i][0] + mod;
				dp[i + 1][j] %= mod;
			}
		}
		rep(j, n) {
			sums[i + 1][j + 1] = sums[i + 1][j] + dp[i + 1][j];
			sums[i + 1][j + 1] %= mod;
		}
	}
	cout << sums[n - 1][1] << endl;
	return 0;
}
	

Measured memory_bytes: 144212
#include<cstdio>
#include<vector>
#include<cmath>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n)!=-1){
        int ans=0;
        vector<bool> tab(n+1,true);
        int upto=sqrt(n);
        for(int i=2;i<=upto;i++){
            if(tab[i]){
                for(int j=i*2;j<=n;j+=i){
                    tab[j]=false;
                }
            }
        }
        for(int i=2;i<=n;i++){
            if(tab[i]) ans++;
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 932
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define int64 long long
#define uint64 unsigned long long

#define mod 1000000007

using namespace std;

int64 npk(uint64 nn, uint64 kk)
{
	uint64 tmp = 1;
	for(int64 ii = 0;ii < kk;ii++)
	{
		tmp *= nn;
		tmp %= mod;
		nn--;
	}
	return tmp % mod;
}

int main()
{
	uint64 nn, kk, aa, bb, ans, tmp;
	cin >> nn >> kk;
	uint64 memo[nn] = {0};
	for(int64 ii = 0;ii < nn - 1;ii++)
	{
		cin >> aa >> bb;
		memo[aa-1]++;
		memo[bb-1]++;
	}
	ans = kk;
	for(uint64 ii = 0;ii < nn;ii++)
	{
		if(ii)
			tmp = npk(kk - 2, memo[ii] - 1);
		else
			tmp = npk(kk - 1, memo[ii]);
		ans *= tmp;
		ans %= mod;
	}
	cout << ans % mod << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
const int maxn = 100500;
int head[maxn], d[maxn], v[maxn], c[maxn], pri[maxn], f[maxn];
int n, m, q, x, y, tot;
struct Edge {
	int u, v, next;
} e[maxn*2];
void add_edge(int u, int v) {
	 e[++tot] = (Edge){u, v, head[u]};
	 head[u] = tot;
}
void dfs(int u, int dis, int col) {
	if(dis <= f[u]) return;
	f[u] = dis;
	if(dis <= 0) return;  
	if(!pri[u]) pri[u] = col;
	for(int i = head[u]; i; i = e[i].next) {
		int v = e[i].v;
		dfs(v, dis-1, col);
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++) {
		scanf("%d%d", &x, &y);
		add_edge(x, y);
		add_edge(y, x);
	}
	scanf("%d", &q);
	for(int i = 1; i <= q; i++) scanf("%d%d%d", &v[i], &d[i], &c[i]);
	for(int i = q; i >= 1; i--) dfs(v[i], d[i]+1, c[i]);
	for(int i = 1; i <= n; i++) printf("%d\n", pri[i]);
	return 0;
} 

Measured memory_bytes: 5248
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
        ArrayList<Integer> list = new ArrayList<>();
        for (int i =0; i < 3; i++) {
          list.add(sc.nextInt());
        }
        Collections.sort(list);
    
		// 出力
		System.out.println(list.get(0) + list.get(1));
	}
}

Measured memory_bytes: 23252
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	al = lin()
	ret = mod
	for i in range(-102, 102):
		v = sum([(x-i)**2 for x in al])
		ret = min(v, ret)
	print(ret)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 65484
#include <iostream>
#include <algorithm>
using namespace std;
int x,y,i;
int main(){
	while(cin>>x>>y&&x+y){
		if(y>x)swap(x,y);
		i=0;
		for(;y;i++){
			x%=y;
			swap(x,y);
		}
		cout<<x<<" "<<i<<endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int div(int n){
	int cnt=0;
	for(int i=1; i<=n; i++){
		if(n%i==0) cnt++;
	}
	if(cnt==8) return 1;
	else return 0;
}

int main(){
	int n;
	cin >> n;
	int ans=0;
	for(int i=1; i<=n; i+=2){
		if(div(i)) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
char s0[30];
using namespace std;
int main(){
	scanf("%s",s0+1);
	for(int i=1;i<=strlen(s0+1);i++){
		if(i!=6&&i!=14)printf("%c",s0[i]);
		else printf(" ");
	}
	return 0;
}

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

int main () {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

     string s; cin >> s;
     int N = s.size();
     int64_t sum = 0;
     for (int i = 0; i < N; ++i)
        sum += s[i] - '0';
     cout << (sum%9 ? "No": "Yes") << '\n';
    


    return 0;

}



Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ll n, m;
    cin >> n >> m;
    if (2*n == m) cout << n;
    else if (2*n > m) {
        cout << m/2;
    }
    else {
        ll res = n;
        m -= 2*n;
        res += m/4;
        cout << res;
    }
    return 0;
}


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

const int N = 1e5 + 10;

int a[N];
int n;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    } 
    int dir = 0;
    int res = 0;
    for (int i = 1; i < n; i++) {
        if (a[i - 1] == a[i]) continue;
        if (a[i - 1] > a[i] && dir == 1) {
            res++;
            dir = 0;
        }
        else if (a[i - 1] < a[i] && dir == -1) {
            res++;
            dir = 0;
        }
        else if (dir == 0 && a[i - 1] < a[i]) {
            dir = 1;
        }
        else if (dir == 0 && a[i - 1] > a[i]) {
            dir = -1;
        }
        
    }
    cout << res + 1 << "\n";
    return 0;
}

Measured memory_bytes: 640
import numpy as np

N = int(input())
An = np.array(list(map(int, input().split())))
Bn = np.array(list(range(1,N+1,1)))
Cn = An - Bn

ans = 0
b = int(round(np.median(Cn)))

for c in Cn:
    ans += abs(c - b)

print(ans)

Measured memory_bytes: 34188
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define rep(i, n) for(int i=0;i<(int)(n);i++)

int main(void){
    int m;
    scanf("%d",&m);
    printf("%d",48-m);
    return 0; 
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
#define MAX_E 2000
#define MAX_V 1000
// 頂点fromから頂点toへのコストcostの辺
struct edge { ll from, to, cost; };
edge es[MAX_E]; // 辺
ll d[MAX_V]; // 最短距離
ll V, E; // Vは頂点数、Eは辺数
ll INF = 2000000000000;
// s番目の頂点から各頂点への最短距離を求める
bool shortest_path(int s) {//負のがあるなら閉路ならtrueを返す
	for (int i = 0; i < V; i++) d[i] = INF;
	d[s] = 0;
	int cou = 0;
	while (true) {
		if(cou >= V)
			return true;
		bool update = false;
		for (int i = 0; i < E; i++) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		cou++;
		if (!update) break;
	}
	return false;
}
bool shortest_path_2(int s) {//負のがあるなら閉路ならtrueを返す
	int cou = 0;
	while (true) {
		if(cou >= V)
			return true;
		bool update = false;
		for (int i = 0; i < E; i++) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		cou++;
		if (!update) break;
	}
	return false;
}
int main(){
	cin >> V >> E;
 
	REP(i,E) {
		ll a,b,c;
		cin >> a >> b >> c;
		a--;b--;
 
 
		es[i] = (edge){a,b,-c};
	}

	shortest_path(0);
	ll ans = -d[V - 1];
	shortest_path_2(0);

	if(ans != -d[V - 1]) {
		cout << "inf" << endl;
	}else {
		cout << ans << endl;
	}
 
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int x, a, b;
    int xa, xb;

    cin >> x >> a >> b;

    xa = x - a;
    xb = x - b;
    
    if(xa<0){
        xa *= -1;
    }
    if(xb<0){
        xb *= -1;
    }

    if(xa<xb){
        cout << "A";
    }else{
        cout << "B";
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int INF = 1e18;
signed main(){
    vector<int> res(4);
    rep(i,4)cin >> res[i];
    int ret = -INF;
    for(int i = 0;i < 2;i++)for(int j = 2;j < 4;j++){
        ret = max(ret,res[i]*res[j]);
    }
    cout << ret << endl;

    return 0;
}

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

int main() 
{
    int n;
    cin >> n;
    map<string, vector<pair<int, int>>> mp;
    vector<string> V;
    
    rep(i,n) {
        string s;
        int p;
        cin >> s >> p;
        mp[s].push_back(make_pair(p, i));
        if(count(V.begin(), V.end(), s) == 0) V.push_back(s);
    }
    sort(V.begin(), V.end());

    for (auto city : V) {
        sort(mp[city].rbegin(), mp[city].rend());
        for (auto pir : mp[city]) {
            int idx = pir.second;
            cout << idx+1 << endl;            
        }
    }
    

    return 0;
}


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

#define rep(i,n) for(int i = 0 ; i < (int)(n) ; i++)
static const double EPS = 1e-8;

int n,hx,hy,dx,dy;
int x[20],y[20];
bool flag;

void dfs(int unvisit, int cx, int cy, double t){
   if(flag)return;
  
   if(unvisit==0)flag = true;
   
   else{
      //枝刈り
      rep(i,n){
	 if(!((unvisit >> i) & 1))continue;
	 if(hypot(dx-x[i], dy-y[i]) < t + hypot(cx-x[i], cy-y[i]) + EPS)return;
      }

      rep(i,n){
	 if(!((unvisit >> i) & 1))continue;
	 dfs((unvisit & ~(1 << i)), x[i], y[i], t + hypot(cx-x[i], cy-y[i]));
      }
   }
}

string solve(){
   flag = false;
   dfs((1<<n)-1, hx, hy, 0);
   return (flag) ? "YES" : "NO";
}

int main(){
   while(cin >> n >> hx >> hy >> dx >> dy){
      if((n|hx|hy|dx|dy)==0)break;
   
      rep(i,n){
	 cin >> x[i] >> y[i];
      }
      
      cout << solve() << endl;
   }
   return 0;
}
      

Measured memory_bytes: 928
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

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

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

    int n;
    cin >> n;

    vector<string> v(n);
    rep(i, n){
        cin >> v[i];
        SORT(v[i]);
    }

    map<string, lint> mp;
    lint ans = 0;
    rep(i, n){
        ans += mp[v[i]];
        ++mp[v[i]];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16640
/* ITP1_3_B: Print Test Cases */

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

#define N 10000

int main(void){
	int x, i = 0;

	while(1){
		scanf("%d", &x);
		if(x){
			printf("Case %d: %d\n", ++i, x);
		}else{
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 1928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    string S;
    cin >> S;
    string s,c,r;
    s="Sunny";
    c="Cloudy";
    r="Rainy";
    if(S==s)cout << c;
    else if(S==c)cout << r;
    else cout << s;
    


}

/*



 */



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

int n,q;
long long S;
long long T[510];
int main(){
	cin >> n;
	set<long long> s;
	for(int i=1;i<=n;i++){
		cin >> S;
		s.insert(S);
	}
	cin >> q;
	for(int i=1;i<=q;i++){
		cin >> T[i];
	}
	int count = 0;
	for(int i=1;i<=q;i++){
		decltype(s)::iterator it = s.find(T[i]);
		if(it!=s.end()) count++;
	}
	cout << count << endl;
}


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


int main(){
  ll n; cin>>n;
  ll sum = 0;
  while (sum < n) {
    sum += 1000;
  }
  cout << sum - n << endl;
}

Measured memory_bytes: 3624
package main

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

const YES = "Yes"
const NO = "No"

func solve(N int64, M int64) {
	if N != M {
		fmt.Println(NO)
		return
	}
	fmt.Println(YES)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int64
	scanner.Scan()
	N, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	var M int64
	scanner.Scan()
	M, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	solve(N, M)
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){ 
    VI a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(ALL(a));
    if(a[0] +a[1]==a[2]){
        cout << "Yes"<<endl;
    }
    else cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
D = int(readline())
C = list(map(int,readline().split()))
S = [list(map(int,readline().split())) for i in range(D)]
t = [0]*D
for j,s in enumerate(S):
    ansidx = 0
    anssum = 0
    for i,si in enumerate(s,start=1):
        if anssum < si:
            ansidx = i
            anssum = si
    t[j] = ansidx
def score():
    ans = 0
    minus = 0
    last = [0]*26
    for i in range(D):
        ans += S[i][t[i]-1]
        minus = 0
        last[t[i]-1] = i+1
        for j in range(26):
            minus += C[j]*(i-last[j]+1)
        ans -= minus
    return ans
a = score()
import random
for k in range(15000):
    d,q = random.randint(1,D),random.randint(1,26)
    told = t[::]
    t[d-1] = q
    b = score()
    if a > b:
        t = told
    else:
        a = b
for ti in t:
    print(ti)


Measured memory_bytes: 81400
#include <bits/stdc++.h>
    #define N 2010
    #define ll long long
    #define For(i,x,y) for(int i=(x);i<=(y);++i)
    #define Rof(i,x,y) for(int i=(x);i>=(y);--i)
    #define Edge(x) for(int i=head[x];i;i=e[i].nxt)
    #define mset(x,y) memset(x,y,sizeof(x))
    #define strL strlen
    #define p_b push_back
    #define mcpy(x,y) memcpy(x,y,sizeof(x))
    #define lson l,mid,(o<<1)
    #define rson mid+1,r,((o<<1)|1)
    #define Ls (t[o].ls)
    #define Rs (t[o].rs)
    #define mod 1000000007
    #define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
    using namespace std;
    int _2[N],f[N][N],sub[N][N];
    void init(int n){_2[0]=1;For(i,1,n) _2[i]=(_2[i-1]+_2[i-1])%mod;}
    int main(){
    	int n,k,ans=0;
    	scanf("%d%d",&n,&k);
    	init(n);
    	For(i,2,n+1) sub[0][i]=1;
    	For(i,1,k-1) Rof(j,n-i+1,2){
    		if(j<=n-i+1) (f[i][j]+=sub[i-1][j])%=mod;
    		sub[i][j]=(sub[i][j+1]+f[i][j])%mod;
    	}
    	For(i,2,n-k+2) (ans+=1ll*f[k-1][i])%=mod;
    	if(k==1) ans=1;
    	if(k!=n) ans=1ll*ans*_2[n-k-1]%mod;
    	printf("%d\n",ans); 
    }

Measured memory_bytes: 31360
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a;
	cin>>a;
	cout<<(a/2)*((a+1)/2)<<endl;
}

Measured memory_bytes: 256
m,d  =map(int,input().split())
count = 0
for i in range(1,m+1):
    for j in range(d+1):
        if j < 22 or j%10<2:
            continue
        else:
            a = str(j)
            if int(a[0])*int(a[1])==i:
                count += 1
print(count)

Measured memory_bytes: 39280
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

char ca[200005];
char cb[200005];
int t[200005];
vector<char> v1,v2;
int n,m;

bool check(int a,int i){
	if(a<0 || n<=a)return false;
	if(ca[a]==cb[i])return true;
	return false;
}

int main(){
	int i,j,k;
	int a,b,c;
	char x,y,z;
	cin>>n>>m;
	cin>>ca;
	for(i=0;i<m;i++){
		cin>>cb[i]>>y;
		if(y=='L')t[i]=0;
		else t[i]=1;
	}
	a=0,b=0;
	for(i=m-1;i>=0;i--){
		if(t[i]==0){
			if(check(a,i))a++;
			if(check(n-b,i))b--;
		}else{
			if(check(a-1,i))a--;
			if(check(n-b-1,i))b++;
		}
	}
	int s=n-a-b;
	if(s<0)s=0;
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 1408
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        String[] C = br.readLine().split(" ");

        String[] cards;
        String stability;

        cards = C.clone();
        bubbleSort(cards);
        stability = isStable(C, cards);
        outputArray(cards, N);
        System.out.println(stability);

        cards = C.clone();
        selectionSort(cards);
        stability = isStable(C, cards);
        outputArray(cards, N);
        System.out.println(stability);
    }

    public static void bubbleSort (String[] arr) {
        int i, j;
        String temp;
        int n = arr.length;
        for (i = 0; i < n; i++) {
            for (j = n-1; j > i; j--) {
                if (arr[j-1].charAt(1) > arr[j].charAt(1)) {
                    temp = arr[j-1];
                    arr[j-1] = arr[j];
                    arr[j] = temp;
                }
            }
        }
    }

    public static void selectionSort (String[] arr) {
        int i, j;
        String temp;
        int n = arr.length;
        int mini;
        for (i = 0; i < n; i++) {
            mini = i;
            for (j = i; j < n; j++) {
                if (arr[j].charAt(1) < arr[mini].charAt(1)) {
                    mini = j;
                }
            }
            if (i != mini) {
                temp = arr[i];
                arr[i] = arr[mini];
                arr[mini] = temp;
            }
        }
    }

    public static void outputArray (String[] arr, int n) {
        StringBuilder output = new StringBuilder("");
        for (int i = 0; i < n; i++) {
            output.append(arr[i]);
            if (i != n-1) {
                output.append(" ");
            }
        }
        System.out.println(output.toString());
    }

    public static String isStable (String[] original, String[] sorted) {
        int i, j, n = original.length;
        String ori, sor;
        for (i = 1; i < 10; i++) {
            ori = sor = "";
            for (j = 0; j < n; j++) {
                if (Character.getNumericValue(original[j].charAt(1)) == i) {
                    ori += Character.toString(original[j].charAt(0));
                }
                if (Character.getNumericValue(sorted[j].charAt(1)) == i) {
                    sor += Character.toString(sorted[j].charAt(0));
                }
            }
            if (!ori.equals(sor)) return "Not stable";
        }
        return "Stable";
    }
}

Measured memory_bytes: 24488
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int check(char ch, vl& cnt, vl& cnt2) {
  int ret = 2;
  rep(i, 26) {
    if (cnt[i] != cnt2[i] * 2) {
      if (i != ch - 'a') {
        return -1;
      } else if (cnt[i] == (cnt2[i] * 2 - 1)) {
        ret=1;
      } else {
        return -1;
      }
    }
  }
  return ret;
}

int main() {
  //
  string s;
  cin >> s;
  vl cnt(26, 0), cnt2(26, 0);
  ll n = s.size();
  ll total = 0;
  rep(i, n) {
    if (s[i] != 'x') {
      cnt[s[i] - 'a']++;
      total++;
    }
  }
  if (total == 0) {
    cout << 0 << endl;
    return 0;
  }
  // cout<<total<<endl;

  ll l = -1, r = -1;
  rep(i, n) {
    if (s[i] != 'x') {
      cnt2[s[i] - 'a']++;
      int mode = check(s[i], cnt, cnt2);
      // cout << i << ":" << mode << endl;
      if (mode < 0) continue;
      if (mode == 1) {
        l = i;
        r = i;
        break;
      } else {
        l = i;
        r = i + 1;
        while (s[r] == 'x') r++;
        break;
      }
    }
  }
  // cout << l << "*" << r << endl;
  if (l < 0) {
    cout << -1 << endl;
    return 0;
  }

  ll ans = 0;
  while (true) {
    ll lcnt = 0;
    ll rcnt = 0;
    l--, r++;
    while (l >= 0 && s[l] == 'x') {
      l--;
      lcnt++;
    }
    while (r < n && s[r] == 'x') {
      r++;
      rcnt++;
    }
    // cout << l << ":" << lcnt << "," << r << ":" << rcnt << endl;
    ans += max(lcnt, rcnt) - min(lcnt, rcnt);
    if (l >= 0 && r < n) {
      if (s[l] != s[r]) {
        cout << -1 << endl;
        return 0;
      }
    } else {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
const int N=3e5+5;
int a[N],b[N],n;
bool ck(int l,int r){
	int lb=0,rb=0;
	fp(i,l,r)
		if(b[i]<i){
			if(lb>b[i]||b[i]<l||b[i]>r)return 0;
			lb=b[i];
		}else if(b[i]>i){
			if(rb>b[i]||b[i]<l||b[i]>r)return 0;
			rb=b[i];
		}
	return 1;
}
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&b[i]),a[i]=(b[i]==i);
	fp(i,2,n-1)if(!a[i-1]&&!a[i]&&!a[i+1])return puts("No"),0;
	fp(i,1,n)if(!a[i]){
		R int now=1,r=i;
		while((a[r]^now)&&r<=n)++r,now^=1;
		--r;
		if(!ck(i,r))return puts("No"),0;
		i=r;
	}
	puts("Yes");
	return 0;
}

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

namespace Competitive
{
    internal class Solution
    {
        private long N, M;
        
        public void Run()
        {
            int[] ary = Input.ReadIntArray();
            N = ary[0];
            M = ary[1];

            if (N > M)
            {
                long tmp = N;
                N = M;
                M = tmp;
            }

            if (N >= 2)
            {
                Console.WriteLine((N - 2) * (M - 2));
            }
            else if (M >= 2)
            {
                Console.WriteLine(M - 2);
            }
            else
            {
                Console.WriteLine(1);
            }

        }
    }

    internal static class Input
    {
        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

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

using namespace std;

typedef vector<int> vi;

int dfs(int u, int dest, const vector<vi> &adj, vector<bool> &vis)
{
	if(u == dest)
		return 1;
	vis[u] = true;
	int ret = 0;
	for(auto v: adj[u])
	{
		if(!vis[v])
			ret += dfs(v,dest,adj,vis);
	}
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	// freopen("input.txt", "r", stdin);

	int n, m;
	while(cin >> n >> m)
	{
		int u, v;
		vector<vi> adj(n);
		for(int i=0; i<m; i++)
		{
			cin >> u >> v;
			u--;
			v--;
			adj[u].push_back(v);
			adj[v].push_back(u);
		}
		
		bool ok = true;

		vi fours;
		int mores = 0;
		for(int i=0; i<n; i++)
		{
			if(adj[i].size()&1)
			{
				ok = false;
				break;
			}
			if(adj[i].size() == 4)
				fours.push_back(i);
			else if(adj[i].size() > 4)
				mores++;
		}

		if(!mores)
		{
			if(fours.size() < 2)
			{
				ok = false;
			}
			else if(fours.size() == 2)
			{
				vector<bool> vis(n);
				ok = ok && (dfs(fours[0],fours[1],adj,vis) == 2);
			}
		}

		if(ok)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}

	return 0;
}

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

#define int long long

signed main(){
  int n;cin>>n;
  map<int,int> m;
  int ans=0;
  while(n--){
    int a;cin>>a;ans+=a;
    m[a]++;
  }
  int q;cin>>q;
  while(q--){
    int b,c;cin>>b>>c;
    ans+=(c-b)*m[b];
    m[c]+=m[b];
    m[b]=0;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 9440
#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

using namespace std;

const int N = 111111;
const int M = 111111;


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

int main()
{
	int n,m;
	cin>>n>>m;
	
	UnionFind uf(m);
	
	vector<bool> used(m);
	vector<int> root(m);
	
	rep(i,n)
	{
		int k;
		cin>>k;
		
		int rt;
		
		rep(j,k){
			int a;
			cin>>a;
			a--;
			used[a] = true;
			if(j==0)rt = a;
			else{
				uf.unionSet(rt,a);	
			}
		}
	}
	
	
	bool ok = true;
	int rtmemo = -1;
	rep(i,m)
	{
		if(rtmemo==-1 && used[i])
		{
			rtmemo = uf.root(i);
		}
		
		if(used[i] && rtmemo!=-1)
		{
			if(rtmemo!=uf.root(i)){
				ok = false;
			}
		}
	}
	
	if(ok)puts("YES");
	else puts("NO");
}

/*

5 6
3 1 2 3
2 4 2
2 4 6
1 6
1 5

*/

Measured memory_bytes: 1024
n=int(input())
lis=list(map(int,input().split()))
keep=0
ans=1
for i in range(n):
  ans*=lis[i]
  if ans>10**18:
    keep=1
    ans=0
  if lis[i]==0:
    keep=0
if keep==0:
  print(ans)
else:
  print("-1")

Measured memory_bytes: 21756
from collections import Counter
n = int(input())
a = [i for i in input().split()]
cnt = Counter(a)
ans = 0

for i in cnt:
    if cnt[i] > int(i):
        ans += cnt[i] - int(i)
    elif int(i) > cnt[i]:
        ans += cnt[i]
print(ans)   

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

ans = [0] * (N - 1)
ans[0] = 1

for i in range(1, N - 1):
    for j in range(i + 1, N + 1):
        d = min(j - i, abs(Y - j) + abs(X - i) + 1)
        ans[d - 1] += 1

for a in ans:
    print(a)


Measured memory_bytes: 3444
class Graph:
    def __init__(self):
        n, m = map(int, input().split())

        self.adj = [[] for _ in range(n)]
        for _ in range(m):
            a, b = map(int, input().split())
            a -= 1
            b -= 1
            self.adj[a].append(b)
            self.adj[b].append(a)

        self.cnt = 0
        self.depth = 0
        self.ds = [-1] * n

    def solve(self, u):
        self.ds[u] = self.depth
        if self.ds.count(-1) == 0:
            self.cnt += 1
            return

        self.depth += 1
        for v in self.adj[u]:
            if self.ds[v] == -1:
                self.solve(v)
                self.ds[v] = -1
        self.depth -= 1


def main():
    graph = Graph()
    graph.solve(0)
    print(graph.cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

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

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int from, to;
	T cost;
	Edge() {}
	Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template<class T>
vector<T> Bellman_Ford(vector<Edge<T>> &edges, int V, int st) {

	vector<T> dist(V, INF);
	dist[st] = 0;
	for (int i = 0; i < V - 1; i++) {
		for (const auto &ele : edges) {
			if (dist[ele.from] == INF) continue;
			dist[ele.to] = min(dist[ele.to], dist[ele.from] + ele.cost);
		}
	}

	for (int i = 0; i < 2*V; i++) {
		for (const auto &ele : edges) { // finding negative loop
			if (dist[ele.from] == INF) continue;
			if (dist[ele.from] == -INF) dist[ele.to] = -INF; // src is nloop -> dst is nloop
			if (dist[ele.to] > dist[ele.from] + ele.cost) dist[ele.to] = -INF; // chmin is possible -> nloop
		}
	}

	return dist;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M, P;
	cin >> N >> M >> P;

	int a, b, c;
	vector<Edge<int>> edges(M);
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		a--, b--;
		edges[i] = { a, b, P - c };
	}

	auto dist = Bellman_Ford(edges, N, 0);
	DMP(dist);

	int ans = -dist.back();
	if (ans == INF) cout << "-1\n";
	else if (ans < 0) cout << "0\n";
	else cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
int main(){
    int a, b;
    scanf("%d%d",&a,&b);
    printf("%d",((a-b)>(a+b)?(a-b):(a+b))>(a*b)?((a-b)>(a+b)?(a-b):(a+b)):(a*b));
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	fmt.Println(min(a, b) + min(c, d))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
const int MOD = 1e9+7;

int main() {
	int N;
	cin >> N;
	vi z10bar;
	int sum = 0;
	rep(i, N) {
		int x;
		cin >> x;
		sum += x;
		if (x % 10 != 0) {
			z10bar.push_back(x);
		}
	}
	sort(z10bar);
	if (sum % 10 != 0) {
		cout << sum << endl;
	}
	else if (z10bar.empty()) cout << 0 << endl;
	else {
		cout << sum - z10bar[0] << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX;
using namespace std;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	map<string,int> m;
	set<string> s;
	string str;
	int i,a,b;
	cin>>a;
	rep(i,a){
		cin>>str;
		if(s.find(str)!=s.end()){
			m[str]++;
		}
		else{
			s.insert(str);
			m[str]=1;
		}
	}
	cin>>b;
	rep(i,b){
		cin>>str;
		if(s.find(str)!=s.end()){
			m[str]--;
		}
	}
	int max=0;
	str="llllllllld";
	map<string,int>::iterator it;
	for(it=m.begin();it!=m.end();it++){
		if(it->second>=max){
			max=it->second;
			str=it->first;
		}
	}
	cout<<max<<endl;
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	string s;
	cin>>s;
	REP(i,1,s.size()){
		if((s[i] == 'A' && s[i-1] == 'B') || (s[i] == 'B' && s[i-1] == 'A')){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define N 100005
#define inf 1e18
#define mem(a,b) memset(a,b,sizeof(a))
#define all(v) v.begin(),v.end()

using namespace std;

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

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}


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

void Sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}

//***************************************************************************************************************************//

int arr[N];
ll dp[N];
ll sum[N];
ll mod = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,k;
    cin >> n >> k;
    dp[0] = 1;
    for(int i=1;i<=n;i++)
        cin >> arr[i];
    for(int i=0;i<=N;i++)
        sum[i] = 1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            int t = j-arr[i];
            if(t<=0)
                dp[j] = sum[j];
            else
            {
                dp[j] = sum[j] - sum[t-1];
                if(dp[j] < 0)
                    dp[j] += mod;
            }
        }
        for(int j=1;j<=N;j++)
            sum[j] = (sum[j-1] + dp[j])%mod;
    }
    cout << dp[k];
}


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();
            if (str.equals("A")) {
                out.println("T");
            } else if (str.equals("G")) {
                out.println("C");
            } else if (str.equals("C")) {
                out.println("G");
            } else if (str.equals("T")) {
                out.println("A");
            }
        }

    }
}



Measured memory_bytes: 21588
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
s = input()
def snx(s, target=None, reverse=False, loop=False):
    """文字列sの各要素について、cがiより→で最初に現れる位置n[i][c]
    loop=Trueのとき周回した先のインデックスまで求める
    """
    if target is None:
        target = [chr(v) for v in range(ord("a"), ord("z")+1)]
    d = {c:None for c in target}
    nx = [[None]*len(target) for _ in range(len(s))]
    if not reverse:
        i = len(s)-1
        for c in reversed(s):
            d[c] = i
            for j,t in enumerate(target):
                nx[i][j] = d[t]
            i -= 1
        if loop:
            for i in range(len(s)):
                for j in range(len(target)):
                    if nx[i][j] is None:
                        nx[i][j] = nx[0][j]
    else:
        i = 0
        for c in s:
            d[c] = i
            for j,t in enumerate(target):
                nx[i][j] = d[t]
            i += 1
        if loop:
            for i in range(len(s)):
                for j in range(len(target)):
                    if nx[i][j] is None:
                        nx[i][j] = nx[-1][j]
    return nx
nx = snx(s, target=list(map(str, range(10))))
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            try:
                if nx[0][i] is not None and nx[nx[0][i]+1][j] is not None and nx[nx[nx[0][i]+1][j]+1][k] is not None:
#                     print(i, j, k)
                    ans += 1
            except IndexError:
                pass
print(ans)

Measured memory_bytes: 79732
#include<iostream>
#include<string>
#include<unordered_set>
#include<vector>
using namespace std;
typedef unordered_set<string> US;
typedef vector<string> VS;

int main() {
	int n;
	int lp = 0;
	while (cin >> n, n) {
		VS v[30];
		if (lp != 0)cout << endl;

		for (int i = 0;i < n;i++) {
			string s;
			int a, b, c;
			cin >> s >> a >> b >> c;
			int p = 3 * a + c;
			v[p].push_back(s);
		}

		for (int i = 29;i > -1;i--) {
			for (auto itr = v[i].begin();itr != v[i].end();itr++) {
				cout << *itr << ',' << i << endl;
			}
		}
		lp++;
	}
	return 0;
}

Measured memory_bytes: 2984
X = int(input())

if X >= 1800:
    print(1)
elif X >= 1600:
    print(2)
elif X >= 1400:
    print(3)
elif X >= 1200:
    print(4)
elif X >= 1000:
    print(5)
elif X >= 800:
    print(6)
elif X >= 600:
    print(7)
else:
    print(8)


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

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

Measured memory_bytes: 384