akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
  while(true){
    int M, T, P, R;
    cin >> M >> T >> P >> R;
    if(M == 0 && T == 0 && P == 0 && R == 0){ break; }


    vector<vector<pair<bool, int> > > status(T, vector<pair<bool, int> >(P, make_pair(false, 0)));
    for(int i = 0; i < R; i++){
      int m, t, p, j;
      cin >> m >> t >> p >> j;
      --t;
      --p;
      if(status[t][p].first){ continue; }
      if(j == 0){
        status[t][p].first = true;
        status[t][p].second += m;
      }
      else{ status[t][p].second += 20; }
    }

    vector<pair<pair<int, int>, int> > team(T, make_pair(make_pair(0, 0), 0));
    for(int i = 0; i < T; i++){
      for(int j = 0; j < P; j++){
        if(status[i][j].first){
          --team[i].first.first;
          team[i].first.second += status[i][j].second;
        }
      }
      team[i].second = -(i + 1);
    }
    
    sort(team.begin(), team.end());
    for(int i = 0; i < T; i++){
      if(i != 0){
        if(team[i - 1].first.first == team[i].first.first
           && team[i - 1].first.second == team[i].first.second){
          cout << "=";
        }else{ cout << ","; }
      }
      cout << -team[i].second;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()
	s := "abcdefghij"
	buf := make([]byte, 10)

	var ff func(buf []byte, maxchar, slen int)
	ff = func(buf []byte, maxchar, slen int) {
		slen++
		maxchar++
		for i := 0; i <= maxchar; i++ {
			buf[slen-1] = s[i]
			if slen < n {
				ff(buf, []int{maxchar - 1, maxchar}[b2i(i == maxchar)], slen)
			} else {
				fmt.Fprintln(stdout, string(buf[:slen]))
			}
		}
	}
	ff(buf, -1, 0)
}


Measured memory_bytes: 5632
#include<bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
using ull = unsigned long long;
 
// #define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
 
 
signed main() {
    accell();
    string a, b;
    cin >> a >> b;
    cout << b + a << endl;
    return 0;
}


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

typedef std::vector<int> vi;
typedef std::pair<int, int> pii0;
using namespace std;

vi trackAr(26, 0);
vi numChar(26, 0);
vector<vi> trackPosition(26, vi());

void updatePast(long long& past, long long& repeat,const int& new_value){
	past = new_value;
	//cout << "past: " << past << endl;
}


int main(){
	string s, t;
	cin >> s >> t;
	
	for (auto i = 0; i < s.length(); i++){
		trackPosition[s[i] - 'a'].push_back(i + 1);
		numChar[s[i] - 'a'] += 1; //so luong chu cai 
	}

	long long repeat = 0;
	long long past = -1;

	for (auto i = 0; i < t.length(); i++){
		int tmp = t[i] - 'a';
		if (!numChar[tmp])
		{
			cout << -1 << endl;
			return 0;
		}
		if (i == 0){
			past = trackPosition[tmp][trackAr[tmp]];
			trackAr[tmp] = (trackAr[tmp] + 1) % numChar[tmp];
		}
		else
		{
			while (trackAr[tmp] < numChar[tmp] && past >= trackPosition[tmp].at(trackAr[tmp])){
				trackAr[tmp]++;
			}
			if (trackAr[tmp] == numChar[tmp])
			{
				repeat++;
				trackAr = vi(26, 0);
			}	
			updatePast(past, repeat, trackPosition[tmp][trackAr[tmp]]);
			trackAr[tmp]++;
		}
	}
	long long res = repeat * s.length() + past;
	cout <<  res << endl;
	//cin.ignore();
	//cin.get();
	return 0;
}


Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O2")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<pair<lli,int>, null_type,less<pair<lli,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 
template <typename T> 
void DEBUG_ARR(vt<T> a){
	f(i,0,a.size())cout<<a[i]<<" ";
	cout<<"\n";
}

int main() { 
    fastio;
    lli a,b;
    cin>>a>>b;
    cout<<a*b/__gcd(a,b)<<"\n";
    return 0; 	
}

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

int main() {
    int R;
    cin >> R;

    if (R >= 2800) {
        cout << "AGC" << endl;
    }
    else if (R < 2800 && R >= 1200) {
        cout << "ARC" << endl;
    }
    else if (R < 1200) {
        cout << "ABC" << endl;
    }

}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_A = (int)(1e5 + 5);
const int MAX_B = (int)(1e5 + 5);

int a, b, q;

ll s[MAX_A];
ll t[MAX_B];

ll solve(ll x) {
  // cout << "=================" << endl;
  int xs = lower_bound(s, s + a + 2, x) - s;
  int xt = lower_bound(t, t + b + 2, x) - t;

  vector<pair<ll, ll>> plan;

  plan.push_back(make_pair(s[xs], t[xt]));
  plan.push_back(make_pair(s[xs], t[xt - 1]));
  plan.push_back(make_pair(s[xs - 1], t[xt]));
  plan.push_back(make_pair(s[xs - 1], t[xt - 1]));
  plan.push_back(make_pair(t[xt], s[xs]));
  plan.push_back(make_pair(t[xt], s[xs - 1]));
  plan.push_back(make_pair(t[xt - 1], s[xs]));
  plan.push_back(make_pair(t[xt - 1], s[xs - 1]));

  ll tmp_ans = (3e10 + 5);

  for (auto e: plan) {
    ll now = x;
    ll tmp = 0;

    if (e.first >= now) {
      tmp += (e.first - now);
    }
    else {
      tmp += (now - e.first);
    }

    now = e.first;

    if (e.second >= now) {
      tmp += (e.second - now);
    }
    else {
      tmp += (now - e.second);
    }

    tmp_ans = min(tmp_ans, tmp);

    // cout << tmp_ans << "-" << x << ":" << e.first << "-" << e.second << endl;
  }
  // cout << "=================" << endl;

  return tmp_ans;
}

int main(void) {
  // Here your code !
  scanf("%d %d %d", &a, &b, &q);
  s[0] = (-1) * (3e10 + 5);
  t[0] = (-1) * (3e10 + 5);

  for (int i = 1; i <= a; ++i) {
    scanf("%lld", &(s[i]));
  }

  for (int i = 1; i <= b; ++i) {
    scanf("%lld", &(t[i]));
  }

  s[a + 1] = (3e10 + 5);
  t[b + 1] = (3e10 + 5);

  for (int i = 0; i < q; ++i) {
    ll x;
    scanf("%lld\n", &x);

    printf("%lld\n", solve(x));
  }

  return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	int n, m;

	while(true){
		scanf("%d %d\n",&n, &m);
		if(n==0 && m==0){return 0;}

		int* t = new int[n];
		int* h = new int[m];
		int t_sum=0, h_sum=0, d;
		bool flag = true;

		for(int i=0; i<n; i++){ cin >> t[i]; t_sum += t[i];}
		for(int i=0; i<m; i++){ cin >> h[i]; h_sum += h[i];}

		if( (t_sum + h_sum)%2 != 0 ){ cout << -1 << endl;} //全てのカードの合計値が奇数なら解なし
		else{ sort(t, t+n); sort(h, h+m); //ソートしておくと最小のペアが見つけやすい
			d = (h_sum - t_sum)/2; //交換するカードの差分
			for(int i=0; i<n; i++){
				if(!flag){break;}
				for(int j=0; j<m; j++){
					if((h[j]-t[i])==d){cout << t[i] << " " << h[j] << endl; flag=false; break;}
				}
			}
			if(flag){cout << -1 << endl;}
		}
		delete[] t; delete[] h;
	}
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split(' ');
            int A = int.Parse(ss[0]);
            int B = int.Parse(ss[1]);
            if (A < 6)
            {
                Console.WriteLine("0");
            }
            else if (A < 13)
            {
                Console.WriteLine(B / 2);
            }
            else
            {
                Console.WriteLine(B);
            }
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int a[100010];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	sort(a,a+n,greater<int>());
	int l=0;
	while(a[l+1]>l+1)l++;
	int x=a[l]-l-1,y=n-1;
	while(a[y]<=l)y--;
	y-=l;
	int f=0;
	if(x%2==1||y%2==1)f=1;
//	printf("%d %d\n",x,y);
	printf(f?"First":"Second");
}

Measured memory_bytes: 640
import sys 
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int,readline().split()))
Q = int(readline())
sum = sum(A)
d = defaultdict(int)

