akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
#define endl "\n"
#define sd(val) scanf("%d", &val)
#define ss(val) scanf("%s", &val)
#define sl(val) scanf("%lld", &val)
#define debug(val) printf("check%d\n", val)
#define all(v) v.begin(), v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val, 0, sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ                            \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{

    ll count = 0;
    string a, b;

    cin >> a >> b;

    int n = a.length();

    for (int i = 0; i < n; i++)
    {
        if (a[i] != b[i])
            count++;
    }
    cout << count << "\n";

    return 0;
}

Measured memory_bytes: 3864
n, m, l = map(int, input().split(' '))

A = []
for i in range(n):
    A.append(list(map(int, input().split(' '))))


B = []
for i in range(m):
    B.append(list(map(int, input().split(' '))))

C = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for c in C:
    print(' '.join([str(x) for x in c]))

Measured memory_bytes: 8900
abcdStr = input()
abcd = [int(s) for s in abcdStr]

s = ''
f = lambda i, op: abcdStr[0] + ("+" if i < 2 else "-") + abcdStr[1] + ("+" if i % 2 == 0 else "-") + abcdStr[2] + op + abcdStr[3] + "=7"
for i in range(4):
    n = abcd[0]
    n = n + abcd[1] if i < 2 else n - abcd[1]
    n = n + abcd[2] if i % 2 == 0 else n - abcd[2]
    if n + abcd[3] == 7:
        s = f(i, "+")
        break
    elif n - abcd[3] == 7:
        s = f(i, "-")
        break
print(s)

Measured memory_bytes: 38384
/// You just can't beat the person who never gives up
/// ICPC next year

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std ;
const int N = 1e6+5 ;

int n ,a[N] ;
int spf[N] ,vis[N] ,vid ;
bool is[N] ;
void sieve(){
    for(int i=1;i<N;++i) spf[i]=i;
    for(int i=2;i*i<N;++i)if(spf[i]==i){
            for(int j=i*i;j<N;j+=i)if(spf[j]==j)spf[j]=i;
        }
}
vector<int> factorize(int x){
    vector<int> ret;
    ++vid ;
    while(x!=1){
        if(vis[spf[x]]!=vid) ret.push_back(spf[x]);
        vis[spf[x]] = vid ;
        x/=spf[x];
    }
    return ret;
}
int x ;
bool Never_give_up(){
    sieve();
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d",a+i);
        x = __gcd(x,a[i]);
    }
    if(x!=1) return cout << "not coprime\n" ,0 ;
    for(int i=n-1;i>=0;--i){
        auto vec = factorize(a[i]);
        for(int j:vec) if(is[j]) return cout << "setwise coprime\n" ,0 ;
        for(int j:vec) is[j] = 1 ;
    }
    cout << "pairwise coprime\n";
    return 0;
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" ,"r" ,stdin);
    freopen("output.txt" ,"w" ,stdout);
#endif
    //std::ios::sync_with_stdio(0);
    //cin.tie(0) ,cout.tie(0);
    int t = 1 ;
    //scanf("%d",&t);
    while(t--){
        Never_give_up();
    }
    return 0;
}


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

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        int[] ints = {a,b,c};

        Arrays.sort(ints);

        System.out.println(ints[0]+" "+ints[1]+" "+ints[2]);
        
    }
}


Measured memory_bytes: 26272
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n,m;
  cin >> n >> m;
  
  char a[n][n],b[m][m];
  REP(i,n){
    REP(j,n){
      cin >> a[i][j];
    }
  }
  
  REP(i,m){
    REP(j,m){
      cin >> b[i][j];
    }
  }
  
  REP(x,n-m+1){
    REP(y,n-m+1){
      bool f = true;
      REP(i,m){
        REP(j,m){
          if(a[i+x][j+y] != b[i][j]){
            f = false;
            break;
          }
        }
        if(!f) break;
      }
      if(f){
          cout << "Yes" << endl;
          return 0;
      }
    }
  }

  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
let () =
  Scanf.scanf "%d %d" (fun m n ->
    let a, b = min m n, max m n in
    if a = 1 then (if b = 1 then 1 else max 0 (b-2))
    else if a = 2 then 0
    else (a-2) * (b-2))
  |> Printf.printf "%d\n"


Measured memory_bytes: 384
import java.util.*;
import java.io.*;

