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

object Main {
  def solve(sc: Scanner, n: Int, m: Int, loop: Int, point: Array[Int], target: Array[Int]): Array[Int] = {
    if (m == loop) {
      point
    } else {
      for (i <- 0 until n) {
        val v: Int = sc.nextInt - 1
        if (v == target(loop)) {
          point(i) += 1
        } else {
          point(target(loop)) += 1
        }
      }
      solve(sc, n, m, loop + 1, point, target)
    }
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val n: Int = sc.nextInt
    val m: Int = sc.nextInt
    val point: Array[Int] = new Array[Int](n)
    val target: Array[Int] = new Array[Int](m).map(_ => sc.nextInt - 1)
    solve(sc, n, m, 0, point, target).foreach(println)
  }
}

Measured memory_bytes: 56080
#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
#include <map>
#include <cctype>
using namespace std;

#define f first
#define s second

char mas[1111][1111];
int used[1111][1111];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int w,h,sy,sx,n,len = 0;
typedef pair<int,int> P;
vector <P> pi(10);

int bfs(){
  memset(used,-1,sizeof(used));
  queue <P> que;
  que.push(P(sx,sy));
  used[sy][sx] = 0;
  while(!que.empty()){
    P p = que.front();
    que.pop();
    if(p.f == pi[len].f && p.s == pi[len].s){
      len++;
      sx = p.f;
      sy = p.s;
      return used[p.s][p.f];
    }
    for(int i=0;i<4;i++){
      int nx = p.f + dx[i];
      int ny = p.s + dy[i];
      if(nx >= 0 && nx < w && ny >= 0 && ny < h && mas[ny][nx]!='X'&& used[ny][nx] == -1){
	que.push(P(nx,ny));
	used[ny][nx] = used[p.s][p.f] + 1;
      }
    }
  }
}


int main(){
  cin >> h >> w >> n;
  char value = '1';
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> mas[i][j];
      if(mas[i][j] == 'S'){
	sx = j;
	sy = i;
      }
      else if(isdigit(mas[i][j])) pi[mas[i][j]-'0'-1] = P(j,i);
    }
  }
  int ans = 0;
  for(int i=0;i<n;i++) ans += bfs();
  cout << ans << endl;
}

Measured memory_bytes: 7128
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	sum := 0.0
	for i := 0; i < n; i++ {
		var (
			x float64
			u string
		)
		fmt.Scan(&x, &u)
		if u == "BTC" {
			sum += x * 380000.0
		} else {
			sum += x
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec vector<ll>
#define pll pair<ll,ll>
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define inf 100000000000000
#define minf -100000000000000
#define maxi 100005

int main()
{
    fastread;
    int n;
    cin>>n;
    map<pair<int,int>,int > ma;
    for(int i=1;i<=n;i++){
    	int last = i % 10,temp = i;
    	while(temp > 9){
    		temp = temp / 10;
    	}
    	int first = temp;
    	ma[{first,last}] ++ ;
    }
    int ans = 0;
    for(auto ite:ma){
    	int first = (ite).fx.fx;
    	int second = (ite).fx.sx;
    	int cnt = ite.sx;
    	ans += cnt * ma[{second,first}];
    }
    cout<<ans<<endl;
    return 0;
}

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

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

    int check_num = 0;
    for (int i = 0; i >= 0; i++) {
        check_num = X + i;
        int cnt = 0;
        for (int t = 2; t < check_num; t++) {
            if(check_num % t == 0) {
                cnt++;
                break;
            }
        }
        if (cnt == 0) break;
    }

    cout << check_num << endl;
	return 0;
}   

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    char s[100000];
    scanf("%s",s);
    int cnt1=0,cnt2=0;
    int i=0,j=0;
    while(i<strlen(s)){
        if(s[i]=='0'){
            cnt1++;
        }else{
            ;
        }
        i++;
        if(s[i]=='1'){
            cnt1++;
        }else{
            ;
        }
        i++;
    }
    while(j<strlen(s)){
        if(s[j]=='1'){
            cnt2++;
        }else{
            ;
        }
        j++;
        if(s[j]=='0'){
            cnt2++;
        }else{
            ;
        }
        j++;
    }
    (cnt1>cnt2)?printf("%d",cnt2):printf("%d",cnt1);
}