for i in range(N):
    d[A[i]] += 1
       
for i in range(Q):
    b, c = map(int,readline().split())
    sum += (c-b)*d[b]
    d[c] += d[b]
    d[b] = 0
    print(sum)

Measured memory_bytes: 24548
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

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

typedef long long ll;

string str;

ll dfs(int pos, ll now, ll sum) {
	if (pos == str.size())
		return now + sum;

	ll res = 0;
	
	res += dfs(pos + 1, str[pos] - '0', sum + now);
	res += dfs(pos + 1, now * 10 + (str[pos] - '0'), sum);
	
	return res;
}

int main() {
	cin >> str;
	cout << dfs(1, str[0] - '0', 0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979;

int main(){
    ios::sync_with_stdio(0);
    double a, b, x;
    cin >> a >> b >> x;
    double theata;
    if (x > a * a * b / 2){
        theata = atan(2.0 * (a * a * b - x) / (a * a * a));
    }
    else{
        theata = atan((a * b * b) / (2.0 * x));
    }
    theata *= (180.0 / pi);
    cout << setprecision(10) << fixed << theata << "\n";
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




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

    int N;
    cin >> N;
    vector<long long> A(N), B(N), C(N-1);
    for (int i = 0; i < N; ++i) cin >> A[i], --A[i];
    for (int i = 0; i < N; ++i) cin >> B[i];
    for (int i = 0; i < N-1; ++i) cin >> C[i];

    long long res = 0;
    for (int i = 0; i < N; ++i) {
        res += B[A[i]];
        if (i && A[i] == A[i-1] + 1) res += C[A[i-1]];
    }
    cout << res << endl;
}


















Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
m1 = A[-1]
m2 = m1 // 2 + int(m1 % 2 == 1)
ans = [m1, 0]
tmp = 10**9 + 1

for a in A[:len(A) - 1]:
    if tmp > abs(m2 - a):
        tmp = abs(m2 - a)
        ans[1] = a

print(*ans)

Measured memory_bytes: 62704
#include <iostream>
using namespace std;
 int main()
   {
     int N,s=0;
     cin>>N;
     int a[N];
     for(int i=1;i<=N;i++)
        {
          cin>>a[i];
          if(a[i]%2!=0&&i%2!=0)
            {
              s++;
            }
        }
    cout<<s<<endl ;
  
   }

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

bool has_key(unordered_map<string, ll> &m, string s){
    if (m.find(s) == m.end()){
        return false;
    }
    else{
        return true;
    }
}


bool vector_find(std::vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) {
    return true;
  }
  else {
    return false;
  }
}


void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}


