akhauriyash/Code-Regression huggingface dataset:
m = []
f = []
r = []
while True:
    m1,f1,r1 = map(int,input().split())
    if (m1 == -1)*(f1 == -1)*(r1 == -1) :
        break
    m.append(int(m1))
    f.append(int(f1))
    r.append(int(r1))

for i in range (len(m)):
    if (m[i] == -1) or (f[i] == -1):
        print("F")
    elif (m[i]+f[i]) >=80:
        print("A")
    elif (m[i]+f[i]) >=65:
        print("B")
    elif (m[i]+f[i]) >=50:
        print("C")
    elif ((m[i]+f[i]) >=30)*(r[i]>=50):
        print("C")
    elif ((m[i]+f[i]) >=30)*(r[i]<50):
        print("D")
    else:
        print("F")




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

namespace B_RollerCoaster
{
    class Program
    {
        static void Main(string[] args)
        {
            var str0 = Console.ReadLine().Split(' ');
            int N = Int32.Parse(str0[0]);
            int K = Int32.Parse(str0[1]);
            var str1 = Console.ReadLine().Split(' ');
            int[] h = new int[N];
            for (int i = 0; i < N; i++)
            {
                h[i] = Int32.Parse(str1[i]);
            }
            int ans = h
                .Where(x => x >= K)
                .Count();
            Console.WriteLine(ans);

            //Console.ReadKey();
        }
    }
}


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

int main() {
    /* Input */
    int N, K;
    cin >> N >> K;
    
    vector<int> p(N);

    rep (i, N) {
        cin >> p.at(i);
    }

    /* Main Logic */
    int ans = 0;

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

    rep (i, K) {
        ans += p.at(i);
    }

    /* Output */
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3536
#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define Pi pair<int,int>
#define IINF 1e9
#define LINF 1e18
#define vi vector<int>
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 0, 1,0,-1 };
int dy[] = { 1, 0,-1,0 };
int dx8[] = { -1,-1,-1,0,0,1,1,1 };
int dy8[] = { -1,0,1,-1,1,-1,0,1 };

unsigned long long sttoi(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

ull gcd(ull a, ull b) {
	if (b > a)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a%b);
}

int comb(int n, int k) {
	int ans = 1;
	for (int i = 0; i < min(k, n - k); i++) {
		ans *= n - i;
		ans /= i + 1;
	}
	return ans;
}

ll mod_pow(ll n, ll p, ll mod) {
	if (p == 0) return 1 % mod;
	if (p < 2) {
		return n % mod;
	}
	else {
		ll d = 2, value = (n%mod)*(n%mod) % mod;
		while (d * 2 < p) { d *= 2;	value *= value;	value %= mod; }
		value %= mod;
		return ((value%mod) * (mod_pow(n, p - d, mod) % mod)) % mod;
	}
}

bool isPrime(int n) {
	if (n <= 1)return false;
	if (n == 2)return true;
	if (n % 2 == 0)return false;
	for (int i = 3; i*i <= n; i += 2) {
		if (n%i == 0)return false;
	}
	return true;
}

void solve() {
	string s;
	cin >> s;
	ll k;
	cin >> k;
	ll sum = 0;
	rep(i, s.length()) {
		sum += ('z' - s[i] + 1)%26;
	}

	if (k < sum) {
		rep(i, s.length()) {
			if (('z' - s[i] + 1) % 26 <= k) {
				k -= ('z' - s[i] + 1) % 26;
				s[i] = 'a';
			}
		}		
		vector<string> vs;
		string mini = "";
		rep(i, s.length()) {
			string tmp = s;
			char c = 'a' + (((tmp[i] + (k%26))-'a')%26);
			tmp[i] = c;
			if (tmp < mini || mini == "") {
				mini = tmp;
			}
		}
		P(mini);
	}
	else if (k == sum) {
		string ans = "";
		rep(i, s.length()) {
			ans = ans + "a";
		}
		P(ans);
	}
	else {
		string ans = "";
		rep(i, s.length() - 1) {
			ans = ans + "a";
		}
		ll left = k - sum;
		char last = ('a' + (left % 26));
		P(ans + last);
	}
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 824
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
long long a[100005];
int main()
{
	int n;
	int minn=0x3f3f3f3f,k;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	int t=a[n-1]/2,temp=(a[n-1]+1)/2;
	for(int i=0;i<n;i++)
	 {
	 	
	 	if(abs(a[i]-t)+abs(a[i]-temp)<minn)
	 	{
	 		//cout<<i<<endl;
	 		k=i;
	 		minn=abs(a[i]-t)+abs(a[i]-temp);
	 	}

		 
		 }
	 cout<<a[n-1]<<' '<<a[k];
	 return 0;
	
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int ans,n;
int main() {
	cin>>n;
	int k=n;
	while(k!=0){
		ans+=k%10;
		k/=10;
	} 
	if(n%ans==0) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
x[]={1,2,1,2,1,4,1,4},o[]={0,2,6,4,1,3,7,5},a[8];
main(i,j,v,V,m,t){for(;;){
for(i=0;i<8;i++)if(scanf("%d",a+i)==-1)exit(0);
v=99999,V=0;
for(i=0;i<8;i++){for(m=j=0;j<8;j++)t=a[j]-x[(o[i]+j)%8],m+=t<0?0:t;if(m<v)v=m,V=o[i];}
for(j=0;j<8;j++)printf(j<7?"%d ":"%d\n",x[(V+j)%8]);
}}

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

using namespace std;

const int N = 1e6 + 5;

int a[N], b[N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    if (u > v) swap(u, v);
    if (u == 1)
      a[v] = 1;
    if (v == n)
      b[u] = 1;
  }
  bool ans = 0;
  for (int i = 1; i <= n; i++)
    if (a[i] && b[i])
      ans = 1;
  puts(ans ? "POSSIBLE" : "IMPOSSIBLE"); 
  return 0;
}

Measured memory_bytes: 5120
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		boolean[] prime = new boolean[100000000];
		Arrays.fill(prime,true);
		prime[0] = false;
		prime[1] = false;

		for (int i=2; i<100000000; i++) {
			if (prime[i]) {
				for (int j=i; j<100000000; j+=i) {
					prime[j] = false;
				}
				prime[i] = true;
			}
		}

		int count = 0;
		for (int i=0; i<n; i++) {
			if(prime[stdIn.nextInt()])
				count++;
		}
		System.out.println(count);
	}
}

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