public class Main {
	static int dp[];
	static int k;
	public static void main(String[] args) throws IOException {	
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		k=s.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
			a[i]=s.nextInt();
		dp=new int[n];
		Arrays.fill(dp, -1);
		
		System.out.println(rec(0,a));
		
	}

	private static int rec(int i, int[] a) {
		if(dp[i]!=-1)
			return dp[i];
		if(i>=a.length)
			return (int)(1e5);
		if(i==a.length-1)
			return 0;
		
		
		int op=Integer.MAX_VALUE;
		for(int j=1;j<=k;j++) {
			if(i+j<a.length)
				op=Math.min(op,Math.abs(a[i]-a[i+j])+rec(i+j, a));
		}
		
		
		
		return dp[i]=op;
	}
}

Measured memory_bytes: 71988
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>
#include <bitset>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define pb push_back
#define x  first
#define y  second
#define mp make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#ifndef ONLINE_JUDGE
	#include "debug.h"
#else
// #define debug(...) 42
#endif

const int mxN=5e5+5;
const ld PI=acos(-1);
const int MD=1e9+9;


int main() {
	fast_cin();
	int t=1;
	// cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		for(int i=0;i<3;i++) cout<<s[i];
	}
	return 0;	
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<string> s(N);
	for (size_t i = 0; i < N; i++)
		cin >> s[i];
	int M;
	cin >> M;
	vector<string> t(M);
	for (size_t i = 0; i < M; i++)
		cin >> t[i];

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		int ansTmp = 0;
		for (int j = 0; j < N; j++)
		{
			if (s[j] == s[i])
				ansTmp++;
		}
		for (int j = 0; j < M; j++)
		{
			if (t[j] == s[i])
				ansTmp--;
		}
		ans = max(ans, ansTmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define REV(s) (s).rbegin(), (s).rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

const double EPS = 1e-9;
double dp[1<<15][15];
int id[15], d[15], num[15];

int w[1<<15];
int nxt[1<<15][15];

int n;
double dfs(int vis, int pos){
	if(vis+1 == 1<<n) return 0;

	double &res = dp[vis][pos];
	if(res > -EPS) return res;

	res = 1e15;
	rep(i, n){
		if(vis&(1<<i)) continue;
		double t = dfs(vis|(1<<i), i)+abs(d[pos]-d[i])/(2000./(70+w[vis]));
		if(res > t){
			res = t;
			nxt[vis][pos] = vis|(1<<i);
		}
	}

	return res;
}

int main(){
	cin >> n;
	rep(i, n) cin >> id[i] >> d[i] >> num[i];
	rep(i, 1<<n) rep(j, n) if(i&(1<<j)) w[i] += num[j]*20;

	rep(i, 1<<n) rep(j, n) dp[i][j] = -1;
	double opt = 1e15;
	int start = 0;
	rep(i, n) if(opt > dfs(0, i)) opt = dfs(0, i), start = i;

	vector<int> ans;
	int x = 0, p = start;
	while(x+1 != 1<<n){
		int xx = x^nxt[x][p];
		x = nxt[x][p];
		rep(i, n) if(xx&(1<<i)) p = i, ans.push_back(id[i]);
	}

	rep(i, ans.size()){
		cout << (i?" ":"") << ans[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 7108
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <numeric>
#include <cmath>

using namespace std;

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

    for (int i = X-(K-1); i < X+K; i++) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
#define INF (int)1e18


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}


ld dist(pair<int,int> a,pair<int,int> b)
{
	return sqrt((a.F-b.F)*(a.F-b.F)+(a.S-b.S)*(a.S-b.S));
}

signed main()
{
	fio
	inp(n)
	vector<pair<int,int>> a(n);
	fo(i,n)
		cin>>a[i].F>>a[i].S;
	ld ans=0;
	fo(i,n)
	{
		for(int j=i+1;j<n;j++)
		{
			// cout<<i<<','<<j<<' '<<dist(a[i],a[j])<<endl;
			ans+=dist(a[i],a[j]);
		}
	}
	ans=(ans*2)/n;
	cout<<fixed<<setprecision(10)<<ans<<'\n';
	printclock;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,a,b,ans;
  cin>>N>>M;
  int R[N+1][N+1]={0};
  for(int i=0;i<M;i++){
    cin>>a>>b;
    R[a][b]++;
    R[b][a]++;
  }
  for(int i=1;i<N+1;i++){
    ans=0;
    for(int j=1;j<N+1;j++){
      ans+=R[i][j];
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  
  Q[tail] = x;
  tail = (tail + 1) % LEN;
  
}

P dequeue(){
  P x = Q[head];
  head =(head + 1) % LEN;
  return x;

}

int min(int a, int b){return a < b ? a : b;}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }


  head = 1;
  tail = n + 1;

  while(head != tail){
    u = dequeue();
    c = min(q,u.t);
    u.t = u.t - c;
    elaps = elaps + c;
    if(u.t > 0){
      enqueue(u);
    }
    else{
      printf("%s %d\n",u.name, elaps);
    }
  }


  return 0;
}

Measured memory_bytes: 10756
#include <iostream>
#include <string>

#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	std::string str;

#if INPUT_FROM_FILE
	ifs >> str;
#else
	std::cin >> str;
#endif

	for(int i = str.size() - 1; i >= 0; i--){
		std::cout << str.at(i);
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 3144
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y,z;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=a+b+c+d;
	y=x/60;
	z=x%60;
	printf("%d\n",y);
	printf("%d\n",z);
	return 0;
}

Measured memory_bytes: 2668
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30;
pair <ll, ll> A[10000000] = {}, X[1000000] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
ll a = 0, b = 0, c = 0, n = 0, sum = 0, max = INF;
str S;
ll ans = 0;

int findDigits(int n) {
	int i = 0;
	while (n > 0) {

		sum += n % 10;
		n /= 10;
		i++;
	}
	return i;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Code Line
	cin >> a;
	b = 1;
	for (int i = 0; i > -1; i++) {
		if (a / b == 1) {
			break;
		}
		b *= 2;

	}
	cout << b << endl;
	//Code Line
	return 0;
}


Measured memory_bytes: 172160
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int64_t k;
    cin >> k;

    const int n = 50;
    cout << n << '\n';

    int64_t q = (k + n - 1) / n, r = k % n; if (r == 0) r = n;
    int64_t p[2] = { -r - 1, n - r };

    for (int i = 0; i < n; i++) {
        cout << n - 1 + q + p[i >= n - r] << " \n"[i == n - 1];
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
        int n = sc.nextInt();
        int x = sc.nextInt();
            if(n == 0 && x == 0) break;
        int s = 0;
        for(int i = 1; i <= n; i++) {
            for(int j = i + 1; j <= n; j++) {
                for(int k = j + 1; k <= n; k++) {
                    if(i + j + k == x) s++;
                }
            }
        }
        System.out.println(s);
        }
    }
}



Measured memory_bytes: 26664
N, D = map(int, input().split(' '))
lst=[]
for i in range(N):
    lst.append(list(map(int,input().split())))

import math
count = 0

for i in lst:
    a, b = i
    x = ( a**2 + b**2 )
    y = math.sqrt(x)
    if y <= D:
      count += 1
print(count)

Measured memory_bytes: 45420
#include <stdio.h>

#define MAX 100000
#define INFTY 2000000000

typedef struct{
  char mark;
  int number;
}Card;

int partition(Card *,int ,int);
void quickS(Card *,int ,int);

void marge(Card *,int,int,int);
void margeSort(Card *,int,int);

Card L[MAX];
Card R[MAX];

int main(){
  int n;
  int i;
  int num;
  int flag=1;
  Card A[MAX],B[MAX];
  char S[2];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %d",S,&num);
    A[i].mark=S[0];
    A[i].number=num;
    B[i].mark=S[0];
    B[i].number=num;
  }

  margeSort(A,0,n);
  quickS(B,0,n-1);

  for(i=0;i<n;i++){
    if(A[i].mark!=B[i].mark) flag=0;
  }

  if(flag==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].mark,B[i].number);
  }

  return 0;
}



