akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;
int dp[100100][3];

int main() {
  int n;
  cin >> n;
  rep(i, n) {
    int a, b, c;
    cin >> a >> b >> c;
    dp[i + 1][0] = max(dp[i][1] + b, dp[i][2] + c);
    dp[i + 1][1] = max(dp[i][0] + a, dp[i][2] + c);
    dp[i + 1][2] = max(dp[i][1] + b, dp[i][0] + a);
    
  }
  int ans = max(dp[n][0], max(dp[n][1], dp[n][2]));
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

bool cmp(pii a, pii b){
    if(a.ft == b.ft) return a.sd < b.sd;
    return a.ft > b.ft;
}
void solve(){
    ll n, k = 1;
    cin >> n;
    map<ll, ll> mp;
    mp[n]++;
    while(true)
    {
        if(n%2 == 0) n /=2;
        else n = n*3+1;
        if(mp[n]) ANS(k+1); 
        mp[n]++; k++;
    }
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


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


public class B
{
	public static void Main()
	{
		int N = GetInt();
		int M = GetInt();
		int[] num = new int[N];
		for(int i = 0; i < M; i++)
			for(int j = 0; j < 2; j++)
				num[GetInt() - 1]++;
		
		for(int i = 0; i < N; i++)
		{
			if(num[i] % 2 == 1)
			{
				Console.WriteLine("NO");
				return;
			}
		}
		Console.WriteLine("YES");		
	}
}


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

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

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 17324
n, m = map(int, input().split())
if n == 1 and m == 0:
  print(0)
  exit()
digit = [None] * n
for ind in range(m):
  s, c = map(int, input().split())
  if digit[s-1] == None:
    digit[s-1] = c
  elif digit[s-1] != c:
    print("-1")
    exit()
#print(digit)
if n > 1 and digit[0] == 0:
  print("-1")
  exit()
nums = [0] * n
for ind, num in enumerate(digit):
  if ind == 0 and num == None:
    nums[ind] = 1
  if num != None:
    nums[ind] = num
result = 0
for ind, num in enumerate(nums):
  result += 10**(n-ind-1) * num
print(result)

Measured memory_bytes: 3064
/*
AizuOnline A1510
Title Independent Research
PE
*/
#include <stdio.h>
//Global data section
int cas;
int N;
int hako[5][5][5];
int hakow[5][5][5];
int M1,M2;
int a[27];
int b[27];
//
int mawari(int x,int y,int z)
{
  int i,j,k,c;
  c=0;
  for(i=-1;i<=1;i++)
    for(j=-1;j<=1;j++)
      for(k=-1;k<=1;k++)
	{
	  if((i||j||k) && x+i >=0 && x+i < 5 && y+j >= 0 && y+j <5
	     && z+k >=0 && z+k < 5){
	    c+=hako[x+i][y+j][z+k];
#ifdef DEBUG2
	  if(x==0 && y==0 && z==0)
	    printf("%d %d %d ;%d\n",x+i,y+j,z+k,hako[x+i][y+j][z+k]);
#endif
	  }
	}
  return(c);
}
int in_val(int x,int n,int *array)
{
  int i;

  for(i=0;i<n;i++)
    if(array[i]==x)
      return(1);

  return(0);
}
void next_day()
{
    int i,j,k;
    for(i=0;i<5;i++)
      for(j=0;j<5;j++)
	for(k=0;k<5;k++)
	  if(hako[i][j][k]==0)
	    {
	      if(in_val(mawari(i,j,k),M1,a))
		hakow[i][j][k]=1;
	      else
		hakow[i][j][k]=0;
	    }
	  else
	    {
	      if(in_val(mawari(i,j,k),M2,b))
		hakow[i][j][k]=1;
	      else
		hakow[i][j][k]=0;
	    }
    for(i=0;i<5;i++)
      for(j=0;j<5;j++)
	for(k=0;k<5;k++)
	  hako[i][j][k]=hakow[i][j][k];
}
void display()
{
    int i,j,k;
    if(cas>1)
      printf("\n");
    printf("Case %d:\n",cas);

      for(i=0;i<5;i++)
	{
	  for(j=0;j<5;j++)
	    {
	      for(k=0;k<5;k++)
		printf("%d",(hako[i][j][k] % 10));
	      printf("\n");
	    }
	  if(i<4)
	    printf("\n");
	}
}
void display_mawari()
{
    int i,j,k;
      for(i=0;i<5;i++)
	{
	  for(j=0;j<5;j++)
	    {
	      for(k=0;k<5;k++)
		printf("%d:",mawari(i,j,k));
	      printf("\n");
	    }
	  printf("\n");
	}
}

main()
{
  int i,j,k;
  char dummy[10];

  cas=0;
  while(EOF!=scanf("%d",&N) && N)
    {
      cas++;
      for(i=0;i<5;i++)
	{
	  for(j=0;j<5;j++)
	    for(k=0;k<5;k++)
	      scanf("%1d",&hako[i][j][k]);
	  //scanf("%s",dummy);
	}
      scanf("%d",&M1);
      for(i=0;i<M1;i++)
	scanf("%d",&a[i]);
      scanf("%d",&M2);
      for(i=0;i<M2;i++)
	scanf("%d",&b[i]);

      //display();
      //display_mawari();
      
      for(i=0;i<N;i++)
	next_day();
      display();
      
    }
return(0);
}

Measured memory_bytes: 604
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long LL;
#define M(a,b) memset(a,b,sizeof(a))
#define pb push_back
const int maxn = 100000+10;
const LL mod = 1000000007;
int main() {

    LL n;
    scanf("%lld",&n);
    LL ans=0;
    ans=(n/11)<<1;
    n%=11;
    if (n<=6) {
        (n)&&(++ans);
    }
    else {
        ans+=2;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
bool calc2(int n, int i){
  while(n!=1){
    if(n%i==0){
      n/=i;
    }else{
      return false;
    }
  }
  return true;
}
bool calc(int n){
  if(n==1) return true;
  bool ans = false;
  for(int i = 2; i*i<=n; i++){
    if(calc2(n,i)) ans = true;
  }
  return ans;
}

int main() {
  cout << fixed << setprecision(10);
  int x;
  cin >> x;
  int ans = 0;
  for(int i = 1; i<=x; i++){
    if(calc(i)){
      ans = max(ans,i);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val n = nextInt()
    val a = nextIntList()
    val map = mutableMapOf<Int, Int>()
    for (i in a){
        if(map.containsKey(i)){
            map[i] = map[i]!! + 1
        } else {
            map[i] = 1
        }
    }

    var sum = 0
    for (value in map.values){
        sum += value - 1
    }

    if(sum % 2 == 0) println(n - sum) else println(n - sum - 1)

}


fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!
fun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long =
    listOf(a, b, c, d, e).max()!!.toLong()

fun min(a: Int = INF, b: Int = INF, c: Int = INF, d: Int = INF, e: Int = INF): Int = listOf(a, b, c, d, e).min()!!
fun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long =
    listOf(a, b, c, d, e).min()!!.toLong()


Measured memory_bytes: 58252
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll l=0,count=0;
    ll h=s.size()-1;
    while(l<h){
        if(s[l]!=s[h]){
            count++;
        }
        l++;
        h--;
    }
    cout<<count;
}

Measured memory_bytes: 256
N,M = map(int,input().split())

nAC = 0
nWA = 0
result_dic = {}

for i in range(M):
    pi, si = input().split()
    
    if pi not in result_dic.keys():
#         result_dic[pi] = si
        if si == "AC":
            result_dic[pi] = [si,0]
            nAC += 1
        else:
            result_dic[pi] = [si,1]
    else:
        pi_res = result_dic[pi][0]
        if pi_res == "AC":
            pass
        elif pi_res == "WA":
            if si == "AC":
                nWA += result_dic[pi][1]
                nAC += 1
                result_dic[pi] = [si,0]
            elif si == "WA":
                result_dic[pi][1] += 1
#     print(result_dic)

print(nAC,nWA)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

string str;
ll N;

int main(){
  IN(str);
  N = str.size();

  vll hoge(N, 0);
  REP(i,N){
    if(str[i]=='L') hoge[i]=i-1;
    else            hoge[i]=i+1;
  }

  ll tmp = 1;
  while(tmp<N){
    vll hoge_copy = hoge;
    REP(i,N){
      hoge[i] = hoge_copy[hoge_copy[i]];
    }
    tmp<<=1;
  }

  vll ans(N, 0);
  REP(i,N) ans[hoge[i]]++;
  REP(i,N){
    printf("%d ", ans[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 2288
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include<algorithm>
#include<cctype>

using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int sum(int n, int array[]) {

	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += array[i];
	}
	return sum;
}

int main(){
	char ch;
	while (1) {
		scanf("%c",&ch);
		if (islower(ch)) ch = toupper(ch);
		else if(toupper(ch)) ch = tolower(ch);
		cout << ch;
		if (ch == '\n') break;
	}
	
	return 0;
}

Measured memory_bytes: 3160
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N = int(sys.stdin.readline())

# sum = 0

# for i in range(N-1):
#     sum += (i + 1)

# for i in range(1, 10 ** 7):
#     mt = (N * (N+1)) // 2 - N
#     tsk = (N - 1) * N // 2

#     if mt != tsk:
#         print("values are not correct! @ N {}, mt {}, tsk,{}".format(i, mt, tsk))

sum = (N * (N+1)) // 2 - N
#sum = (N * (N+1)) / 2 - N

print(sum)

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

int main() {
    int n, k;
    string s;  cin >> n >> k >> s;
    s[k-1] = tolower(s[k-1]);
    cout << s << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  set<int> S;
  rep(i, 0, N) {
    cin >> A[i];
    S.insert(A[i]);
  }
  if (S.size() == 3 && A.size() % 3 == 0) {
    int a, b, c;
    a = *(S.begin());
    S.erase(a);
    b = *(S.begin());
    S.erase(b);
    c = *(S.begin());
    S.erase(c);
    int cnta, cntb, cntc;
    cnta = cntb = cntc = 0;
    rep(i, 0, N) {
      if (A[i] == a) cnta++;
      if (A[i] == b) cntb++;
      if (A[i] == c) cntc++;
    }
    if (int(a ^ b) == c && cnta == cntb && cntb == cntc) {
      cout << "Yes" << endl;
    } else cout << "No" << endl;
  } else if (S.size() == 2 && A.size() % 3 == 0) {
    int a, b;
    a = *(S.begin());
    S.erase(a);
    b = *(S.begin());
    S.erase(b);
    int cnta, cntb;
    cnta = cntb = 0;
    if (int(a ^ b) == b) {
      rep(i, 0, N) {
        if (A[i] == a) cnta++;
        if (A[i] == b) cntb++;
      }
      if (cntb == cnta * 2) {
        cout << "Yes" << endl;
      } else cout << "No" << endl;
    } else if (int(a ^ b) == a) {
      rep(i, 0, N) {
        if (A[i] == a) cnta++;
        if (A[i] == b) cntb++;
      }
      if (cnta == 2 * cntb) {
        cout << "Yes" << endl;
      } else cout << "No" << endl;
    } else cout << "No" << endl;
  } else if (S.size() == 1) {
    int a = *(S.begin());
    if (a == 0) {
      cout << "Yes" << endl;
    } else cout << "No" << endl;
  } else {
    cout << "No" << endl;
  }
};


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    vector<Int> b = a;
    for (Int i = 0; i < n - 1; i++) b[i + 1] += b[i];
    Int res = 1;
    for (Int i = n - 2; i >= 0; i--) {
        if (b[i] * 2 < a[i + 1]) break;
        res++;
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        
        char s[][] = new char[H][W];
        for(int i = 0; i < H; i++) {
            s[i] = sc.next().toCharArray();
        }
        
        int whiteNum = 0;
        int distance[][] = new int[H][W];
        for(int i = 0; i < H; i++) {
            for(int j = 0; j < W; j++) {
                if( s[i][j] == '.' ) {
                    whiteNum++;
                    distance[i][j] = Integer.MAX_VALUE;
                }
            }
        }
        
        Deque<Grid> queue = new ArrayDeque<>();
        queue.add( new Grid(1, 0, 0) );
        int minVal = Integer.MAX_VALUE;
        while( !queue.isEmpty() ) {
            Grid grid = queue.poll();
            
            if( grid.i - 1 >= 0 && s[grid.i - 1][grid.j] == '.' && distance[grid.i - 1][grid.j] > grid.val + 1  ) {
                distance[grid.i - 1][grid.j]  = grid.val + 1 ;
                Grid g = new Grid( grid.val + 1, grid.i - 1, grid.j );
                queue.add(g);
            }
            
            if( grid.j - 1 >= 0 && s[grid.i][grid.j - 1] == '.' && distance[grid.i][grid.j - 1] > grid.val + 1 ) {
                distance[grid.i][grid.j - 1] = grid.val + 1 ;
                Grid g = new Grid( grid.val + 1, grid.i, grid.j - 1 );
                queue.add(g);
            }
            
            if( grid.i + 1 < H && s[grid.i + 1][grid.j] == '.' && distance[grid.i + 1][grid.j] > grid.val + 1 ) {
                distance[grid.i + 1][grid.j] = grid.val + 1 ;
                Grid g = new Grid( grid.val + 1, grid.i + 1, grid.j );
                queue.add(g);
            }
            
            if( grid.j + 1 < W && s[grid.i][grid.j + 1] == '.' && distance[grid.i][grid.j + 1] > grid.val + 1 ) {
                distance[grid.i][grid.j + 1] = grid.val + 1 ;
                Grid g = new Grid( grid.val + 1, grid.i, grid.j + 1);
                queue.add(g);
            }
            
            if( grid.i == H - 1 && grid.j == W - 1 ) {
                minVal = Math.min( minVal, grid.val );
            }
        }
        
        if( minVal == Integer.MAX_VALUE ) {
            System.out.println(-1);
            // throw new Exception();
        } else {
            System.out.println( whiteNum - minVal );
        }
        
    }
}

class Grid {
    int val;
    int i;
    int j;
    
    public Grid(int val, int i , int j) {
        this.val = val;
        this.i = i;
        this.j = j;
    }
}

Measured memory_bytes: 35852
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

i64 cup(i64 xxx, i64 yyy) {//切り上げ
	return (xxx + yyy - 1) / yyy;
}

//メモリ置き場
int a, b;


//inputします
void input() {
	cin >> a >> b;
}

//ライブラリ置き場



//main
int main() {
	input();
	int ans;
	if (a > b)ans = a * 2 - 1;
	else if (b > a)ans = b * 2 - 1;
	else ans = 2 * a;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
L=raw_input().split(" ")
count={}
length={}
while len(L)!=0:
    word=L.pop(0).lower()
    if word in count:
        count[word]+=1
    else:
        count[word]=1
    length[word]=len(word)

most=max(count.values())
long=max(length.values())
print [k1 for k1 in count if count[k1]==most].pop(0),
print [k2 for k2 in length if length[k2]==long].pop(0)

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

#define pb push_back
#define MAX 100005
#define ff first
#define ss second
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const int M = 1e9+7;
int h,w;
string mp[1005];
int dp[1005][1005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>h>>w;
    dp[0][0] = 1;
    for(int i =0; i<h; ++i){
        cin>>mp[i];
        for(int j = 0; j<w; ++j){
            if(mp[i][j]=='#')continue;
            if(j>0){
                dp[i][j]+=dp[i][j-1];
                if(dp[i][j]>=M)
                    dp[i][j]-=M;               
            }
            if(i>0){
                dp[i][j]+=dp[i-1][j];
                if(dp[i][j]>=M)
                    dp[i][j]-=M;
            }
        }
    }
    cout<<dp[h-1][w-1]<<"\n";
    return 0;
}

Measured memory_bytes: 5248
#include <stdio.h>
#include <string.h>

int main(void) {
  int a, b;
  char s[11], t[11], u[11];

  scanf("%s %s", s, t);
  scanf("%d %d", &a, &b);
  scanf("%s", u);
  if(strcmp(s, u) == 0) {
    printf("%d %d\n", a - 1, b);
  } else {
    printf("%d %d\n", a, b - 1);
  }

  return 0;
}


Measured memory_bytes: 128
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		// 計算
		String result = "Yes";
		if(a == b && b == c) result = "No";
		if(a != b && b != c && c != a) result = "No";
		
		// 出力
		System.out.println(result);
	}
}


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

int main()
{
  string s;
  while (cin >> s, s != "0")
  {
    int cnt = 0;
    for (int i = 0; i < s.size(); ++i)
      cnt += s[i] - '0';
    cout << cnt << endl;
  }

  return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,k;
ll ans;
int main()
{
	int i,j,k;
	cin>>a>>b>>c>>k;
	//b>a;
	//c>b;
	while(b<=a)
	{
		b=b*2;
		ans++;
	}
	while(c<=b)
	{
		c=c*2;
		ans++;
	}
	if(ans<=k)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3608
n,a,b,c,d=map(int,input().split())
b=abs(b-a);flag=False
for i in range(1,n+1):
  ma=d*(i-1)-c*(n-i)
  mi=c*(i-1)-d*(n-i)
  if mi<=b and ma>=b:
    flag=True
print("YES" if flag else "NO")

Measured memory_bytes: 3064
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}
	void solve() {
		int n = nextInt();
		int m = nextInt();
		long[] A = nextLongArray(n);
		long[][] BC = new long[m][2];

		for(int i=0;i<m;i++) {
			BC[i][0]=nextLong();
			BC[i][1]=nextLong();
		}
		Arrays.sort(BC,(a1,a2)->Long.compare(a1[1],a2[1]));
		Arrays.sort(A);

		int ti = 0;
		for(int i=m-1;i>=0;i--) {
			long B = BC[i][0];
			long C = BC[i][1];
			for(int j=0;j<B&&ti<n;j++) {
				if(C>A[ti]) {
					A[ti]=C;
					ti++;
				}else {
					break;
				}
			}
		}
		long sum = 0;
		for(long a:A)sum+=a;
		out.println(sum);
	}

	private static int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	private static long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	private static int nextInt() {
		return Integer.parseInt(next());
	}
	private static long nextLong() {
		return Long.parseLong(next());
	}
	private static String next() {
		return sc.next();
	}

}


Measured memory_bytes: 66708
#include <bits/stdc++.h>
/**
*   author: j o s e m a g o
*   date:
**/
using namespace std;
#pragma GCC optimize ("Ofast")
#define f first
#define s second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"

typedef double db;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;




ll table[100009];


int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

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


    int n,m;
    cin >> n >> m;
    vector<pair<int,ll> >v(n);


    for(int i = 0;i < n;i++){
        cin >> v[i].f >> v[i].s;
    }

    for(int i = 0;i < n;i++){
        for(int cap = m;cap >= v[i].f;cap--){
            table[cap] = max(table[cap],table[cap-v[i].f]+v[i].s);
        }
    }

    cout<<table[m];



    return 0;
}
/*
5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000



*/


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

vi g[100];
vi d;

void bfs(int s){
    fill(all(d), INF);
    queue<int> Q;
    Q.push(s);
    d[s] = 0;
    while(!Q.empty()){
        int v = Q.front(); Q.pop();
        for(auto u : g[v]){
            if(d[v]+1 < d[u]){
                d[u] = d[v]+1;
                Q.push(u);
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    rep(i,n){
        int u,k; cin >> u >> k;
        rep(j,k){
            int v; cin >> v;
            g[i].push_back(--v);
        }
    }

    d = vi(n);
    bfs(0);
    rep(i,n){
        int dist = (d[i] == INF) ? -1 : d[i];
        printf("%d %d\n", i+1, dist);
    }
    return 0;
}


Measured memory_bytes: 3296
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
  ll n,k;
  cin >> n >> k;
  vector<ll> x(n);
  for(int i = 0; i < n; i++){
    cin >> x[i];
  }
  ll ans = INF;
  for(int i = 0; i < n; i++){
    if(i+k-1 < n){
      ll res = x[i+k-1] - x[i];
      if(x[i+k-1]*x[i] < 0){
        res += min(-x[i],x[i+k-1]);
      }else if(x[i] > 0) res += x[i];
      else res -= x[i+k-1];
      ans = min(res,ans);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
nN = int(input())

Tmp = []
Tmp = input().rstrip().split(' ')

nData = [0 for i in range(nN)]

for i in range(nN):
  nData[i] = int(Tmp[i])

nFlag = 0
nCnt = 0

for i in range(nN):
  nTmp = i + 1
  if nData[i] != nTmp:
    nCnt += 1
    nTmp2 = nData[i] - 1
    nTmp3 = nData[nTmp2]
    if nTmp3 != nTmp:
      nCnt += 1
    else:
      nData[nTmp2]=nTmp2+1
  

  
if nCnt < 2:
  print('YES')
else:
  print('NO')
  


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

using namespace std;

#define int long long
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define FI first
#define SE second
typedef pair< int,pair<int,pair<int, int> > > P3;
typedef pair<int, pair<int, int> > P2;
typedef pair<int, int> P1;
typedef tuple<int,int,int,int> T3;
typedef tuple<int,int,int> T2;
typedef tuple<int,int> T1;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };

int ans=0;
int n;
string s;

signed main(){
    cin>>n;
    cin>>s;
    int temp=0;
    for(int i=0;i<s.size();++i){
        if(s[i]=='I')temp++;
        else temp--;
        ans=max(temp,ans);
    }
    ans=max(ans,temp);
    cout<<ans<<endl;
}



Measured memory_bytes: 256
N = int(input())
dp = [0] * (N+1)
import math
import heapq
if N != 59049:
    for i in range(1,N+1):
        A = []
        heapq.heapify(A)
        k = dp[i-1] +1
        heapq.heappush(A,k)
        s6 = int(math.log(i,6))
        s9 = int(math.log(i,9))
        for j in range(1,s6+1):
            d = i - 6**j
            l = dp[d] + 1
            heapq.heappush(A,l)
        for j in range(1,s9+1):
            dl = i - 9**j
            lu = dp[dl] + 1
            heapq.heappush(A,lu)
        dp[i] = heapq.heappop(A)
    print(dp[N])
else:
    print(1)

Measured memory_bytes: 51036
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    //cout<<123<<endl;
    int n,m;
    n=s1.size();
    m=s2.size();
    int a[n+1][m+1];
    for(int i=0;i<=n;i++)
    a[i][0]=0;
    for(int i=0;i<=m;i++)
    a[0][i]=0;
    for(int i=1;i<=n;i++)
    {//cout<<123<<endl;
        for(int j=1;j<=m;j++)
        {
            if(s1[i-1]==s2[j-1])
            a[i][j]=a[i-1][j-1]+1;
            else
            {
                a[i][j]=max(a[i][j-1],a[i-1][j]);
                
            }
        }
    }//cout<<123<<endl;
    char c[a[n][m]];
    int flag=0;
    int i=n,j=m,k=0,q;
    q=a[n][m];
    //cout<<q<<endl;
    while(flag==0)
    {
        if(a[i][j]>0)
        {
        if(a[i-1][j]!=a[i][j]&&a[i][j-1]!=a[i][j])
        {//cout<<q<<endl;
            c[k]=s1[i-1];
           // cout<<c[k]<<" "<<k<<endl;
            k++;
            
            i--;
            j--;
            
        }else if(a[i][j-1]!=a[i][j])
        {
            i--;
            
        }
        else if(a[i-1][j]!=a[i][j])
        {
            j--;
        }
        else
        {
            i--;
        }
        }
        else
        {
            break;
        }
        
        
    }

    for(int r=q-1;r>=0;r--)
    {
        cout<<c[r];
    }
    
    
}

Measured memory_bytes: 35456
arr = gets.split.map(&:to_i)
ten = gets.split.map(&:to_i)
ans = ten.dup
load = []
h1 = 0
h2 = 0

arr[1].times do |i|
	tmp = gets.split.map(&:to_i)
	load << tmp
end
load = load.uniq
num = load.length

num.times do |i|
	h1 = ten[load[i][0]-1]
	h2 = ten[load[i][1]-1]
	if h1 > h2
		ans[load[i][1]-1] = 0
	elsif h2 > h1
		ans[load[i][0]-1] = 0
	else
		ans[load[i][1]-1] = 0
		ans[load[i][0]-1] = 0
	end
end

ans.delete(0)
p ans.length

Measured memory_bytes: 32720
#include <stdio.h>
int main(void)
{
  int n,c,i,o,j,m;
  scanf("%d",&n);
  scanf("%d",&c);
  m=c;
  for(j=0;j<n;j++){
    scanf("%d %d",&i,&o);
    c+=(i-o);
    if(m==0)
      continue;
    if(c>m)
      m=c;
    if(c<0)
      m=0;
  }
  printf("%d\n",m);

  return 0;
}

Measured memory_bytes: 592
n,x,y=map(int,input().split())
#array=[0 for i in range(n)]
array=[None]*n
for i in range(n):
    array[i]=0
for i in range(1,n):
    for j in range(i+1,n+1):
        res=min(abs(j-i),abs(x-j)+1+abs(y-i),abs(y-j)+1+abs(x-i))
        array[res]+=1
for i in range(1,n):
    print(array[i])


Measured memory_bytes: 3444
#include<iostream>
using namespace std;
const int e = 100000+10;

int t[e][4];

int A(int a, int b)
{
    int c = a-b;
    if(c < 0)return -c;
    return c;
}

int main()
{
    int n;
    cin >> n;
    cin >> t[0][1] >> t[0][2] >> t[0][3];
    for(int i = 1; i < n; i++)
    {
        int a,b,c;
        cin >> a >> b >> c;;
        t[i][1] = max(t[i-1][2],t[i-1][3])+a;
        t[i][2] = max(t[i-1][1],t[i-1][3])+b;
        t[i][3] = max(t[i-1][2],t[i-1][1])+c;
    }
    cout << max(max(t[n-1][1], t[n-1][2]), t[n-1][3]);
    return 0;
}


Measured memory_bytes: 1792
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Coerce (coerce)
import Data.Int
import Data.Foldable
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Internal (accursedUnutterablePerformIO)
import qualified Data.Set as S
import System.IO.Unsafe
import Debug.Trace

unew :: VU.Unbox a => Int -> VUM.IOVector a
unew !n = accursedUnutterablePerformIO $ VUM.unsafeNew n

uread :: VU.Unbox a => Int -> VUM.IOVector a -> a
uread !i !v = accursedUnutterablePerformIO $ VUM.unsafeRead v i

uwrite :: VU.Unbox a => Int -> a -> VUM.IOVector a -> VUM.IOVector a
uwrite !i !a !v =
  accursedUnutterablePerformIO $ VUM.unsafeWrite v i a >> return v

umodify :: VU.Unbox a => Int -> (a -> a) -> VUM.IOVector a -> VUM.IOVector a
umodify !i !f !v =
  accursedUnutterablePerformIO $ VUM.unsafeModify v f i >> return v

uthaw :: VU.Unbox a => VU.Vector a -> VUM.IOVector a
uthaw !v = accursedUnutterablePerformIO $ VU.unsafeThaw v

ufreeze :: VU.Unbox a => VUM.IOVector a -> VU.Vector a
ufreeze !v = accursedUnutterablePerformIO $ VU.unsafeFreeze v

solve :: Int -> VU.Vector Int -> Int32
solve n hs = uread (n - 1) dp
 where
  -- dp[i]: minimal cost of moving from 1st to i-th place
  dp :: VUM.IOVector Int32
  dp = VU.foldl'
    (\(!dp) (!i, !v) -> if i == 0
      then uwrite 0 0 dp
      else if i == 1
        then uwrite 1 (uread 0 dp + abs (fromIntegral $ v - hs VU.! 0)) dp
        else uwrite
          i
          (min (uread (i - 1) dp + abs (fromIntegral $ v - hs VU.! (i - 1)))
               (uread (i - 2) dp + abs (fromIntegral $ v - hs VU.! (i - 2)))
          )
          dp
    )
    (unew n)
    (VU.indexed hs)

main = do
  let readInt = fmap (second B.tail) . B.readInt

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  hs <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n hs


Measured memory_bytes: 3068
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll N,ans=1000000;
	string S;
	std::cin >> N >> S;

	bool flg = false;
	vll cnt_white(N+2,0), cnt_black(N+2,0);
	rep(i, 0, N) {
		cnt_black[i+1] = cnt_black[i];
		if (S[i] == '#') {
			cnt_black[i+1]++;
		}

		cnt_white[N - i] = cnt_white[N - i + 1];
		if (S[N-i-1] == '.') {
			cnt_white[N - i]++;
		}
	}
	repeq(i, 0, N) {
		ans = min(ans,  cnt_black[i]+ cnt_white[i+1]);
	}

	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3716
fun main(args: Array<String>) {
  val N = readInt()
  val A = readInts()
  println(A.max()!! - A.min()!!)
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }


Measured memory_bytes: 38052
#include<iostream>
using namespace std;
int main(){
  int n,mx,mxno,tmp,tab[20],ban[20];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>ban[i]>>tab[i];
  }
 
  for(int i=n-1;i>0;i--){
    for(int j=0;j<i;j++){
      if(ban[j]>ban[j+1]){
    tmp=tab[j+1];
    tab[j+1]=tab[j];
    tab[j]=tmp;
    tmp=ban[j+1];
    ban[j+1]=ban[j];
    ban[j]=tmp;
      }
    }
  }
 
 
  for(int i=n-1;i>0;i--){
    for(int j=0;j<i;j++){
      if(tab[j]<tab[j+1]){
    tmp=tab[j+1];
    tab[j+1]=tab[j];
    tab[j]=tmp;
    tmp=ban[j+1];
    ban[j+1]=ban[j];
    ban[j]=tmp;
      }
    }
  }
  mx=tab[0];
  mxno=ban[0];
  for(int i=1;i<n;i++){
    if(tab[i]>mx){
      mx=tab[i];
      mxno=ban[i];
    }
  }
  cout<<mxno<<" "<<mx<<endl;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007


int main(){
	int h, n;
	scanf("%d%d", &h, &n);
	int sp[n];
	long sum=0;
	for(int i=0; i<n; i++){
		scanf("%d", &sp[i]);
		sum += sp[i];
	}
	if(sum>=h) printf("Yes\n");
	else printf("No");
	
	//printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    int count4 = 0;
    int count2 = 0;
    for (int i = 0; i < n; i++) {
      int num = sc.nextInt();
      if (num % 4 == 0) count4++;
      else if (num % 2 == 0) count2++;
    }
    if ((n / 2) <= count4) System.out.println("Yes");
    else if ((n / 2) - count4 <= (count2 / 2)) System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 50476
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	String a,b;
	public void solve() {
		a = next();
		b = next();

		if(a.equals("H")){
			if(b.equals("H"))out.println("H");
			else out.println("D");
		}else{
			if(b.equals("H"))out.println("D");
			else out.println("H");
		}
	}
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 21332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();
        long k = sc.NextLong();

        int length = s.Length;
        SortedSet<string> set = new SortedSet<string>();

        int left = 0;
        int right = 1;

        while (true)
        {
            string str = s.Substring(left, right - left);

            if (set.Count < k)
            {
                set.Add(str);
                right++;
                if (right > length)
                {
                    left++;
                    right = left + 1;
                }
            }
            else
            {
                var last = set.Last();
                if (string.Compare(last, str) == 1)
                {
                    if (!set.Contains(str))
                    {
                        set.Remove(last);
                        set.Add(str);
                    }
                    right++;
                    if (right > length)
                    {
                        left++;
                        right = left + 1;
                    }
                }
                else
                {
                    left++;
                    right = left + 1;
                }
            }

            if (right > length || left == length)
            {
                break;
            }
        }

        string answer = set.Last();

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(void) {
    int a, b;
    string s;
    bool flg = true;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    cin >> s;
    REP(i, a) {
        if (s[i] < '0' || '9' < s[i]) {
            flg = false;
        }
    }
    if (flg && s[a] != '-') {
        flg = false;
    }
    if (flg) {
        FOR(i, a + 1, s.length()) {
            if (s[i] < '0' || '9' < s[i]) {
               flg = false;
            }
        }
    }

    cout << (flg? "Yes" : "No") << "\n";
    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll ans = 1000;
vector<ll> A(100);

/*void dfs(ll money, ll kabu, ll i,ll N)
{
    if(i==N){
        ans = max(ans, money);
        return;
    }

    dfs(money, kabu, i + 1,N);

    
    ll tmp = money / A.at(i);
    if (tmp>=1){
        dfs(money - A.at(i) * tmp, kabu + tmp, i + 1, N);
    }
    if(kabu>=1){
        ll tmp1 = kabu * A.at(i);
        dfs(money + tmp1, 0, i + 1, N);
    }

}*/

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

    ll N;
    string S;
    cin >> N;

    
    REP(i,N){
        cin >> A.at(i);
    }

    //dfs(1000, 0, 0, N);

    ll money, kabu;

    money = 1000;
    kabu = 0;

    REPS(i,N-2){
        if(A.at(i-1)<=A.at(i)&&A.at(i)>=A.at(i+1)){
            money += kabu * A.at(i);
            kabu = 0;
        }
        if (A.at(i - 1) >= A.at(i) && A.at(i) <= A.at(i + 1)){
            ll tmp = money / A.at(i);
            kabu += tmp;
            money -= tmp * A.at(i);
        }
    }

    money += kabu * A.at(N - 1);

    ans = max(ans, money) ;

    kabu = 1000 / A.at(0);
    money = 1000 - kabu * A.at(0);

    REPS(i, N - 2)
    {
        if (A.at(i - 1) <= A.at(i) && A.at(i) >= A.at(i + 1))
        {
            money += kabu * A.at(i);
            kabu = 0;
        }
        if (A.at(i - 1) >= A.at(i) && A.at(i) <= A.at(i + 1))
        {
            ll tmp = money / A.at(i);
            kabu += tmp;
            money -= tmp * A.at(i);
        }
    }

    money += kabu * A.at(N - 1);
    ans = max(ans, money);

    cout << ans << endl;
}


Measured memory_bytes: 3616