int n,a[6005],dp[2005][2005],mx,f[2005],three;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(int i=1;i<=n*3;i++){
        cin>>a[i];
    }
    memset(dp,0x80,sizeof(dp));
    memset(f,0x80,sizeof(f));
    dp[a[1]][a[2]]=mx=f[a[1]]=f[a[2]]=0;
    for(int i=3;i+2<=n*3;i+=3){
        if(a[i]==a[i+1]&&a[i]==a[i+2]){
            three++;
            continue;
        }
        vector<pair<pair<int,int>,int>> op;
        if(a[i]==a[i+1]||a[i+1]==a[i+2]||a[i]==a[i+2]){
            const int &p=a[i]==a[i+1]?a[i]:a[i+2],&q=a[i]+a[i+1]+a[i+2]-p*2;
            for(int k=1;k<=n;k++){
                op.emplace_back(make_pair(k,q),max(dp[p][k],dp[k][p])+1);
            }
        }
        const int &p=a[i],&q=a[i+1],&r=a[i+2];
        op.emplace_back(make_pair(q,r),max(mx,dp[p][p]+1));
        op.emplace_back(make_pair(p,r),max(mx,dp[q][q]+1));
        op.emplace_back(make_pair(p,q),max(mx,dp[r][r]+1));
        for(int k=1;k<=n;k++){
            op.emplace_back(make_pair(k,p),f[k]);
            op.emplace_back(make_pair(k,q),f[k]);
            op.emplace_back(make_pair(k,r),f[k]);
        }
        for(pair<pair<int,int>,int> &p:op){
            dp[p.first.first][p.first.second]=max(dp[p.first.first][p.first.second],p.second);
            mx=max(mx,p.second);
            f[p.first.first]=max(f[p.first.first],p.second);
            f[p.first.second]=max(f[p.first.second],p.second);
        }
    }
    int ans=dp[a[n*3]][a[n*3]]+1;
    for(int i=1;i<=n;i++){
        ans=max(ans,*max_element(dp[i]+1,dp[i]+1+n));
    }
    cout<<ans+three<<endl;

    return 0;
}

Measured memory_bytes: 19524
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 10, maxM = 1e3, maxMask = 1<<9; int n, m, k;
const int inf = maxN * maxM;
char bar[maxN][maxM + 1];
int acc[maxN + 1][maxM + 1];

int getSum(int loi, int hii, int loj, int hij)
{
  loi++, hii++, loj++, hij++;
  return acc[hii][hij] - acc[hii][loj - 1] - acc[loi - 1][hij] + acc[loi - 1][loj - 1];
}

int ones(int num)
{
  int o = 0;
  while (num)
  {
    o += num & 1;
    num >>= 1;
  }
  return o;
}