int partition(Card *A, int p, int r){
  Card judge;
  int i=0;
  int j=0;
  Card swap;
  judge=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].number<=judge.number){
      i++;
      swap=A[j];
      A[j]=A[i];
      A[i]=swap;
    }
  }
  swap=A[r];
  A[r]=A[i+1];
  A[i+1]=swap;
  return i+1;
}

void quickS(Card *A,int p,int r){
  int q=0;
  if(p<r){
    q=partition(A,p,r);
    quickS(A,p,q-1);
    quickS(A,q+1,r);
  }
}



void marge(Card *S,int left,int mid, int right){
  int i=0;
  int j=0;
  int n_S=0;
  int n_left=0;
  int n_right=0;
  
  n_left=mid-left;
  n_right=right-mid;
  
  for(i=0;i<n_left;i++){
    L[i]=S[left+i];
  }
  
  for(i=0;i<n_right;i++){
    R[i]=S[mid+i];
  }
  
  L[n_left].number=INFTY;
  R[n_right].number=INFTY;
  i=0;
  j=0;
  
  for(n_S=left;n_S<right;n_S++){
    if(L[i].number<=R[j].number){
      S[n_S]=L[i];
      i++;
    }
    else{
      S[n_S]=R[j];
      j++;
    }
  }
}

