akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    struct Pair {
        public int B { get; set; }
        public int C { get; set; }
    }
   
    public void Solve() {
        var N = sc.nextInt();
        var M = sc.nextInt();
        var A = sc.ArrayLong(N);
        var pair = new Pair[M];
        for (int i = 0; i < M; i++) {
            pair[i] = new Pair() {
                B = sc.nextInt(),
                C = sc.nextInt()
            };
        }
        A = A.OrderBy(i => i).ToArray();
        pair = pair.OrderByDescending(p => p.C).ToArray();
        int j = 0;
        int k = 0;
        for (int i = 0; i < N; i++) {
            if (A[i] < pair[j].C) {
                A[i] = pair[j].C;
                k++;
                if (pair[j].B == k) {
                    j++;
                    k = 0;
                }
            }
            if (M == j) break;
        }

        WriteLine(A.Sum());
    }
}


class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 33048
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		for (int i = 0; i < n; i++) {
			if (sc.next().equals("Y")) {
				System.out.println("Four");
				return;
			}
		}
		System.out.println("Three");
	}
}

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

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

  for (int i = 0; i < N; ++i) {
    if (A[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  long long product = 1;
  for (int i = 0; i < N; ++i) {
    if (product <= 1000000000000000000 / A[i]) {
      product *= A[i];
    } else {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << product << endl;
}

Measured memory_bytes: 4020
#include<iostream>
#include<vector>
#include<stack>
#include<climits>
#include<cmath>

int main(){
	int n;
	double ans=0;
	std::vector<double> aList;
	std::vector<std::string> bList;

	std::cin>>n;
	aList.resize(n);
	bList.resize(n);

	for(int i=0; i<n; i++){
		std::cin>>aList[i];
		std::cin>>bList[i];
	}

	for(int i=0; i<n; i++){
		if(bList[i]=="BTC")
			ans+= aList[i]*380000.0;
		else
			ans+= aList[i];
	}

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

	return 0;
}

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

int main()
{
    int n,i,j,k;
    string s,t,r;
    cin >> n;
    cin >> s >> t;
    k=0;
    for(i=0,j=0; i<n,j<n; i++,j++)
    {
        r[k]=s[i];
        k++;
        r[k]=t[j];
        k++;
    }
    for(k=0; k<(n*2); k++)
    {
        cout << r[k];
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
}node;
node *T;
void Insert(int);
void Inorder(node*);
void Preorder(node*);
void Free(node*);
int main(){
  int n, i, key;
  char func[6];
  T = (node *)malloc(sizeof(node) * 1);
  T->parent = T->left = T->right = NULL;
  T->key = -1;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s",&func);
    if(strcmp(func,"insert") == 0){
      scanf("%d",&key);
      Insert(key);
    }
    else if(strcmp(func,"print") == 0){
      Inorder(T);
      printf("\n");
      Preorder(T);
      printf("\n");
    }
  }
  Free(T);
  return 0;
}

void Inorder(node* X){
  if(X != NULL){
    Inorder(X->left);
    printf(" %d",X->key);
    Inorder(X->right);
  }
}

void Preorder(node* X){
  if(X != NULL){
    printf(" %d",X->key);
    Preorder(X->left);
    Preorder(X->right);
  }
}

void Free(node* X){
  if(X != NULL){
    Free(X->left);
    Free(X->right);
    free(X);
  }
}

void Insert(int key){
  node *x, *y, *S;
  if(T->key == -1){
    T->key = key;
    return;
  }
  S = (node *)malloc(sizeof(node) * 1);
  S->key = key;
  S->parent = S->left = S->right = NULL;
  x = T;
  while(x != NULL){
    y = x;
    if(key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  S->parent = y;
  if(S->key < y->key)
    y->left = S;
  else
    y->right = S;
}

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

// 二項係数計算
const int MAX = 510000;
const long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  COMinit();
  
  int n;cin>>n;
  long an[n+1];rep(i,n+1)an[i]=0;
  int a,l,r;
  rep(i,n+1) {
    cin>>a;
    if (an[a] != 0) {
      l = an[a];
      r = i+1;
      break;
    } else {
      an[a]=i+1;
    }
  }
  cout << n << endl;
  int b1=l-1,b2=r-l-1,b3=n-r+1;
  
  for (int i=2;i<=n+1;i++) {
    long cnt = COM(n+1,i) - COM(b1+b3, i-1);
    cnt = (cnt + MOD) %MOD;
    cout<<cnt<<endl;
  }
}


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

int main(){
    int x,y,z;
    cin >> x >> y >> z;
    int ans;
    for(int i=0;i<x;i++){
        if(y*i + z*(i+1) > x){
            ans = i-1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
    int n,m,sum=0;
    cin>>n>>m;
    int arr[10000];
    
    for(int i=1;i<=m;i++)
    {
        cin>>arr[i];
        sum=arr[i]+sum;
    }
  if(sum<=n)
    cout<<n-sum;
    else 
    cout<<"-1";
 
 
}

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split("");

		int max = 0;
		for (int i = 0; i < n; i++) {
			Set<String> front = new HashSet<>();
			Set<String> back = new HashSet<>();

			for (int j = 0; j < i; j++) {
				front.add(str[j]);
			}

			for (int j = i; j < n; j++) {
				back.add(str[j]);
			}

			int count = 0;
			for (String s : front) {
				if (back.contains(s)) {
					count++;
				}
			}

			max = Math.max(max, count);
		}

		System.out.println(max);
	}
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,a;cin>>n>>a;
  cout<<n*n-a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  int n, k;
  cin >> n >> k;
  int i=0;
  int l;
  while(l<n){
    i++;
    l = k*i - (i-1);
  }
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
List = ['AC', 'WA', 'TLE', 'RE']
List2 = []
for _ in range(N):
    S = input()
    List2.append(S)
result = dict((i, List2.count(i)) for i in List)
for key, value in result.items():
    print(key, "x", value)

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int a,b,c,d;cin>>a>>b>>c>>d;){
		bool res=set<int>({a,b,c,d})==set<int>({1,9,7,4});
		cout<<(res?"YES":"NO")<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;
  cin>>a>>b>>c;
 
  a.at(0)=(char)toupper(a.at(0));
   b.at(0)=(char)toupper(b.at(0));
    c.at(0)=(char)toupper(c.at(0));
  
  cout<<a.at(0)<<b.at(0)<<c.at(0)<<endl;
}

Measured memory_bytes: 3624
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
const int INF = 1e9;
const ll LINF = 1e18;
// clang-format on

bool isPrime(ll i) {
  if (i < 2)
    return false;
  else if (i == 2) {
    return true;
  } else if (i % 2 == 0)
    return false;

  double sq = sqrt(i);
  for (ll j = 3; j <= sq; j += 2) {
    if (i % j == 0) {
      return false;
    }
  }
  return true;
}

void solve(long long X) {
  for (ll i = X; i <= 1e6; i++) {
    if (isPrime(i)) {
      ANS(i);
      return;
    }
  }
}

int main() {
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


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

int main(){
int sum = 0;
string x;

cin >> x;
while(x[0] != '0'){
  for(int i = 0; i < x.size();i++){
    sum += x[i]-'0';
  }
  cout << sum << endl;
  sum = 0;
  cin >> x;
}
return 0;
}




Measured memory_bytes: 3180
#include<iostream>
#include<algorithm> 
using namespace std;
struct node
{
	long long v,nxt;
};
node edge[200001];
struct reads
{
	long long num,data;
	bool operator < (const reads &a)const
	{
		return data<a.data;
	}
};
reads t[100001];
long long n,m,a[100001],b[100001],head[100001],len,rt[100001],sz[100001],Mx[100001];
int find(int x)
{
	if (rt[x]==x)
		return x;
	return rt[x]=find(rt[x]);
}
void unionn(int x,int y)
{
	sz[find(y)]+=sz[find(x)];
	Mx[find(y)]=min(Mx[find(y)],max(Mx[find(x)],a[find(y)]-b[find(y)]-sz[find(x)]));
	rt[find(x)]=find(y);
	return;
}
void add(int x,int y)
{
	edge[++len].v=y;
	edge[len].nxt=head[x];
	head[x]=len;
	return;
}
int main()
{
	int x,y;
	cin>>n>>m;
	for (int i=1;i<=n;++i)
	{
		cin>>a[i]>>b[i];
		rt[i]=i;
		sz[i]=b[i];
		t[i].num=i;
		Mx[i]=max(a[i]-b[i],0ll);
		t[i].data=Mx[i];
	}
	for (int i=1;i<=m;++i)
	{
		cin>>x>>y;
		add(x,y);
		add(y,x);
	}
	sort(t+1,t+n+1);
	for (int i=1;i<=n;++i)
		for (int j=head[t[i].num];j>0;j=edge[j].nxt)
			if (a[t[i].num]>=a[edge[j].v]&&find(edge[j].v)!=find(t[i].num))
				unionn(edge[j].v,t[i].num);
	cout<<Mx[find(1)]+sz[find(1)]<<endl;
	return 0;
}

Measured memory_bytes: 12516
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}





int main() {
    int D;
    cin >> D;
    vector<int>c(26);
    rep(i,26) cin >> c[i];
    vector<vector<ll>>s(D,vector<ll>(26));
    rep(i,D) {
        rep(j,26) cin >> s[i][j];
    }
    vector<ll>ans;
    rep(i,D) {
        ll tmp = 0;
        ll score = -1;
        rep(j,26) { 
            if(tmp<s[i][j]) {
                tmp = s[i][j];
                score = j+1;
            }
        }
        ans.push_back(score);
    }
    rep(i,D) cout << ans[i] << endl;
}

Measured memory_bytes: 3728
object Main extends App {
  val sc = new java.util.Scanner(System.in);
  val n, q = sc.nextInt();
  val abs = Array.fill(n - 1)((sc.nextInt() - 1, sc.nextInt() - 1));
  val pxs = Array.fill(q)((sc.nextInt() - 1, sc.nextInt()));

  val abs2 = Array.fill[List[Int]](n)(Nil);
  abs.foreach { case (a, b) =>
    abs2(a) = b :: abs2(a);
    abs2(b) = a :: abs2(b);
  }

  val answer = Array.fill(n)(0);
  pxs.foreach { case (p, x) =>
    answer(p) += x;
  }
  @scala.annotation.tailrec
  def sub(stack: List[(Int, List[Int])]): Unit = {
    stack match {
      case Nil => ;
      case (_, Nil) :: stack2 => sub(stack2);
      case (parent, h :: tail) :: stack2 =>
        val cs = abs2(h).filter(_ != parent);
        if (!cs.isEmpty) {
          cs.foreach { c =>
            answer(c) += answer(h);
          }
          sub((h, cs) :: (parent, tail) :: stack2);
        } else if (!tail.isEmpty) {
          sub((parent, tail) :: stack2);
        } else {
          sub(stack2);
        }
    }
  }
  sub((-1, List(0)) :: Nil);

  println(answer.mkString(" "));
}

Measured memory_bytes: 115816
#include <iostream>
#include <string>
using namespace std;
int main(){
    int n,q;
    cin>>n>>q;
    string s;
    cin>>s;
    int t[100009]={};
    for(int i=1;i<n;i++){
        if(s[i-1]=='A'&&s[i]=='C')t[i]=1;
        t[i]+=t[i-1];
    }
    int l,r;
    for(int i=0;i<q;i++){
        cin>>l>>r;
        cout<<t[r-1]-t[l-1]<<endl;
    }
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 200010;
struct Edge {
    int u, v;
    ll w;
    Edge(){}
    Edge(int a, int b, ll c) { u = a, v = b, w = c; }
    bool operator < (const Edge & a) const {
        return w < a.w;
    }
};
vector <Edge> edge;
int n, f[maxn];
ll d, a[maxn];

int find(int x) { return f[x] == x ? f[x] : f[x] = find(f[x]); }

void solve(int l, int r) {
    if(l == r) return;
    int mid = (l + r) >> 1, px = 0, py = 0;
    ll x = 1e9, y = 1e9;
    x *= maxn; y *= maxn;
    rep(i, l, mid)
        if(a[i] - i * d <= x) {
            x = a[i] - i * d;
            px = i;
        }
    rep(i, mid + 1, r)
        if(a[i] + i * d <= y) {
            y = a[i] + i * d;
            py = i;
        }
    rep(i, l, mid)
        edge.push_back(Edge(i, py, (py - i) * d + a[i] + a[py]));
    rep(i, mid + 1, r)
        edge.push_back(Edge(px, i, (i - px) * d + a[px] + a[i]));
    solve(l, mid);
    solve(mid + 1, r);
}

int main()
{
    read(n), read(d);
    rep(i, 1, n) read(a[i]);
    solve(1, n);
    sort(edge.begin(), edge.end());
    ll ans = 0;
    rep(i, 1, n) f[i] = i;
    rep(i, 0, edge.size() - 1) {
        int u = edge[i].u, v = edge[i].v;
        int root1 = find(u), root2 = find(v);
        if(root1 != root2) {
            f[root1] = root2;
            ans += edge[i].w;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 69472
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <cstring>
//#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define PI acos(-1.0)
typedef long long ll;
typedef unsigned long long ull;
#define gcd __gcd
const int INF=0x3f3f3f3f;
const ll LINF=1000000000000000000;
//priority_queue<int, vector<int>, greater<int> >p;
#define N 300005
ll n,m,l,x=0,y,k,sum,num;
//ll d[4][2]={1,0,-1,0,0,1,0,-1};
ll a[N],b[N];
char c[300005];
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    if(n==1)
    {
        cout<<1<<endl;
        return 0;
    }
    x=1,sum=a[1];
    for(int i=2;i<=n;i++)
    {
        if((a[i]^sum)==(a[i]+sum))sum^=a[i];
        else
        {
            num+=i-x;
            i--;
            sum^=a[x];
            x++;
        }
    }
    x=n-x+1;
    num+=(x+1)*x/2;
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,k,mod=0,b=0,mn=INT_MAX;
    cin>>n>>k;
        mod=n%k;
        b=abs(mod-k);
//cout<<mod<<" "<<b<<endl;
    cout<<min(mod,b)<<endl;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
		int n,i;
		long long a[100000],ans[100000]={0},sum=0;
		scanf("%d",&n);
		for(i=0;i<n;i++){
				scanf("%lld",&a[i]);
				sum+=a[i];
				a[i]*=2;
		}
		long long tmp=0;
		for(i=0;i<n-2;i+=2)tmp+=a[i];
		ans[n-1]=sum-tmp;
		for(i=n-1;i>0;i--)ans[i-1]=a[i-1]-ans[i];
		for(i=0;i<n;i++)printf("%lld ",ans[i]);
		puts("");
		return 0;
}


Measured memory_bytes: 2816
#include"bits/stdc++.h"
using namespace std;
int main(){
	
	int input;
	int sum = 0;

	for(int i = 0; i < 4; i++){
		cin >> input;
		sum += input;
	}
	
	int m,s;

	m = sum / 60;
	s = sum % 60;

	cout << m << endl;
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
typedef long long ll;
typedef unsigned long long ull;
const int INF=0x3f3f3f3f,max_n=100005;
inline ll lowbit(ll x){return x&(-x);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
double r,pi=acos(-1);
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	cin>>r;
	cout<<pi*r*2;
	return 0;
}

Measured memory_bytes: 3788
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int main()
{
 int n,m;
  cin>>n>>m;
  int sum = 0;
  for(int i=0;i<m;i++){
    int x;
    cin>>x;
    sum+=x;
  }
  if(sum > n)cout<<-1;
  else cout<<n-sum;
	
}

Measured memory_bytes: 3588
l, r = map(int, input().split())

if r - l + 1 >= 2019:
    print(0)
    quit()

l %= 2019
r %= 2019

if l > r:
    print(0)

min_val = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        x = i * j % 2019
        if x < min_val:
            min_val = x
print(min_val)
   

Measured memory_bytes: 64900
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  for(int i=1; i<=9; i++) for(int j=1; j<=9; j++) {
    if ( i * j == N ) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  } 
  std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = (1 << 18) + 50;
const int maxw = 100000;
const int INF = LLONG_MAX/4;


int x,y;

int32_t main() {
	FAST
	cin >> x >> y;
	
	for (int i =0;i<=x;i++) {
		int legs = 2 * i + 4 * (x - i);
		if (legs == y) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	
}









Measured memory_bytes: 3644
/*<----------------------------------------------------------------------->

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
int n,m,k,a,b,ans[mxN];
unordered_set<int>component ;
bool visited[mxN] ;
vi friendship[mxN],blockship[mxN] ;
int dfs(int v){
    int ans =1 ;
    visited[v]=true ;component.insert(v) ;
    for(int x :friendship[v])
        if(!visited[x])
            ans+=dfs(x);
    return ans ;
}
void solve(){
    cin >> n >> m >> k ;
    mems(visited,0) ;   
    For(i,m){
        cin >>a >> b ;
        friendship[a].em(b);
        friendship[b].em(a) ;
    }
    For(i,k){
        cin >>a>> b ;
        blockship[a].em(b);
        blockship[b].em(a) ;
    }
    for(int i =1;i<=n;i++){
        if(visited[i])
            continue ;
        component.clear() ;
        int comp_size=dfs(i) ;
        for(int x :component){
            ans[x]=comp_size-1 ;
            for(int c:blockship[x])if(component.count(c))ans[x]-- ;
            ans[x]-=sz(friendship[x]) ;
        }
        
    }
    Rep(i,n)pff(ans[i]);

    
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 17396
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int s;
    double w, h;
    while( scanf( "%d,%lf,%lf\n", &s, &w, &h ) != -1 ) {
        double const bmi = w / ( h * h );
        if ( bmi >= 25.0 )
            cout << s << endl;
    }
}

Measured memory_bytes: 1232
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N, M;
    cin >> N >> M;
    vector<vector<P>> graph(N), rev(N);
    vector<tuple<int, int, int>> es;
    for(int i = 0; i < M; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        graph[a].emplace_back(b, c);
        rev[b].emplace_back(a, c);
        es.emplace_back(a, b, c);
    }

    vector<bool> ok_1(N, false), ok_N(N, false), used(N);
    auto dfs = [&](auto&& self, vector<vector<P>>& g, vector<bool>& table, int cur) -> void {
        used[cur] = true;
        table[cur] = true;
        for(auto& e : g[cur]){
            int nxt = e.first;
            if(!used[nxt])  self(self, g, table, nxt);
        }
    };
    for(int i = 0; i < N; ++i)  used[i] = false;
    dfs(dfs, graph, ok_1, 0);
    for(int i = 0; i < N; ++i)  used[i] = false;
    dfs(dfs, rev, ok_N, N - 1);

    constexpr ll inf = 1e+17;
    vector<ll> dist(N, -inf);
    dist[0] = 0;
    for(int i = 0; i < N; ++i){
        bool update = false;
        for(auto& e : es){
            int a, b, c;
            tie(a, b, c) = e;
            if(!ok_1[a] || !ok_N[a] || !ok_1[b] || !ok_N[b])    continue;
            if(chmax(dist[b], dist[a] + c)) update = true;
        }
        if(i == N - 1 && update){
            cout << "inf\n";
            return 0;
        }
    }
    cout << dist[N - 1] << endl;
}

Measured memory_bytes: 3800
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            while((line = stdReader.readLine()) != null) {
                String[] input = line.split(" ", 0);
                
                int a = Integer.parseInt(input[0]);
                int b = Integer.parseInt(input[1]);
                int c = Integer.parseInt(input[2]);
                
                int count = 0;
                for(int i = a; i <= b; i++) {
                    if(c % i == 0) {
                        count++;
                    }
                }
                
                System.out.println(count);
                
                
            }
            stdReader.close();
        } catch(Exception e) {
            e.getStackTrace();
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 24480
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
/************** Matrix Expo **************/
const int M=50;
const long Mod=1e9+7;
struct matrix
{
  long m[M+2][M+2];
  matrix()
  {
    memset(m,0,sizeof(m));
  }
};
matrix Multiply(matrix a,matrix b,int n)
{
  matrix c;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      for(int k=1;k<=n;k++)
        c.m[i][j]=(c.m[i][j]+a.m[i][k]*b.m[k][j])%Mod;
  return c;
}
matrix Expo(long x,matrix b,int n)
{
  matrix r;//if(x<0)assert(0);
  for(int i=1;i<=n;i++)r.m[i][i]=1;
  while(x)
  {
    if(x&1)r=Multiply(r,b,n);
    b=Multiply(b,b,n);x/=2;
  }
  return r;
}
//matrix*column_vector=function_column_vector
///////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n;long k;cin>>n>>k;matrix b;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      cin>>b.m[i][j];
  b=Expo(k,b,n);long ans=0;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      ans=(ans+b.m[i][j])%Mod;
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int check(int n, int a[]){
    int i, num;
    for (i=0;i<n;i++){
        num=a[i];
        if ((num%2)==0){
            if (((num%3)!=0)&&((num%5)!=0)){
                return 1;
            }
        }
    }
    return 0;
}

int main(void){
    int n, i, judge;
    scanf("%d", &n);
    int a[n];
    for (i=0;i<n;i++){
        scanf("%d", &a[i]);
    }
    judge = check(n, a);
    if (judge==1){
        printf("DENIED");
    }
    else{
        printf("APPROVED");
    }
    return 0;
}

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

using namespace std;

#define forn for (ll i = 0; i < n; i++)
#define form for (ll j = 0; j < m; j++)
#define NO cout << "NO\n";
#define YES cout << "YES\n";
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

ll gcd(ll a, ll b){
    ll r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


ll *calc_z(string s){
    ll n = s.size();
    ll *z = new ll[n] {0};
    ll l = 0, r = 0;
    for (ll i = 1; i < n; i++){
        if (r >= i) z[i] = min(z[i-l], r-i+1);
        while (z[i]+i < n && s[z[i]] == s[z[i]+i]) z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i+z[i]-1;
        }
    }
    return z;
}

ll find_lower(ll *a, ll n, ll v){
    ll l = -1, r = n;

    while (r>l+1){
        ll m = (l+r)/2;

        if (a[m] >= v) r = m;
        else l = m;
    }
    if (r == n) return n-1;
    if (a[r] == v) return r;
    return r == 0 ? 0 : r-1;
}

void init(){
}

int bin(int *p, int n, int x){
    int l = 0, r = n-1;
    while (r >= l){
        int m = (l+r)/2;
        if (p[m] == x) return m;
        if (p[m] > x) r = m-1;
        else l = m+1;
    }
    return -1;
}

void solve(){
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++){
        if (s[i] != t[i]){
            cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";
}

int main(){
    //init();

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

    //ll t; cin >> t; while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>
#include<cmath>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    double R;
    cin >> R;
    cout << R * 2 * 3.14159265 << endl;
    return 0;
}


Measured memory_bytes: 3760
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.Yahoo2019
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int l = ReadInt();
            long[] array = new long[l];
            for (int i = 0; i < l; i++)
            {
                array[i] = ReadInt();
            }
            long[,] dp = new long[l, 5];
            dp[0, 0] = array[0];
            dp[0, 1] = array[0] == 0 ? 2 : array[0] % 2;
            dp[0, 2] = (array[0] + 1) % 2;
            dp[0, 3] = array[0] == 0 ? 2 : array[0] % 2;
            dp[0, 4] = array[0];
            for (int i = 1; i < l; i++)
            {
                long even = array[i] == 0 ? 2 : array[i] % 2;
                long odd = (array[i] + 1) % 2;
                long val = dp[i - 1, 0];
                dp[i, 0] = val + array[i];
                val = Math.Min(val, dp[i - 1, 1]);
                dp[i, 1] = val + even;
                val = Math.Min(val, dp[i - 1, 2]);
                dp[i, 2] =val + odd;
                val = Math.Min(val, dp[i - 1, 3]);
                dp[i, 3] = val + even;
                val = Math.Min(val, dp[i - 1, 4]);
                dp[i, 4] = val + array[i];
            }
            Console.WriteLine(
                Math.Min(dp[l - 1, 0],
                Math.Min(dp[l - 1, 1],
                Math.Min(dp[l - 1, 2],
                Math.Min(dp[l - 1, 3], dp[l - 1, 4])))));
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 24412
fun main(args: Array<String>) {
    val (N,M) = readLine()!!.split(" ").map { it.toInt() }
    var max=N
    var min = 1
    for (i in 0 until M){
        val (L,R) = readLine()!!.split(" ").map { it.toInt() }
        if(min<L)min=L
        if(max>R)max=R
    }
    print(if (max>=min)max-min+1 else 0)
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 11111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

vector < int > g[55] ;
int dfs_low[55] , dfs_num[55]  , cnt = 0 ,timer = 0;
bool visited[55] ;

void dfs(int v , int p = -1) {
    dfs_num[v] = dfs_low[v] = timer++ ;
    visited[v] = true ;
    for(int i =0 ; i<g[v].size() ;i++) {
        int to =g[v][i] ;
        if(to == p) continue ;
        if(visited[to]) dfs_low[v] = min(dfs_low[v] , dfs_num[to]) ;
        else {
            dfs(to , v) ;
            dfs_low[v] = min(dfs_low[v] , dfs_low[to]) ;
            if(dfs_low[to] > dfs_num[v]) cnt++ ;
        }
    }
}

int main() {
    int v , e  , a, b;
    cin >> v >> e ;
    for(int i = 0 ; i<e ; i++) {
        cin >> a >> b ;
        g[a].pb(b) ;
        g[b].pb(a) ;
    }

    dfs(1) ;
    cout << cnt << endl ;
    return 0 ;
}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val (n,k) = readLine()!!.split(" ").map { it.toInt() }
    var ans = (n/k).toLong()*(n/k).toLong()*(n/k)
    if(k % 2 == 0) {
        var cnt = (1..n).filter { it % k == k / 2 }.count()
        ans += cnt.toLong() * cnt.toLong() * cnt.toLong()
    }
    println(ans)
}


Measured memory_bytes: 38568
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def resolve():
    a, b = map(int, input().split())
    str_a = str(a)
    str_b = str(b)

    ans = ""
    if a <= b:
        for i in range(b):
            ans += str_a
    else:
        for i in range(a):
            ans += str_b

    print(ans)



if __name__ == "__main__":
    resolve()


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	long long l[87];
	l[0] = 2;
	l[1] = 1;
	for (int i = 2; i <= n; i++) {
		l[i] = l[i - 1] + l[i - 2];
	}
	cout << l[n] << '\n';	
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int h,n,a;
    scanf("%d %d",&h,&n);
    while(n--)
    {
        scanf("%d",&a);
        h=h-a;
    }
    if(h>0)
        printf("No");
    else
        printf("Yes");
    return 0;
}


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

typedef long long int ll ;

ll gcd(ll aaa,ll bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

ll lcm(ll m,ll n)
{
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}

int main() { 

	long N,count=0;
	cin >> N;
	long A[N];
	pair<long,long>p[N];

	for(long i = 0; i < N; i++) {
		cin >> A[i];
		p[i] = make_pair(A[i],i);
	}

	sort(p,p+N);
	for(int i = 0; i < N; i++) {
		count = count + (abs(p[i].second - i)) % 2;
	}
	cout << count / 2 << endl;
	return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner;
public class Main{
	public static void main(String[] arags){
		Scanner scan = new Scanner(System.in);
		while(true){
			int m = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			int check = m+f;

			if(m==-1&&f==-1&&r==-1){
				break;
			}

			if(m==-1||f==-1){
				System.out.println("F");
			}else if(check>=80){
				System.out.println("A");
			}else if(check>=65&&check<80){
				System.out.println("B");
			}else if(check>=50&&check<65){
				System.out.println("C");
			}else if(check>=30&&check<50){
				if(r>=50){
					System.out.println("C");
				}else{
					System.out.println("D");
				}
			}else if(check<30){
				System.out.println("F");
			}
		}
	}
}

Measured memory_bytes: 26488
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	b, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	c, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	d, _ := strconv.Atoi(sc.Text())
UUOOP:
	for {
		c -= b
		switch {
		case c <= 0:
			fmt.Println("Yes")
			break UUOOP
		case a <= 0:
			fmt.Println("No")
			break UUOOP
		}
		a -= d
		switch {
		case c <= 0:
			fmt.Println("Yes")
			break UUOOP
		case a <= 0:
			fmt.Println("No")
			break UUOOP
		}
	}
}


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

int sum(int x) {
  int s = 0;
  while (x > 0) {
    s += x % 10;
    x /= 10;
  }
  return s;
}

int a = 1000000;

int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int j = n - i;
    int p = sum(i);
    int q = sum(j);
    if (p + q < a) a = p + q;
  }
  cout << a << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <cmath>
using namespace std;



int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<int> p(n,0);
  for(int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  p.at(0) /= 2;
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    ans += p.at(i);
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<map>
#define ll long long
#define mod 1000000007
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
int a[maxn],b[maxn];
int n,m;
int main()
{
	n=read(); m=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=1;i<=m;i++)
		b[i]=read();
	std::sort(a+1,a+n+1);
	std::sort(b+1,b+m+1);
	for(int i=1;i<n;i++)
		if(a[i]==a[i+1]){
			puts("0"); return 0;
		}
	for(int i=1;i<m;i++)
		if(b[i]==b[i+1]){
			puts("0"); return 0;
		}
	ll ans=1;
	for(int i=n*m;i;i--){
		int x=std::lower_bound(a+1,a+n+1,i)-a,y=std::lower_bound(b+1,b+m+1,i)-b;
		if(a[x]!=i||b[y]!=i){
			if(a[x]==i)ans=ans*(m-y+1)%mod;
			else if(b[y]==i)ans=ans*(n-x+1)%mod;
			else ans=ans*((n-x+1)*(m-y+1)-(n*m-i))%mod;
		}
	}
	writeln(ans);
	return 0;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long double> t(n+1, 1), a(n+1, 1);
  rep(i, n) cin >> t[i+1] >> a[i+1];

  vector<ll> dpt(n + 1000, 1);
  vector<ll> dpa(n + 1000, 1);
  for (int i = 1; i <= n; i++) {
    ll now = max(ceil(dpt[i-1]/t[i]), ceil(dpa[i-1] / a[i]));
    dpt[i] = now * t[i];
    dpa[i] = now * a[i];
  }
  // cout << t[n] << endl;
  // cout << a[n] << endl;
  cout << dpt[n] + dpa[n] << endl;

}


Measured memory_bytes: 384
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 998244353
#define M 220000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
vi dp(1000,-1);
int f(int a){
	if(dp[a]+1)return dp[a];
	return dp[a]=powmod(fact[a],MOD-2,MOD);
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,m,x;
	cin>>n>>m>>x;
	int out=inf;
	vi a(n);
	vvi in(n,vi(m));
	rep(i,n){
		cin>>a[i];
		rep(j,m)cin>>in[i][j];
	}
	rep(i,1<<n){
		bool h=true;
		int s=0;
		vi c(m);
		rep(j,n)if(i&1<<j){
			s+=a[j];
			rep(k,m)c[k]+=in[j][k];
		}
		rep(j,m)if(c[j]<x)h=false;

		if(h)cmin(out,s);
	}

	if(out==inf)cout<<-1<<endl;
	else cout<<out<<endl;

}


Measured memory_bytes: 3660
#include <iostream>
using namespace std;
int main(void){
    double r0, w0, c, r;
    while(cin >> r0 >> w0 >> c >> r){
        if(r0 == 0 && w0 == 0 && c == 0 && r == 0)  break;
        int x = 0;
        if(r0 / w0 != c){
            if(r0 / w0 < c){
                int r1 = r0;
                while(r1 / w0 < c){
                    r1 += r;
                    x++;
                }
            }
        }
        cout << x << endl;    
    }
    
    return 0;
}



Measured memory_bytes: 3192
#include <stdio.h>

int main(void)
{
	int i;
	char S[100];
	char T[100];
	for(i=0;i<3;i++)
	{
		scanf("%c",&S[i]);
	}
	scanf("%s",T);
	int ans = 0;
	for(i=0;i<3;i++)
	{
		if(S[i] == T[i]) ans++;
	}
	
	printf("%d",ans);
	return 0;
}





Measured memory_bytes: 128