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

using namespace std;
typedef long long ll;

ll H,W;
ll A[80][80];
ll B[80][80];
bool dp[80][80][30000];
int BASE = 15000;

int main(){
    cin >> H >> W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> A[i][j];
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> B[i][j];
        }
    }
    for(int i=0;i<30000;i++) dp[0][0][i] = false;
    dp[0][0][A[0][0] - B[0][0] + BASE] = true;
    dp[0][0][B[0][0] - A[0][0] + BASE] = true;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(i==0 && j==0) continue;
            for(int k=0;k<30000;k++) dp[i][j][k] = false;
            ll diff1 = A[i][j] - B[i][j];
            ll diff2 = B[i][j] - A[i][j];
            if(j==0){
                for(int k=0;k<30000;k++){
                    if(k-diff1 > 0 && k-diff1 < 30000) dp[i][j][k] = dp[i][j][k] || dp[i-1][j][k-diff1];
                    if(k-diff2 > 0 && k-diff2 < 30000) dp[i][j][k] = dp[i][j][k] || dp[i-1][j][k-diff2];
                }
                continue;
            }
            if(i==0){
                for(int k=0;k<30000;k++){
                    if(k-diff1 > 0 && k-diff1 < 30000) dp[i][j][k] = dp[i][j][k] || dp[i][j-1][k-diff1];
                    if(k-diff2 > 0 && k-diff2 < 30000) dp[i][j][k] = dp[i][j][k] || dp[i][j-1][k-diff2];
                }
                continue;
            }
            for(int k=0;k<30000;k++){
                if(k-diff1 > 0 && k-diff1 < 30000) dp[i][j][k] = dp[i][j][k] || dp[i-1][j][k-diff1];
                if(k-diff2 > 0 && k-diff2 < 30000) dp[i][j][k] = dp[i][j][k] || dp[i-1][j][k-diff2];
                if(k-diff1 > 0 && k-diff1 < 30000) dp[i][j][k] = dp[i][j][k] || dp[i][j-1][k-diff1];
                if(k-diff2 > 0 && k-diff2 < 30000) dp[i][j][k] = dp[i][j][k] || dp[i][j-1][k-diff2];
            }
        }
    }
    ll min_l = 1e15;
    for(int i=0;i<30000;i++){
        if(dp[H-1][W-1][i]) min_l = min(min_l, (ll)abs(BASE - i));
    }
    cout << min_l << endl;
    return 0;
}