void margeSort(Card *S,int left,int right){
  int mid=0;
  if(left+1<right){
    mid=(left+right)/2;
    margeSort(S,left,mid);
    margeSort(S,mid,right);
    marge(S,left,mid,right);
  }
}



Measured memory_bytes: 4068
wdlist=list()
N=int(input())
for i in range(N):
	wdlist.append(input())

winflag=True

for i in range(1,N):
	if(wdlist[i-1][-1]!=wdlist[i][0]):
		winflag=False
		break
	for j in range(i):
		if(wdlist[j]==wdlist[i]):
			winflag=False
			break
if(winflag==True):
	print ("Yes")
else:
	print("No")


Measured memory_bytes: 3060
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	int R, G;
	cin >> R >> G;
	cout << (G - R) * 2 + R << endl;
}


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

int main(){

    int N = 0;
    double A = 0;
    double B = 0;

    cin >> N;

    switch(N){

    case 1:
        cout << "Hello World" << endl;
        break;

    case 2:
        cin >> A >> B;
        cout << A + B << endl;
        break;

    default:
        break;
    }

    return 0;
}

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

typedef long long llong;

const int MaxTruckNum = 100000;
const int MaxPackageNum = 100000;
const int MaxWeight = 10000;


int g_Packages[MaxPackageNum];
int g_PackageNum;
int g_TruckNum;

int CalcPackageNum(llong limitWeight)
{
    llong weight = 0;
    int packageIndex = 0;
    for(int i = 0; i < g_TruckNum; i++)
    {
        weight = 0;
        while(packageIndex < g_PackageNum)
        {
            if(weight + g_Packages[packageIndex] <= limitWeight)
            {
                weight += g_Packages[packageIndex];
                packageIndex++;
            }
            else
            {
                 break;
            }
        }
        if(packageIndex == g_PackageNum)
        {
            return packageIndex;
        }
    }
    return packageIndex;
}

int main()
{
    scanf("%d %d", &g_PackageNum, &g_TruckNum);
    for(int i = 0; i < g_PackageNum; i++)
    {
        scanf("%d", &g_Packages[i]);
    }

    llong left = 0;
    llong right = MaxWeight * MaxPackageNum;
    llong num = 0;
    llong mid;

    while(right - left > 1)
    {
        mid = (right + left) / 2;
        num = CalcPackageNum(mid);
        if (num < g_PackageNum)
        {
            left = mid;
        }
        else
        {
            right = mid;
        }
    }
    printf("%lld\n", right);
    
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, d;
    cin >> n >> d;
    ll ans = 0;
    ll x, y;
    d *= d;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        if(x * x + y * y <= d){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int maxe = 0;
    int count = 0;
    rep(i, n) {
        if(s[i] == 'I') count++;
        else count--;
        maxe = max(maxe, count);
    }
    cout << maxe << endl;
    return 0;
}

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

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

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

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

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

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

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

constexpr int ALPHABET=26;

int ToInt(char c)
{
	return c-'a';
}

char ToChar(int x)
{
	return x+'a';
}

struct Node{
	char value;
	shared_ptr<Node> parent;
	array<shared_ptr<Node>,ALPHABET> children;
	bool last;
	int count;
	Node(char v):value(v),last(false),count(0){}
};

struct Patricia{
	shared_ptr<Node> root;
	vector<shared_ptr<Node>> lasts;
	Patricia():root(make_shared<Node>('!')){}
	void Add(const string& s){
		auto cur=root;
		for(char c:s){
			auto& child=cur->children[ToInt(c)];
			if(!child){
				child=make_shared<Node>(c);
				child->parent=cur;
			}
			cur=child;
			cur->count++;
		}
		cur->last=true;
		lasts.push_back(cur);
	}
	void Compress(){
		for(auto cur:lasts){
			while(cur && cur->parent && cur->parent->parent){
				auto p=cur->parent,g=p->parent;
				if(cur->count==p->count){
					g->children[ToInt(p->value)]=cur;
					cur->value=p->value;
					cur->parent=g;
				}
				else
					cur=p;
			}
		}
	}
};

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

	for(int n;cin>>n && n;){
		vs ss(n);
		rep(i,n) cin>>ss[i];
		int q; cin>>q;
		vi ks(q);
		vs ps(q);
		rep(i,q){
			cin>>ks[i]>>ps[i];
			ks[i]--;
		}

		Patricia pt;
		vector<shared_ptr<Node>> lasts;
		for(auto s:ss) pt.Add(s);

		pt.Compress();

		rep(_,q){
			string p=ps[_];
			int res=0;
			for(auto cur=pt.lasts[ks[_]];cur!=pt.root;cur=cur->parent){
				if(cur->last) res++;
				for(char c:p){
					if(c==cur->value) break;
					if(cur->parent->children[ToInt(c)])
						res+=cur->parent->children[ToInt(c)]->count;
				}
			}
			cout<<res<<endl;
		}
	}
}


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