void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}



int main() {
    
    ll N, M;
    cin >> N >> M;

    vector<ll> A(N);
    vector<ll> B(N);
    vector<vector<ll>> C(N, vector<ll>(2));

    for (ll i = 0; i < N; i++) {
      cin >> C.at(i).at(0) >> C.at(i).at(1);
    }
    

    sort(C.begin(),C.end(),[](const vector<ll> &alpha,const vector<ll> &beta){return alpha[0] < beta[0];});

    ll ans = 0;

    for (ll i = 0; i < N; i++) {
      
      if (C.at(i).at(1) < M) {
        M = M - C.at(i).at(1);
        ans = ans + C.at(i).at(1) * C.at(i).at(0);
      } else {
        ans = ans + M * C.at(i).at(0);
        break;
      }
    }
    

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 7296
import java.util.Scanner;

class Main{
  public static void main(String[] args) throws Exception{
	  Scanner sc = new Scanner(System.in);
	  String a = sc.next();
	  if(Character.isUpperCase(a.charAt(0))) {
		 System.out.println("A");
	  }
	  else {
		  System.out.println("a");
	  }
  }
}

Measured memory_bytes: 35452
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int f=0;
  if(a==1){
    f=f+300000;
  }else if(a==2){
    f=f+200000;
  }else if(a==3){
    f=f+100000;
  }
  if(b==1){
    f=f+300000;
  }else if(b==2){
    f=f+200000;
  }else if(b==3){
    f=f+100000;
  }
  if(a==1&&b==1){
    f=f+400000;
  }
  cout << f <<endl;
  return 0;
}

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

int main()
{
   long long n, m;
   cin >> n >> m;

   if (n == 1 && m == 1) cout << 1 << endl;
   else if (n == 1 && m > 1) cout << m-2 << endl;
   else if (n > 1 && m == 1) cout << n-2 << endl;
   else cout << (n-2)*(m-2) << endl;

   return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    map<string, int> mp;
    rep(i, n) mp[s[i]]++;

    int cnt = 0;
    for (auto&& p : mp) cnt++;

    if (cnt == 4) cout << "Four" << endl;
    else cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var inputA, inputB int
	fmt.Scanf("%d %d", &inputA, &inputB)

	fmt.Printf("%d\n", leastMultiple(inputA, inputB))
}

func leastMultiple(pA, pB int) int {
	mulA := 1
	mulB := 1
	checkA := pA
	checkB := pB

	var i int
	for i = 0; i < 1000000; i++ {
		if checkA == checkB {
			return checkA
		}

		if checkA > checkB {
			mulB++
			checkB = pB * mulB
		} else {
			mulA++
			checkA = pA * mulA
		}
	}

	return 0
}