Measured memory_bytes: 1832
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  string a,b;cin>>a>>b;
  int c=a.size(),d=b.size();
  if(c>d){
    cout<<"GREATER"<<endl;
    return 0;
  }
  else if(c<d){
    cout<<"LESS"<<endl;
    return 0;
  }
  else {
    rep(i,c){
      if(a[i]==b[i])continue;
      else if(a[i]>b[i]){
        cout<<"GREATER"<<endl;
        return 0;
      }
      else {
        cout<<"LESS"<<endl;
        return 0;
      }
    }
  }
  cout<<"EQUAL"<<endl;
}

Measured memory_bytes: 3540
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] t = new int[n+1];
		int[] x = new int[n+1];
		int[] y = new int[n+1];

		t[0] = 0;
		x[0] = 0;
		y[0] = 0;

		for(int t_i = 0; t_i < n; t_i++) {
			t[t_i + 1] = scan.nextInt();
			x[t_i + 1] = scan.nextInt();
			y[t_i + 1] = scan.nextInt();

			int dt = t[t_i+1] - t[t_i];
			int dist = Math.abs(x[t_i+1] - x[t_i]) + Math.abs(y[t_i+1] - y[t_i]);

			if ((dist>dt) || ((dt % 2) != (dist % 2))) {
					System.out.println("No");
					return;
			}
		}
		System.out.println("Yes");
	}

}


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

int main(void)
{
	char str[2001];
	int i;
	int k;
	int n;
	
	scanf("%d", &n);
	fgets(str, 2001, stdin);
	
	for(k = 0; k < n; k++){	
		fgets(str, 2001, stdin);
		
		str[strlen(str) - 1] = '\0';
		
		if (strlen(str) >= 7){
			for (i = 0; str[i + 6] != '\0'; i++){
				if (strncmp("Hoshino", &str[i], 7) == 0){
					strncpy(&str[i], "Hoshina", 7);
				}
			}
		}
		printf("%s\n", str);
	}
	return (0);
}

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

using namespace std;
using ll = long long;

ll a,b,c,d,e,f,g,h,i,j,k,n,m,l;
string S,T;


int main()
{
    //cin >> N;
    //cin >> a >> b;
    //cin >> S >> T;
    int N,Q;cin >> N >> Q;
    string s;cin >> s;
    vector<int> v;
    v.push_back(0);
    for(int i = 0;i < N-1;i++){
        if(s[i] == 'A' && s[i + 1] == 'C'){
            v.push_back(v.back()+1);
        }else{
            v.push_back(v.back());
        }
    }
    for(int i = 0;i < Q;i++){
        int l,r;cin >> l >> r;
        cout<<v[r-1] - v[l-1]<<endl;
    }
}


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

int main ()
{
    int n;
    cin>> n;
    vector<int> mochi(n);
    for(int i=0;i<n;i++)
    {
        cin>>mochi.at(i);
    }

    sort(mochi.begin(),mochi.end());

    int ans=1;
    for(int i=1;i<n;i++)
    {
        if(mochi.at(i)!=mochi.at(i-1))
        ans+=1;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b // a を b の倍数値まで増やす
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;} // a / b 以上の最小整数
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	bool n = false;
	bool w = false;
	bool s = false;
	bool e = false;
	string S;
	cin>>S;
	REP(i, S.size()) {
		if(S[i] == 'N') n = true;
		if(S[i] == 'W') w = true;
		if(S[i] == 'S') s = true;
		if(S[i] == 'E') e = true;
	}
	if((n && s) || (!n && !s)) {
		if((w && e) || (!w && !e)) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	} else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

#define MAX_V 1000
int V;
VI G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v) {
  G[u].PB(v);
  G[v].PB(u);
}