int main(){
	int n,i;
	cin>>n;
	int a[n+1];
	 
	for(i=1;i<=n;i++)
		cin>>a[i];
		
	sort(a+1,a+n+1);
	
	for(i=2;i<=n;i++)
		if(a[i]==a[i-1])
		{
			cout<<"NO"<<endl;
			return 0;
			}	
			
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
    int i;
  int n; cin >> n;
  ll b[n-1]; ll ans = 0;
  rep(i,n-1){cin >> b[i];}

  rep(i,n){
      if(i == 0){ans += b[0];continue;}
      if(i == n-1){ans += b[n-2];continue;}
      ans += min(b[i-1],b[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define INF 1000000

int g[101][101];

int prim(int n){
  int i,u,mincost,color[101],pi[101],d[101];

  for(i=1;i<=n;i++){
    d[i]=INF;
    pi[i]=-1;
    color[i]=1;
  }

  d[1]=0;

  while(1){
    mincost=INF;

    for(i=1;i<=n;i++){
      if(color[i] && d[i]<mincost){
        mincost=d[i];
        u=i;
      }
    }

    if(mincost==INF) break;

    color[u]=0;

    for(i=1;i<=n;i++){

      if(g[u][i]!=-1){
        if(color[i] && g[u][i]<d[i]){
          pi[i]=u;
          d[i]=g[u][i];
        }
      }

    }

  }

  mincost=0;
  for(i=1;i<=n;i++){
    mincost+=d[i];
  }

  return mincost;

}

int main(){
  int i,j,n;


  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&g[i][j]);
    }
  }

  printf("%d\n",prim(n));


  return 0;
}



Measured memory_bytes: 2052
#include <stdio.h>

typedef struct ver{
  int u,v;
} ver;
  
int n,u;
ver adj[101];
int A[101][101];

int main(){
  int i,j,k,v;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      adj[j].u=u;
      adj[j].v=v;
      A[adj[j].u][adj[j].v]=1; 
    }
  }
  
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
    printf("%d",A[i][j]);
    if(j != n)
      printf(" ");
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 640
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, X, A[2010], mi[2010];

