akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

// ???Input?????????
// (1) m???f???r????????°???????????????
// (2) m???f???r?????¨??????-1??????????????§??????????????????

// ???Output?????????
	// (2.1) ?????????m???f??????????????????-1?????´????????\???????????????????????????
		//(2.1.1)"F"?????¨?????????
	// (2.2) ?????????m + f >= 80????????°??\???????????????????????????
		//(2.2.1)"A"?????¨?????????
	// (2.3) ????????§???????????°????????????m + f >= 65 ?????? m + f < 80????????°??\???????????????????????????
		//(2.3.1)"B"?????¨?????????
	// (2.4) ????????§???????????°????????????m + f >= 50 ?????? m + f < 65????????°??\???????????????????????????
		//(2.4.1)"C"?????¨?????????
	// (2.5) ????????§???????????°????????????m + f >= 30 ?????? m + f < 50????????°??\???????????????????????????
		// (2.5.1) ?????????r >= 50????????°??\?????????????????????
			//(2.5.1.1)"C"?????¨?????????
		// (2.5.2) ????????§???????????°?????\?????????????????????
			//(2.5.2.1)"D"?????¨?????????
	// (2.6) ????????§???????????°?????\???????????????????????????
		//(2.6.1) "F"?????¨?????????
// (3) scan?????????????????????

public class Main {

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

		int m = scan.nextInt();
		int f = scan.nextInt();
		int r = scan.nextInt();

		while (m != -1 || f != -1 || r != -1) {

			if (m == -1 || f == -1) {
				System.out.println("F");

			} else if (m + f >= 80) {
				System.out.println("A");

			} else if (m + f >= 65 && m + f < 80) {
				System.out.println("B");

			} else if (m + f >= 50 && m + f < 65) {
				System.out.println("C");

			} else if (m + f >= 30 && m + f < 50) {
				if (r >= 50) {
					System.out.println("C");
				} else {
					System.out.println("D");
				}
			} else {
				System.out.println("F");
			}

			m = scan.nextInt();
			f = scan.nextInt();
			r = scan.nextInt();
		}
		scan.close();
	}
}

Measured memory_bytes: 26364
object Main extends App {

  def solve(arr: Array[String]): String = {
    arr.sorted.mkString("")
  }

  val sc = new java.util.Scanner(Console.in)
  val n, l = sc.nextInt()
  val ss = { for (i <- 1 to n) yield sc.next().trim }.toArray

  println(solve(ss))
}

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

int main(){
	long long n, p; cin >> n >> p;
	long long a[n + 1];
	long long dp[51][2];
	for(int i = 0; i <= 50; ++i){
		dp[i][0] = dp[i][1] = 0;
	}
	dp[0][0] = 1;
	for(long long i = 1; i <= n; ++i){
		cin >> a[i];
	}
	for(long long i = 1; i <= n; ++i){
		long long dpe = dp[i - 1][0];
		long long dpo = dp[i - 1][1];
		if(a[i] & 1){
			dp[i][1] = dpe + dpo;
			dp[i][0] = dpe + dpo;
		}else{
			dp[i][0] = 2 * dpe;
			dp[i][1] = 2 * dpo;
		}
	}
	cout << dp[n][p] << endl;
	return 0;
}

Measured memory_bytes: 256
N = input()
N = N[::-1]
a = int(N[0])
ans = []
if a==2 or a==4 or a==5 or a==7 or a==9:
  ans = "hon"
if a==0 or a==1 or a==6 or a==8:
  ans = "pon"
if a==3:
  ans = "bon"
  
print(ans)


Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main()
{
  int a,b;
  char op;
  cin >> a >> op >> b;
  if(op == '+')
    cout << a + b;
  else if(op == '-')
    cout << a - b << endl;
  return 0;
}


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