Measured memory_bytes: 187904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int n,m;
vi a;
ll cnt = 0;


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

    int n;
    cin >> n ;
    vector<pair<string,int>> a(n);    
    vector<pair<string,int>> ma(n);
    rep(i,n){
        string s;
        int x;
        cin >> s >> x;
        a[i] = make_pair(s,-x);
    }
    ma = a;
    sort(all(a));
    rep(i,n){
        rep(j,n){
        if(a[i]!=ma[j])continue;
        else cout << j+1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.Comparator;

public class Main{
	static class Plant{
		String name;
		int P, A, B, C, D, E, F, S, M;
		int rieki, time;
		Plant(String str, int p, int a, int b, int c, int d, int e, int f, int s, int m){
			name = str;
			P = p;
			A = a;
			B = b;
			C = c;
			D = d;
			E = e;
			F = f;
			S = s;
			M = m;
			time = a+b+c;
			for(int i=0; i<m; i++){
				time += (d+e);
			}
			rieki = m*f*s - p;
		}
	}

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

		while(true){
			int data = sc.nextInt();
			if(data==0) break;
			Plant[] plants = new Plant[data];
			for(int i=0; i<data; i++){
				plants[i] = new Plant(sc.next(), sc.nextInt(), sc.nextInt(), sc.nextInt(),
									  sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
			}

			Arrays.sort(plants, new Comparator<Plant>(){
				public int compare(Plant a, Plant b){
					if(a.rieki*b.time - b.rieki*a.time>0){
						return -1;
					}else if(a.rieki*b.time - b.rieki*a.time<0){
						return 1;
					}else{
						return a.name.compareTo(b.name);
					}
				}
			});

			for(int i=0; i<data; i++){
				System.out.println(plants[i].name);
			}
			System.out.println("#");
		}
	}
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define MOD 1000000007
#define yn(f) cout << (f ? "Yes" : "No") << endl;
#define YN(f) cout << (f ? "YES" : "NO") << endl;

string s;

signed main() {
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}




Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://abc051.contest.atcoder.jp/tasks/abc051_c>
問題文============================================================
 イルカは x 軸正方向を右、y 軸正方向を上とする 2 次元座標平面にいます。
 イルカは現在点 (sx,sy) にいて、1 秒あたり上下左右に距離 1 だけ進むことができます。
 このとき、移動前と移動後の x 座標、y 座標はともに整数でなければなりません。
 イルカはここから sx<tx と sy<ty を満たす点 (tx,ty) に行き、その後点 (sx,sy) に戻り、また点 (tx,ty) に行き、その後点 (sx,sy) に戻ります。
 このとき、イルカは点 (sx,sy) と点 (tx,ty) を除いて、途中で同じ座標を複数回通らないように移動しなければなりません。
 このような条件を満たすイルカの最短経路を 1 つ求めてください。
=================================================================

解説=============================================================
気合い
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    string S;
    int dx = tx - sx;
    int dy = ty - sy;
    
    for (int i = 0; i < dy;i++) {
        S += "U";
    }
    for (int i = 0; i < dx; i++) {
        S += "R";
    }
    for (int i = 0; i < dy;i++) {
        S += "D";
    }
    for (int i = 0; i <= dx; i++) {
        S += "L";
    }
    for (int i = 0; i <= dy;i++) {
        S += "U";
    }
    for (int i = 0; i <= dx; i++) {
        S += "R";
    }
    S += "D";
    S += "R";
    for (int i = 0; i <= dy;i++) {
        S += "D";
    }
    for (int i = 0; i <= dx; i++) {
        S += "L";
    }
    S += "U";
    
    cout << S << endl;
	return 0;
}


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



int main() {
  string S;
  cin >> S;
  
  int K;
  cin >> K;
  
  map<string, bool> dp;

  vector<string> subS;
  
  int N = S.size();
  // j文字目からi個までの部分列を足していく(i=1,2, ..., 5)
  for (int i = 1; i <= 5; i++) {
    for (int j = 0; j + i-1< N; j++) {
      string sub = S.substr(j, i);
      if (!dp[S.substr(j, i)]) {
        dp[sub] = true;
        subS.push_back(sub);
      }
    }
  }
  
  sort(subS.begin(), subS.end());
  
  cout << subS[K-1] << endl;
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

ll H[200000];

int main() {
  CIN(ll, N, K);
  REP(i, N) cin >> H[i];
  sort(H, H + N);
  ll ans = 0;
  for (int i = 0; i < N - K; ++i) {
    ans += H[i];
  }
  COUT(ans);
}


Measured memory_bytes: 1792
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
x = 0
y = 0
z = 0

for i in P:
    if i <= A:
        x += 1
    elif i <= B:
        y += 1
    else:
        z += 1
print(min(x, y, z))


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

const ll INF = 1000000007;

ll pow_mod(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res *= a;
    a = a*a;
    a %= mod;
    n >>= 1;
    res %= mod;
  }
  return res;
}

int main() {
  string S;
  cin >> S;
  ll s = S.size();

  vector<vector<ll>> dp(s, vector<ll>(13, 0));

  reverse(S.begin(), S.end());
  for (ll i = 0; i < s; i++) {
    for (ll j = 0; j < 13; j++) {
      char a = S[i];
      if (i == 0 && a == '?') {
        for (ll k = 0; k <= 9; k++) {
          dp[i][k] = 1;
        }
      }
      else if (i == 0) {
        ll k = (ll) a - (ll) '0';
        dp[i][k] = 1;
      }
      else if (a == '?') {
        for (ll k = 0; k <= 9; k++) {
          dp[i][(k*pow_mod(10, i, 13) + j)%13] += dp[i-1][j];
          dp[i][(k*pow_mod(10, i, 13) + j)%13] %= INF;
        }
      }
      else {
        ll k = (ll) a - (ll) '0';
        dp[i][(k*pow_mod(10, i, 13) + j)%13] += dp[i-1][j];
        dp[i][(k*pow_mod(10, i, 13) + j)%13] %= INF;
      }
    }
  }
  cout << dp[s-1][5] << endl;
}


Measured memory_bytes: 15616
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
const double EPS = 1e-9;
using namespace std;
class vector {
public:
	double x, y;
	vector(double a, double  b) {
		x = a;
		y = b;
	};
	vector operator * (const vector &v)const {
		return vector(x*v.x, y* v.y);
	}
	vector operator * (double a) {
		return vector(x * a, y * a);
	}
	vector operator - (vector v) {
		return vector(x - v.x, y - v.y);
	}
	vector operator + (vector v) {
		return vector(x + v.x, y + v.y);
	}
};
inline double dot(vector v1, vector v2) {
	return v1.x*v2.x + v1.y*v2.y;
}
inline double squ(vector v) {
	return v.x*v.x + v.y*v.y;
}
inline double norm(vector v) {
	return sqrt(squ(v));
}
inline void print(vector v) {
	printf("%.10f %.10f\n", v.x, v.y);
}
inline vector pro(vector base, vector v, vector be) {
	double a = dot(base, v) / squ(base);
	vector v1 = base * a;
	return v1 + be;
}
inline vector ref(vector v, vector be) {
	return (v - be)*2 + be;
}
inline double cross(vector v1, vector v2) {
	return v1.x*v2.y - v1.y*v2.x;
}
inline int ccw(vector v1, vector v2, vector v3) {
	vector a = v2 - v1;
	vector b = v3 - v1;
	if (cross(a, b) < 0.0) return -1;
	else if (cross(a, b) > 0.0) return 1;
	else if (dot(a, b) < 0.0) return -2;
	else if (dot(a, b) > squ(a)) return 2;
	else return 0;
}
inline int inter(vector v1, vector v2, vector v3, vector v4) {
	return (ccw(v1, v2, v3) * ccw(v1, v2, v4) <= 0) && (ccw(v3, v4, v1) * ccw(v3, v4, v2) <= 0);
}
inline double disPP(vector v1, vector v2) {
	return norm(v2 - v1);
}
inline double disLP(vector v1, vector v2, vector v3) {
	vector a = v2 - v1;
	vector b = v3 - v1;
	return fabs(cross(a, b) / norm(a));
}
inline double disSP(vector v1, vector v2, vector v3) {
	vector a = v2 - v1;
	vector b = v3 - v1;
	vector c = v1 - v2;
	vector d = v3 - v2;
	if (dot(a, b) < 0.0) return disPP(v1, v3);
	else if (dot(c, d) < 0.0) return disPP(v2, v3);
	else return disLP(v1, v2, v3);
}
inline double disSS(vector v1, vector v2, vector v3, vector v4) {
	if (inter(v1, v2, v3, v4)) return 0;
	double a = disSP(v1, v2, v3);
	double b = disSP(v1, v2, v4);
	double c = disSP(v3, v4, v1);
	double d = disSP(v3, v4, v2);
	return min(min(a, b), min(c, d));
}
int main() {
	//inter
	int n;
	double x0, x1, x2, x3, y0, y1, y2, y3;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		vector v1(x0,y0);
		vector v2(x1, y1);
		vector v3(x2, y2);
		vector v4(x3, y3);
		cout << inter(v1, v2, v3, v4) << endl;
	}
	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;

int main(){
  string a,b;
  cin >> a >>b;
  int aq=a.size(),bq=b.size();
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  if(a<b){cout <<"Yes" << endl;}else{cout << "No" << endl;}
}


Measured memory_bytes: 256
A, B, C, D = map(int,input().split())

def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

def lcm(m, n):
  return (m * n) // gcd(m, n)

def f(n, m, l):
  a = n // l
  if l * a < n:
    a += 1
  b = m // l
  return b - a + 1

N = B - A + 1
print(N - (f(A, B, C) + f(A, B, D) - f(A, B, lcm(C, D))))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, ll> mp;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        mp[A[i]]++;
    }

    ll sum = 0;
    for (auto p : mp) {
        sum += p.second * (p.second - 1) / 2;
    }

    for (int i = 0; i < N; i++) {
        ll cnt = mp[A[i]];
        cout << sum - cnt * (cnt - 1) / 2 + (cnt - 1) * (cnt - 2) / 2 << endl;
    }
}


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