signed main() {
    cin >> N >> X;
    for(int i=0; i<N; i++) cin >> A[i];
    fill(mi, mi + N, INF);

    int ans = INF;
    for(int magic=0; magic<N; magic++) {
        int tmp = magic * X;
        for(int i=0; i<N; i++) {
            chmin(mi[i], A[(i-magic+N)%N]);
            tmp += mi[i];
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

#define MAX_V 105
#define INF 1000000000

int m[MAX_V][MAX_V];
int mn[MAX_V];
int dijflag[MAX_V];

void dijk(int start, int V){
  for(int i = 0; i < MAX_V; i++)mn[i] = INF;
  for(int i = 0; i < MAX_V; i++)dijflag[i] = 0;
  mn[start] = 0;
  for(;;){
    int v = -1;
    for(int i = 0; i < V; i++){
      if(dijflag[i] == 0){
        if(v == -1){
          v = i;
        }
        else{
          if(mn[i] < mn[v]){
            v = i;
          }
        }
      }
    }
    if(v == -1)break;
    dijflag[v] = 1;
    for(int i = 0; i < V; i++){
      if(mn[i] > mn[v] + m[v][i]){
        mn[i] = mn[v] + m[v][i];
      }
    }
  }
}

int main() {
  ll n,q;
  cin>>n>>q;
  vector<pair<ll,pair<ll,ll> > > v;
  for (int i = 0; i < q; i++) {
    ll a,b;
    cin>>a>>b;
    a--;b--;
    ll c;
    cin>>c;
    v.pb(mp(c,mp(a,b)));
  }
  sort(all(v));
  reverse(all(v));
  ll ans = 0;
  rep(i,0,v.sz){
    ll a = v[i].fi;
    ll b = v[i].se.fi;
    ll c = v[i].se.se;
    rep(j,0,n){
      rep(k,0,n){
        m[j][k] = INF;
      }
    }
    rep(j,0,v.sz){
      if(i==j)continue;
      ll a1 = v[j].fi;
      ll b1 = v[j].se.fi;
      ll c1 = v[j].se.se;
      m[c1][b1] = a1;
      m[b1][c1] = a1;
    }
    dijk(b,n);
    ll d = mn[c];
    if(a>d)ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e12+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	while(-1){
		llint a,b;char c;cin>>a>>c>>b;
		if(c=='+'){cout<<a+b<<endl;}
		if(c=='-'){cout<<a-b<<endl;}
		if(c=='*'){cout<<a*b<<endl;}
		if(c=='/'){cout<<a/b<<endl;}
		if(c=='?'){RE;}
	}
	RE;
}


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

vector<int>v[114514];
bool vst[114514];
deque<int>DQ;

int main(){
	int n,m;
	cin>>n>>m;
	
	fill(vst,vst+n,false);
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		v[a-1].push_back(b-1);
		v[b-1].push_back(a-1);
		}
		
	DQ.push_back(0);
	vst[0]=true;
	int now=0;
	while(1){
		int flg=0;
		for(int i=0;i<v[now].size();i++){
			if(vst[v[now][i]])continue;
			
			now=v[now][i];
			flg=1;
			DQ.push_back(now);
			vst[now]=true;
			break;
			}
		if(!flg)break;	
		}
		
	now=0;	
	while(1){
		int flg=0;
		for(int i=0;i<v[now].size();i++){
			if(vst[v[now][i]])continue;
			
			now=v[now][i];
			flg=1;
			DQ.push_front(now);
			vst[now]=true;
			break;
			}
			if(!flg)break;
		}		
		
		int cnt=0;
		cout<<DQ.size()<<endl;
		while(DQ.size()){
			if(cnt)cout<<' ';
			cout<<DQ.front()+1;
			DQ.pop_front();
			cnt++;
			}
			cout<<endl;
			return 0;
	}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n,k;cin>>n>>k;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    rep(i,0,k-1){
        ans+=a[i];
    }
    cout<<ans<<endl;
    
    return 0;
}



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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;

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

    auto count = 0;
    int prev = S[0];
    for (auto i = 1; i < N; i++) {
        if (prev != S[i]) {
            count++;
            prev = S[i];
        }
    }

    int n_del = max(count - 2 * K, 0);
    cout << N - 1 - n_del << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
// gcd function
// __gcd(a, b)
// for max of n elements
// cout<<max({a,b,c,d})<<endl;

lli input(lli n, vector<lli> &ve);
lli input(lli n, vector<lli> &ve) {
    lli val;
    for (lli i = 0; i < n; i++) {
        cin >> val;
        ve.pb(val);
    }
    return 0;
}

struct val {
    lli a, b, c;
};

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    lli n, a, b, c;
    vector<struct val> v;
    cin >> n;
    fr(i, 0, n) {
        struct val t;
        cin >> t.a >> t.b >> t.c;
        v.pb(t);
    }

    struct val p;
    p.a = -1, p.b = -1, p.c = -1;

    vector<struct val> dp(n + 2, p);
    dp[0].a = v[0].a;
    dp[0].b = v[0].b;
    dp[0].c = v[0].c;

    for (lli i = 1; i < n; i++) {
        dp[i].a = max(v[i].a + dp[i - 1].b, v[i].a + dp[i - 1].c);
        dp[i].b = max(v[i].b + dp[i - 1].a, v[i].b + dp[i - 1].c);
        dp[i].c = max(v[i].c + dp[i - 1].b, v[i].c + dp[i - 1].a);
    }

    cout << max({dp[n - 1].a, dp[n - 1].b, dp[n - 1].c}) << endl;
    rt;
}

Measured memory_bytes: 5744
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		long ans=0;
		for(int i=1;i<=N;i++){
			if(i%3!=0&&i%5!=0)
				ans+=i;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35848
#include<stdio.h>

int main(){
    int a,b,c,d,n,count=0;
    while(scanf("%d",&n)!=EOF){
    for(a=0;a<=9;a++){
        for(b=0;b<=9;b++){
            for(c=0;c<=9;c++){
                for(d=0;d<=9;d++){
                    if(a+b+c+d==n)count++;
                }
            }
        }
    }
    printf("%d\n",count);
    count=0;
    }
    return 0;
}

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

string str;

void dfs(int depth, string s){
    if(depth == str.size()){
        int ans = 0;
        ans += (int)(s[0] - '0');
        for(int i = 1; i < s.size(); i += 2){
            (s[i] == '+') ? ans += (int)(s[i+1] - '0'): ans -= (int)(s[i+1] - '0');
        }
        if(ans == 7){
            cout << s << "=7"<< endl;
            exit(0);
        }
        return;
    }
    if(depth == str.size() - 1){
        dfs(depth + 1, s + str[depth]);
    }else{
        dfs(depth + 1, s + str[depth] + '+');
        dfs(depth + 1, s + str[depth] + '-');
    }
}

int main(){
    cin >> str;
    dfs(0, "");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long i,n,a[10000000],min=1000000001,min2=1000000001;
  cin>>n;
  for(i=0;i<n;i++){
	cin>>a[i];
    if(a[i]<min){
		min=a[i];
    }
  }
int c=0;
   while(c<10){
  for(i=0;i<n;i++){
	if(a[i]>min){
      if(a[i]%min!=0){
		a[i]=a[i]%min;
      }else{
		a[i]=min;
      }
    }
    if(a[i]<min){
      min=a[i];
    }
  }
     c++;
     
   }
   
    cout<<min<<endl;
 
}
    


Measured memory_bytes: 2816
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;

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

  string S;
  cin >> S;
  int n = (int)S.size();
  string res(n, 'x');


  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC003_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var S = s.Any(i => i == 'S');
            var N = s.Any(i => i == 'N');
            var W = s.Any(i => i == 'W');
            var E = s.Any(i => i == 'E');
            if (S==N&&W==E)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 2776
#include<bits/stdc++.h>
using namespace std;
int cnt[100005];
int cnt2[100005];
int main() {
  int n;
  int a1, a2, a3, a4;
  int t1, t2, t3, t4;
  cin >> n;
  int a;
  for(int i = 0; i < n; ++i){
    cin >> a;
    if(i % 2) ++cnt2[a];
    else ++cnt[a];
  }
  a1 = a2 = a3 = a4 = 0;
  t1 = t2 = t3 = t4 = 0;

  for(int i = 1; i < 100005; ++i) {
    if(cnt[i] >= t1) {
      t2 = t1;
      t1 = cnt[i];
      a2 = a1;
      a1 = i;
    } else if(cnt[i] >= t2) {
      t2 = cnt[i];
      a2 = i;
    }
    if(cnt2[i] >= t3) {
      t4 = t3;
      t3 = cnt2[i];
      a4 = a3;
      a3 = i;
    } else if(cnt2[i] >= t4) {
      t4 = cnt2[i];
      a4 = i;
    }
  }
  //t1 = 3 t2 = 0 t3 = 2 t4 = 1
  //cout << t1 << " " << t2 << " " << t3 << " " << t4 << endl;
  if(a1 != a3) cout << (n / 2) - t1 + (n / 2) - t3 << endl;
  else {
    if((n/2)-t1+(n/2)-t4>(n/2)-t2+(n/2)-t3) cout<<(n/2)-t2+(n/2)-t3<<endl;
    else cout<<(n/2)-t1+(n/2)-t4<<endl;
  }
  return 0;
}

Measured memory_bytes: 1024
use std::collections::{BTreeMap, BTreeSet};

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut map = BTreeMap::new();
    for _ in 0..n {
        let s: String = sc.read();
        *map.entry(s).or_insert(0) += 1;
    }

    let max = *map.values().max().unwrap();
    let mut ans = vec![];
    for (s, count) in map.into_iter() {
        if count == max {
            ans.push(s);
        }
    }
    ans.sort();
    for ans in ans.into_iter() {
        println!("{}", ans);
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 26104
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <fstream>
using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
const double pi = 3.14159265359;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pii> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first;
        a[i].second = i;
    }
    SORT(a);
    vector<int> ans(n);
    for (int i = 0; i < n; ++i) {
        if (i!=n-1) {
           ans[a[i].second]=a[n - 1].first;
        }
        else {
            ans[a[i].second]=a[n - 2].first;

        }
    }
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(x) x.begin(), x.end()
#define lp(i, n) for (int i = 0; i < n; i++)
#define mem(a, v) memset(a, v, sizeof(a))
#define X real()
#define Y imag()
#define angle(a) (atan2(a.Y, a.X))
#define vec(a, b) ((b) - (a))
//#define length(a) (hypot(a.Y , a.X))
#define normalize(a) (a) / length(a)
#define dotP(a, b) ((conj(a) * b).X)
#define crossP(a, b) ((conj(a) * b).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(a) dotP(a, a)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(v, m) conj(v / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll n, ll x) {
  if (!x)
    return 1;
  if (x % 2)
    return n * fastpow(n, x - 1);
  ll p = fastpow(n, x / 2);
  p %= mod;
  p *= p;
  p %= mod;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll ret = num % mod;
  while (ret < 0)
    ret += mod;
  return ret;
}

ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
long double dist(pair<ll, ll> &a, pair<ll, ll> &b) {
  return sqrt(
      ((a.f - b.f) * (a.f - b.f) * 1.0 + (a.se - b.se) * (a.se - b.se)));
}
/*vector<int> ap;
bool np[MX];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <MX; j+=i) np[j] = 0;
        }
    }
    for(ll i = 2 ; i< MX ; i++) if(np[i]) ap.pb(i);
}*/
const ll MX = 1e5+5;
double dp[305][305][305];
bool v[305][305][305];
int n;
double solve(int one , int two , int three){
	if(!one && !two && !three)
		return 0;
	double &ret = dp[one][two][three];
	if(v[one][two][three]) return ret;
	int s = one + two + three;
	ret = 1.0*n/s;
	if(one) ret += 1.0*one/s*solve(one-1,two,three);
	if(two) ret += 1.0*two/s*solve(one+1,two-1,three);
	if(three) ret += 1.0*three/s*solve(one,two+1,three-1);
	v[one][two][three] = 1;
	return ret;
}
int main()
{
    IO;
    cin>>n;
    vector<int> cnt(4);
    for(int i = 0 ; i< n ;i++){
		int x;
		cin>>x;
		cnt[x]++;
	}
	cout<<fixed<<setprecision(10)<<solve(cnt[1],cnt[2],cnt[3]);
    
    return 0;
}



Measured memory_bytes: 246016
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		String p = kb.next();
		if (p.equals("AAA") || p.equals("BBB"))
			System.out.println("No");
		else
			System.out.println("Yes");
		kb.close();
	}

}


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