namespace cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var pg = new Program();

            pg.Execute();
         
        }

        private void Execute()
        {
            var input = ReadLinesLongList;
            var ALists = ReadLinesLongList.ToList();
            var K = input.ElementAt(0);
            var N = input.ElementAt(1);

            var subList = new List<long>();

            for (int i = 0; i < ALists.Count()-1; i++)
            {
                subList.Add(ALists[i+1] - ALists[i]);
            }

            subList.Add(K - ALists.Last() + ALists.First());

            var max = subList.Max();

            OutputResult(subList.Sum() - max);
        }

        private void OutputResult<Type>(Type result){
            Console.WriteLine(result);
        }

        static long ReadLineLong => long.Parse(Console.ReadLine());
        static string ReadLineString => Console.ReadLine();
        static IEnumerable<long> ReadLinesLongList => Console.ReadLine().Split(' ').Select(i => long.Parse(i));
        static IEnumerable<string> ReadLinesStringList => Console.ReadLine().Split(' ');

    }
}


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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,m,i; cin >>n >>m;
	if (m%2==1) {
		cout <<"No";
		return 0;
	}
	int x=2*n,y=4*n;
	if (m>=x && m<=y) {
		cout <<"Yes";
		return 0;
	}
	cout <<"No";
	return 0;
}
/******************************************************************************
******************************************************************************/


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

int c=0,n,k,s;

void check(int i,int sm,int _k){
    if(i>n||_k<0||sm>s) return;
    if(sm==s&&_k==0) c++;
    else{
        check(i+1,sm+i,_k-1);
        check(i+1,sm,_k);
    }
}

int main(void){
    while(cin>>n>>k>>s,n){
        n++;
        check(1,0,k);
        cout<<c<<endl;
        c=0;
    }
}



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

typedef long long ll;
const int N = 1e5 + 5;
int a[N];
int n;

int main() {
    scanf("%d", &n);
    for (int i=1; i<=n; ++i) {
        scanf("%d", &a[i]);
    }
    sort(a+1, a+n+1);
    ll sum = 0;
    int ans = 0;
    for (int i=1; i<n; ++i) {
        sum += a[i];
        if (2LL*sum >= a[i+1]) ans++;
        else ans = 0;
    }
    ans++;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 640
// C - March
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define out(x) cout << x << '\n'
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
//---------------------------------------------------------------------------------------------------
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

lli solve()
{
  lli a = 0, b = 0, c = 0, h = 0, n = 0, w = 0, ans = 0, count = 0;
  string s = "", t = "";
  vector<pair<lli, lli>> pr;
  map<lli, lli> mp;
  set<lli> st;
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  vs d;
  map<char, lli> e;
  rep(i, 0, n)
  {
    cin >> s;
    if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H')
    {
      e[s[0]]++;
      count++;
    }
  }
  b = e.size();
  for (auto x : e)
  {
    for (auto y : e)
    {
      for (auto z : e)
      {
        if (z.first > y.first && y.first > x.first)
        {
          ans += x.second * y.second * z.second;
        }
      }
    }
  }
  if (b >= 3)
  {
    return ans;
  }
  else
  {
    return 0;
  }
}

//---------------------------------------------------------------------------------------------------
signed main()
{
  out(solve());
}

Measured memory_bytes: 3660
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    a = [list(map(int,input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]

    for num in b:
        for i in range(3):
            for j in range(3):
                if a[i][j] == num:
                    a[i][j] = 0
    if sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[2]) == 0:
        print('Yes')
    elif a[0][0] + a[1][0] + a[2][0] == 0 or a[0][1] + a[1][1] + a[2][1] == 0 or a[0][2] + a[1][2] + a[2][2] == 0:
        print('Yes')
    elif a[0][0] + a[1][1] + a[2][2] == 0 or a[0][2] + a[1][1] + a[2][0] == 0:
        print('Yes')
    else:
        print('No')

main()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      	
        //sec--1
        String S = sc.nextLine();
        String T = sc.nextLine();
        int cnt = 0;
      
        //sec--2
        for(int i=0; i<S.length(); i++) {
          //if(S[i].equals(T[i]){
          //} else {S[i] == T[i];
          
          //文字列のi番目が異なるときカウントする
          //文字列を書き換えるという必要はないのでカウントのみ
          if(S.charAt(i) != T.charAt(i)) {
            cnt++;
          }
        }
      	
        System.out.println(cnt);
   }
}