Measured memory_bytes: 512
#include <cstdint>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

struct Edge
{
    int node;
    int cost;

    bool operator<(const Edge &other) const
    {
        return cost > other.cost;
    }
};

using Graph = vector<vector<Edge>>;

Graph BuildGraph(int num)
{
    Graph graph(num);
    for (int i = 0; i < num; i += 1) {
        graph[i].push_back({(i + 1) % num, 1});
        graph[i].push_back({(i * 10) % num, 0});
    }
    return graph;
}

int MinDist(const Graph &g, int start, int stop)
{
    vector<int> dist(g.size(), (1 << 30));
    dist[start] = 0;

    priority_queue<Edge> heap;
    heap.push({start, 0});

    while (!heap.empty()) {
        int node = heap.top().node;
        int cost = heap.top().cost;
        heap.pop();

        if (cost > dist[node]) {
            continue;
        }
        if (node == stop) {
            break;
        }

        for (const auto &e : g[node]) {
            if (dist[node] + e.cost < dist[e.node]) {
                dist[e.node] = dist[node] + e.cost;
                heap.push({e.node, dist[e.node]});
            }
        }
    }
    return dist[stop];
}

int Solve(int num)
{
    auto graph = BuildGraph(num);
    return MinDist(graph, 1, 0) + 1;
}

int main()
{
    int num;
    cin >> num;

    int res = Solve(num);
    cout << res << "\n";

    return 0;
}


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

int main() {
    int N, K;
  cin >> N >> K;
  string s;
  cin >> s;

  int ans = 0, r = 0, cont = 0;

  if (s[0] == '0') cont++;

  for (int l = 0; l < N; l++) {

    while (cont <= K && r < N) {
      if (r + 1 < N && s[r] == '1' && s[r + 1] == '0') cont++;
      r++;
    }

    ans = max(ans, r - l);

    if (l + 1 < N && s[l] == '0' && s[l + 1] == '1') cont--;
  }

  cout << ans << endl;
}

Measured memory_bytes: 512
a,b,c,d =map(int,input().split())

A=a*c
B=a*d
C=b*c
D=b*d

if A>=B and A>=C and A>=D:
    print(A)

elif B>=A and B>=C and B>=D:
    print(B)

elif C>=A and C>=B and C>=D:
    print(C)

