akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=3003;

ll dp[maxn][maxn][4];
ll val[maxn][maxn];
int main()
{
	int n,m,k,x,y;
	ll v;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d%d%lld",&x,&y,&v);
		val[x][y]=v;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			for(int k=0;k<=3;k++)
			{
				dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][0]);
				dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][1]);
				dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][2]);
				dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][3]);
				dp[i][j][k]=max(dp[i][j][k],dp[i][j-1][k]);
			}
			if(val[i][j]) for(int k=3;k;k--) dp[i][j][k]=max(dp[i][j][k],dp[i][j][k-1]+val[i][j]); 
		}
	}
	ll ans=0;
	for(int i=0;i<=3;i++)
	{
		ans=max(ans,dp[n][m][i]);
	}
	printf("%lld",ans);
 } 

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

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; i++)
  {
    cin >> H.at(i);
  }
  sort(H.begin(), H.end());

  int64_t ans = 0;
  for (int i = 0; i < (int)H.size() - K; i++)
  {
    ans += H.at(i);
  }
  cout << ans << endl;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD 998244353ll


ll N,S;
ll A[202020];
ll dp[3030][6060];
ll i, j, k;

int main(){
    scanf("%lld%lld", &N,&S);
    fornum(i,0,N){
        scanf("%lld", &A[i]);
    }
    dp[0][0] = 1;
    fornum(i,0,N){
        fornum(j,0,S+1){
            (dp[i + 1][j + A[i]] += dp[i][j])%=MOD;
            (dp[i + 1][j] += dp[i][j] * 2) %= MOD;
        }
    }
    printf("%lld\n", dp[N][S]);
    return 0;
}

Measured memory_bytes: 97784
n = int(input())
cij =[[0]*10 for i in range (10)]

for x in range (1,n+1):
    s=str(x)
    i=int(s[0])
    j=int(s[-1])
    cij[i][j]+=1

ans=0
for i in range(1,10):
    for j in range (1,10):
        ans += cij[i][j]*cij[j][i]

print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a,b = LI()

for i in range(100000):
    if int(i * 0.08) != a:
        continue
    if int(i * 0.1) != b:
        continue
    print(i)
    quit()
print(-1)

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CIN(int, M);
    vector<int> P(M, 0);
    vector<int> Y(M, 0);
    vector<pair<int,pair<int,int>>> myList(M);

    for (int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
        myList[i] = make_pair(Y[i], make_pair(P[i], i));
    }
    sort(myList.begin(), myList.end());


    vector<ll> count(N + 1, 0);
    vector<ll> ans(M);
    for (int i = 0; i < M; i++) {
        pair<int, int> p = myList[i].second;
        count[p.first]++;
        ans[p.second] = count[p.first];
    }

    for (int i = 0; i < M; i++) {
        cout << setfill('0') << right << setw(6) << P[i];
        cout << setfill('0') << right << setw(6) << ans[i];
        cout << "\n";
    }
    cout << setfill(' ');

    return 0;
}

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

int main() {
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s==u)
    cout << a-1 << " " << b << endl;
  else
    cout << a << " " << b-1 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();

		int M = (N * (N - 1)) / 2 - N / 2;
		int C = ((N % 2) == 1) ? N : N + 1;
		var ans = new List<string>();
		for(int i = 1; i < N; i++)
		{
			for(int j = i + 1; j <= N; j++)
			{
				if(i + j == C)
					continue;

				ans.Add($"{i} {j}");
			}
		}

		Console.WriteLine(M);
		Console.WriteLine(string.Join("\n", ans));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
}


Measured memory_bytes: 13280
n = int(input())
town = []

for _ in range(n):
    x, y = map(int, input().split())
    town.append([x, y])

ans = 0
for i in range(n):
    x1, y1 = town[i]
    for j in range(n):
        if j == i:
            continue
        x2, y2 = town[j]
        dist = ((x1 - x2)**2 + (y1 - y2)**2) ** 0.5
        ans += dist

ans /= n
print(ans)

Measured memory_bytes: 3064
import sys
stdin = sys.stdin

     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
N=int(input())
A=nl()


l_b=[0]*N

for i in range(N-1):
    l_b[A[i]-1]+=1

for i in range(N):
    print(l_b[i])

Measured memory_bytes: 31092
#include <iostream>

using namespace std;