Measured memory_bytes: 42304
def main():
    s = list(map(int,input().split()))
    num_animals, foots = s[0], s[1]
    flag = 0
    for i in range(0, num_animals, 1):
        # 数
        i += 1
        i, j = i, num_animals - i
        # 判定
        if i * 2 + j * 4 == foots:
            flag += 1
            break
        elif i * 4 + j * 2 == foots:
            flag += 1
            break
    if flag == 1:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 9228
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {
	public static void main(String[] args) { 
		/*
		 * */
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		long ans = 0;
		for (int A = 1; A<N; A++) {
			for (int mult = A; mult<N; mult+=A) {
				ans++;
			}
		}
		O.pln(ans);
	}
	public static double max(double a, double b) {return Math.max(a, b);}
	public static double min(double a, double b) {return Math.min(a, b);}
	public static long min(long a, long b) {return Math.min(a,b);}
	public static long max(long a, long b) {return Math.max(a,b);}
	public static int min(int a, int b) {return Math.min(a,b);}
	public static int max(int a, int b) {return Math.max(a,b);}
	public static long abs(long x) {return Math.abs(x);}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return max(a,b);
		return GCD(min(a,b),max(a,b)%min(a,b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}

Measured memory_bytes: 25780
#include <stdio.h>
#include <stdint.h>
#include <set>

int main(){
  int flg = 0;
  int c;
  int count = 0;
  int base_count = 0;
  while((c = getchar()) != EOF) {
    if(c < '0' || '9' < c) break;
    c -= '0';
    base_count += c;
    if(flg){
      count += 9;
      continue;
    }
    if(c == 9){
      count += 9;
      continue;
    }
    flg = 1;
    if(!count)count += c - 1;
    else count += 8;
  }
  if(base_count > count) count = base_count;
  printf("%d\n", count);
}

Measured memory_bytes: 256
#include <iostream>
int main()
{
    int a;
    int b;
    while(std::cin >> a >> b)
    {
        int number = 1;
        int data = a + b;
        for(int i = 0;;i++)
        {
            if(data / 10 != 0)
            {
                number += 1;
                data /= 10;
            }
 
            else if(data / 10 == 0)
            {
                break;
            }
        }
        std::cout << number << '\n';
    }
}

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

P = list(map(int, input().split()))
candidates = [i for i in range(102)]

ans = 1000
min_diff = 1000
for c in candidates:
    if c in P:
        continue
    diff = abs(X - c)
    if diff < min_diff:
        ans = c
        min_diff = diff

print(ans)


Measured memory_bytes: 9184
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        const int M = 998244353;

        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);
            int C = int.Parse(s[2]);

            int[] B = new int[M];
            s = Console.ReadLine().Split(' ');
            for (int i = 0; i < M; i++)
            {
                B[i] = int.Parse(s[i]);
            }

            int ans = 0;
            for (int i = 0; i < N; i++)
            {
                s = Console.ReadLine().Split(' ');
                int t = 0;
                for (int j = 0; j < M; j++)
                {
                    t += int.Parse(s[j]) * B[j];
                }
                t += C;

                if (t > 0)
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int64_t minll(int64_t a, int64_t b){
  if(a > b) return b;
  else return a;
}
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)  cin >> a.at(i);
  int sum = 0;
  for(int i = 0; i < n; i++) sum += a.at(i);
  int r1 = sum;
  for(int i = 0; i < (n-1)/2; i++){
    r1 -= 2*a.at(1+i*2);
  }
  cout << r1;
  int ri = r1;
  int rj = 0;
  for(int i = 0; i < n-1; i++){
    rj = 2*a.at(i)-ri;
    ri = rj;
    cout << " " << ri;
  }
  cout << endl;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=1e5;
const int mod=1e9+7;
int n,buk[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	n=nxi();
	for(int i=1; i<=n; ++i){
		++buk[nxi()];
	}
	for(int i=1+(n&1); i<n; i+=2){
		if(buk[i]!=2){
			puts("0");
			return 0;
		}
	}
	int ans=1;
	for(int i=1; i<=n>>1; ++i){
		ans=(ans<<1)%mod;
	}
	printf("%d\n",ans);
	return 0;
}


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

int main() {
  int n,k,x,sum=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>x;
    sum+=min(2*x,2*abs(k-x));
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {


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

		while (true) {
			final int N = sc.nextInt();
			final int T = sc.nextInt();
			final int L = sc.nextInt();
			final int B = sc.nextInt();
			
			if(N == 0 && T == 0 && L == 0 && B == 0){
				break;
			}
			
			boolean[] lose = new boolean[N+1];
			boolean[] back = new boolean[N+1];
			for(int i = 0; i < L; i++){
				lose[sc.nextInt()] = true;
			}
			for(int i = 0; i < B; i++){
				back[sc.nextInt()] = true;
			}
			
			double[][] DP = new double[T+1][N+1];
			DP[0][0] = 1;
			
			for(int turn = 0; turn < T; turn++){
				for(int pos = 0; pos < N; pos++){
					for(int dice = 1; dice <= 6; dice++){
						int next = pos + dice;
						if(next > N){
							next = 2 * N - next; 
						}
						
						if(back[next]){
							next = 0;
						}
						
						if(lose[next] && turn == T - 1){
							continue;
						}
						
						DP[turn + 1 + (lose[next] ? 1 : 0)][next] += DP[turn][pos] / 6;
					}
				}
			}
			/*
			for(int turn = 0; turn <= T; turn++){
				for(int pos = 0; pos <= N; pos++){
					System.out.print(DP[turn][pos] + ", ");
				}
				System.out.println();
			}
			*/
			double sum = 0;
			for(int turn = 0; turn <= T; turn++){
				sum += DP[turn][N];
			}
			
			System.out.printf("%6f\n", sum);
		}
	}

}

Measured memory_bytes: 24216
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>0)puts("Positive");               
    else if(b>=0)puts("Zero");             
    else if((a&1)^(b&1))puts("Positive");  
    else puts("Negative");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;