elif D>=A and D>=B and D>=C:
    print(D)
   

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
 
 
int main()
{
	long long n;  cin>>n;
	string s;
	int a=0;
	int b=0;
	int c=0;
	int d=0; 
	for(int i=0;i<n;i++)
	{
		cin>>s;
		
		if(s=="AC" ) {
			a++;
		}
			if(s=="WA" ) {
			b++;
		}
			if(s=="TLE" ) {
			c++;
		}
			if(s=="RE" ) {
			d++;
		}
	
	}
	
	
	cout<<"AC x " <<a<<endl;
	cout<<"WA x " <<b<<endl;
	cout<<"TLE x " <<c<<endl;
	cout<<"RE x " <<d<<endl;
	//cout<<"AC"<<" "<<"*"<<" " <<a<<endl;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<iostream>
#include<algorithm>
#define m(a,b) memset(a,b,sizeof(a));
using namespace std;
const int maxn = 1e4;
const int inf = 1<<30;
typedef long long LL;
int k;
int n;
int main(){
	cin >> n >> k;
	map<int,int>m;
	int a;
	for(int i = 0;i<k;i++){
		cin >> a;
		m[a] = 1;
	}
	for(int i = n;;i++){
		bool ans = true;
		int a = i;
		while(a){
			int b = a%10;
			if(m[b]) {ans = false;break;}
			a/=10;
		}
		if(ans) {n = i;break;}
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines

MOD = 10**9 + 7

N,X,Y = map(int,readline().split())
CW = (tuple(int(x) for x in line.split()) for line in readlines())

C_to_W = [[] for _ in range(N+1)]
for c,w in CW:
    C_to_W[c].append(w)

for c in range(N+1):
    C_to_W[c].sort()

C_to_W.sort()

C_to_W = [x for x in C_to_W if x]

min_wt = C_to_W[0][0]
C_to_W = [x for x in C_to_W if x[0]+min_wt <= Y]

if len(C_to_W) <= 1:
    print(1)
    exit()

comp_size = [0] * (len(C_to_W))
for x in C_to_W[0]:
    if x+C_to_W[0][0] <= X or x + C_to_W[1][0] <= Y:
        comp_size[0] += 1

for i,arr in enumerate(C_to_W[1:],1):
    for x in arr:
        if x+min_wt <= Y or x+arr[0] <= X:
            comp_size[i] += 1

fact = [1] * (N+1)
for i in range(1,N+1):
    fact[i] = fact[i-1] * i % MOD

num = fact[sum(comp_size)]
den = 1
for x in comp_size:
    den *= fact[x]
    den %= MOD
answer = num * pow(den,MOD-2,MOD) % MOD
print(answer)

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


int main() {
    int N,val1;
    vector<int> seqe;
    cin >> N;
    for (int i=0; i<N; ++i) {
        cin >> val1;
        seqe.push_back(val1);
    }
    for (int i=seqe.size()-1; i>-1; --i) {
        if (i== 0) {
            cout << seqe[i];
        }else{
            cout << seqe[i] << ' ';
        }
    }
    cout << endl;
    
    return 0;
}




Measured memory_bytes: 3128
require 'prime'

# 約数リスト
def divisors(n)
  n.prime_division.inject([1]) do |array, (k, v)|
    (0..v).map{ |i| k ** i }.product(array).map{ |a, b| a * b }
  end.sort
end

n = gets.to_i
n_divisors = divisors(n)
ans = 0
n_divisors.each do |num|
  tmp = n - num
  next if tmp < 1
  divisor = tmp / num
  ans += divisor if num == n % divisor
end
puts ans

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

int main()
{
    int k, s;
    int ans = 0;
    cin >> k >> s;
    
    for (int a = 0; a <= k; a++) {
        for (int b = 0; b <= k; b++) {
            int sum = s - a - b;
            if (sum >= 0 && k - sum >= 0) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
r,s,p = map(int, input().split())
S = input()
ans = 0
for i in range(k):
    Ssep = S[i::k] 
    flg = False
    for j in range(len(Ssep)):
        if j >= 1 and Ssep[j] == Ssep[j-1] and not flg:
            flg = True
            continue
        if Ssep[j] == "r":
            ans += p
        if Ssep[j] == "s":
            ans += r
        if Ssep[j] == "p":
            ans += s
        flg = False
print(ans)

Measured memory_bytes: 3444
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>

using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(int i=n;i<(int)(m);i++)


int main() {


	string str;

	cin >> str;

	bool flag = true;

	vector<int>word(26, 0);

	for (int i = 0; i < str.size(); i++) {

		word[str[i]-'a' ]++;
		if (2 <= word[str[i]-'a'])flag = false;

	}

	
	if (flag)cout << "yes" << endl;
	else cout << "no" << endl;

	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define N 2200
#define mod 1000000007
using namespace std;
int f[N][N],s[N],n,k,ans;//设f[i][j]表示已经选取了1~i个位置 最小的那个数是j的方案数 
int main(){
    //freopen("arc.in","r",stdin);
    scanf("%d%d",&n,&k);f[0][n+1]=1;s[n+1]=1;
    for (int i=n;i>=1;--i) s[i]=s[i+1]+f[0][i];
    for (int i=1;i<=k-1;++i){
        for (int j=1;j<=n-i+1;++j) f[i][j]=s[j];
        s[n+1]=f[i][n+1];for (int j=n;j>=1;--j) s[j]=(s[j+1]+f[i][j])%mod;
    }for (int i=2;i<=n+1;++i) (ans+=f[k-1][i])%=mod;
    for (int i=1;i<=n-k-1;++i) (ans*=2)%=mod;printf("%d",ans);
    return 0;
}

Measured memory_bytes: 18560
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <map>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int main(){
  string s;
  cin >> s;
  for(int i=s.size();i--;)
    cout << s[i];
  cout << endl;
}

Measured memory_bytes: 1176
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        for(int i=0;i<s.length()-1;i++){
            if(s.charAt(i)==s.charAt(i+1)){
                System.out.println((i+1)+" "+(i+2));
                return;
            }
        }
        for(int i=0;i<s.length()-2;i++){
            if(s.charAt(i)==s.charAt(i+2)){
                System.out.println((i+1)+" "+(i+3));
                return;
            }
        }
        System.out.println("-1 -1");
    }
    
 
}

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

int main(){
    int h, m, s;
    cin >> s;
    
    h = s / 3600; s %= 3600;
    m = s /60; s %= 60;
    
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3100
import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO Int
readInt = fst . fromJust . BS.readInt <$> BS.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readIntLists :: Int -> IO [[Int]]
readIntLists n = replicateM n readInts

readInteger :: IO Integer
readInteger = fst . fromJust . BS.readInteger <$> BS.getLine

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegerLists :: Int -> IO [[Integer]]
readIntegerLists n = replicateM n readIntegers

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n <$> readStrings

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = print n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStrLn n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

divCeiling x n | b == 0    = a
               | otherwise = a + 1
  where (a, b) = x `divMod` n

main = do
  n  <- readInt
  as <- readIntegers
  print $ sum $ zipWith (\n x -> if odd n then x else 0) [1 ..] $ drop n $ sort
    as


Measured memory_bytes: 51580
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int N, M, dp[MAX];
vector<int> adj[MAX];

int dfs(int cur){
    int &ret = dp[cur];
    if(ret != -1)   return ret;
    ret = 0;
    for(auto &next : adj[cur]){
        ret = max(ret, dfs(next) + 1);
    }
    return ret;
}

int main(){
    memset(dp, -1, sizeof(dp));
    scanf("%d %d", &N, &M);
    for(int i = 1; i <= M; i++){
        int u, v;
        scanf("%d %d", &u, &v);
        adj[u].push_back(v);
    }
    int ans = 0;
    for(int i = 1; i <= N; i++){
        ans = max(ans, dfs(i));
    }
    printf("%d\n", ans);
    return 0;
}


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

namespace Palindromephilia
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().ToCharArray();
            int middleSize = input.Count() / 2;
            int hugs = 0;

            if (input.Count() % 2 != 0)
            {
                for (int i = 0; i < middleSize + 1; i++)
                {
                    if (input[i] != input[input.Count() - i - 1])
                    {
                        input[input.Count() - i - 1] = input[i];
                        hugs++;
                    }
                }
            }

            if (input.Count() % 2 == 0)
            {
                for (int i = 0; i < middleSize + 1; i++)
                {
                    if (input[i] != input[input.Count() - i - 1])
                    {
                        input[input.Count() - i - 1] = input[i];
                        hugs++;
                    }
                }
            }
            Console.WriteLine(hugs);
        }
    }
}

Measured memory_bytes: 11220
# https://atcoder.jp/contests/abc109/tasks/abc109_c

n, x = map(int, input().split())
nums = [int(i) for i in input().split()]

def gcd(x, y): #GCD
    # greatest_common_divisor
    if x < y:
        x, y = y, x
    if y == 0:
        return 0
    if x % y == 0:
        return y
    return gcd(y, x % y)

ans = abs(x - nums[0])
for num in nums:
    d = abs(x - num)
    ans = gcd(d, ans)
print(ans)

Measured memory_bytes: 62576
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll h,w,n;
  cin >> h >> w >> n;
  cout << (n-1)/max(h,w)+1 << endl;
}

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


Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const int maxn = 1000005;

int main() {
   // freopen("in.cpp","r",stdin);
    int x,y;
    while(cin>>x>>y) {
        int ret = 0;
        if(x==0||y==0) {
            if(x==0) {
                if(y>0) {
                    ret = y;
                } else {
                    ret = -y + 1;
                }
            } else {
                if(x<0) {
                    ret = -x;
                } else {
                    ret = x + 1;
                }
            }
        } else {
            if(x>=0) {
                if(y>=x) {
                    ret = y - x;
                } else {
                    if(y>=0) {
                        ret = 2 + x - y;
                    } else {
                        if(abs(y)>=x) {
                            ret = abs(y) - x + 1;
                        } else {
                            ret = 1 + y + x;
                        }
                    }
                }
            } else {
                if(y>=0) {
                    if(y>=abs(x)) {
                        ret = 1 + y + x;
                    } else {
                        ret = -y - x + 1;
                    }
                } else {
                    if (y>=x) {
                        ret = y - x;
                    } else {
                        ret = 1 + abs(y) - abs(x) + 1;
                    }
                }
            }
        }
        cout<<ret<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
from math import gcd

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    if k > max(A):
        print("IMPOSSIBLE")
        exit()

    g = A[0]
    for a in A:
        g = gcd(g, a)

    print("POSSIBLE" if k % g == 0 else "IMPOSSIBLE")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 20192
import sys
input=sys.stdin.readline
 
cardamt,sousa=map(int,input().split())
init=list(map(int,input().split()))
cardlist=[(1,a) for a in init]
for i in range(sousa):
    add=tuple(map(int,input().split()))
    cardlist.append(add)
cardlist.sort(reverse=True, key=lambda x:x[1])
result,totalcard,idx=0,0,0
while(totalcard<cardamt):
    newcardamt=cardlist[idx][0]
    if totalcard+newcardamt<=cardamt:
        totalcard=totalcard+newcardamt
        result=result+cardlist[idx][1]*newcardamt
    else:
        cardamtdelta=cardamt-totalcard
        totalcard=totalcard+cardamtdelta
        result=result+cardlist[idx][1]*cardamtdelta
    idx+=1
    #print(result,totalcard)
print(result)

Measured memory_bytes: 32580
object Main extends App {

  import scala.io.StdIn._

  solve
  def solve:Unit = {
    val n = readInt
    if (n == 0) return
    val count = Array.tabulate(10){_ ⇒ 0}
    for (_ ← 0 until n){
      count(readInt) += 1
    }
    println(count.map(i ⇒ if (i == 0) "-" else "*" * i).mkString("\n"))
    solve
  }
  implicit class Extension[T](val value :T) extends AnyVal {
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


Measured memory_bytes: 49104
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  long long A,B,C;
  cin >> A >> B >> C;

  if(A == B && B == C && C == A) {
    if(A % 2 == 0) {
      cout << -1 << endl;
      return 0;
    }else {
      cout << 0 << endl;
      return 0;
    }
  }

  int ans = 0;
  while(A%2==0 && B%2==0 && C%2==0) {
    long long a = A/2,b = B/2,c=C/2;
    A = b+c;
    B = a+c;
    C = a+b;
    ans++;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;//A:TH B:TS C:AH D:AS
	for(int i = 0; ; i++){
		c -= b;
		if(c <= 0){
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if(a <= 0){
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int A;
	
	cin >> A;

	ll ori = 1;
	for (int i = 1; i <= A; i++)
	{
		ori = (ori * i) % MOD;
	}

	cout << ori << endl;

	
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    cin >> S;
    ll ans = 700;
    iter(c, S) ans += 100 * (c == 'o');
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

int main(){
long long N ;
string S;
cin >> N;
cin >> S;
vector<long long> cnt(N+1,0);
for(int i = 0;i < N;i++){
	cnt[i+1] = cnt[i];
	if(S[i] == 'W')cnt[i+1]++;
}

long long ans = INF;
for(int i = 1; i<= N;i++){
ans = min(((N-i)-(cnt[N]-cnt[i])+cnt[i-1]),ans);
}
cout << ans << endl;
}



Measured memory_bytes: 3076
from bisect import bisect_left
n = int(input())
ss = input()
ans = 0

d = {str(i):[] for i in range(10)}
for i,c in enumerate(ss):
    d[c].append(i)

for i in range(1000):
    a,b,c = str(i).zfill(3)
    if d[a] == [] or d[b] == [] or d[c] == []:
        continue
    x,z = d[a][0], d[c][-1]
    y = bisect_left(d[b], x+1)
    if y >= len(d[b]):
        continue
    tmp = [x, d[b][y], z]
    if tmp[0] < tmp[1] and tmp[1] < tmp[2]:
        ans += 1

print(ans)

Measured memory_bytes: 4468
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;

    pii xy[100];
    REP(i, N) {
        int x, y;
        cin >> x >> y;
        xy[i] = {x, y};
    }
    sort(xy, xy + N, [](const pii &p1, const pii&p2) { return atan2(p1.second, p1.first) < atan2(p2.second, p2.first); });


    double ans = 0;
    REP(i, N) {
        ll x = 0, y = 0, r = i;
        REP(j, N) {
            x += xy[r].first;
            y += xy[r].second;
            ans = max(ans, sqrt(x * x + y * y));
            r = (r + 1) % N;
        }
    }
    cout << setprecision(30) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	float a,b;
	while(1){
	if( -1 == scanf("%f %f",&a,&b) )
		break ;
	
	if(a<35.50&&b<71.00){
		printf("AAA\n");
	}
	else if(a<37.50&&b<77.00){
		printf("AA\n");
	}
	else if(a<40.00&&b<83.00){
		printf("A\n");
	}
	else if(a<43.00&&b<89.00){
		printf("B\n");
	}
	else if(a<50.00&&b<105.00){
		printf("C\n");
	}
	else if(a<55.00&&b<116.00){
		printf("D\n");
	}
	else if(a<70.00&&b<148.00){
		printf("E\n");
	}
	else{
		printf("NA\n");
	}
	}
	return 0;
}

Measured memory_bytes: 2680
#include<stdio.h>

int main(void)
{
  int sum;
  int n[5000];
  int a=0,i,j,x=0,k;

  while(scanf("%d",&k) != EOF){
    if(k==0)
      break;

    for(i=0; i<k; i++){
      scanf("%d",&n[i]);
    }

    x=-10000000;
    for(i=0; i<k; i++){
      sum =0; 
      for(j=i; j<k; j++){
	sum=sum+n[j];
	if(x<sum)
	  x=sum;
      }
    }
    printf("%d\n",x);
  }

  return 0;
}

Measured memory_bytes: 616
#include<bits/stdc++.h>
using namespace std;
#define REPS(i,s,e) for(int i=(s);i<(e);i++)

void Push(queue<vector<int>>&q,int i,int j){
  q.push(vector<int>(2));
  q.back()[0] = i; q.back()[1] = j;
}

int main(){
  int H,W; cin >> H >> W;
  const int INF = H+W+5;
  string str;
  vector<vector<int>> table(H+2,vector<int>(W+2,INF));
  queue<vector<int>> q;
  REPS(i,1,H+1){
    cin >> str;
    REPS(j,1,W+1){
      if(str[j-1]=='#'){
        Push(q,i,j);
        table[i][j] = 0;
      }else{
        table[i][j] = INF-1;
      }
    }
  }
  while(!q.empty()){
    int i = q.front()[0];
    int j = q.front()[1];
    int c = table[i][j] + 1;
    int u = table[i-1][j];
    int d = table[i+1][j];
    int l = table[i][j-1];
    int r = table[i][j+1];
    if(u<INF&&u>c){
      table[i-1][j] = c;
      Push(q,i-1,j);
    }
    if(d<INF&&d>c){
      table[i+1][j] = c;
      Push(q,i+1,j);
    }
    if(l<INF&&l>c){
      table[i][j-1] = c;
      Push(q,i,j-1);
    }
    if(r<INF&&r>c){
      table[i][j+1] = c;
      Push(q,i,j+1);
    }
    q.pop();
  }

  int m = 0;
  REPS(i,1,H+1){
    REPS(j,1,W+1){
      if(m<table[i][j]){
        m = table[i][j];
      }
    }
  }
  cout << m << endl;

  return 0;
}

Measured memory_bytes: 59700
import java.util.Scanner;
import java.util.Arrays;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                int N = scan.nextInt();
                int[] costs = new int[N];
                int[] cache = new int[N];
                for(int i = 0 ; i < N ; i++) {
                        costs[i] = scan.nextInt();
                        cache[i] = 2147483647;
                }
                cache[0] = 0;
                cache[1] = Math.abs(costs[1]-costs[0]);
                System.out.println(jump(costs, 2, cache));
                return;
        }

        private static int jump(int[] costs, int k, int[] cache) {
                for(int i = 2 ; i < costs.length ; i++) {
                    //for(int j = i-1 ; j >= i-k ; j--){
                        //cache[i] = Math.min(cache[i], cache[j]+(Math.abs(costs[i] - costs[j])));
                    //}
                    cache[i] = Math.min(cache[i-1]+Math.abs(costs[i-1]-costs[i]), cache[i-2]+Math.abs(costs[i-2]-costs[i]));
                }
                return cache[costs.length-1];
        }
}

Measured memory_bytes: 60292
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * for (int i = 0; i < N; i++) {}
 * System.out.println();
 * HashMap<Integer, Integer> hm = new HashMap<>();
 * int[] s = new int[M];
 * ArrayDeque<Integer> deq = new ArrayDeque<>();
 *
 */
public class Main implements Runnable { //クラス名はMain1

	public static void main(String[] args) {
		Thread.setDefaultUncaughtExceptionHandler((t, e) -> System.exit(1));
		new Thread(null, new Main(), "", 1024 * 1024 * 1024).start(); //16MBスタックを確保して実行
	}

	public void run() {
		FastScannerMainD sc = new FastScannerMainD(System.in);

		try {
			int N = sc.nextInt();
			Integer[] arr = new Integer[N];
			for (int i = 0; i < N; i++) {
				arr[i] = sc.nextInt();
			}

			int count = 0;
			int num = 0;
			for (int i = 0; i < N; i++) {
				if ((count + 1) == arr[i]) {
					count++;
				} else {
					num++;
				}
			}

			//System.out.println(count);
			//System.out.println(num);
			if (count == 0) {
				System.out.println(-1);
			} else {
				System.out.println(num);
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}

//高速なScanner
class FastScannerMainD {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScannerMainD(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

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

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

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

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

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

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


Measured memory_bytes: 50180
#include <iostream>

using namespace std;

int main()
{
    int S[31]={0};
    int tmp;

    for(int i=0; i<28; ++i) {
        cin >> tmp;
        S[tmp]=1;
    }
    for(int i=1; i<=30; ++i) {
        if(S[i]==0) {
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3084