int main() {
  int n, m;
  cin >> n;
  // vector<string> s(n);
  map<string, int> s{}, t{};
  for (int i = 0; i < n; i++) {
    string p;
    cin >> p;
    s[p]++;
    // s.at(p)++;
  }
  cin >> m;
  // vector<string> t(m);
  for (int i = 0; i < m; i++) {
    string n;
    cin >> n;
    s[n]--;
  }
  int x = 0;
  for (auto itr = s.begin(); itr != s.end(); itr++) {
    if (x < itr->second) {
      x = itr->second;
    }
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
typedef vector<double>	vd;
#define br "\n"
#define MAXIM 1000003
ll n,k;
vll v;

bool p(ll x){
	ll c = 0;
	rep(i,0,n){
		c += (v[i]/x);
		if(v[i] % x == 0) c--; 
	}
	if(c > k) return false;
	return true;
}

void solve(){
	cin >> n >> k;
	v.resize(n);
	ll maxi = 0;
	rep(i,0,n) {
		cin >> v[i];
		maxi = max(v[i],maxi);
	}
	ll lo = 1,hi = maxi;
    while (lo < hi){
        ll mid = lo + (hi - lo)/2;
        if (p(mid) == true) hi = mid;
        else lo = mid + 1;
    }
    cout <<  lo; // lo is the least x for which p(x) is true FFFFFTTTTTT


}
 
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif  
	ll t = 1;
	// cin >> t;
	rep(i,0,t){
		solve();
	}
 
}

Measured memory_bytes: 4728