int main(){
    int N;
    cin>>N;
    set<int>st;
    int x=N;
    while(st.count(x)==0){
        st.insert(x);
        if(x%2==0){
            x/=2;
        }else{
            x=x*3+1;
        }
    }
    cout<<st.size()+1<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[101][101];
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>h>>w;
    map<char,ll> mp;
    rep(i,h){
        rep(j,w){
            cin>>s[i][j];
            mp[s[i][j]]++;
        }
    }
    if(h==1){
        for(char c='a';c<='z';c++){
            if(mp[c]%2==1)cnt++;
        }
        if(w%2==1)cnt--;
        if(cnt>0)cout<<"No\n";
        else cout<<"Yes\n";
    }
    else if(w==1){
        for(char c='a';c<='z';c++){
            if(mp[c]%2==1)cnt++;
        }
        if(h%2==1)cnt--;
        if(cnt>0)cout<<"No\n";
        else cout<<"Yes\n";
    }
    else{
        ll need;
        need=(h/2)*(w/2);
        for(char c='a';c<='z';c++){
            while(1){
                if(mp[c]<=3)break;
                mp[c]-=4;
                cnt++;
                if(cnt==need)break;
            }
            if(cnt==need)break;
        }
        if(cnt!=need){
            cout<<"No\n";
            return 0;
        }
        cnt=0;
        for(char c='a';c<='z';c++){
            cnt+=(mp[c]/2);
        }
        need=0;
        if(h%2==1)need=w/2;
        if(w%2==1)need=h/2;
        if(cnt>=need)cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    cnt = 0
    for i in range(N):
        x, u = input().split(' ')
        if u == 'JPY':
            cnt += float(x)
        else:
            cnt += float(x)*380000.0
    print('{}'.format(cnt))

if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
const int N = 2e5 + 7;
const int mod = 2019;
char s[N];
ll dp[2][2020];
int main(void){
    IOS;
    cin >> (s+1);
    int n =  strlen(s+1);
    int now = 0;
    ll ans = 0;
    for (int i = 1; i <= n; ++i){
        int d = s[i]-'0';
        for (int j = 0; j < 2019; ++j){
            if (!dp[now^1][j]) continue;
            int k = (j*10+d)%mod;
            dp[now][k] += dp[now^1][j];
        }
        dp[now][d]++;
       /* for (int j = 0; j < 2019; ++j){
            if (dp[now][j]){
                printf("i %d j %d cnt %d\n", i, j, dp[now][j]);
            }
        }*/
        ans += dp[now][0];
        now ^= 1;
        memset(dp[now], 0, sizeof dp[now]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3828
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def combinations_count(n, r, mod=MOD):
    def factorial_mod(N, mod=MOD):
        ret = 1
        for n in range(1, N + 1):
            ret *= n
            ret %= mod
        return ret

    q = factorial_mod(n + r, mod)
    b = factorial_mod(n, mod)
    d = factorial_mod(r, mod)
    b = pow(b, mod - 2, mod)
    d = pow(d, mod - 2, mod)
    return (q * b * d) % mod


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    ret = 0
    while N != 0:
        N //= K
        ret += 1
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 93792
from math import sin,cos,radians
a,b,c=map(int,input().split())
c=radians(c)
s=a*b*sin(c)*0.5
for i in[s,a+b+(a*a+b*b-2*a*b*cos(c))**0.5,s/a*2]:print('%5f'%i)



Measured memory_bytes: 5732
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MX = 1e10 + 10;;
unsigned long long fac[200001];

#include <math.h>
#define PI 3.14159265358979323846264338327950L

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
    return (a * b) / gcd(a, b);
}
long long digits(long long m) {
    long long cnt = 0;
    while (m) {
        cnt++;
        m /= 10;
    }
    return cnt;
}

unsigned long long power(unsigned long long x, unsigned long long y){
    unsigned long long res = 1;
    x = x % MOD;

    while (y > 0) {
        // If y is odd, multiply x with result 
        if (y & 1)
            res = (res * x) % MOD;

        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % MOD;
    }
    return res;
}
unsigned long long modInverse(unsigned long long n) {
    return power(n, MOD - 2);
}

long long nCr(long long n, long long r) {
    if (r > n) return 0;
    return (fac[n] * modInverse(fac[r]) % MOD * modInverse(fac[n - r]) % MOD) % MOD;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    for (int i = 1; i < n; i += 2) sum -= a[i] * 2ll;
    vector<int> x(n);
    x[0] = sum;
    for (int i = 1; i < n; i++) {
        x[i] = a[i - 1] * 2 - x[i - 1];
    }
    for (int i = 0; i < n; i++) cout << x[i] << " ";

    return 0;
}

Measured memory_bytes: 3968
S = input()
p = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
if S == p[0]:
    print(7)
elif S == p[1]:
    print(6)
elif S == p[2]:
    print(5)
elif S == p[3]:
    print(4)
elif S == p[4]:
    print(3)
elif S == p[5]:
    print(2)
elif S == p[6]:
    print(1)

Measured memory_bytes: 3060
N = int(input())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i
        
Cx,Cy,H = -1,-1,-1
        
for cx in range(101):
    for cy in range(101):
        if H >= 0:
            break
        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            Cx,Cy,H = cx,cy,h

print(Cx,Cy,H)

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, M; cin >> N >> M;
  vector<int> X(M); REP(i, M) cin >> X[i];
  if(N >= M) {
    cout << 0 << endl;
  } else {
    vector<ll> tmp(M - 1, 0);
    sort(all(X));
    REP(i, M - 1) {
      tmp[i] = X[i + 1] - X[i];
    }
    sort(all(tmp), greater<ll>());
    ll a = accumulate(all(tmp), 0LL);
    REP(i, N - 1) {
      a -= tmp[i];
    }
    cout << a << endl;
  }
}


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

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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int ans=0;
  for(int i=1;i<=n;i++){
    if(a<=sum(i)&&sum(i)<=b){
      ans+=i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int n,q;
char s[200010],t[200010],d[200010];
bool CR(int x){
  rep(i,q){
    if(x==n) return true;
    if(t[i]==s[x]){
      if(d[i]=='R') x++;
      else x--;
    }
  }
  if(x==n) return true;
  else return false;
}
bool CL(int x){
  rep(i,q){
    if(x==-1) return true;
    if(t[i]==s[x]){
      if(d[i]=='L') x--;
      else x++;
    }
  }
  if(x==-1) return true;
  else return false;
}
int upper(int l,int r){
  int lb=l,ub=r;
  while(ub-lb>1){
    int mid=(lb+ub)/2;
    if(CR(mid)){
      ub=mid;
    }
    else{
      lb=mid;
    }
  }
  return ub;
}

int lower(int l,int r){
  int lb=l,ub=r;
  while(ub-lb>1){
    int mid=(lb+ub)/2;
    if(CL(mid)){
      lb=mid;
    }
    else{
      ub=mid;
    }
  }
  return lb;
} 



int main(){
  cin>>n>>q;
  rep(i,n){
    cin>>s[i];
  }
  rep(i,q){
    cin>>t[i]>>d[i];
  }
  int ub=upper(-1,n),lb=lower(-1,n);
  //  prin2(ub,lb);
  prin(max(0,ub-lb-1));
  
  
  return 0;
}


Measured memory_bytes: 768
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N;
  cin >> N;
  vector<P> p;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    p.pb(P(tmp, i));
  }

  sort(ALL(p));

  int sum = 0, max = 0, cont = 1;
  for (int i = 0; i + 1 < N; i++) {
    if (p[i].second > p[i + 1].second) {
      sum += cont;
      chmax(max, cont);
      cont = 1;
    } else {
      cont++;
    }
  }
  if (cont != 0) {
    sum += cont;
    chmax(max, cont);
  }

  cout << sum - max << endl;
  return 0;
}


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

using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const i64 INFL = (1LL << 62);
const i64 MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int cnt = 0;
  int tmp = 0;
  char acgt[4] = {'A', 'C', 'G', 'T'};
  rep(i, s.size()) {
    bool flag = true;
    rep(j, 4) {
      if (s[i] == acgt[j]) flag = false;
    }
    if (flag) {
      cnt = max(cnt, tmp);
      tmp = 0;
    } else {
      ++tmp;
    }
  }
  cnt = max(cnt, tmp);
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
using namespace std;
const int maxn=1e6+10;
int n,p;
long long ans,dp[10][maxn];
char s[maxn];
map<int,int>num;
int main()
{
	scanf("%d%d%s",&n,&p,s+1);
	if (p==2)
	{
		for (int i=1;i<=n;i++) if ((s[i]-'0')%2==0) ans+=i;
		printf("%lld\n",ans);
	}
	else if (p==5)
	{
		for (int i=1;i<=n;i++) if ((s[i]-'0')%5==0) ans+=i;
		printf("%lld\n",ans);
	}
	else 
	{
		int now=0,mi=1; num[0]=1;
		for (int i=n;i>=1;i--)
		{
			now=(now+(s[i]-'0')*mi%p)%p;
			ans+=num[now]; num[now]++; mi=mi*10%p;
		}
		printf("%lld\n",ans);
	}
return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

main(){
    int P,Q,R;
    int max = 0;

    cin >> P;
    if(P >= max) max = P;

    cin >> Q;
    if(Q >= max) max = Q;

    cin >> R;
    if(R >= max) max = R;

    cout << P+Q+R-max <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, i, j, a[200001]; long long sum;
int main ()
{
    cin >> n;
    for(i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1, greater < int > ());
    sum = a[1];
    for(i = 3, j = 2; i <= n; i += 2, j++)
    {
        sum += a[j];
        if(i+1 <= n) sum += a[j];
    }
    cout << sum << endl;
}


Measured memory_bytes: 4396
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    int n,k;
    cin>>n>>k;
    set<int>s;
    bool done=0;
    int p[n+5],ans=1,x=0;
    rep(i,1,n){
        cin>>p[i];
        if(i<=k) s.insert(p[i]);
        if(i>1 and i<=k){
            if(p[i-1]>p[i]) x++;
        }
    }
    if(x==0) done=1;
    rep(i,k+1,n){
        if(p[i-k]>p[i-k+1]) x--;
        if(p[i-1]>p[i]) x++;
        if(p[i-k]==*s.begin() and p[i]>*s.rbegin());
        else if(x) ans++;
        else if(!done){
            ans++;
            done=1;
        }
        s.insert(p[i]);
        s.erase(p[i-k]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 10368
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n, k;
	cin >> n >> k;
	if (n % k == 0)
		cout << 0 << endl;
	else
		cout << 1 << endl;
} 

Measured memory_bytes: 3560
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;

int main()
{
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	
	if(a>b) swap(a,b);
	if((b-a)&1) printf("%lld\n",min(a-1,n-b)+1+(b-a-1)/2);
	else printf("%lld\n",(b-a)/2);
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

int dp[100010];
bool possible[100010];
signed main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/
	int N, M; cin >> N >> M;
	REP(i, 100010)possible[i] = true;
	REP(i, M) {
		int x; cin >> x;
		possible[x] = false;
	}
	dp[0] = 1;
	REP(i, N) {
		if (possible[i + 1]) {
			dp[i + 1] += dp[i];
			dp[i + 1] %= MOD;
		}
		if (possible[i + 2]) {
			dp[i + 2] += dp[i];
			dp[i + 2] %= MOD;
		}
	}
	print(dp[N]%MOD);
}


Measured memory_bytes: 1152
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val a = inputs(0)
  val b = inputs(1)

  println(solve(a, b))

  private def solve(a: String, b: String): String = {
    val as = a.size
    val bs = b.size
    if(as > bs) {
      return "GREATER"
    } else if (as < bs){
      return "LESS"
    } else {
      (0 until as).foreach { i =>
        val ac = a(i).toString.toInt
        val bc = b(i).toString.toInt

        if(ac > bc) {
          return "GREATER"
        } else if (ac < bc){
          return "LESS"
        }
      }

      return "EQUAL"
    }
  }
}

Measured memory_bytes: 54792
#define DEBUG
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e10+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int wa=0,age=0;
	for(int i=0;i<5;i++){
		int a;cin>>a;
		int b=10-a%10;
		if(a%10==0){b=0;}
		maxeq(age,b);
		wa+=a+b;
	}
	cout<<wa-age<<endl;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    int x = A[0], ans = -1000000000;
    for (int i = 1; i < N; i++)
    {
        ans = max(ans, A[i] - x);
        x = min(x, A[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main (){
  int A, B;
  
  cin >> A >> B;
  
  if((A+B <= A-B)&&(A*B <= A-B)){cout << A-B << endl;}
  else if((A-B <= A*B)&&(A+B <= A*B)){cout << A*B << endl;}
  else if((A-B <= A+B)&&(A*B <= A+B)){cout << A+B << endl;}
}

Measured memory_bytes: 888
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int h, w;
string s[405];
int vis[405][405];
int ind[405][405];
int W[200005];
int nm;

void dfs(int i, int j){
	if(vis[i][j]) return;
	vis[i][j] = 1;
	ind[i][j] = nm;
	if(s[i][j] == '.') W[nm]++;
	if(i < (h - 1) && s[i + 1][j] != s[i][j]) dfs(i + 1, j);
	if(j < (w - 1) && s[i][j + 1] != s[i][j]) dfs(i, j + 1);
	if(i > 0 && s[i - 1][j] != s[i][j]) dfs(i - 1, j);
	if(j > 0 && s[i][j - 1] != s[i][j]) dfs(i, j - 1);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> h >> w;
	rep(i, h) cin >> s[i];
	nm = 0;
	rep(i, h) rep(j, w) if(!vis[i][j]){
		nm++;
		dfs(i, j);
	}
	ll ans = 0;
	rep(i, h) rep(j, w) if(s[i][j] == '#') ans += W[ind[i][j]];
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 16640
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

const int INF=1e9+7;

int main(){
  int n;
  cin>>n;
  
  vector<int> A(n);
  rep(i,n) cin>>A[i];
  reverse(ALL(A));
  
  vector<int> L(n+1);
  rep(i,n+1) L[i]=INF;
  
  rep(i,n) *upper_bound(ALL(L),A[i])=A[i];
  cout<<lower_bound(ALL(L),INF)-L.begin()<<endl;
  
  return 0;
}

Measured memory_bytes: 3948
#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 MOD=1e9+7;

int main() {
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  x/=50;
  int ans=0;
  rep(i,a+1) rep(j,b+1){
    //cout<<i<<" "<<j<<endl;
    if(x>=i*10+2*j && x-10*i-2*j<=c) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

template <unsigned T>
bool nextBitset(bitset<T> &bs, int digit)
{
    if(bs.none())
        return false;
    bitset<T> x, y, z;
    x = bs.to_ulong() & (~(bs.to_ulong()) + 1ULL);
    y = bs.to_ulong() + x.to_ulong() + 0ULL;
    z = bs & ~y;
    if(bs[digit-1] && bs == z)
        return false;
    bs = ((z.to_ulong() / x.to_ulong()) >> 1) + 0ULL;
    bs |= y;
    return true;
}

int main()
{
    for(;;){
        int n, k;
        cin >> n >> k;
        if(n == 0)
            return 0;

        vector<int> num(n);
        for(int i=0; i<n; ++i)
            cin >> num[i];

        set<int> si;
        bitset<10> bs((1<<k)-1);
        do{
            vector<int> tmp;
            for(int i=0; i<n; ++i){
                if(bs[i])
                    tmp.push_back(num[i]);
            }
            sort(tmp.begin(), tmp.end());
            do{
                int x = 0;
                for(int i=0; i<k; ++i){
                    if(tmp[i] >= 10)
                        x *= 100;
                    else
                        x *= 10;
                    x += tmp[i];
                }
                si.insert(x);
            }while(next_permutation(tmp.begin(), tmp.end()));
        }while(nextBitset(bs, n));

        cout << si.size() << endl;
    }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 998244353;

int main() {
	int N;
	cin >> N;
	vector<int> b(N);
	for (int i = 0; i < N; i++) {
		cin >> b[i];
		b[i]--;
	}
	vector<int> ans;
	while (!b.empty()) {
		int idx = -1;
		for (idx = b.size() - 1; idx >= 0; idx--) {
			if (b[idx] == idx) break;
		}
		if (idx == -1) {
			cout << -1 << endl;
			return 0;
		}
		ans.push_back(idx + 1);
		b.erase(b.begin() + idx);
	}
	for (int i = N - 1; i >= 0; i--) cout << ans[i] << endl;
}


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


int main() {
    int N;
    cin >> N;
    //配列の初期化
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    
    int sum = accumulate(a.begin(), a.end(), 0);
    int base = round((float)sum / (float)N);

    int cost = 0;

    for(int i = 0; i < N; i++){
        cost += (a.at(i) - base)*(a.at(i) - base);
    }

    cout << cost << endl;

    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
using namespace std;

int main() {
  int N, X;
  scanf("%d %d", &N, &X);
  int pos = 0;
  int count = 1;
  int l;
  for (int i=0; i<N; i++) {
    scanf("%d", &l);
    pos += l;
    if (pos <= X) count++;
  }
  printf("%d\n", count);
}


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

int prime[300000];
void make_prime(){
  prime[0] = prime[1] = 1;
  for(int i = 2; i * i <= 300000; i++){
    if(!prime[i]){
      for(int j = i; i * j < 300000; j++){
        prime[i*j] = 1;
      }
    }
  }
}

int main(){
  int n, p;
  make_prime();
  while(cin >> n >> p){
    if(n == -1 && p == -1) break;
    int idx = n, cnt = 0;
    int sum[100] = {};
    while(cnt < 100){
      idx++;
      if(prime[idx] == 0){
        sum[cnt] = idx;
        cnt++;
      }
    }
    vector<int> ans;
    for(int i = 0; i < 100; i++){
      for(int j = i; j < 100; j++){
        ans.push_back(sum[i] + sum[j]);
      }
    }
    sort(ans.begin(), ans.end());
    cout << ans[p-1] << endl;
  }
  return 0;
}



Measured memory_bytes: 4288