int main() {
    int n;  cin >> n;
    for (int i = 1; i <= 9; i++) {
        if (n % i == 0 && n / i < 10) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;

int H, W;

int main(){
  ios_base::sync_with_stdio(false); 
  //cin >> H >> W;
  int x, y; cin >> x >> y;
  int cop[13];
  memset(cop, 0, sizeof(cop));
  cop[2] = 2;
  for(int i=1; i<=12; i+=2){
    cop[i] = 1;
    if(i == 7) --i;
  }
  (cop[x] == cop[y]) ? cout << "Yes\n" : cout << "No\n"; 
  /* if(H < W)
    swap(H, W);
  int ar = H*W;
  int res = 0;
  if(ar%3 != 0){
    
  }
  cout << res << "\n";
  */return 0;
}



Measured memory_bytes: 256
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
main()
{
    timesave;
    int n=5,i,ar[10],ans,a;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        if(a==0)
        {
            ans=i;
        }
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 3608
n = int(input())
a = list(map(int, input().split()))

four = 0
two = 0
one = 0
for i in a:
  if i%4 == 0:
    four += 1
  elif i%2 == 0 and i%4 != 0:
    two += 1
  elif i%2 != 0:
    one += 1

if four >= one or four + 1 >= two//2 + two%2 + one or n == two:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  int ans=0;
  for(int i=0;i<n;i++){
    int l,r;cin>>l>>r;
    ans+=(r-l+1);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	while (b > 0) {
		if (b & 1) {res = (res * a); b--;}
		a = (a * a);
		b >>= 1;
	}
	return res;
}
//ll n;
ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}
vector < vector <ll > > dp(101, vector <ll> (100005,-1));
vector <ll> w(101);
vector <ll> v(101);
ll n;
ll ww;

ll solve(ll i,ll j){
	if(dp[i][j]!=-1)
		return dp[i][j];
	if(i==0){
		if(w[i]<=j)
			return v[i];
		else
			return 0LL;
	}
	if(w[i]<=j)
		dp[i][j]=max(v[i]+solve(i-1,j-w[i]),solve(i-1,j));
	else
		dp[i][j]=solve(i-1,j);
	return dp[i][j];
}


int main() {
	cin>>n>>ww;
	for(ll i=0;i<n;i++)
		cin>>w[i]>>v[i];
	
	ll ans=solve(n-1,ww);
	cout<<ans<<"\n";
	
}

Measured memory_bytes: 83024
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define eb emplace_back
#define PF pop_front
#define PB pop_back
#define mp make_pair
#define s second
#define f first
#define mt make_tuple
#define foreach(it, a) for(__typeof(a.begin()) it=a.begin(); it!=a.end(); it++)
#define forn(i, a) for(int i=0; i<a; i++)
#define INF 1e9
#define all(x) x.begin(), x.end()
#define MOD 1e9+7 
 
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef unsigned int uint;
 
const int dx[4]={0, 0, 1, -1};
const int dy[4]={1, -1, 0, 0};
 
int n, m, stx, sty, step[805][805], mx, res=2e9;
char grid[805][805];
queue<int> q;
 
inline bool out(int x, int y)
{
	return x<0||x==n||y<0||y==m;
}
 
void Init()
{
	cin>>n>>m>>mx;
	memset(step, -1, sizeof(step));
	for(int i=0; i<n; i++)
		for(int j=0; j<m; j++)
		{
			cin>>grid[i][j];
			if(grid[i][j]=='S')
				stx=i, sty=j;
		}
		
	q.push(stx), q.push(sty);
	
	step[stx][sty]=0;
	while(!q.empty())
	{
		int x=q.front();	q.pop();
		int y=q.front();	q.pop();
		if(step[x][y]==mx+1)
			break;
		for(int i=0; i<4; i++)
		{
			int xx=x+dx[i], yy=y+dy[i];
			if(!out(xx, yy)&&step[xx][yy]==-1&&grid[xx][yy]!='#')
			{
				step[xx][yy]=step[x][y]+1;
				q.push(xx);
				q.push(yy);
			}
		}
	}
	while(!q.empty())
		q.pop();
	for(int i=0; i<n; i++)
		for(int j=0; j<m; j++)
			if(step[i][j]<=mx&&step[i][j]!=-1)
				q.push(i), q.push(j);
}
 
int main() 
{
	Init();
	while(!q.empty())
	{
		int x=q.front();	q.pop();
		int y=q.front();	q.pop();
		res=min(res, (min(min(n-x-1, x), min(y, m-y-1))+mx-1)/mx);
	}
	printf("%d", res+1);
	return 0;
}
//

Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
//#include <algorithm>
#define endl "\n"
typedef long long ll;

using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

int  frq[200];
int main(){
	Lancer();
	//cout << fixed << setprecision(12);

	ll n,sum=0,a,b,d;
	cin >> n;
	for (int i = 1; i <= n; i++){
		for (int c = 1; c <= n; c++){
			for (int j = 1; j <= n; j++){
				a = i; b = c; d = j;
				while (b)
				{
					int r = a%b;
					a = b;
					b = r;
				}
				while (d)
				{
					int r = a%d;
					a = d;
					d = r;
				}
				sum += a;
			}
		}
	}
	cout << sum;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3652
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    static Map<Long, Long> fact(long N) {
        Map<Long, Long> ret = new HashMap<>();
        long i = 2;
        while (i <= Math.sqrt(N)) {
            long cnt = 0;
            while (N > 0 && N % i == 0) {
                cnt++;
                N /= i;
            }
            if (cnt > 0) {
                ret.put(i, cnt);
            }
            i++;
        }
        if (N > 2) ret.put(N, 1L);

        return ret;
    }

    static long solve(long N) {
        Map<Long, Long> factor = fact(N);
        long ret = 0;
        for (long k : factor.keySet()) {
            long cnt = factor.get(k);
            int i = 1;
            while (i * (i + 1) / 2 <= cnt) i++;
            ret += i - 1;
        }

        return ret;
    }

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

        long N = in.nextLong();
        System.out.println(solve(N));
    }
}


Measured memory_bytes: 35856
S = [input() for i in range(3)]

def abctoint(x):
        if x=='a':
                return 0
        elif x=='b':
                return 1
        else:
                return 2

ban = 0

while True:
        if len(S[ban]) == 0:
                break
        next_ban = abctoint(S[ban][0])
        S[ban] = S[ban][1:]
        ban = next_ban

if ban == 0:
        print('A')
elif ban == 1:
        print('B')
else:
        print('C')


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

#define rep(i,n) for(int i=0;i<n;i++)
#define deb(n) cout << #n<<' '<<n<<endl

using namespace std;

char field[100][100];
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main() {
    int H, W;
    cin >> H >> W;
    rep(i, H) {
        rep(j, W) {
            cin >> field[i][j];
        }
    }
    bool fflag = false;
    rep(y, H) {
        rep(x, W) {
            if (field[y][x] == '#') {
                rep(a, 4) {
                    int nx = x + dx[a];
                    int ny = y + dy[a];
                    if (0 <= nx&&nx < W && 0 <= ny&&ny < H && field[ny][nx] == '#') {
                        break;
                    }
                    if (a == 3) {
                        fflag = true;
                        goto end;

                    }
                }
            }
        }
    }
end:
    if (fflag) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define P pair<ll,ll>

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;
struct edge{
    int to;
    int yen;
    int snuke;
};

void dijkstra(int s,vector<vector<edge>> &g,vector<ll> &y_cost,vector<ll> &s_cost,int x){
    priority_queue<P,vector<P>,greater<P>> q;
    q.push(P(0,s));
    if(x==0){
        //sから開始してiまで行くのにかかる最小円を求める
        fill(ALL(y_cost),1e16);
        y_cost[s] = 0;
        while(!q.empty()){
            P now = q.top();q.pop();
            ll cost = now.first;
            ll nowv = now.second;
            for(int i=0;i<g[nowv].size();i++){
                edge nextedge = g[nowv][i];
                if(y_cost[nextedge.to]>y_cost[nowv]+nextedge.yen){
                    y_cost[nextedge.to] = y_cost[nowv]+nextedge.yen;
                    q.push(P(y_cost[nowv]+nextedge.yen,nextedge.to));
                }
            }
        }
    }else{
        //sから開始してiまで行くのにかかる最小スクークを求める
        fill(ALL(s_cost),1e16);
        s_cost[s] = 0;
        while(!q.empty()){
            P now = q.top();q.pop();
            ll cost = now.first;
            ll nowv = now.second;
            for(int i=0;i<g[nowv].size();i++){
                edge nextedge = g[nowv][i];
                if(s_cost[nextedge.to]>s_cost[nowv]+nextedge.snuke){
                    s_cost[nextedge.to] = s_cost[nowv]+nextedge.snuke;
                    q.push(P(y_cost[nowv]+nextedge.snuke,nextedge.to));
                }
            }
        }
    }

}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,s,t;
    cin >> n >> m >> s >> t;
    s--;t--;
    vector<vector<edge>> g(n);
    vector<ll> y_cost(n),s_cost(n),ans(n); 
    //y_cost[i] := sからiまで行くのにかかる最小円
    //s_cost[i] := tからiまで行くのにかかる最小スヌーク
    rep(i,m){
        int u,v,a,b;
        cin >> u >> v >> a >> b;
        u--;v--;
        g[u].push_back({v,a,b});
        g[v].push_back({u,a,b});
    }
    dijkstra(s,g,y_cost,s_cost,0);
    dijkstra(t,g,y_cost,s_cost,1);
    //y_cost[i] := sからiまで行くのにかかる最小円
    //s_cost[i] := tからiまで行くのにかかる最小スヌーク
    //ans[i]:= 都市n-1からiまで使った時の最短経路
    ans[n-1] = y_cost[n-1] + s_cost[n-1];
    for(int i=n-2;i>=0;i--){
        ans[i] = min(ans[i+1],y_cost[i]+s_cost[i]);
    }
    for(auto x:ans)cout << (ll)(1e15)-x << endl;
}

Measured memory_bytes: 11712
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    int n;
    int ans=0;
    bool is_ok=false;
    cin >> n;
    vector<int> s(n);
    for(int i=0; i<n; i++){
        cin >> s[i];
        ans+=s[i];
    }

    sort(s.begin(), s.end());

    if(ans%10!=0){
        cout << ans << endl;
    }else{
        for(int i=0; i<n; i++){
            if(s[i]%10!=0){
                ans-=s[i];
                is_ok=true;
                break;
            }

        }
        if(is_ok==true){
            cout << ans << endl;
        }else{
            cout << 0 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

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


int main(){
    int N, K, ans, d[220000];
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> d[i];
    sort(d, d+N);
    int m = N / 2;
    ans = d[m] - d[m-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int H,A,count=0;
    scanf("%d%d",&H,&A);
    int ara[A];
    for(int i=0;i<A;i++)
    {
        scanf("%d",&ara[i]);
    }
    for(int j=0;j<A;j++)
    {
        count=count+ara[j];
    }
    if(count>=H)
    {
        printf("Yes\n");
    }
    else
    printf("No\n");
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,al=0,bo=0,k[100];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>k[i];
  }
  sort(k,k+n);
  reverse(k,k+n);
  for(int i=0;i<=n-1;i+=2){
    al+=k[i];
  }
  for(int i=1;i<=n-1;i+=2){
    bo+=k[i];
  }
  
  cout<<al-bo<<endl;
}

Measured memory_bytes: 256
#import <stdio.h>
#import <string.h>
int main() {
    char S[200005];
    scanf("%s", S);
    long s = strlen(S);
    long a;
    for (a=0;a<s;a++){
        if (S[a]=='A') {
            break;
        }
    }
    long b;
    for (b=s-1;b>=0;b--){
        if (S[b]=='Z') {
            break;
        }
    }
    printf("%ld", b-a+1);
}


Measured memory_bytes: 7112
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

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

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    ll X, t;
    cin >> X >> t;
    ll left = X - t;
    if (left < 0) {
        cout << 0 << endl;
    } else {
        cout << left << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int n = 1;
    while(n < b){
        n += a - 1;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<iostream>
#include<algorithm>

#define rep(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define END '.'
#define SB '('
#define CB ')'
#define P 'P'
#define Q 'Q'
#define R 'R'
#define zero '\0'
#define Su '-'
#define cal '*'
char input[100]={0};
int coun=0;
int index;
using namespace std;
int func(int p,int q,int r);
int nega(int p,int q,int r){
	//cout<<input[index]<<endl;
int left=0;
int sw=input[index++];
switch(sw){
case SB:left=func(p,q,r);break;
case Su:left=nega(p,q,r);break;
case P:left=p;break;
case Q:left=q;break;
case R:left=r;break;
default:left=sw-'0';break;
}


return(2-left);
}

int func(int p,int q,int r){
	int left=0,right=0;
	char ac;
	char sw=input[index++];
	switch(sw){
	case SB:left=func(p,q,r);break;
	case Su:left=nega(p,q,r);break;
	case P:left=p;break;
	case Q:left=q;break;
	case R:left=r;break;
	default:left=sw-'0';break;
	}
	ac=input[index++];
	sw=input[index++];
		switch(sw){
		case SB:right=func(p,q,r);break;
		case Su:right=nega(p,q,r);break;
		case P:right=p;break;
		case Q:right=q;break;
		case R:right=r;break;
		default:right=sw-'0';break;
		}
		index++;
		//printf("%d%c%d\n",left,ac,right);
	if(ac==cal){
		if(left<right)return (left);
		else return right;
	}
	if(left<right)return (right);
	else return left;


}
int fun(int p,int q,int r){
	if(input[1]==zero)
		switch(input[0]){
		case P:return(p);
		case Q:return(q);
		case R:return(r);
		}
	index++;
	if(input[0]==Su)return(nega(p,q,r));
	if(input[0]==SB)
	return(func(p,q,r));
	return(input[0]-'0');
}

int main(){

	cin>>input;
	while(input[0]!=END){
	coun=0;
	index=0;
		rep(p,0,3)rep(q,0,3)rep(r,0,3){
			index=0;
				if(fun(p,q,r)==2)coun++;
		}
		cout<<coun<<endl;
		cin>>input;
	}

	return(0);
}

Measured memory_bytes: 1144
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const ll inf=1ll<<55;
const int N=200010;
struct A{
    int l,r,fix,v;
    ll p,v1,v2,mn,m1,m2;
}t[N*2];
void pushup(int x){
    int l=t[x].l,r=t[x].r;
    t[x].m1=min(min(t[l].m1,t[r].m1),t[x].v1);
    t[x].m2=min(min(t[l].m2,t[r].m2),t[x].v2);
    t[x].mn=min(min(t[l].mn,t[r].mn),t[x].p);
}
void left(int &x){
    int p=t[x].r;
    t[x].r=t[p].l;pushup(x);
    t[p].l=x;pushup(p);
    x=p;
}
void right(int &x){
    int p=t[x].l;
    t[x].l=t[p].r;pushup(x);
    t[p].r=x;pushup(p);
    x=p;
}
int cnt=0;
void insert(int &x,int v,ll p){
    if(x==0){
        x=++cnt;
        t[x]=(A){0,0,rand(),v,p,p-v,p+v,p,p-v,p+v};
        return;
    }
    if(v<t[x].v){
        insert(t[x].l,v,p);
        if(t[t[x].l].fix<t[x].fix) right(x);
    }
    else{
        insert(t[x].r,v,p);
        if(t[t[x].r].fix<t[x].fix) left(x);
    }
    pushup(x);
}
ll get1(int x,ll v){
    if(x==0) return inf;
    if(v<t[x].v) return get1(t[x].l,v);
    else return min(t[x].v1,min(t[t[x].l].m1,get1(t[x].r,v)));
}
ll get2(int x,ll v){
    if(x==0) return inf;
    if(v>t[x].v) return get2(t[x].r,v);
    else return min(t[x].v2,min(t[t[x].r].m2,get2(t[x].l,v)));
}
int pos[N];
int ab(int x){return max(x,-x);}
ll ad;
void out(int x){
    if(x==0) return;
    
    printf("(%d %lld)",t[x].v,t[x].p+ad);out(t[x].l);
    out(t[x].r);
}
int main(){
    int n,q,a,b,rf=0,rg=0,i,las1,las2;
    ll ad1,ad2,now1,now2,ans=0;
    scanf("%d %d %d %d",&n,&q,&a,&b);
    insert(rf,b,0);ad1=0;
    insert(rg,a,0);ad2=0;
    t[0].m1=t[0].m2=t[0].mn=inf;
    for(i=1;i<=q;i++){
        scanf("%d",&pos[i]);
        
        now1=min(get1(rf,pos[i])+pos[i],get2(rf,pos[i])-pos[i])+ad1;
        now2=min(get1(rg,pos[i])+pos[i],get2(rg,pos[i])-pos[i])+ad2;
        
        if(i==1) las1=a;else las1=pos[i-1];
        ad1+=ab(pos[i]-las1);
        
        if(i==1) las2=b;else las2=pos[i-1];
        ad2+=ab(pos[i]-las2);
        
        insert(rg,las1,now1-ad2);
        insert(rf,las2,now2-ad1);
        
        //ad=ad1;out(rf);printf("\n");
        //ad=ad2;out(rg);printf("\n");
        //printf("-------------\n");
    }
    ans=min(t[rf].mn+ad1,t[rg].mn+ad2);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 25984
N = int(input())
l = len(str(N))

if N <= 9:
    res = N
elif N%10**(l-1) == 10**(l-1)-1:
    res = N//10**(l-1) + 9*(l-1)
else:
    res = (N//10**(l-1) - 1) + 9*(l-1)
print(res)

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

int main() {
    lint a, b, c;
    cin >> a >> b >> c;
    lint d = c - a - b;
    if (d < 0) {
        cout << "No" << endl;
        return 0;
    }
    if (4 * a * b < d * d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b;
    int result;
    scanf("%d %d", &a,&b);
    switch (6-a-b) {
      case 1:result=1;  break;
      case 2:result=2;  break;
      case 3:result=3;  break;
    }
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 128
import sys
import numpy as np

read = sys.stdin.read


def main():
    N, *txy = map(int, read().split())
    t = np.array([0] + txy[::3], np.int64)
    x = np.array([0] + txy[1::3], np.int64)
    y = np.array([0] + txy[2::3], np.int64)
    time = t[1:] - t[:-1]
    length = np.abs(y[1:] - y[:-1]) + np.abs(x[1:] - x[:-1])
    if np.any((time < length) | (time % 2 != length % 2)):
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 35904
k = int(input())
def gcd1 (a, b):
    while True:
        if (a < b):
            a, b = b, a
        c = a%b
        if (c == 0):
            return (b)
        else:
            a = b
            b = c

count = 0
for i in range(k):
    for j in range(k):
        tmp = gcd1(i + 1, j + 1)
        if (tmp == 1):
            count = count + k
        else:
            for l in range(k):
                tmp2 = gcd1(tmp, l + 1)
                count = count + tmp2

print(count)


Measured memory_bytes: 9184
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
int a[]{ 0,31,28,31,30,31,30,31,31,30,31,30,31 };
int main()
{
	int d1, d2, m1, m2;
	scanf("%d %d %d %d", &m1, &d1, & m2, &d2);
	if (a[m1] == d1) printf("1\n");
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s: chars
    }
    let cp = compress(&s);
    let mut is_bad = false;
    for i in 0..cp.len() {
        if cp[i].0 >= 2 {
            is_bad = true;
        }
    }
    println!("{}", if is_bad {"Bad"} else {"Good"});
}

#[doc = " aaabbccccaa = (3,a),(2,b),(4,c),(2,a)"]
#[allow(dead_code)]
fn compress<T: Clone + PartialEq>(slice: &[T]) -> Vec<(u64, T)> {
    if slice.len() == 0 {
        return vec![];
    }
    let mut acc = vec![];
    let mut current = slice[0].clone();
    let mut cnt = 1u64;
    for i in 1..slice.len() {
        if current != slice[i] {
            acc.push((cnt, current));
            cnt = 0;
        }
        current = slice[i].clone();
        cnt += 1;
    }
    acc.push((cnt, current));
    acc
}

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

int main() {
  double a;
  double b;
  double taxa = 0.08, taxb=0.1;
  cin >> a >> b;
  for(int i =12;i<1251;i++){
 //   cout << int(i * taxa) << " " << int (i*taxb) << endl;
    if((int(i*taxa) == int (a)) && (int(i*taxb) == int (b))){
      cout << i << endl;
      return 0;
    } else if(int(i*taxa)>a){
      cout << -1 << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string A, B;
  cin >> A >> B;
  if(A.length() < B.length()){
    int len = B.length();
    for(int i=0; i<len-A.length(); i++){
      A = "0"+A;
    }
  }else if(A.length() > B.length()){
    int len = A.length();
    for(int i=0; i<len-B.length(); i++){
      B = "0"+B;
    }
  }
  if(A==B){
    cout << "EQUAL" << endl;
  }else if(A<B){
    cout << "LESS" << endl;
  }else{
    cout << "GREATER" << endl;
  }
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){

    int n;
    
    cin >> n;
    vector<int> vi(10010,0);
    int res = 0;
    reps(x,1,101){
        reps(y,1,101){
            reps(z,1,101){
                res = x*x+ y*y+z*z + x*y+y*z+z*x;
                if(res <= n){
                    vi[res]++;
                }
            }
        }
    }
    reps(i,1,n+1){
        cout << vi[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
//const ll MOD=1000000007;
const ll MOD=998244353;

ll dp[3030][3030];

int main(){
  int N,S; cin>>N>>S;
  int A[N]; rep(i,N) cin>>A[i];
  dp[0][0]=1;
  rep(i,N) rep(j,S+1){
    (dp[i+1][j]+=dp[i][j]*2)%=MOD;
    if(j+A[i]>S) continue;
    (dp[i+1][j+A[i]]+=dp[i][j])%=MOD;
  }
  cout<<dp[N][S]<<endl;
  return 0;
}

Measured memory_bytes: 74548
#include<stdio.h>

int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a + b == c)printf("Yes");
	else if (b + c == a)printf("Yes");
	else if (a + c == b)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>


using namespace std;

int main(void)
{

	int n;
	vector<int> a;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		int t;
		cin >> t;
		a.push_back(t);
	}

	vector<int> b;
	bool push = true;
	vector<int>::iterator it;

	for (int i = 0; i < n; ++i)
	{
		if (push == true)
			b.push_back(a[i]);
		else
		{
			it = b.begin();
			it = b.insert(it, a[i]);
		}
		push = !push;
		//reverse(begin(b), end(b));
	}

	if (push == true)
	{
		cout << b[0];
		for (int i = 1; i < n; ++i)
		{
			cout << " " << b[i];
		}
		cout << endl;
	}
	else
	{
		cout << b[n - 1];
		for (int i = n - 2; i >= 0; --i)
		{
			cout << " " << b[i];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3828
a, b, c = gets.split(" ").map(&:to_i)
k = gets.chomp.to_i

k.times do
  if a >= b
    b *= 2
  elsif b >= c
    c *= 2
  end
  if a < b && b < c
    puts "Yes"
    exit
  end
end

puts "No"


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

long long gcd(long long m, long long n){
  long long tmp;
  while(m % n != 0){
    tmp = n;
    n = m % n;
    m = tmp;
  }
  return n;
}

int main(){
  long long A, B, C, D;
  cin >> A >> B >> C >> D;

  long long min_c = ((A-1) / C) + 1;
  long long max_c = B / C;
  long long min_d = ((A-1) / D) + 1;
  long long max_d = B / D;

  // A と B の間の Cの倍数の個数は max_c - min_c + 1
  // A と B の間の Dの倍数の個数は max_d - min_d + !

  // A と B の間の CとD共通の倍数の個数は？
  // CとD最小公倍数を求める
  long long lcm = 0;
  if (C < D){
    lcm = C * D / gcd(D, C);
  } else{
    lcm = C * D / gcd(C, D);
  }
  long long min_lcm = ((A-1) / lcm) + 1;
  long long max_lcm = B / lcm;

  long long ans = B - A + 1 - (max_c - min_c + 1) - (max_d - min_d + 1) + (max_lcm - min_lcm + 1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;


int main(){
  prep();
 int n, m;
  cin >> n >> m;
  int red[n][m];
 int blue[n][m];
  for (int i=0; i<n; i++){
      for (int j=0;j <m; j++){
          cin >> red[i][j];
      }
  }
  for (int i=0; i<n; i++){
      for (int j=0;j <m; j++){
          cin >> blue[i][j];
      }
  }
  int diffs[n][m];
  for (int i=0; i<n; i++){
      for (int j=0; j<m; j++){
          diffs[i][j] = abs(red[i][j]-blue[i][j]);
      }
  }
  int thing = 6400;
  bitset<12801> arr[n][m]; // we only need ones w/ abs val <= 6400
  arr[0][0].set(thing-diffs[0][0]);
  arr[0][0].set(thing+diffs[0][0]);
  for (int i=0; i<n; i++){
      for (int j=0; j<m; j++){
          if (i == 0 && j == 0){
              continue;
          }
          bitset<12801> first(0);
          if (i > 0){
              first |= arr[i-1][j];
          }
          if (j > 0){
              first |= arr[i][j-1];
          }
          arr[i][j] = (first<<diffs[i][j])|(first>>diffs[i][j]);
      }
  }
  int minnest = 1000000000;
  for (int i=0; i<12801; i++){
      if (arr[n-1][m-1][i]){
          minnest = min(minnest, abs(i-6400));
      }
      
  }
  cout << minnest;
  return 0; 
}


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

int main() {
  int h, w;
  cin >> h >> w;
  
  string s;
  vector<vector<char>> v(h+2, vector<char>(w+2));
  for(int i=0; i<h+2; i++) {
    if(i==0 || i==h+1) for(int j=0; j<w+2; j++) v[i][j] = '.';
    else {
      cin >> s;
      for(int j=0; j<w+2; j++) {
        if(j==0 || j==w+1) v[i][j] = '.';
        else v[i][j] = s[j-1];
      }
    }
  }
  
  bool check = true;
  for(int i=0; i<h+2; i++) {
    for(int j=0; j<w+2; j++) {
      if(v[i][j]=='#') {
        if(v[i-1][j]!='#' && v[i+1][j]!='#' && v[i][j-1]!='#' && v[i][j+1]!='#') check = false;
      }
    }
  }

  if(check) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  ll ans;
  if(k % 2 == 0) {
    ans = a - b;
  } else {
    ans = b - a;
  }
  cout << ans << endl;

  return 0;

}


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

ll middle(ll a, ll b, ll c){
    ll ret = a + b + c - max({a, b, c}) - min({a, b, c});
    return ret;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> p(N);
    rep(i, 0, N) cin >> p[i];
    ll ans = 0;
    rep(i, 0, N-2){
        if(p[i+1] == middle(p[i], p[i+1], p[i+2])) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let (N, K) = get!(usize, usize);
    let MOD: usize = 1000000007;

    // floor(N / i) の値に応じてグループ分けし、
    // グループ単位で条件を満たす列の個数を動的計画法で求める
    let P = (N as f64).sqrt() as usize;
    let Q = N / P;
    let R = P + Q;
    let C = (0..R).map(|i|
        if i <= P {
            1
        } else {
            N / (R - i) - N / (R - i + 1)
        }
    ).collect::<Vec<_>>();
    let mut dp = vec![vec![0; R]; K];
    for i in 0..R {
        dp[0][i] = C[i];
    }
    for j in 1..K {
        let mut acc = 0;
        for i in (1..R).rev() {
            acc = (acc + dp[j - 1][(R - i)]) % MOD;
            dp[j][i] = (C[i] * acc) % MOD;
        }
    }
    let ans: usize = dp[K - 1].iter().sum::<usize>() % MOD;

    println!("{}", ans);
}


Measured memory_bytes: 71932
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		V = sc.nextInt();
		E = sc.nextInt();
		g = new ArrayList[V];
		for (int i = 0; i < V; ++i)
			g[i] = new ArrayList<>();

		for (int i = 0; i < E; ++i) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			g[s].add(t);
		}

		vis = new boolean[V];
		ord = new int[V];
		pending = new boolean[V];

		topologialSort();

		for (int i = V - 1; i >= 0; --i) {
			System.out.println(ord[i]);
		}

	}

	static ArrayList<Integer>[] g;
	static boolean[] vis;
	static boolean[] pending;
	static int V, E;
	static int[] ord;
	static int now = 0;

	static void topologialSort() {
		for (int i = 0; i < V; ++i) {
			if (!vis[i])
				dfs(i, -1);
		}
	}

	static void dfs(int cur, int pre) {
		pending[cur]=true;
		for (int to : g[cur]) {
			if (!vis[to] && pre != cur){
				if(pending[to])throw new AssertionError();
				dfs(to, cur);
			}
		}
		vis[cur] = true;
		ord[now++] = cur;
	}
}

Measured memory_bytes: 70768
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define track  1;
#define d(...) 2;
#endif

#define int long long int

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j,cnt=0;
	bool flag=0;
	int n;

	cin>>n;

	map<string, int>mp;

	for(i=0;i<n;i++)
	{
		string s;
		cin>>s;
		mp[s]++;
	}

	cout<<mp.size()<<endl;

	

}

Measured memory_bytes: 19276
#include<stdio.h>
#include<stdbool.h>
#define N 3000
bool solve(int,int);
int A[N],a;
int main(){
  int b,z,i;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&z);
    if(solve(0,z))
      printf("yes\n");
    else
      printf("no\n");
  }
    return 0;
}
bool solve(int x,int y){
  if(y==0)
    return true;
  if(x>=a)
    return false;
  int res=solve(x+1,y)||solve(x+1,y-A[x]);
  return res;
}



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

template<class T>
struct SegmentTree {
	using F = function<T(T, T)>;
	const T init;
	const F f;
	int sz;
	vector<T> seg;
	SegmentTree(int n, const T init, const F f) :
		init(init),
		f(f)
		{
			sz = 1;
			while(sz < n) sz <<= 1;
			seg.resize(sz << 1, init);
		}
	void update(int id) {
		while(id >>= 1) {
			seg[id] = f(seg[2 * id], seg[2 * id + 1]);
		}
	}
	void replace(int id, T x){
		id += sz;
		seg[id] = x;
		update(id);
	}
	// [l,r)
	T get(int l, int r){
		T L = init, R = init;
		for(l += sz, r += sz; l < r; l >>= 1, r>>= 1) {
			if(l & 1) L = f(L, seg[l++]);
			if(r & 1) R = f(seg[--r], R);
		}
		return f(L, R);
	}
	void debug(){
		int i = 1;
		for(int r = 2; r <= 2 * sz; r <<= 1) {
			while(i < r) {
				cout << seg[i++] << " ";
			}
			cout << "\n";
		}
	}
};

int main() {
	int n; cin >> n;
	int64_t k; cin >> k;
	vector<int64_t> a(n + 1);
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
		a[i] -= k;
		a[i] += a[i - 1];
	}
	vector<int64_t> mp = a;
	sort(mp.begin(), mp.end());
	mp.erase(unique(mp.begin(), mp.end()), mp.end());
	int vn = mp.size();
	vector<int64_t> idx(n + 1);
	for(int i = 0; i < n + 1; ++i) {
		idx[i] = lower_bound(mp.begin(), mp.end(), a[i]) - mp.begin();
	}
	SegmentTree<int64_t> seg(vn, 0, [](int64_t lhs, int64_t rhs) {
		return lhs + rhs;
	});
	int64_t ans = 0;
	for(int i = n; i >= 0; --i) {
		ans += seg.get(idx[i], vn);
		seg.replace(idx[i], seg.get(idx[i], idx[i] + 1) + 1);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define mp make_pair
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
int main(){
     ll a,b,c,d;
     cin>>a>>b>>c>>d;
     
     vector<ll>arr(4) ;
     
     arr[0]=a*c;
     arr[1]=a*d;
     arr[2]=b*c;
     arr[3]=b*d;
     sort(arr.begin(), arr.end());
     cout<<arr[3];
     
     
     
    
    return 0;
    
}

Measured memory_bytes: 3628