int bitmask;
bool valid(int loj, int hij)
{
  int mk = 0;
  int loi = 0;
  for (int i = 0; i < n - 1; i++)
    if (bitmask & (1 << i))
    {
      mk = max(mk, getSum(loi, i, loj, hij));
      loi = i + 1;
    }
  mk = max(mk, getSum(loi, n - 1, loj, hij));
  return mk <= k;
}
int solve()
{
  int verticalCuts = -1, lo = 0;
  for (int j = 0; j < m; j++)
  {
    while (j + 1 < m && valid(lo, j + 1)) j++;
    if (j == lo && !valid(lo, j))
      return inf;
    lo = j + 1, verticalCuts++;
  }
  return ones(bitmask) + verticalCuts;
}

int main()
{
  while (scanf("%d %d %d", &n, &m, &k) != EOF)
  {
    for (int i = 0; i < n; i++)
      scanf(" %s", bar[i]);

    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        acc[i + 1][j + 1] = (bar[i][j] == '1') + acc[i][j + 1] + acc[i + 1][j] - acc[i][j];

    int ans = inf;
    for (bitmask = 0; bitmask < maxMask; bitmask++)
      ans = min(ans, solve());
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
 using namespace std ;
 int main()
{
 int A, B, C, D, x, y, z, k;
 cin>>A;
 cin>>B;
 cin>>C;
 cin>>D;
x=(A+C);
y=(A+D);
z=(B+C);
k=(B+D);
if (x<=y&&x<=z&&x<=k)
{
  cout<<x<<endl;
}
if  (y<=k&&y<x&&y<=z)
{
  cout<<y<<endl;
}
if (z<y&&z<x&&z<=k)
{
  cout<<z<<endl;
}
if (k<y&&k<z&&k<x)
{
  cout<<k<<endl;
}
}

Measured memory_bytes: 3604
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int tmp = n;
        int t = 0;
        while(tmp > 0){
            t += tmp % 10;
            tmp /= 10;
        }
        System.out.println(n % t == 0 ? "Yes" : "No");
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	vvll v(3,vll(3)),x(3,vll(3,0));
	rep(i,3)rep(j,3) cin >> v[i][j];
	ll n;
	cin >> n;
	ll b;
	rep(i,n){
		cin >> b;
		rep(j,3){
			rep(k,3){
				if(b==v[j][k]) x[j][k]=1;
			}
		}
	}
	if(x[0][0]&&x[0][1]&&x[0][2]) cout << "Yes\n";
	else if(x[1][0]&&x[1][1]&&x[1][2]) cout << "Yes\n";
	else if(x[2][0]&&x[2][1]&&x[2][2]) cout << "Yes\n";
	else if(x[0][0]&&x[1][0]&&x[2][0]) cout << "Yes\n";
	else if(x[0][1]&&x[1][1]&&x[2][1]) cout << "Yes\n";
	else if(x[0][2]&&x[1][2]&&x[2][2]) cout << "Yes\n";
	else if(x[0][0]&&x[1][1]&&x[2][2]) cout << "Yes\n";
	else if(x[0][2]&&x[1][1]&&x[2][0]) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iomanip>

int main()
{
	const double pi = std::acos(-1);

	double radius;
	double area, circumference;

	std::cin >> radius;

	area = pi * (radius * radius);
	circumference = 2 * pi * radius;

	std::cout << std::fixed << std::setprecision(6)
		<< area << " " << circumference << std::endl;

	return 0;
}


Measured memory_bytes: 3236
import sys
input = sys.stdin.readline
n,Q = map(int, input().split(' '))
ab = [list(map(int, input().split(' '))) for i in range(n-1)]
q = [list(map(int, input().split(' '))) for i in range(Q)]
graph = [[] for i in range(n+1)]
parent = [0 for i in range(n+1)]
root = 1
order = []
stack = [root]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if parent[x] == y:
            continue
        parent[y] = x
        stack.append(y)
cnt = [0]*(n+1)
for i,x in q:
    cnt[i] += x
ans = [0]*(n+1)
for x in order:
    ans[x] += cnt[x]+ans[parent[x]]
print(*ans[1:],sep=" ")

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

int main(){
    int N;
    cin >> N;
    string S;
    string T;
    cin >> S >> T;

    for(int i=0; i<S.size(); i++){
        cout << S.at(i) << T.at(i);
    }

    cout << endl;

    return 0;
}

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

const int MAX = 3e5 + 111;

int l;

vector<pair<pair<int, int>, int> > ans;

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);    
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> l;
    for (int i = 1; i < 19; ++i) {
        ans.push_back({{i, i + 1}, (1 << (20 - i - 2))});
        ans.push_back({{i, i + 1}, 0});
    }
    int cur = 0;
    int cc = (l & (3 << 18));
    for (int m = ((cc - 1) & (3 << 18)); cc != 0; m = ((m - 1) & (3 << 18))) {
        ans.push_back({{0, 1}, m});
        if (m == 0)
            break;
    }
    cur = cc;
    for (int i = 17; i >= 0; --i) {
        if (l & (1 << i)) {
            ans.push_back({{0, 20 - i - 1}, cur});
            cur += (1 << i);
        }
    }
    cout << 20 << " " << ans.size() << "\n";
    assert(ans.size() <= 60);
    for (auto x : ans) {
        cout << x.first.first + 1 << " " << x.first.second + 1 << " " << x.second << "\n";
    }
    return 0;
}

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