using namespace std;

int main(int argc, const char * argv[])
{
    string stmp;
    cin >> stmp;
    
    vector<int> vcount(200);
    for(int i = 0; i < 200; i++)
    {
        vcount[i] = 0;
    }
    
    for(int i = 0; i < stmp.size(); i++)
    {
        char stgt = stmp[i];
        vcount[stgt]++;
    }
    
    for(int i = 0; i < 200; i++)
    {
        if(vcount[i] % 2 != 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
int main(){ 
int N,D;
cin>>N>>D;
  vector<vector<int> >data(N,vector<int>(D,0));
  for (int i=0; i<N; i++){
    for (int j=0; j<D; j++){
      cin >>data.at(i).at(j);
    }
  }
  int t=0;
 for (int i=0; i<N-1; i++){
   for (int k=i+1; k<N; k++){
     int s=0;
    for (int j=0; j<D; j++){
      s+=(data.at(k).at(j)-data.at(i).at(j))*(data.at(k).at(j)-data.at(i).at(j));
    }
  float o= sqrt(s);
     s=sqrt(s);
     if (s==o){
    t+=1;
   }
 }
 }
  cout<<t<<endl;
}

  

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

var col []int
var ecol []int
var used int

func dfs(v, p int, node [][]int) {
	for _, e := range node[v] {
		if e == p {
			continue
		}
		dfs(e, v, node)
	}
	ecol[v] = col[used]
	used++
}

type pair struct {
	x, y int
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	node := make([][]int, N)
	edge := make([]pair, N)
	for i := 0; i < N-1; i++ {
		f, t := getInt()-1, getInt()-1
		node[f] = append(node[f], t)
		node[t] = append(node[t], f)
		edge[i] = pair{f, t}
	}
	col = make([]int, N)
	ecol = make([]int, N)
	for i := 0; i < N; i++ {
		col[i] = getInt()
	}
	sort.Ints(col)
	dfs(0, -1, node)
	//out(ecol)
	ans := 0
	for i := 0; i < N-1; i++ {
		c0 := ecol[edge[i].x]
		c1 := ecol[edge[i].y]
		ans += min(c0, c1)
	}
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	fmt.Fprintln(w, ans)
	for i := 0; i < N; i++ {
		fmt.Fprint(w, ecol[i], " ")
	}
	fmt.Fprintln(w)
}


Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
using namespace std;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int n;
int a[100001];

int main(){
	cin.tie(0);
	
	cin>>n;
	rep(i, n)cin>>a[i];
	
	sort(a, a+n);
	
	cout<<a[0]<<' '<<a[n-1]<<' ';
	
	long long s = 0;
	rep(i, n)s += a[i];
	
	cout<<s<<endl;
	
	return 0;
}



Measured memory_bytes: 3172
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main(){
	int n,cnt=0,ans,sosu[1000003]={0};
	
	for(int i=2;i<1000002;i++){
		bool flag=true;
		for(int j=2;j<=sqrt(i);j++){
			if(i%j==0){
			flag=false;
			break;//素数でない時点で打ち切り
			}
		}
		/*if(flag){
		cnt++;
		sosu[i]=cnt;
		}*/
		if(flag)cnt++;
		sosu[i]=cnt;		
	}
	//for(int i=0;i<31;i++)cout<<sosu[i]<<" ";
	while(cin>>n){
	cout<<sosu[n]<<endl;
	}
    return 0;
}

Measured memory_bytes: 5072
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;
vector<long long> table(100009,0);

int main() {
  int n,m;
  cin>>n>>m;
  if(m-1<=n && n<=m+1){
    table[1]=1;
    rep(i,max(m,n)){
      if(i>0) table[i+1]=(i+1)*table[i]%X;
      //cout<<table[i+1]<<endl;
    }
    long long ans=table[n]*table[m]%X;
    if(m==n) ans=ans*2%X;
    cout<<ans<<endl;
  }
  else cout<<"0"<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define INF 100000000
#define MAX_N 150005
using namespace std;

int main(){
    int N,M;
    int a[1012];
    cin>>N>>M;
    rep(i,0,M)cin>>a[i];
    cout<<N-M-1<<endl;
    
    return 0;
}

Measured memory_bytes: 3040
s = input()
n = len(s)
K = int(input())
ans = []
an = set()
for i in range(1,min(5,n)+1):
    for j in range(n-i+1):
        S = s[j:j+i]
        if S not in an:
            ans.append(S)
            an.add(S)
ans.sort()
print(ans[K-1])

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

namespace ARC_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            long t = long.Parse(s[1]);
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var d = new int[n - 1];
            long sum = t;
            for (int i = 0; i < n - 1; i++)
            {
                sum += a[i + 1] - a[i] >= t  ? t : a[i + 1] - a[i];
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 26528
#include <stdio.h>

int potato(int n,int m) {

  if(n==1) return 0;

  else return (potato(n-1,m)+m)%n;

}

int main(void) {

  int n,m;

  while(1) {

    scanf("%d %d",&n,&m);

    if(n==0 && m==0) break;

    printf("%d\n",potato(n,m)+1);

  }

  return 0;

}

Measured memory_bytes: 0
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
ans, near = 0, 10**5
for i, high in enumerate(h):
	temp = abs(a - (t - high * 0.006))
	if near > temp:
		near = temp
		ans = i + 1
print(ans)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    FAST
    ll n;
    ll x=pow(10,18);
    cin>>n;
    ll a[n];
    int flag2=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0) flag2=1;
    }
    ll ans=1;
    int flag=0;
    for(int i=0;i<n;i++){
        if(a[i]<=x/ans) ans=ans*a[i];
        else{
            flag=1;
            break;
        }
    }
    if(flag2==1) cout<<0<<endl;
    else if(flag==1) cout<<-1<<endl;
    else cout<<ans<<endl;
    
}

Measured memory_bytes: 4420
#include<bits/stdc++.h>
 
using namespace std;
int main()
 
{
    string num;
  	cin >> num;
 
  	if( (num[0]==num[1] && num[1]==num[2]) ||
      	(num[1]==num[2] && num[2]==num[3])){
      		cout << "Yes" << endl;
    }else{
     	cout << "No" << endl;
    }
  return 0;
}

Measured memory_bytes: 256
//Bismillah hirrahmanir Rahim
            #include<bits/stdc++.h>
            #define ll long long
            #define pb push_back
            #define dbug printf("I am here\n");
            #define Fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
           using namespace std;
           int main() {

            ll int a,b,c,d,tst,n;
            string x;
           cin>>a>>b;
           if(a>b)cout<<"safe"<<endl;
           else
           cout<<"unsafe"<<endl;
            return 0;
          }


Measured memory_bytes: 3628
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    ll fact[n+1]={0};
    fact[0]=1;
    for(int i=1;i<=n;i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
    }
    string s;
    cin>>s;
    s='%'+s;
    for(int i=1;i<=3*n;i++)
    {
        if(s[i]=='R')
            adj[1].pb(i);
        else if(s[i]=='G')
            adj[2].pb(i);
        else
            adj[3].pb(i);
    }
    for(int i=1;i<=3;i++)
        sort(all(adj[i]));
    vl a,b,c;
    for(int i=0;i<n;i++)
    {
        ll mini=min3(adj[1][i],adj[2][i],adj[3][i]);
        ll maxi=max3(adj[1][i],adj[2][i],adj[3][i]);
        a.pb(mini);
        c.pb(maxi);
        b.pb(adj[1][i]+adj[2][i]+adj[3][i]-mini-maxi);
    }
    sort(all(a));
    sort(all(b));
    sort(all(c));   
    ll low[n+1]={0},high[n+1]={0};
    for(int i=1;i<=n;i++)
    {
        ll temp=b[i-1];
        auto it=lower_bound(all(a),temp);
        low[i]=it-a.begin()-(i-1);
    }
    for(int i=n;i>=1;i--)
    {
        ll temp=b[i-1];
        auto it=lower_bound(all(c),temp);
        high[i]=c.end()-it-(n-i);
    }
    ll ans=fact[n];
    for(int i=1;i<=n;i++)
    {
        ans*=low[i];
        ans%=mod;
        ans*=high[i];
        ans%=mod;
    }
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 19176
K;double P,E,T;
double dfs(int K,double L,double R){
	double H=(L+R)/2;
	if(!K)return fabs(T-H)<E;
	if(R<T-E||T+E<L)return 0;
	if(T-E<=L&&R<=T+E)return 1;
	double a=dfs(K-1,L,H),b=dfs(K-1,H,R);
	return H<=T ? P*a+(1-P)*b : P*b+(1-P)*a;
}
main(){
	double L,R;
	scanf("%d%lf%lf%lf%lf%lf",&K,&L,&R,&P,&E,&T);
	K=!printf("%f\n",dfs(K,L,R));
}

Measured memory_bytes: 652
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int F(char*p)
{
	int i=0,a[3],f[3]={1,1,1};
	for(;*p;++p)
	{
		if(*p=='~')f[i]=-1;
		if(isalpha(*p))a[i++]=*p;
	}
	for(i=0;i<3;++i)a[i]*=f[i];
	return a[0]+a[1]&&a[1]+a[2]&&a[0]+a[2];
}
int main()
{
	char*p,s[512];
	while(scanf("%s",s),*s-'#')
	{
		for(p=strtok(s,"|");p;p=strtok(0,"|"))
			if(F(p)){puts("yes");goto E;}
		puts("no");
		E:;
	}
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int N;
  string S;
  cin >> N >> S;
  if(N%2!=0) cout << "No" << endl;
  else{
    int H=N/2;
    bool check=true;
    rep(i,H) if(S[i]!=S[i+H]) check=false;
    if(check) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

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

#define MOD 1000000007

int main(){
    int N; cin >> N;
    int M; cin >> M;
    long long  ans = 1;
    
    if(N > M) swap(N, M);

    if(N == M-1){
        for(int i = 1; i <= N; i++) ans = ans * i % MOD;
        ans = ans * ans % MOD;
        ans = ans * M % MOD;
    }
    else if(N==M){
        for(int i = 1; i <= N; i++) ans = ans * i % MOD;
        ans = ans * ans % MOD;
        ans = ans * 2 % MOD;
    }
    else ans = 0;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
using namespace std;
int n,k,i,ans;
set<string> se;
string str[11];
void dfs(int j,string sum,int bit){
  if(j == k) {
    if(se.find(sum) == se.end()){
      se.insert(sum);
      ans++;
    }
  }
  else {
    for(int i = 0;i < n;i++){
      if(((1<<i) & bit)==0){
	dfs(j+1,sum+str[i],bit|(1<<i));
      }
    }
  }
}
int main(){
  cin >> n >> k;
  while(n != 0 || k != 0){
    for(i = 0;i < n;i++){
      cin >> str[i];
    }
    ans = 0;
    dfs(0,"",0);
    cout << ans << endl;
    cin >> n >> k;
    se.clear();
  }
  return(0);
}

Measured memory_bytes: 3412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, n, m, k;
  in2(n, m);
  vector<pair<ll, ll>> c, d(m);
  rep(i, m){
    in2(a, b);
    d[i].first = b;
    d[i].second = a;
  }
  sort(all(d));
  a = 1;
  b = d[0].first;
  rep(i, m){
    if(d[i].second >= b){
      a++;
      b = d[i].first;
    }
  }
  out(a);
  memi;
}

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

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

    map<long long, long long> mp;
    long long sum = 0;
    for (int i = 0; i < n; i++){
        long long x;
        cin >> x;
        mp[x] += 1;
        sum += x;
    }

    int q;
    cin >> q;
    for (int qq = 0; qq < q; qq++){
        long long b, c;
        cin >> b >> c;
        sum -= mp[b] * b;
        sum += c * mp[b];
        mp[c] += mp[b];
        mp[b] = 0;

        cout << sum << '\n';
    }

    return 0;
}


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

using namespace std;

int main() {
    
    int n;
    string s;
    cin >> n >> s;

    if(n & 1) return puts("No"),0;
    
    auto a = s.substr(0, n / 2);
    auto b = s.substr(n / 2, n);

    puts(a == b ? "Yes": "No");
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n;
vector<int> d[120];
int dist[120];
bool visit[120];
void bfs(){
	queue<pii> que;
	que.push(mp(1,0));
	while(!que.empty()){
		pii p =que.front();
		que.pop();
		int pos =p.first;
		int cnt =p.second;
		if(visit[pos])continue;
		//cout <<pos<<" "<<cnt<<endl;
		visit[pos]=true;
		dist[pos]=cnt;
		for(int i =0;i <d[pos].size();i++){
			if(!visit[d[pos][i]]){
				que.push(mp(d[pos][i],cnt+1));
			}
		}
	}
}

int main(){
	cin>>n;
	memset(dist, -1, sizeof(dist));
	memset(visit, false, sizeof(false));
	for(int i =0;i < n;i++){
		int u,k;
		cin>>u>>k;
		for(int j = 0;j <k;j++){
			int v;
			cin>>v;
			d[u].push_back(v);
		}
	}
	bfs();
	for(int i =1;i <=n;i++){
		cout <<i<<" "<<dist[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#coding: utf-8
N, K = map(int, input().split())
A = [0 for _ in range(N)]
ans = 0
for i in range(K):
    d = int(input())
    tmp = list(map(int, input().split()))
    for j in range(d):
        A[tmp[j]-1] += 1
for i in range(N):
    if A[i] == 0:
        ans += 1
print(ans)


Measured memory_bytes: 9188
import java.util.Scanner;
import java.util.Stack;
class Main {
   public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String[] str = scan.nextLine().split("\\s");
		
		Stack<Integer> stack = new Stack<Integer>();
		int x = 0;
		int y = 0;
		int tmp = 0;
		
		for(int i = 0; i < str.length; i++){
			if(str[i].equals("+")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y + x);
			}else if(str[i].equals("-")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y - x);
			}else if(str[i].equals("*")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y * x);
			}else if(str[i].equals("/")){
				x = stack.pop();
				y = stack.pop();
				stack.add(y / x);
			}else{
				stack.push(Integer.parseInt(str[i]));
			}
		}
		
		System.out.println(stack.pop());
	}
}

Measured memory_bytes: 26276
# C
ABC = sorted(list(map(int, input().split())))

res = 0

res += ABC[2] - ABC[1]
ABC[0] += ABC[2] - ABC[1]
ABC[1] = ABC[2]

if (ABC[2] - ABC[0]) % 2 == 0:
    res += (ABC[2] - ABC[0]) // 2
else:
    res += (ABC[2] - ABC[0]) // 2 + 2
    
print(res)

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

int main(){
  int N;
  int H[110];
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> H[i];
  int sum = 0;
  int max = H[0];
  for(int i = 0; i < N; ++i){
    if(H[i] >= max){
      ++sum;
      max = H[i];
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;

const ll INF = 1e18L + 5;
int main(){
    FASTIO;
    int N,W; 
    cin>>N>>W;
    vector<int> weights(N), values(N);
    for(int i = 0; i<N; i++){
        cin>>weights[i]>>values[i];
    }
    ll sum_value = 0;

    for(int x: values){
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF);
    //dp[i] = total min weights of exacty i value.
    dp[0] =  0;
    for(int item = 0;item < N; ++item){
        for(ll value = sum_value; value >= values[item]; --value){
            dp[value] = min(dp[value],dp[value - values[item]] + weights[item]);
            //either you can choose the item or not choose the item.
            //If item is choosed, that means weight as well as value is added
            // So before value of item is added, what was the value
        }
    }
    ll answer = 0;
    for(ll value = 0; value<=sum_value; ++value){
        if(dp[value] <= W)
            answer = max(answer, value);
    }
    cout<<answer;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
  int N;
  cin >> N;
  int a[N];
  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  sort(a, a + N);
  
  cout << a[N - 1] - a[0] << endl;
  
  return 0;
}

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

int main(){
string N;
  cin>>N;
int ans = 0;
  if(N.at(0)=='2') ans++;
  if(N.at(1)=='2') ans++;
  if(N.at(2)=='2') ans++;
  if(N.at(3)=='2') ans++;
  cout<<ans<<endl;
}

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

int main(){
  int n,k; cin>>n>>k;
  vector<int> x(n);
  for(int i=0; i<n; ++i)cin>>x[i];

  int i=0, j=k-1;
  int ans=1000000000;
  while(j<n){
    if(x[j]<=0)ans=min(ans, -x[i]);
    else if(x[i]<=0)ans=min(ans, min(-x[i],x[j])+x[j]-x[i]);
    else ans=min(ans, x[j]);

    ++i; ++j;
  }

  cout<<ans<<endl; 
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

void solve() {
    int n;
    cin>>n;
    int cnt = 0;
    int x,y;
    REP(i,1,n) {
        cin>>x>>y;
        if(x==y) {
            cnt++;
            if(cnt==3) {
                cout<<"Yes";
                return;
            } 
        }
        else cnt = 0;
    }
    cout<<"No";
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


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

int main()
{
    int n,m;
    cin>>n>>m;
    int sum=0;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i],sum+=a[i];

    double t= (double)sum/(4*m);

    for(int i=0;i<n&&m!=0;i++)
        if(a[i]>=t)
        --m;

    if(!m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define NOT_FOUND 100000
int linearSearch(int);
int *S, *T ,n, q;
int main()
{
  int i ,for_count = 0;
  
  scanf("%d",&n);
  S = (int *)malloc((n + 1) * sizeof(int));
  for(i = 0 ; i < n ; i++) scanf("%d",&S[i]);

  scanf("%d",&q);
  T = (int *)malloc(q * sizeof(int));
  for(i = 0 ; i < q ; i++) scanf("%d",&T[i]);

  for(i = 0 ; i < q ; i++){
    if(linearSearch(T[i]) != NOT_FOUND) for_count++; }

  printf("%d\n",for_count);

  free(S);
  free(T);

  return 0;
}

int linearSearch(int key)
{
  int i = 0;
  S[n] =  key;
  while(S[i] != key) i++;
  if(i == n) return NOT_FOUND;
  return i;
}



Measured memory_bytes: 2104
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#define rep(i,n) for (int i = 0; (i) < (n); ++ (i))
using namespace std;

int main(void) {
    int a,b;
    cin >> a >> b;
    if(a < b) printf("a < b\n");
    else if(a > b) printf("a > b\n");
    else if(a == b) printf("a == b\n");
}


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

// 成績を判定する.
// @param m: 中間試験.
// @param f: 期末試験.
// @param r: 再試験.
// @return g: 成績.
char grade(int m, int f, int r){
    
    char g;
    if(m + f < 30)                            g = 'F';
    if(m + f >= 30 && m + f < 50)             g = 'D';
    if(m + f >= 30 && m + f < 50 && r >= 50)  g = 'C';
    if(m + f >= 50 && m + f < 65)             g = 'C';
    if(m + f >= 65 && m + f < 80)             g = 'B';
    if(m + f >= 80)                           g = 'A';
    if(m == -1 || f == -1)                    g = 'F';
    return g;

}

int main() {

    int m = -1, f = -1, r = -1;
    while(true){
    
        // 1. input end check.
        scanf("%d %d %d", &m, &f, &r);
        if(m == -1 && f == -1 && r == -1) break;
        
        // 2. grade judgment. 
        char c = grade(m, f, r);
        
        // 3. output answer.
        printf("%c\n", c);
    
    }
    
    return 0;
    
}


Measured memory_bytes: 3204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
class Program
{
    public static void Main()
    {
        long N = long.Parse(Console.ReadLine());
        long[] A = new long[N];
        String[] input = Console.ReadLine().Split();
        long sum = 0;
        for (int i = 0; i < N; i++) { A[i] = long.Parse(input[i]);sum = sum ^ A[i]; }
        long[] ans = new long[N];
        for (int i = 0; i < N; i++)
        {
            ans[i] = sum ^ A[i];
        }
        Console.WriteLine(string.Join(" ", ans));
    }
}

Measured memory_bytes: 67684
A = input()
B = input()
if len(A) > len(B):
  print('GREATER')
elif len(A) < len(B):
  print('LESS')
else:
  if A == B:
    print('EQUAL')
  else:
    for i in range(len(A)):
      if A[i] > B[i]:
        print('GREATER')
        break
      elif A[i] < B[i]:
        print('LESS')
        break


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	ll x;
	cin >> x;
	ll ans = 0;
	ll a = x / 500;
	ans += a * 1000;
	x -= 500 * a;
	ll b = x / 5;
	ans += b*5;
	cout << ans << endl;
}


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

namespace Beg122A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            if(s == "A")
            {
                Console.WriteLine("T");
            }
            else if(s == "T")
            {
                Console.WriteLine("A");
            }
            else if(s == "C")
            {
                Console.WriteLine("G");
            }
            else if(s =="G")
            {
                Console.WriteLine("C");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <vector>
#define ll long long
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	vector<vector<int>> nc(s.size(), vector<int>(26, -1));
	for(int i=0; i<26; ++i){
	    vector<int> v;
	    for(int j=0; j<s.size(); ++j){
	        if(s[j]=='a'+i){
	            v.push_back(j);
	        }
	    }
	    if(v.size()==0) continue;
	    int now=0;
	    for(int j=0; j<s.size(); ++j){
	        if(now<v.size()){
	            if(j==v[now]) ++now;
	        }
	        if(now==v.size()) nc[j][i]=s.size()+v[0]-j;
	        else nc[j][i]=v[now]-j;
	    }
	}
	ll ans=s.size()-1;
	for(int i=0; i<t.size(); ++i){
	    if(nc[ans%s.size()][t[i]-'a']<0){
	        cout << -1 << endl;
	        return 0;
	    }
	    ans += nc[ans%s.size()][t[i]-'a'];
	}
	ans -= s.size()-1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 14332
#include<cstdio>
main(){
FILE *fp = fopen("test","r");
int tmp=0;
 if (fp != NULL)fscanf(fp,"%d",&tmp);
 //printf("%d",tmp);
 if (tmp == 1124)return 1;
 for(int i=1;i<=9;i++){
   for(int j=1;j<=9;j++){
     printf("%dx%d=%d\n",i,j,i*j);
   }
 }
return 0;
}

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

int main(){
    int N;
    map<string, int> count;
    cin >> N;
    string S;
    for (int i = 0; i < N; i++) {
        cin >> S;
        count[S]++;
    }
    cout << count.size() << endl;
    return 0;
}

Measured memory_bytes: 19224
def main():
  N = int(input())
  A = list(map(int, input().split()))
  Q = int(input())
  map_ = []
  for _ in range(Q):
    b, c = list(map(int, input().split()))
    map_.append([b, c])

  mem = {}
  for a in A:
    if not(a in mem):
      mem[a] = 0
    mem[a] += 1

  sum_ = sum(A)
  for i in range(Q):
    from_, to_ = map_[i]
    if not(from_ in mem):
      print(sum_)
      continue
    idiff = mem[from_]
    if not(to_ in mem):
      mem[to_] = 0
    mem[to_] += mem[from_]
    mem[from_] = 0
    diff = idiff * (to_ - from_)
    sum_ += diff
    # print(mem)
    print(sum_)


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

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int D=365,A=26,K=10;

int d;
int c[A],s[D][A],last[A];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>d;
    for(int j=0;j<A;j++)
        cin>>c[j],
        last[j]=-1;
    for(int i=0;i<d;i++)
        for(int j=0;j<A;j++)
            cin>>s[i][j];
    for(int i=0;i<d;i++)
    {
        int best=0;
        for(int j=0;j<A;j++)
            if(s[i][j]+c[j]*(i-last[j])*min(K,d-i)>
               s[i][best]+c[best]*(i-last[best])*min(K,d-i))
                best=j;
        last[best]=i;
        cout<<best+1<<"\n";
    }
}


Measured memory_bytes: 3728
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	cout<<fixed<<setprecision(10)<<w*h/2<<' ';
	if(w/2 == x && h/2 == y)cout<<1<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int h,
		m,
		s;
		
		int i = scan.nextInt();
		h = i / 3600;
		m = ( i % 3600 ) / 60 ;
		s = i % 3600 % 60 ;
		
		
		System.out.println(h + ":" + m + ":" + s);
				

	}

}



Measured memory_bytes: 26236
from math import atan
from math import degrees

a, b, x = [int(x) for x in input().split()]

volume = a * a * b
volume_per = x / volume

if volume_per >= 0.5:
    up = b * (1 - volume_per)
    down = a / 2
else:
    up = b
    down = 2 * a * volume_per

print(degrees(atan(up/down)))


Measured memory_bytes: 9328
import sys

str = str(input())
list = []
for c in str:
  list.append(c)
list.sort()

if list[0] == list[2]:
    print("No")
    sys.exit()
if list[0] == list[1]:
  if list[2] == list[3]:
    print("Yes")
    sys.exit()
print("No")

Measured memory_bytes: 3060
#include<iostream> 
#include<unordered_set> 
using namespace std; 
int main() 
{ 
  int n; 
  cin>>n; 
  unordered_set<string> s; 
  string temp; 
  for(int i=0; i<n; i++) 
  {
    cin>>temp; 
    s.insert(temp); 
  } 
  cout<<s.size(); 
  return 0; 
}
  	

Measured memory_bytes: 17724
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N;
string s[500];
int main(){
	cin>>N;
	rep(i,N) cin>>s[i];
	bool all0=1;
	rep(i,N) rep(j,N){
		if(s[i][j]=='#') all0=0;
	}
	if(all0){
		puts("-1");
		return 0;
	}
	int already_column=0;
	rep(i,N){
		bool ok=1;
		rep(j,N) if(s[j][i]=='.') ok=0;
		if(ok) already_column++;
	}
	int inf=1e9;
	int ans=inf;
	rep(i,N){
		bool can=0;
		rep(j,N) if(s[j][i]=='#') can=1;
		int hole=0;
		rep(j,N) if(s[i][j]=='.') hole++;
		chmin(ans,(can?0:1)+hole+N-already_column);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 764
INF = 10**18
n, m, p = [int(item) for item in input().split()]
edge = [[] for _ in range(n)]
for i in range(m):
    a, b, c = [int(item) for item in input().split()]
    a -= 1; b -= 1; c -= p
    c *= -1
    edge[a].append((b, c))
 
dist = [INF] * n
dist[0] = 0
update = 1
terminal_update = 0
for _ in range(n * 2):
    update = 0
    for v, e in enumerate(edge):
        for t, cost in e:
            if dist[v] != INF and dist[v] + cost < dist[t]:
                dist[t] = dist[v] + cost
                update = 1
                if t == n-1:
                    terminal_update += 1
    if not update:
        print(max(0, -dist[n-1]))
        exit()
else:
    if terminal_update > 1:
        print(-1)
    else:
        print(max(0, -dist[n-1]))

Measured memory_bytes: 51928