bool dfs(int v) {
  used[v] = true;
  REP(i, G[v].size()) {
    int u = G[v][i], w = match[u];
    if(w < 0 || !used[w] && dfs(w)) {
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching() {
  int res = 0;
  memset(match, -1, sizeof(match));
  REP(v, V) {
    if(match[v] < 0) {
      memset(used, 0, sizeof(used));
      if(dfs(v)) res++;
    }
  }
  return res;
}

bool use[805];
int x[805], y[805];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, a, b;
  cin >> n >> a >> b;
  REP(i, n) cin >> x[i] >> y[i];

  int ans = 0;
  REP(i, n) {
    if(abs(x[i]-y[i]) <= a || (b <= abs(x[i]-y[i]) && abs(x[i]-y[i]) <= 2*a)) {
      use[i] = true;
      ans++;
      // cout << i << endl;
    }
  }

  vector<PII> e;
  VI v;
  REP(i, n) FOR(j, i+1, n) {
    if(use[i] || use[j]) continue;
    int diff = abs(x[i]+x[j]-y[i]-y[j]);
    if(diff <= a || (b <= diff && diff <= 2*a)) {
      e.PB({i, j});
      v.PB(i); v.PB(j);
    }
  }

  VI vv = v;
  VI trans(n+5);
  sort(ALL(vv)); vv.erase(unique(ALL(vv)), vv.end());
  REP(i, v.size()) {
    v[i] = lower_bound(ALL(vv), vv[i]) - vv.begin();
    trans[vv[i]] = v[i];
  }

  V = vv.size();
  REP(i, e.size()) add_edge(trans[e[i].first], trans[e[i].second]);

  cout << ans + bipartite_matching() << endl;

  return 0;
}



Measured memory_bytes: 5608
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 200001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

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

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

int main(){
  ll n,m; cin >> n >> m;
  vl imos(n);
  
  rep(i,m){
    ll left,right; cin >> left >> right;
    imos[left-1]++;
    if(right != n) imos[right]--;
  }
  
  rep(i,n-1){
    imos[i+1] += imos[i];
  }
  
  ll ans = 0;
  rep(i,n){
    if(imos[i] == m) ans++;
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 4012
N,M,L,Q;
D[301][301];
i,j,k;
a,b,c;
main()
{
	scanf("%d%d%d",&N,&M,&L);
	for(i=1;i<=N;i++)for(j=i+1;j<=N;j++)D[i][j]=D[j][i]=1000000001;
	for(i=0;i<M;i++)
	{
		scanf("%d%d%d",&a,&b,&c);
		D[a][b]=D[b][a]=c;
	}
	for(k=1;k<=N;k++)for(i=1;i<=N;i++)for(j=1;j<=N;j++)
		if(D[i][j]>D[i][k]+D[k][j])D[i][j]=D[i][k]+D[k][j];
	for(i=1;i<=N;i++)for(j=1;j<=N;j++)
	{
		D[i][j]=D[i][j]>L?1000000000:1;
	}
	for(k=1;k<=N;k++)for(i=1;i<=N;i++)for(j=1;j<=N;j++)
		if(D[i][j]>D[i][k]+D[k][j])D[i][j]=D[i][k]+D[k][j];
	scanf("%d",&Q);
	for(i=0;i<Q;i++)
	{
		scanf("%d%d",&a,&b);
		printf("%d\n",D[a][b]<1000000000?D[a][b]-1:-1);
	}
}

Measured memory_bytes: 768
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

int N,M,a[310][310],cnt[310],id[310];
bool valid[310];

bool check(int maxk){
    int i;
    memset(valid,1,sizeof(valid));
    memset(cnt,0,sizeof(cnt));
    for (i=1; i<=N; i++) id[i]=1,cnt[a[i][1]]++;

    while (1){
        bool ok=1;

        for (i=1; i<=M; i++)
            if (valid[i] && cnt[i]>maxk)
                valid[i]=0,ok=0;

        if (ok) return 1;

        for (i=1; i<=N; i++)
            while (!valid[a[i][id[i]]]){
                cnt[a[i][id[i]]]--;
                id[i]++;
                if (id[i]>M) return 0;
                cnt[a[i][id[i]]]++;
            }
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N >> M;

    int i,j;
    for (i=1; i<=N; i++)
        for (j=1; j<=M; j++)
            cin >> a[i][j];

    int l=1,r=N,mid;
    while (l<r){
        mid=(l+r)/2;
        if (check(mid)) r=mid;
        else l=mid+1;
    }

    cout << r << "\n";
    return 0;
}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = x[i];
		}
		Arrays.sort(y);
		int smaller = y[n / 2 - 1];
		int larger = y[n / 2];

		for (int i = 0; i < n; i++) {
			if (smaller != larger) {
				if (x[i] <= smaller) {
					System.out.println(larger);
				} else if (x[i] >= larger) {
					System.out.println(smaller);
				}
			} else {
				System.out.println(smaller);
			}
		}

		System.out.println();

		sc.close();
	}
}

Measured memory_bytes: 92972
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
LL n,m;
int main() {
    scanf("%lld%lld",&n,&m);
    if (n==1&&m==1) {
	printf("1\n");
	return 0;
    }
    if (n==1) {
	printf("%lld\n",m-2);
	return 0;
    }
    if (m==1) {
	printf("%lld\n",n-2);
	return 0;
    }
    printf("%lld\n",(n-2)*(m-2));
    return 0;
}	    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}

int main(){
	IOS;
	cout.precision(30) ;
	ll l , r ; cin >> l >> r ;
	if(r - l >= 2019) return cout << 0  <<"\n" , 0 ;
	ll ans  = 2018 ;
	for(ll i = l ; i < r ; i++){
		for(ll j = i + 1 ; j <= r ; j++){
			ans = min(ans , (i * j) % 2019) ;
		}
	}
	cout << ans << endl ;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, d; cin >> n >> d;

    int num = 2 * d + 1;
    cout << (n + num - 1) / num << endl;

    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

void calc(int n) {
    string get() { return readln.chomp; }

    writeln(0);
    stdout.flush();

    auto s = get();
    int lo = 1;
    int hi = n - 1;
    for (int i = 0; i < 19; i++) {
        int m = (lo + hi) / 2;
        writeln(m);
        stdout.flush();

        auto t = get();
        if (t == "Vacant") break;

        if (m % 2 == 0) {
            if (s == t)
                lo = m + 1;
            else
                hi = m - 1;
        }
        else {
            if (s == t)
                hi = m - 1;
            else
                lo = m + 1;
        }
    }
}

void main() {
    int n = readint;
    calc(n);
}

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

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

  ll n, k;
  cin >> n >> k;
  ll r = n % k;
  ll over = k -r;
  cout << min(r, over) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;i++)
typedef long long ll;
using namespace std;
int main()
{
    string s;
    cin >> s;
    rep(i,0,s.length()-1)
    {
       if(s[i]=='A'&&s[i+1]=='C'){
          cout << "Yes" << endl;
          return 0;
       }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/agc011/tasks/agc011_b
from copy import deepcopy
n = int(input())
nums = [int(i) for i in input().split()]
nums.sort()
cums = deepcopy(nums)
for i in range(1, n):
    cums[i] += cums[i - 1]

t = 1
for i in range(n - 1)[::-1]:
    if nums[i + 1] <= cums[i] * 2:
        t += 1
    else:
        break
print(t)

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

int main(){
    string str;
    cin >> str;
    int sum=0;

    for(int i=0;i<str.length();i++){
        if(str[i]=='+')
            sum++;
        else if(str[i]=='-')
            sum--;
    }

    cout << sum << endl;



    return 0;
}

Measured memory_bytes: 256
@n = gets.to_i

def include3(a)
  if a % 10 == 3
    return true
  elsif a != 0
    return include3(a/10)
  else
    return false
  end
end

def check_num(i)
  print " #{i}" if i % 3 == 0 or include3(i)
end

1.upto(@n) do |i|
  check_num(i)
end

puts



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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, m, mxs = 0;
  cin >> n >> m;
  vector<ll> s(m), c(m);
  map<ll, ll> mp;
  rep(i, m) {
    cin >> s[i] >> c[i];
    s[i]--;
    if (mp[s[i]] && mp[s[i]] != c[i]) {
      puts("-1");
      return 0;
    }
    mp[s[i]] = c[i];
  }

  rep(i, 1000) {
    string S = to_string(i);
    if ((int)S.size() != n) continue;
    bool ok = true;
    for (auto m : mp)
      if (S[m.first] - '0' != m.second) {
        ok = false;
        break;
      }

    if (ok) {
      cout << i << endl;
      return 0;
    }
  }

  puts("-1");
  return 0;
}

Measured memory_bytes: 3708
# import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    a = list(map(int,ipti().split()))
    ball = [0] * (n+1)

    for i in range(n, 0, -1):
        cnt = a[i-1]
        num = i
        while num <= n:
            if ball[num] == 1:
                cnt += 1
            num += i
        if cnt % 2 == 1:
            ball[i] = 1

    res = []
    m = 0

    for i in range(1, n+1):
        if ball[i] == 1:
            res.append(i)
            m+=1
    if m > 0:
        print(m)
        print(*res)
    else:
        print(0)


if __name__ == '__main__':
    main()

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

#define mod 1000000007

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

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N, Q;
	string S;
	
	cin >> N >> Q;
	cin >> S;
	
	int l[Q], r[Q];
	
	ll ans;
	rep(i, Q){
		cin >> l[i] >> r[i];
	}
	
	vector<int> vec(N);
	int count = 0;
	rep(i, N-1){
		if(S[i] == 'A' && S[i+1] == 'C'){
			count++;
			vec[i] = count;
		}
		else
			vec[i] = count;
	}
	
	vec[N-1] = count;
	
	rep(i, Q)
		cout << vec[r[i]-2] - vec[l[i]-2] << endl;
	
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=1145141919810364364;

vector<vector<long long>> d; //d[from][to]:=2点間の最短距離

void Warshall_Floyd(int n){ //頂点数n
	rep(i,n){               //経由点i
		rep(j,n){           //始点j
			rep(k,n){       //終点k
				d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
			}
		}
	}
}

int main(){
	int n,m,R; cin>>n>>m>>R;
	long long r[R]; rep(i,R) {cin>>r[i];r[i]--;}
	sort(r,r+R);
	//n*nの盤面をINFで初期化
	d=vector<vector<long long>>(n,vector<long long>(n,INF));
	rep(i,m){
		long long from,to,cost; cin>>from>>to>>cost;
		from--; to--;
		d[from][to]=d[to][from]=cost;
	}
	Warshall_Floyd(n);
	// rep(i,n)rep(j,n) cout<<d[i][j]<<endl;
	long long ans=LINF;
	do{
		long long tmp=0;
		for(int i=1;i<R;i++){
			tmp+=d[r[i]][r[i-1]];
		}
		// cout<<tmp<<endl;
		ans=min(ans,tmp);
	}while(next_permutation(r,r+R));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  int r; cin >> r;
  cout << r * r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     db(i)               cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    string s; cin>>s;
    if(s=="ABC"){
    	cout<<"ARC";
    }
    else{
    	cout<<"ABC";
    }
}

signed main() { 
    IO();
    
    int t=1;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define x first
#define y second
#define gcd(x, y) __gcd((x), (y))
using namespace std;

using i64 = long long;
using f64 = double;
using pii = pair<int, int>;
using pq = priority_queue<i64>;

const int N = 1e5 + 5;

vector<int> g[N];
i64 a[N];
bool f[N];

vector<i64> v;
i64 ant;
int n, m, cnx = -1;

pq pr;

static void dfs(int u) {
	f[u] = true;
	pr.push(a[u]);
	for (auto v: g[u]) if (!f[v])
		dfs(v); }

int main() {
#ifdef HOME
	freopen("atc.in", "r", stdin);
	freopen("atc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		cin >> a[i], a[i]*= -1; }

	for (int x, y, i = 0; i < m; ++i) {
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x); }

	for (int i = 0; i < n; ++i) if (!f[i]) {
		cnx+= 1;
		while (!pr.empty()) {
			v.push_back(pr.top());
			pr.pop(); }
		dfs(i);
		ant+= pr.top();
		pr.pop(); }

	while (!pr.empty()) {
		v.push_back(pr.top());
		pr.pop(); }

	sort(begin(v), end(v));
	reverse(begin(v), end(v));

	if (2 * cnx > n) {
		cout << "Impossible\n";
		return 0; }

	for (int i = 0; i < cnx - 1; ++i)
		ant+= v[i];

	if (cnx == 0)
		ant = 0;
	cout << -ant << endl;

	return 0; }


Measured memory_bytes: 8948
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2*acos(0))
#define cross(a, b) ((conj(a)*b).Y)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> point;
typedef pair<point, point> segment;
typedef tuple<ll, ll, ll> line;
const int N = 1e5 + 5, M = 100 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 9;

int n, arr[N], memo[N];
int solve(int i = 0)
{
	if(i == n - 1)
		return 0;
	if(i >= n)
		return OO;
	int &ret  = memo[i];
	if(~ret)
		return ret;
	ret = solve(i + 1) + abs(arr[i + 1] - arr[i]);
	ret = min(ret, solve(i + 2) + abs(arr[i + 2] - arr[i]));
	return ret;
}
int main()
{
	MuhammedAly
	mem(memo, -1);
	cin >> n;
	for(int i = 0 ; i < n ; i++)
		cin >> arr[i];
	cout << solve();
	return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main() {
	cin>>a;
	b=a;
	reverse(a.begin(),a.end());
	for(int i=0; i<a.size(); i++) {
		if(a[i]=='b') a[i]='d';
		else if(a[i]=='d') a[i]='b';
		else if(a[i]=='p') a[i]='q';
		else if(a[i]=='q') a[i]='p';
	}
	if(a==b) cout<<"Yes";
	else cout<<"No";
}

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


class BIT{
    public:
    int size;
    vector<int> tree;
    
    void set(int n){
        size = n;
        tree = vector<int>(n+1, 0);
        return;
    }
    
    void add(int a, int n) {
        int x = n;
        while (x <= size){
            tree[x] += a;
            x += (x & -x);
        }
        return;
    }
    
    int sum(int a) {
        int x = a;
        int sum = 0;
        while (x > 0) {
            sum += tree[x];
            x -= (x & -x);
        }
        return sum;
    }
    
};


int main(){
    int N, K;
    cin >> N >> K;
    
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    
    vector<ll> sum(N+1, 0);
    for (int i = 1; i <= N; i++) sum[i] = sum[i-1] + a[i-1] - K;
    vector<ll> t;
    t = sum;
    sort(t.begin(), t.end());
    auto result = unique(t.begin(), t.end());
    t.erase(result, t.end());
    for (int i = 0; i < N+1; i++) {
        sum[i] = distance(t.begin(), lower_bound(t.begin(), t.end(), sum[i]))+1;
    }
    
    BIT bit;
    bit.set(N*2);
    ll ans = 0;
    for (int i = 0; i < N+1; i++) {
        bit.add(1, sum[i]);
        ans += bit.sum(sum[i]) - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using p = pair<int,int>;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int>hight(n);
  rep(i,n)cin >> hight[i];
  vector<int>jdg(n,1);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    int a_h, b_h;
    a_h = hight[a-1];
    b_h = hight[b-1];
    if(a_h == b_h){
      jdg[a-1] = 0;
      jdg[b-1] = 0;
      continue;
    }
    int f;
    if(a_h > b_h) f = b;
    else f = a;
    jdg[f-1] = 0;
  }
  int count = 0;
  rep(i,n){
    if(jdg[i] == 1)count++;
  }
  cout << count << endl;
  return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

#define INF 1000000000

struct edge{int to;};
using graph = vector<vector<edge>>;

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

    int n, m, x;
    cin >> n >> m >> x;
    vi C(n);
    vii A(n, vi(m));
    rep(i, 0, n) {
        cin >> C[i];
        rep (j, 0, m) cin >> A[i][j];
    }
    int mn_c = INF;
    rep (b, 0, 1 << n) {
        int cc = 0;
        vi know(n);
        rep(i, 0, n) if ((1 << i) & b) {
            cc += C[i];
            rep(j, 0, m) {
                know[j] += A[i][j];
            }
        }
        bool good = true;
        rep (i, 0, m) {
            if (know[i] < x) {good = false; break;}
        }
        if (!good) continue;
        mn_c = min(mn_c, cc);
    }
    if (mn_c == INF) cout << -1 << endl;
    else cout << mn_c << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



void init() {

}

void input() {

}

void solve() {
  int n, t, a;
  int h[1010];
  cin >> n >> t >> a;
  REP(i, n) cin >>h[i];

  int res = -1;
  double  d = 1000000;
  REP(i, n) {
    double dd = t-h[i]*0.006;
    if (abs(dd-a) < d) {
      res = i+1;
      d = abs(dd-a);
    }
  }
  cout << res << endl;
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int color[100010];
vector<int> g[100010];
ll n, m;
bool isbipartite(int idx, int pre) {
  bool ret = true;
  if(color[idx] == 0) {
    color[idx] = pre * (-1);
  } else {
    if(color[idx] == pre)
      return false;
    else
      return true;
  }
  for(int i=0;i<g[idx].size();i++) {
    ret &= isbipartite(g[idx][i], pre*(-1));
  }
  return ret;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for(int i=0;i<m;i++) {
    int ai, bi;
    cin >> ai >> bi;
    ai--;bi--;
    g[ai].push_back(bi);
    g[bi].push_back(ai);
  }
 
  for(int i=0;i<n;i++) {
    color[i] = 0;
  }
 
  bool bin = isbipartite(0, -1);
  if(bin) {
    ll c1 = 0, c2 = 0;
    for(int i=0;i<n;i++) {
      if(color[i] == 1)
        c1++;
    }
    c2 = n - c1;
    cout << c1*c2 - m << endl;
  } else {
    cout << n*(n-1)/2 - m << endl;
  }
 
 
 
}

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

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int N;
	cin>>N;
	int arr[N][3];
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>arr[i][j];
		}
	}
	int dp[N][3];
	dp[0][0]=arr[0][0];
	dp[0][1]=arr[0][1];
	dp[0][2]=arr[0][2];
	//cout<<dp[0][1];
	for(int i=1;i<N;i++)
	{
		
		dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=arr[i][2]+max(dp[i-1][1],dp[i-1][0]);
	//	cout<<arr[i][0]<<"\t"<<dp[i][1]<<endl;	
	}
	int a=max(dp[N-1][0],dp[N-1][1]);
	int b=max(a,dp[N-1][2]);
	cout<<b;
	return 0;
}

Measured memory_bytes: 5968
from itertools import product

n,m = map(int,input().split())
x=[0]*n
y=[0]*n
z=[0]*n

for i in range(n):
  x[i],y[i],z[i] = map(int,input().split())
  
sign = product([1,-1],repeat=3)
ans = 0
for s in sign:
  tmp = [0]*n
  for i in range(n):
    tmp[i] = s[0]*x[i] + s[1]*y[i] + s[2]*z[i]
  tmp = sorted(tmp,reverse=True)  
  tmp = sum(tmp[:m])
  ans = max(ans,tmp)
  
print(ans)  

Measured memory_bytes: 3188
N = int(input())
A = list(map(int, input().split()))
B = [a-(i+1) for i, a in enumerate(A)]
B = sorted(B)

if N % 2 == 1:
    median = B[N//2]
    print(sum([abs(b - median) for b in B]))
else:
    median1 = B[N//2]
    median2 = B[N//2+1]
    print(min(sum([abs(b - median1) for b in B]), sum([abs(b - median2) for b in B])))

Measured memory_bytes: 27588
import java.util.*;

public class Main{
	
	public static void main(String... args){
		Map<String, List<Integer>> map = new TreeMap<>();
		
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()){
			String line = sc.nextLine();
			if(line.equals("end")) break;
			String word = line.split(" ")[0];
			int page = Integer.parseInt(line.split(" ")[1]);
			List<Integer> pageList = map.getOrDefault(word, new ArrayList<>());
			pageList.add(page);
			map.put(word, pageList);
		}
		sc.close();
		
		for(Map.Entry<String, List<Integer>> entry: map.entrySet()){
			System.out.println(entry.getKey());
			entry.getValue().sort(Comparator.comparing(Integer::intValue));
			for(int i = 0; i < entry.getValue().size()-1; i++){
				System.out.print(entry.getValue().get(i) + " ");
			}
			System.out.println(entry.getValue().get(entry.getValue().size()-1));
		}
	}
}

Measured memory_bytes: 32176
#include<iostream>
#include<vector>

using namespace std;

void outputArray(vector<int> array)
{
	for (int i = 0; i != array.size(); ++i)
	{
		cout << array[i];
		if (i + 1 != array.size())
			cout << " ";
	}
	cout << endl;
}

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

	vector<int> array(num);
	for (int i = 0; i != num; ++i)
	{
		cin >> array[i];
	}

	outputArray(array);

	for (int i = 1; i != num; ++i)
	{
		int v = array[i];
		int j;
		for (j = i - 1; j >= 0; --j)
		{
			if (array[j] > v)
			{
				array[j + 1] = array[j];
			}
			else
				break;
		}
		array[j + 1] = v;
		outputArray(array);
	}

	return 0;
}


Measured memory_bytes: 3140
#include <cstring>
#include <cstdio>
#include <string>
#include <set>

using namespace std;

#define FOR(i, a, b) for(i=a; i<b; ++i)
#define EFOR(i, a, b) for(i=a; i>b; --i)

#define MAXN 100
#define MAXW 11

int ck(char *sPrev, char *sNext) {
	return ((sPrev[strlen(sPrev)-1] == sNext[0])?0:1);
}

void soluver(char (*s)[MAXW], int sSize) {
	int i,j;
	FOR(i, 1, sSize) {
		if (ck(s[i-1], s[i])) {
			printf("No\n");
			return;
		}

		EFOR(j, i-1, -1) {
			if (strcmp(s[j], s[i]) == 0) {
				printf("No\n");
				return;
			}	
		}
	}
	printf("Yes\n");
}

void soluver2(char (*s)[MAXW], int sSize) {
	set<string>st;
	set<string>::iterator it;

	int i;

	st.insert(s[0]);
	FOR(i, 1, sSize) {
		if (ck(s[i-1], s[i])) {
			printf("No\n");
			return;
		}

		it = st.find(s[i]);

		if (it != st.end()) {
			printf("No\n");
			return;
		}

		st.insert(s[i]);
	}

	printf("Yes\n");
}

int main() {
	int i,n;
	char a[MAXN][MAXW] = {0};

	scanf("%d", &n);

	FOR(i, 0, n) {
		scanf("%s", a[i]);
	}

	soluver2(a, n);
	return 0;
}


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


int main()
{
	int n, m, l, mat1[100][100], mat2[100][100];
	long long sum, mat3[100][100];
	cin >> n >> m >> l;

	for (int i = 0;i < n;i++) {
		for (int j = 0;j < m;j++) {
			cin >> mat1[i][j];
		}
	}

	for (int i = 0;i < m;i++) {
		for (int j = 0;j < l;j++) {
			cin >> mat2[i][j];
		}
	}

	for (int i = 0;i < n;i++) {
		for (int j = 0;j < l;j++) {
			sum = 0;
			for (int k = 0;k < m;k++) {
				sum += mat1[i][k] * mat2[k][j];
			}

			mat3[i][j] = sum;
		}
	}

	for (int i = 0;i < n;i++) {
		for (int j = 0;j < l;j++) {
			if (j == l - 1) {
				cout << mat3[i][j] << endl;
			}
			else
			{
				cout << mat3[i][j] << " ";
			}
		}
	}

    return 0;
}



Measured memory_bytes: 3228
#include<stdio.h>
#define N 45

int F[N],i;

int fib(int);

int main()
{
  int n;
  scanf("%d",&n);
  printf("%d\n",fib(n));
  return 0;
}

int fib(int n)
{
  F[0]=1;
  F[1]=1;

  for(i=2; i<=n; i++)
    {
      F[i]=F[i-2]+F[i-1];
    }
  return F[n];
}



Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>

using namespace std;

unsigned gcd(unsigned a, unsigned b) {
  if(a < b) gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(void) {
    int a,b,k;
    cin >> a;
    cin >> b;
    cin >> k;

    auto x = gcd(a, b);
    // cout << x << endl;
    vector<int> dst;
    for(int i = 1 ; i <= x ; ++i) {
        if ((x % i) == 0){
            dst.push_back(i);
        }
    }
    cout << dst[dst.size() - k] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

unsigned short calculate_num_monitor (unsigned short num_tree_all, unsigned short num_range)
{
	// variable for this function
	register unsigned short num_tree_monitored;
	register unsigned short num_monitor;

	num_tree_monitored = (unsigned short)(2) * num_range + (unsigned short)(1);
	num_monitor        = num_tree_all / num_tree_monitored;

	if ( num_tree_all % num_tree_monitored != (unsigned short)(0) ) { num_monitor += (unsigned short)(1); }

	return num_monitor;
}

int main (void)
{
	// variables for main process
	unsigned short N;
	unsigned short D;
	int            rtvl_scanf;

	// STEP.01
	// read out the given data
	rtvl_scanf = scanf("%d %d", &N, &D);

	// STEP.02
	// output the answer of this task
	printf("%d\n", calculate_num_monitor(N, D));

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<stack>
#include<climits>
#include<cmath>

using namespace std;

#define int long long
#define MOD (1000000007)
#define MINF (-1*(LLONG_MAX-10))
#define INF (LLONG_MAX-10)

signed main(){
    int mi=INF;
    int ans=0;
    int N;

    cin>>N;

    for(int i=0;i<N;i++){
        int A;
        cin>>A;
        if(mi>=A) ans++;
        mi=min(mi,A);
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N; cin >> N;
    vector<int>A(N);
    int ans = 0;
    rep(i, N) {
        cin >> A[i];
        if (A[i] % 2 == 1)ans++;
    }
    cout << (ans%2==1? "NO":"YES") << endl;
}

Measured memory_bytes: 3796
X, K , D = map(int, input().split()) 

move_count = 0
D = abs(D)
X = abs(X)

q = X // D
mod = X % D
vi = X //2
if q > K:
  print(X - D*K)
else:
  if (K-q) % 2 == 0:
    print(X- D*q)
  else:
    print(abs(X-D*(q+1)))

Measured memory_bytes: 9176
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }





void solve(void)
{
  int N;cin>>N;
  vector<int> A (N+1,0);
  for (int i = 0; i < N+1; i++)
  {
     cin>>A[i];
  }

  vector<int> B (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>B[i];
  }
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
    int D = A[i] - B[i];
    if(D <= 0)
    {
     

      ANS += min(A[i] + A[i+1],B[i]);
      A[i+1] += max(D,-1*A[i+1]);
      // DEBUG(D);
      A[i] = 0;
    }
    else
    {
      A[i] = D;
      ANS += B[i];
    }
    // DEBUG(A);
    // DEBUG(ANS);
    
  }
  cout<<ANS<<endl;
  return;
  
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 1792