using namespace std;


struct Bipartite_Matching
{
  vector< vector< int > > graph;
  vector< int > dist, match;
  vector< bool > used, vv;

  Bipartite_Matching(int n, int m)
  {
    graph.resize(n);
    match.assign(m, -1);
    used.assign(n, false);
  }

  void add_edge(int u, int v)
  {
    graph[u].push_back(v);
  }

  void bfs()
  {
    dist.assign(graph.size(), -1);
    queue< int > que;
    for(int i = 0; i < graph.size(); i++) {
      if(!used[i]) {
        que.emplace(i);
        dist[i] = 0;
      }
    }

    while(!que.empty()) {
      int a = que.front();
      que.pop();
      for(auto &b : graph[a]) {
        int c = match[b];
        if(c >= 0 && dist[c] == -1) {
          dist[c] = dist[a] + 1;
          que.emplace(c);
        }
      }
    }
  }

  bool dfs(int a)
  {
    vv[a] = true;
    for(auto &b : graph[a]) {
      int c = match[b];
      if(c < 0 || (!vv[c] && dist[c] == dist[a] + 1 && dfs(c))) {
        match[b] = a;
        used[a] = true;
        return (true);
      }
    }
    return (false);
  }

  int bipartite_matching()
  {
    int ret = 0;
    while(true) {
      bfs();
      vv.assign(graph.size(), false);
      int flow = 0;
      for(int i = 0; i < graph.size(); i++) {
        if(!used[i] && dfs(i)) ++flow;
      }
      if(flow == 0) return (ret);
      ret += flow;
    }
  }
};

int dp[3000][3000];

int gcd(int x, int y)
{
  if(x < 3000) {
    if(~dp[x][y]) return (dp[x][y]);
    int r = x % y;
    if(r == 0) return dp[x][y] = y;
    return dp[x][y] = gcd(y, r);
  } else {
    int r = x % y;
    if(r == 0) return y;
    return gcd(y, r);
  }
}

int main()
{
  memset(dp, -1, sizeof(dp));

  int M, N, B[500], R[500];
  while(scanf("%d %d", &M, &N), M) {
    Bipartite_Matching flow(M, N);
    for(int i = 0; i < M; i++) scanf("%d", &B[i]);
    for(int i = 0; i < N; i++) scanf("%d", &R[i]);
    for(int i = 0; i < M; i++) {
      for(int j = 0; j < N; j++) {
        if(__gcd(B[i], R[j]) > 1) flow.add_edge(i, j);
      }
    }
    printf("%d\n", flow.bipartite_matching());
  }
}

Measured memory_bytes: 38848
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <string>

using namespace std;
int main()
{
    typedef tuple<int, int, string, long long int, string> Item;
    int n;
    cin >> n;
    vector<Item> A;
    A.reserve(n);
    for (int i = 0; i < n; i++)
    {
        int v, w;
        long long int d;
        string t, s;
        cin >> v >> w >> t >> d >> s;
        A.push_back(make_tuple(v, w, t, d, s));
    }
    sort(A.begin(), A.end());
    for (auto it = A.begin(); it != A.end(); it++)
    {
        cout << get<0>(*it) << " " << get<1>(*it) << " " << get<2>(*it) << " " << get<3>(*it) << " " << get<4>(*it) << endl;
        // for (size_t i = 0; i < 4; i++)
        // {
        //     cout << get<i>(*it) << " ";
        // }
        // cout << get<4>(*it) << endl;
    }
    return 0;
}


Measured memory_bytes: 16948
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	for (string s; cin >> s; ) {
		vi a;
		rep(i, 10) a.pb(s[i] - '0');
		rep(i, 9) {
			vi b;
			rep(j, a.size() - 1) b.pb((a[j] + a[j + 1]) % 10);
			a = b;
		}
		cout << a.front() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N;
    cin>>N;
    REP(i,N){
        int A;cin>>A;
        if(A%2==0){
            if(A%3!=0&&A%5!=0){
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 256
function Main(input){
  input=input.split("\n");
  input=input[0].split(" ");
  const x = parseInt(input[0],10);
  const a = parseInt(input[1],10);
  const b = parseInt(input[2],10);
  var dist_xa = Math.abs(x-a);
  var dist_xb = Math.abs(x-b);

  console.log(dist_xa<=dist_xb ? "A" : "B");
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));


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

int main(){
	int n,l;
  	cin >> n >> l;
  	vector<string> s(n); 
  	for (int i=0;i<n;i++){
    	cin >> s[i];
    }
  	sort(s.begin(),s.end());
  	for (int i=0;i<n;i++){
    	cout << s[i];
    } 
}

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

using namespace std;

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

    int X;  cin >> X;
    if (X >= 1800)
        cout << 1;
    else if(X >= 1600)
        cout << 2;
    else if(X >= 1400)
        cout << 3;
    else if(X >= 1200)
        cout << 4;
    else if(X >= 1000)
        cout << 5;
    else if(X >= 800)
        cout << 6;
    else if(X >= 600)
        cout << 7;
    else if(X >= 400)
        cout << 8;
}


Measured memory_bytes: 3604
#include <cstdio>
int n, a[200005], b[200005];
long long ans;
long long calc(int x){ return 1ll * x * (x - 1) / 2; }
int main(){
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i)
    scanf("%d", &a[i]), ++b[a[i]];
  for (register int i = 1; i <= n; ++i)
    ans += calc(b[i]);
  for (register int i = 1; i <= n; ++i)
    printf("%lld\n", ans - calc(b[a[i]]) + calc(b[a[i]] - 1));
}


Measured memory_bytes: 3584
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second

using namespace std;

char a[1000];
int b,c;

int main()
{
	while(fgets(a,999,stdin))
	{
		c=0;
		while(true)
		{
			if(strstr(a,"this")||strstr(a,"the")||strstr(a,"that"))break;
			for(b=0;b<strlen(a);b++)
			{
				if(islower(a[b]))
				a[b]++;
				if(a[b]>122)
				a[b]=97;
			}
			c++;
			if(c>27)
			break;
		}
		printf("%s",a);
	}
	return 0;
}

Measured memory_bytes: 1124
#include<bits//stdc++.h>
using namespace std;
int main()
{
    int a,b,c,i,j,d;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d)
        cout<<"Yes"<<endl;
    else if(abs(a-b)<=d && abs(b-c)<=d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3616
//BROWNIE TK

#include <bits/stdc++.h>

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second

#define forz(i, n) for (int i = 0; i < n; i++)
#define forzm(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define rforzm(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#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 oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetlli tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

using namespace std;

/*STD fucntions*/
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        //y must be even now
        y = y >> 1; //y=y/2
        x = (x * x) % p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{
    return a * b / gcd(a, b);
}
lli modi(lli a, lli m)
{
    // fermat little thm where m is prime
    return power(a, m - 2, m);
}
/*CODE BEGINS*/
int ispal(string s)
{
    int n=int(s.si);
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-1-i])return 0;
    }
    return 1;
}
int main()
{
    kira;
    string s;
    cin>>s;
    int n=int(s.si);
    int k=n/2;
    string a=s.substr(0,k);
    string b=s.substr(k+1,k);
    if(ispal(s)&&ispal(a)&&ispal(b))cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import numpy as np
import random
import time
import bisect

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A.sort()
B.sort()
C.sort()

sum = 0

for i in range(N):
    a = bisect.bisect_left(A,B[i])

    c = N-bisect.bisect_right(C,B[i])
    # print(a,c)

    sum += a*c

print(sum)


Measured memory_bytes: 40140
INF = float('inf')

N, Ma, Mb = map(int, input().split())

cmax = N * 10
t = [[INF] * (cmax + 1) for _ in range(cmax + 1)]
for _ in range(N):
    a, b, c = map(int, input().split())
    for aa in range(cmax, 0, -1):
        for bb in range(cmax, 0, -1):
            if t[aa][bb] == INF:
                continue
            t[aa + a][bb + b] = min(t[aa + a][bb + b], t[aa][bb] + c)
    t[a][b] = min(t[a][b], c)

result = INF
for a in range(1, cmax):
    for b in range(1, cmax):
        if a * Mb == b * Ma:
            result = min(result, t[a][b])
if result == INF:
    result = -1
print(result)


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

int main(){
  int N,M;
  std::cin>>N>>M;
  int cnt[30];
  for(int i=0;i<30;++i)cnt[i]=0;
  for(int i=0;i<N;++i){
    int k;
    std::cin>>k;
    for(int j=0;j<k;++j){
      int a;
      std::cin>>a;
      --a;
      ++cnt[a];
    }
  }
  int ans=0;
  for(int i=0;i<M;++i){
    if(cnt[i]==N)++ans;
  }
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 384
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    X = [0]*N
    Y = [0]*N
    for i in range(N):
        X[i], Y[i] = map(int, input().split())
    
    r = [[0]*N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            r[i][j] = math.sqrt((X[i] - X[j])**2 + (Y[i] - Y[j])**2)

    ans = 0
    for route in itertools.permutations([i for i in range(N)]):
        for i in range(N-1):
            ans += r[route[i]][route[i+1]]
    ans /= math.factorial(N)

    print(ans)
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 64624
//ABC131B
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(){
	int n, l;
	scanf("%d %d",&n,&l);
	int i;
	int num=0;
	int a[n];
	for(i=0;i<n;i++){
		a[i] = l+i;
	}
	if(l<1-n){
		for(i=0;i<n-1;i++){
			num = num + a[i];
		}
	}else{
		if(1-n<=l && l<=0){
			for(i=0;i<n;i++){
				num = num + a[i];
			}
		}else{
			for(i=1;i<n;i++){
				num = num + a[i];
			}
		}
	}
	printf("%d",num);
	return 0;
}

Measured memory_bytes: 128
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){return "";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var output = 2;
  for(var i = 0; i < N; i++){
    output = output + 1 + output + 1;
  }
  myout(output);
}


Measured memory_bytes: 7620
import sys
from itertools import accumulate
#booltable=[0]+booltable


def resolve():
    input = sys.stdin.readline
    N,M=map(int, input().rstrip().split())
    G=[list(map(int,input().rstrip().split())) for _ in range(M)]
    l=[0 for _ in range(N)]
    for i in range(M):
        l[G[i][0]-1]+=1
        if G[i][1]!=N:
            l[G[i][1]]-=1
    l=[0]+l
    cumsum=list(accumulate(l))#0~N

    ans=cumsum.count(int(M))
    print(ans)

    

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4 2
1 3
2 4"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """10 3
3 6
5 7
6 9"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """100000 1
1 100000"""
        output = """100000"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Measured memory_bytes: 75736
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] d = S.toCharArray();
        HashSet<Character> set = new HashSet<>();
        for (int i = 0; i < 3; i++) {
            set.add(d[i]);
        }
        if (1 < set.size()) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;

signed main() {
	int n; cin >> n;
	int ans = 0;
	rep(i, n) {
		string s; cin >> s;
		if (s == "E869120")ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3196
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val s = (1..n).map { sc.next() }

  val array = Array(n) { Array(26) { 0 } }

  for ((i, si) in s.withIndex()) {
    val ai = array[i]
    for (c in si) {
      ai[c.toInt() - 'a'.toInt()] += 1
    }
  }

  val ans = Array(26) { 0 }
  for (i in 0 until 26) {
    var min = Int.MAX_VALUE
    for (ai in array) {
      val count = ai[i.toInt()]
      min = Math.min(min, count)
    }
    ans[i] = min
  }

  var str = ""
  var c = 'a'
  for (ai in ans) {
    if (ai == 0) {
      c++
      continue
    }

    (1..ai).map{ str += c }

    c++
  }

  println(str)

}


Measured memory_bytes: 37596
N=int(input())
S=str(input())

E=[0]*N
W=[0]*N
c=0
for i in range(N):
  W[i] =c
  if S[i]=='W':
    c +=1
c=0
for j in range(N):
  E[-1-j]=c
  if S[-1-j]=='E':
    c +=1
E=[E[0]]+E+[0]
W=[0]+W+[W[-1]]
answer=float('inf')
for i in range(N+2):
  answer=min(answer,E[i]+W[i])
print(answer)

Measured memory_bytes: 22320
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>
#include <functional>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846264338327950L

int main() {
	char a;
	cin >> a;
	if (isupper(a))
	{
		cout << "A" << endl;
	}
	else
	{
		cout << "a" << endl;
	}
	
}

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

int main() {
  int N,K,R,S,P;
  cin>>N>>K>>R>>S>>P;
  string T;
  cin>>T;
  long ans=0;
  string U="";
  for(int i=0;i<N;i++){
    if(T[i]=='r'){
      if(i-K>=0&&U[i-K]=='p') ans+=0,U+="d";
      else{
        ans+=P;
        U+="p";
      }
    }
    if(T[i]=='s'){
      if(i-K>=0&&U[i-K]=='r') ans+=0,U+="d";
      else{
        ans+=R;
        U+="r";
      }
    }
    if(T[i]=='p'){
      if(i-K>=0&&U[i-K]=='s') ans+=0,U+="d";
      else{
        ans+=S;
        U+="s";
      }
    }
  }
  //cout<<U<<endl;
  cout<<ans<<endl;
}


Measured memory_bytes: 640
N = int(input())
a_list = list(map(int, input().split()))
count = 0
while True:
    tmp = []
    for a in a_list:
        if a % 2 == 0:
            a = a / 2
            tmp.append(a)
        else:
            print(count)
            exit()
    count += 1
    a_list = tmp

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

int main(void){
    int h,w,n;
    cin>>h>>w>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    int b[100][100];
    int y=0,x=0;
    rep(i,n){
        while(a[i]>0){
            b[y][x] = i+1;
            if(y%2==0) x++;
            else x--;
            if(x==w) x--,y++;
            if(x==-1) x++,y++;
            a[i]--;
        }
    }

    rep(i,h)rep(j,w){
        cout<<b[i][j]<<(j<w-1 ? " " : "\n");
    }
    return 0;
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void __print(vector<bool> x){cerr<<"{";int f=x.size();for(auto i:x){cerr<<i;(--f !=0)?cerr<<",":cerr<<"";}cerr<<"}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
//void __print(vector<bool> x) {int f = 0; cerr << '{'; for (auto i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
//void _print() {cerr << "]\n";}

#ifndef ONLINE_JUDGE
#define ANTHRO(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define ANTHRO(x...)
#endif

template<typename... T>
void read(T&... args) {
	((cin >> args), ...);
}

template<typename... T>
void writ(T&&... args) {
	((cout << args << " "), ...);
}
#define ll long long
#define MOD 1000000007
#define INF (ll)1e18
#define EPS 1e-9
/*
	XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    No, nothing good starts in a getaway car
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,n; read(a,b,n);
    ll x=min(n,b-1);
  	cout<<((a*x)/b)-(a*(x/b));
    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll A, B, N;
    cin >> A >> B >> N;
    auto f = [&](ll x) {
        return (A * x) / B - A * (x / B);
    };
    cout << f(min(B - 1, N)) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		TreeSet<Record> gtop = new TreeSet<Record>();
		TreeSet<Record> otop = new TreeSet<Record>();
		for (int g = 0; g < 3; g++) {
			for (int t = 0; t < 8; t++) {
				gtop.add(new Record(in.nextInt(), in.nextDouble()));
			}
			for (int i = 0; i < 2; i++) {
				System.out.println(gtop.pollFirst());
			}
			otop.addAll(gtop);
			gtop.clear();
		}
		for (int i = 0; i < 2; i++) {
			System.out.println(otop.pollFirst());
		}
	}
}

class Record implements Comparable<Record> {
	final int num;
	final double time;

	public Record(int num, double time) {
		this.num = num;
		this.time = time;
	}

	@Override
	public int compareTo(Record other) {
		return Double.compare(this.time, other.time);
	}

	@Override
	public String toString() {
		return String.format("%d %.2f", num, time);
	}

}

Measured memory_bytes: 20168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Program
{


    static void Main(string[] args)
    {
        Solve();
    }

    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        var s = sc.intarr;
        int n = s[0];
        int x = s[1];
        int sowa = 0;
        int mi = 1000000;
        for(int i = 0; i < n; ++i)
        {
            int m = sc.intarr[0];
            sowa += m;
            mi = Math.Min(mi, m);

        }

        wr.wri(n + (x - sowa) / mi);
    }


}
    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(void){
 int n; cin >> n; ll a[3*n]; for(int i=0;i<3*n;i++) cin >> a[i];
 sort(&a[0], &a[3*n]); 
 ll ans = 0;
 for(int i=0;i<n;i++){ans += a[3*n-2-2*i];}
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll X,K,D;
    cin>>X>>K>>D;
    bool minus = false;
    if(X<0)minus = true;
    X = abs(X);

    if(K >= X/D){
        K -= X/D;
        X -= (X/D) * D;
        if(K%2 == 1){
            X = X-D;
        }
    }
    else{
        X -= K*D;
    }

    cout<<abs(X);
    return 0;
}

Measured memory_bytes: 3508
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let r: usize = itr.next().unwrap().parse().unwrap();
    if n >= 10 {
        println!("{}", r);
    } else {
        println!("{}", r + 100 * (10 - n));
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long
//#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define re(v) {for(auto &_re : v) cin >> _re;}
#define rre(v){for(auto &_re : v) for(auto &_rre : _re) cin >> _rre;}
#define pr(v) {for(auto _pr : v) cout << _pr << " "; cout << endl;}
#define prr(v) {for(auto _prr : v) cout << _prr.ff << " " << _prr.ss << endl;}
#define eb emplace_back
using namespace std;
const ll M = 1e9 + 7;
const ll mod = 998244353;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
	int n;
	cin >> n;
	map<pii,int> m;
	string s;
	ll x, ans = 0;
	int a,b;
	for(int i=0;i<n;i++){
		cin >> s;
		string y;
		x = -1; a = 0; b = 0;
		for(int j=0;j<s.size();j++){
			if(s[j] == '.'){
				while(j+1 < s.size()){
					j++;
					y.pb(s[j]);
					a--;
					b--;
				}
			}
			else{
				y.pb(s[j]);
			}
		}
		x = stoll(y);
		while(x%10==0){
			x/=10LL;
			a++; b++;
		}
		while(x%2==0){
			a++;
			x /= 2LL;
		}
		while(x%5==0){
			b++;
			x /= 5LL;
		}
		for(int dx=-a; dx <= 25; dx++){
			for(int dy=-b; dy <= 25; dy++){
				auto it = m.find({dx,dy});
				if(it!=m.end())
					ans += it->ss;
			}
		}
		m[{a,b}]++;
	}
	cout << ans << endl;
}
int32_t main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }  
}


Measured memory_bytes: 3648
#include <stdio.h>

#define NMAX 100
#define WMAX 2000
#define INF WMAX + 1
#define NIL -1

int n;
int M[NMAX][NMAX];
int d[NMAX]; // distance to mst
int p[NMAX]; // parent
int c[NMAX]; // c[i]=1 if i in mst

int solve() { // find total cost of mst
    for (int i = 0; i < n; i++) {
        c[i] = 0;
        p[i] = NIL;
        d[i] = INF;
    }
    d[0] = 0; // root
    p[0] = NIL;
    int total = 0;
    while (1) {
        // find i s.t d[i] is min
        int mincost = INF;
        int u;
        for (int i = 0; i < n; i++) {
            // if i not in mst and d[i] < mincost
            if (!c[i] && d[i] < mincost) {
                mincost = d[i];
                u = i;
            }
        }

        if (mincost == INF)
            break;

        // printf("include %d to mst!\n", u);
        c[u] = 1; // include u to mst
        total += mincost;

        // update d[i] for M[u][i]!=-1
        for (int i = 0; i < n; i++) {
            if (!c[i] && M[u][i] < d[i]) {
                d[i] = M[u][i];
                p[i] = u;
            }
        }
    }
    return total;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int w;
            scanf("%d", &w);
            if (w != -1) {
                M[i][j] = w;
            } else {
                M[i][j] = INF;
            }
        }
    }
    printf("%d\n", solve());
    return 0;
}


Measured memory_bytes: 2760
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long ;
int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n) a[i]--;
    map<ll,ll> data;
    ll i=0,now=0,t1=0,t2=0;
    while(1){
        data[now]++;
        if(data[now]==2&&t1==0) t1=i;
        if(data[now]==3){
            t2=i;
            break;
        }
        now=a[now];
        i++;
    }
    t2-=t1;
    t1-=t2;
    ll ans=0;
    if(k<=t1){
        for(ll ii=0;ii<k;ii++){
            ans=a[ans];
        }
        cout<<ans+1;
    }
    else{
        for(ll ii=0;ii<(k-t1)%t2+t1;ii++){
            ans=a[ans];
        }
        cout<<ans+1;
    }
}

Measured memory_bytes: 17156
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	var start, end int

	isYY := false
	isMM := false

	fmt.Scanf("%s", &s)
	start, _ = strconv.Atoi(s[0:2])
	end, _ = strconv.Atoi(s[2:4])

	if start >= 00 {
		if start > 0 && start <= 12 && end >= 00 {
			isMM = true
		}
		if start <= 99 && end > 00 && end <= 12 {
			isYY = true
		}
	}

	if isYY && isMM {
		fmt.Print("AMBIGUOUS")
	} else if isYY {
		fmt.Print("YYMM")
	} else if isMM {
		fmt.Print("MMYY")
	} else {
		fmt.Print("NA")
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 1e16
ll n0;
ll dp[3005][3005];
string s1,s2,s3;
    

ll solv(ll n,ll m)
{
    if(n==s1.length()||m==s2.length()) return 0;
    if(n>s1.length())
    return -1000000;
    if(m>s2.length())
    return -1000000;
    if(dp[n][m]!=-1) return dp[n][m];
    if(s1[n]==s2[m]) dp[n][m]= 1+solv(n+1,m+1);
    else
    {
    dp[n][m]= max(solv(n+1,m),solv(n,m+1));
    }
    return dp[n][m];
    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d,e,f,n,m,k,t,q;
    t=1;
    //cin>>t;
    while(t--)
    {
        cin>>s1>>s2;
    memset(dp,-1,sizeof(dp));    
        a=solv(0,0);
        //if(a==0){ cout<<"";continue;}
    int i=0,j=0;
    s3="";
    /*
    for(int i=0;i<s1.size();i++)
    {
        for(int j=0;j<s2.size();j++)
        {
            cout<<dp[i][j]<<" ";
            
        }
        cout<<"\n";
    }
    */
    char ch[a+1];
    ll k=0;
    while(i<=s1.size()&&j<=s2.size())
    {
        if(s1[i]==s2[j])
        {
            ch[k]=s1[i];
            i++;
            j++;
            k++;
        }
        else if(dp[i][j+1]>dp[i+1][j]) j++;
        else i++;
    }
    ch[k]='\0';
    cout<<ch;
    }
    return 0;
}


Measured memory_bytes: 71040