akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
  int n;
  scanf("%d", &n);
  vector<double> a(n);
  double seki = 1;
  REP(i, n){
    scanf("%lf", &a.at(i));
    seki *= a.at(i);
  }

  double wa = 0;
  REP(i, n){
    wa += seki / a.at(i);
  }
  double ans = seki / wa;
  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include <iomanip>
#define _USE_MATH_DEFINES

using namespace std;
 
int main() {
    double r;
    cin >> r;
    cout  << setprecision(6) << fixed << M_PI * r * r << ' ' << M_PI * 2 * r << endl;
}

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

using namespace std;

struct Dice
{
  int x, y;
  int l, r, f, b, d, u;

  void RollF()
  {
    --y;
    int buff = d;
    d = f;
    f = u;
    u = b;
    b = buff;
  }

  void RollB()
  {
    ++y;
    int buff = d;
    d = b;
    b = u;
    u = f;
    f = buff;
  }

  void RollL()
  {
    --x;
    int buff = d;
    d = l;
    l = u;
    u = r;
    r = buff;
  }

  void RollR()
  {
    ++x;
    int buff = d;
    d = r;
    r = u;
    u = l;
    l = buff;
  }
};


int main()
{
  auto input = []()
  {
    Dice dice;
    cin >> dice.u;
    cin >> dice.f;
    cin >> dice.l;
    cin >> dice.r;
    cin >> dice.b;
    cin >> dice.d;
    return (dice);
  };

  int N;
  cin >> N;
  vector< Dice > dd;
  for(int i = 0; i < N; i++) dd.push_back(input());

  for(int x = 0; x < N; x++) {
    for(int y = 0; y < x; y++) {
      for(int i = 0; i < 4; i++) {
        dd[x].RollL();
        for(int j = 0; j < 4; j++) {
          dd[x].RollB();
          for(int k = 0; k < 4; k++) {
            dd[x].RollL();
            if(dd[x].u == dd[y].u && dd[x].f == dd[y].f && dd[x].l == dd[y].l && dd[x].r == dd[y].r && dd[x].b == dd[y].b && dd[x].d == dd[y].d) {
              cout << "No" << endl;
              return (0);
            }
          }
        }
      }
    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 3100
class in{struct myIterator{int it;const bool rev;explicit constexpr myIterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(myIterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const myIterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const myIterator& begin(){return i;}const myIterator& end(){return n;}};

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

using i64 = long long;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    i64 n, p, q;
    cin >> n >> p >> q;
    vector<i64> a(n);
    for(i64& x : a) cin >> x;
    vector<i64> c(n);
    for(i64 i : in(n))
      c[i] = (q - i) * p - a[i];
    sort(c.rbegin(), c.rend());
    i64 ma = 0LL, score = 0LL;
    for(i64 i : in(n)) { // i + 1?????????????????¨???
        score += c[i];
        score += 2 * p * i;
        ma = max(ma, score);
    }
    cout << accumulate(a.begin(), a.end(), 0LL) + ma << endl;
}

Measured memory_bytes: 10724
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 60;
constexpr double EPS = 1e-9;

struct custom_tf : numpunct<char> {
  string do_truename() const { return "Yes"; }
  string do_falsename() const { return "No"; }
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new custom_tf));
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

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

int main() {
  int n; cin>>n;
  int dp[100010][3];
  rep(i, n) {
    int a, b, c;
    cin>>a>>b>>c;
    if (i==0) {
      dp[i][0] = a;
      dp[i][1] = b;
      dp[i][2] = c;
      continue;
    }
    dp[i][0] = a + max(dp[i-1][1], dp[i-1][2]);
    dp[i][1] = b + max(dp[i-1][0], dp[i-1][2]);
    dp[i][2] = c + max(dp[i-1][0], dp[i-1][1]);
  }
  print(max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}));
  return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

class MOD {
    static final int mod = 1000000007;

    static int add(int a, int b){
        int x = a + b;
        return (x >= mod) ? x - mod : x;
    }

    static int sub(int a, int b){
        int x = a - b;
        return (x < 0) ? x + mod : x;
    }

    static int mul(int a, int b){
        long x = (long)a * (long)b;
        return (int)(x % mod);
    }

    static int div(int a, int b){
        return mul(a, modinv(b));
    }

    static int modinv(int a) {
        int b = mod;
        int u = 1;
        int v = 0;
        while (b != 0) {
            int t = a / b;
            a -= t * b;
            int temp = a; a = b; b = temp; // swap(a, b)
            u -= t * v;
            temp = u; u = v; v = temp; // swap(u, v)
        }
        u %= mod;
        if (u < 0) u += mod;
        return u;
    }
}

public class Main {
    static Scanner stdIn = new Scanner(System.in);
    public static void main(String[] args){
		int n = stdIn.nextInt();
		int m = stdIn.nextInt();
		boolean[] crash = new boolean[n];
		for(int i=0; i<m; i++){
			int idx = stdIn.nextInt();
			crash[idx-1] = true;
		}

		int[] dp = new int[n];
		dp[0] = crash[0] ? 0 : 1;
		if(2 <= n)
			dp[1] = crash[1] ? 0 : dp[0] + 1;
		for(int i=2; i<n; i++){
			if(!crash[i-1]){
				dp[i] = dp[i-1];
			}
			if(!crash[i-2]){
				dp[i] = MOD.add(dp[i], dp[i-2]);
			}
		}

		System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 58048
//ツ環ョツ青ャ
#include<stdio.h>
int map[51][51];
int w,h;
void search(int _h,int _w){
	if(_h<0||_w<0||_h>h||_w>w||map[_h][_w]==0)return;
	int i,j;
	map[_h][_w]=0;
	search(_h-1,_w);
	search(_h-1,_w+1);
	search(_h,_w+1);
	search(_h+1,_w+1);
	search(_h+1,_w);
	search(_h+1,_w-1);
	search(_h,_w-1);
	search(_h-1,_w-1);
}int main(){
	int i,j,c;
	while(1){
		c=0;
		scanf("%d %d",&w,&h);
		if(!w && !h)break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++)scanf("%d",&map[i][j]);
		}
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(map[i][j]==1){
					search(i,j);
					c++;
				}
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 0
k=int(input())
X=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(X[k-1])

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k;
  int array[1005];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  
  sort(array,array+n);
  int sum=0;
  for(int i=0;i<k;i++){
    sum+=array[i];
  }
  cout<<sum<<endl;
  return(0);
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    ll n;
    cin >> n;
    ll a[n],b[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    ll k = 0;
    ll l = 0;
    for(int i = 0; i < n; i++){
        if(a[i]-b[i] > 0){
            k += a[i]-b[i];
        }else{
            l += (b[i]-a[i])/2;
        }
    }
    if(k <= l){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

#include <math.h>

int dist(int *a){
  //return *a;
  return *(a+4);
};

int main() {
  int n, d, ni, di, ptr, pt1, pt2;
  int sum, temp, ans;
  ans = 0;
  //cout << sizeof(int) << endl;
  cin >> n >> d;
  //cout << n << d << endl;
  int arr[10][10];
  
  for(ni=0; ni<n; ni++){
    for(di=0; di<d; di++){
      cin >> arr[ni][di] ;
    }
  }
  
  //cout << arr[1][1] << endl;
  
  for(pt1=0; pt1<(n-1); pt1++){
//cout << arr[0][0] << arr[0][1] << endl;
    for(pt2=(pt1+1); pt2<n; pt2++){
      sum = 0;
      for(ptr=0; ptr<d; ptr++){
        sum += (arr[pt1][ptr] - arr[pt2][ptr])*(arr[pt1][ptr] - arr[pt2][ptr]);
      }
      //cout << sum << endl;
      temp = sqrt(sum) ;
      if(temp*temp == sum)
        ans++;
    }
  }

  cout << ans << endl;
  //cout << dist( &arr[0][0] ) << endl;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template<class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template<class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

//IN
void IN() {}
template<class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

//OUTS
template<size_t> struct int_{};
template<class Tuple, size_t Pos>
ostream& print_tuple(ostream& out, const Tuple& t, int_<Pos>) {
  out << get<tuple_size<Tuple>::value-Pos>(t) << " ";
  return print_tuple(out, t, int_<Pos-1>());
}

template <class Tuple>
ostream& print_tuple(ostream& out, const Tuple& t, int_<1>) {
  return out << get<tuple_size<Tuple>::value-1>(t);
}

template<class... Args>
ostream& operator<<(ostream& out, const tuple<Args...>& t) {
  return print_tuple(out, t, int_<sizeof...(Args)>());
}

#define OUTS(...) cout << make_tuple(__VA_ARGS__) << "\n";

//OUTL
void OUTL() {}
template<class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

//OUTN
void OUTN() {}
template<class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}
// }}} End

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

  VAR(int, n);

  i64 res = 0;
  map<i64, int> mp;
  rep(i, n) {
    VAR(int, a);
    if (mp[a]) {
      mp[a] = 0;
      --res;
    }
    else {
      mp[a] = 1;
      ++res;
    }
  }

  OUTL(res);
  return 0;
}


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

public class Main {
  Scanner sc;

  int ex(int src, int ratio) {
    return ( src * ( ratio + 100 ) ) / 100;
  }

  void run() {
    for ( ;; ) {
      int x, y, s;

      x = ni();
      y = ni();
      s = ni();

      if ( ( x | y | s ) == 0 ) {
        break;
      }

      int max = 0;
      for ( int i = 1; i <= s / 2; ++i ) {
        int a = ex( i, x );
        for ( int j = s; 0 <= j; --j ) {
          int b = ex( j, x );

          if ( a + b == s ) {
            max = Math.max( max, ex( i, y ) + ex( j, y ) );
            break;
          }
        }
      }

      System.out.println( max );
    }

  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 20988
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  vector<int> p(n);
  int ca,cb,cc;
  ca = cb = cc = 0;
  for(int i = 0;i<n;i++){
    cin >> p[i];
    if(p[i] <= a) ca++;
    else if(a < p[i] && p[i] <= b) cb++;
    else cc++;
  }
  int an = min(ca,cb);
  int answer = min(an,cc);
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 10000
#define Q 500

int compare(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

int *uniq(int *a, int *n){
  int i, j, prev = a[0];
  for(i=1, j=1; i<*n; i++){
    if(prev != a[i]){
      a[j] = a[i];
      prev = a[i];
      j++;
    }
  }
  *n = j;
  return a;
}

int main(void)
{
  int i, j, n, q, c=0;
  int S[N], T[Q];

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

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

  qsort(S, n, sizeof(int), compare);
  uniq(S, &n);

  for(i=0; i<n; i++){
    for(j=0; j<q; j++){
      if(S[i] == T[j]){
        c++;
      }
    }
  }
  printf("%d\n", c);

  return 0;
}

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

void printFrame(int H,int W){
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			if(i==0 || i == H-1 || j == 0 || j == W-1){
				cout<<"#";
			}else{
				cout<<".";
			}
		}
		cout<<endl;
	}
}

int main()
{
	int H,W;
	cin>>H>>W;
	while( H!= 0 && W != 0 ){
		printFrame(H,W);
		cout<<endl;
		cin>>H>>W;
	}
	return 0;
}

Measured memory_bytes: 3020
import sys

N, M = list(map(int, input().split()))
sc_list = []
for _ in range(M):
    sc_list.append(list(map(int, input().split())))

if N == 1:
    nums = range(10)
elif N == 2:
    nums = range(10, 100)
else:
    nums = range(100, 1000)

for num in nums:
    for s, c in sc_list:
        if s > N:
            break
        if int(str(num)[s - 1]) != c:
            break
    else:
        print(num)
        sys.exit(0)
print(-1)

Measured memory_bytes: 3064
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;
import std.math;
void main() {
	string s;
	while( (s=readln()).length != 0 ){
		string[] input = split(s);
		int a = to!int(input[0]);
		int x= 0;
		for(int i=0;i<10;i++){
			if(a%2==1){
				if(x!=0) write(" ");
				write(pow(2,i));
				x++;
			}
			a/=2;
		}
		writeln();
	}
}

Measured memory_bytes: 2456
a,b = map(int,input().split())
import math
c = math.ceil(a/0.08)
d = round(b/ (0.1))
e = math.ceil((a+1)/0.08)-1
f = round((b+1)/0.1)-1
i = c
j = -1
for i in range(c,e+1):
    if d <= i <= f:
        j = i
        break
    else:
        i = i+1
print(j)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
static const int N=100;

int main(){
  int n,p[N+1],m[N+1][N+1];
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>p[i-1]>>p[i];
  }
  for(int i=1;i<=n;i++)m[i][i]=0;
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      m[i][j]=(1<<21);
      for(int k=i;k<=j-1;k++){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  cout<<m[1][n]<<endl;
  return 0;
}



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

using ll = long long int;

const int MAX_N = (int)(2e5 + 5);

int n, k;

ll cnt[MAX_N];
map<int, pair<int, int>> mp;

ll ans;

int main(void){
  scanf("%d %d", &n, &k);

  for (int i = 1; i <= n; ++i) cnt[i % k] += 1;

  for (int i = 1; i <= n; ++i) {
    int amodk = i % k;
    if (mp.find(amodk) != mp.end()) continue;
    int bmodk = (k - amodk) % k;
    int cmodk = (k - bmodk) % k;
    int amodk_re = (k - cmodk) % k;
    if (amodk == amodk_re) mp[amodk] = make_pair(bmodk, cmodk);
  }

  for (const auto e : mp) {
    ans += (cnt[e.first] * cnt[e.second.first] * cnt[e.second.second]);
  }

  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1024
n=int(input())
count1=0
count2=0
count3=0
ans=0
for i in range(n):
	flag=0
	s=str(input())
	for j in range(len(s)-1):
		if(s[j]+s[j+1]=='AB'):
			ans+=1

	if(s[-1]=='A' and s[0]=='B'):
		count1+=1
	elif(s[0]=='B'):
		count2+=1
	elif(s[-1]=='A'):
		count3+=1
#print(ans,count1,count2,count3)
if(count3>0):
	count3-=1
	ans+=count1
	if(count2>0):
		ans+=1
		count2-=1
else:
	if(count1>0):
		ans+=count1-1
		if(count2>0):
			ans+=1
			count2-=1

while(count3>0 and count2>0):
	ans+=1
	count2-=1
	count3-=1

print(ans)


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

signed main()
{
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> cou(3, 0);
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        if(x <= a)
            ++cou[0];
        else if(x >= b + 1)
            ++cou[1];
        else
            ++cou[2];
    }
    cout << *min_element(cou.begin(), cou.end()) << endl;

}


Measured memory_bytes: 256
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var arr = new long[n];
        string[] line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++) arr[i] = int.Parse(line[i]);
        Console.WriteLine("{0} {1} {2}", arr.Min(), arr.Max(), arr.Sum());

    }
}



Measured memory_bytes: 18320
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

	static final int WIN = 1;
	static final int LOSE = 2;
	static final int EVEN = 3;
	
    public static void main( final String[] args ) {

		final Scanner stdin = new Scanner( System.in );

		while ( true ) {

			final int[] array = new int[ 5 ];
			array[ 0 ] = stdin.nextInt();
			if ( array[ 0 ] == 0 ) break;
			for ( int i = 1; i < 5; i++ ) {
				array[ i ] = stdin.nextInt();
			}
			int sum = 0;
			for ( final int val : array ) {
				sum |= 1 << ( val - 1 );
			}
			final int count = Integer.bitCount( sum );
			if ( count == 2 ) {
				int winIndex = -1;
				int loseIndex = -1;
				if ( sum == 3 ) {
					winIndex = 1;
					loseIndex = 2;
				} else if ( sum == 5 ) {
					winIndex = 3;
					loseIndex = 1;
				} else {
					winIndex = 2;
					loseIndex = 3;
				}
				for ( int i = 0; i < 5; i++ ) {
					if ( array[ i ] == winIndex ) { array[ i ] = WIN; }
					else if ( array[ i ] == loseIndex ) { array[ i ] = LOSE; }
				}
			} else {
				Arrays.fill( array, EVEN );
			}
			for ( final int val : array ) {
				System.out.println( val );
			}
		}	
    }    
}

Measured memory_bytes: 20804
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class place {
public:
	int num, volume;
};
int main() {
	int n, m;
	while (cin >> n >> m&&n&m) {
		int x;
		vector<place>G(m);
		for (int i = 0; i < m; i++)G[i].num = i + 1;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				cin >> x;
				G[j].volume += x;
			}
		}
		sort(G.begin(), G.end(), [](const place& a, const place & b) {return (a.volume == b.volume) ? a.num<b.num : a.volume > b.volume; });
		for (int i = 0; i < m; i++) {
			if (i != 0)cout << ' ';
			cout << G[i].num;
		}
		cout << endl;

	}
	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int a[n], sum = 0, result = 1;
    for (int i = 0; cin >> a[i]; i++) {
        sum += a[i];
    }
    auto solve = [&](int num) {
        int r[n], suffix[n + 1];
        for (int i = 0; i < n; i++) {
            r[i] = a[i] % num;
        }
        sort(r, r + n);
        suffix[n] = 0;
        for (int i = n - 1; i >= 0; i--) {
            suffix[i] = suffix[i + 1] + (num - r[i]) % num;
        }
        for (int prefix = 0, i = 0; i < n; i++) {
            prefix += r[i];
            if (prefix == suffix[i + 1] && prefix <= k) {
                return true;
            }
        }
        return false;
    };
    for (int i = 1; i * i <= sum; i++) {
        if (sum % i == 0) {
            if (solve(i)) {
                result = max(result, i);
            }
            if (solve(sum / i)) {
                result = max(result, sum / i);
            }
        }
    }
    cout << result;
    return 0;
}


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

void hawawa()
{
  string str, ans;
  cin >> str;
  for (auto&& i : str) {
    switch (i) {
    case 'B':
      if (ans.size()) {
        ans = ans.substr(0, ans.size() - 1);
      }
      break;
    default:
      ans += i;
    }
  }
  cout << ans << "\n";
}

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


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());

    loop {
        let h: usize = sc.next();
        let w: usize = sc.next();

        if h == 0 || w == 0 {
            break;
        }

        for x in 0..h {
            for y in 0..w {
                print!("{}", if (x + y) % 2 == 0 { '#' } else { '.' });
            }
            println!();
        }
        println!();
    }
}

/* ========== Scanner ========== */

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn next<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.next()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }
}



Measured memory_bytes: 5028
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n,count = 1;
        String s;
        
        n = sc.nextInt();
        s = sc.next();
        
        for(int i = 0; i < n - 1; i++){
            if(s.charAt(i) != s.charAt(i + 1)) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 25624
#include <iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a>b){
		swap(a,b);
	}
	if(a>c){
		swap(a,c);
	}
	if(b>c){
		swap(b,c);
	}
	cout<<a<<" "<<b<<" "<<c<<endl;;
}

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


int main()
{
  int A;
  cin >> A;
  int l, int_arr[A], counter = 0, temp=0;

  for (int i = 0; i < A; i++)
  {
    std::cin >> int_arr[i];

    l = int_arr[i];

    if (i == 0 || temp > l)
    {
      counter++;
      temp = l;
    }
    
  }
  

  cout << counter;

  return 0;
}

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

int main() {
    string n;
    cin >> n;
    for (int tmp = 0; tmp < (int)n.size(); tmp++){
        if (n[tmp] == '1'){
            n[tmp] = '9';
        } else if (n[tmp] =='9'){
            n[tmp] = '1';
        }
    }
    cout << n << endl;
    return 0;
}

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

int main()
{
  int g1[7] = {1, 3 , 5, 7, 8, 10, 12};
  int g2[4] = {4, 6, 9, 11};
  int g3[1] = {2};
  
  int x, y;
  char gx, gy;
  
  cin >> x >> y;
  
  for(int i = 0; i < sizeof(g1); i++)
  {
    if(x == g1[i])
    {
      gx = 'A';
    }
    if(y == g1[i])
    {
      gy = 'A';
    }
  }
  for(int i = 0; i < sizeof(g2); i++)
  {
    if(x == g2[i])
    {
      gx = 'B';
    }
    if(y == g2[i])
    {
      gy = 'B';
    }
  }
    for(int i = 0; i < sizeof(g3); i++)
  {
    if(x == g3[i])
    {
      gx = 'C';
    }
    if(y == g3[i])
    {
      gy = 'C';
    }
  }
  if(gx == gy)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>v(N); rep(i, 0, N) { cin >> v[i]; }
	sort(all(v));
	dump(v);
	vector<int>ans;
	map<int, int>mp;
	vector<int>hoge;
	for (auto x : v) {
		mp[x]++;
	}
	for (auto p : mp) {
		ans.eb(p.first);
		loop(p.second - 1) {
			hoge.eb(p.first);
		}
	}
	dump(ans);
	dump(hoge);

	cout << ans.size()-hoge.size()%2 << endl;

	return 0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  int ans=0;
  for(int i=0;i<n;i++){
    if(a[i]>=k) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>

typedef unsigned long long ull;
using namespace std;

ull permutation(ull a, ull b, ull m) {
  if (a < b) {
    return 0;
  }
  ull ret=1;
  while(b--) {
    ret = ret*(a--) % m;
  }
  return ret;
}

int main() {
  ull n,k,mod=1e9+7;
  cin>>n>>k;
  cout<<permutation(k, n, mod)<<endl;
  return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

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

  int n,m;
  cin >> n >> m;
  vector<int> a(m),b(m);
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
  }
  vector<int> cnt(n+1,0);
  for(int i = 0; i < m; i++){
    cnt[a[i]]++;
    cnt[b[i]]++;
  }
  for(int i = 1; i < n + 1; i++){
    cout << cnt[i] << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
namespace CsProgramSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<int> li = RLl();
            int max = li.Max();
            int lon = li.IndexOf(max);
            int sum = 0;
            for(int i = 0; i<n;i++)
            {
                if (i == lon) continue;
                sum += li[i];
            }
            if (max < sum)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
        private static List<int> RLl() => Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList();
    }
}

Measured memory_bytes: 13280
#![allow(unused)]
use std::io;
use std::collections::*;
use std::str::FromStr;

fn main() {
    let (h, w): (usize, usize) = read_tuple2();

    printw(w);
    for _ in 0..h {
        let line = read_line();
        println!("{}", format!("#{}#", line));
    }
    printw(w);
}

fn printw(w: usize) {
    for _ in 0..w+2 {
        print!("#");
    }
    println!();
}


fn read_line() -> String {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).expect("failed to read line");
    buffer.trim().to_string()
}

fn read_i32() -> i32 {
    read_line().trim().parse().unwrap_or_else(|e| panic!("{}", e))
}

fn read_tuple2<S:FromStr, T:FromStr>() -> (S, T) {
    let v: Vec<String> = read_tokens();
    return (
        v[0].parse().unwrap_or_else(|e| panic!("ohmygod")),
        v[1].parse().unwrap_or_else(|e| panic!("ohmygod"))
    )
}

fn read_tuple3<S:FromStr, T:FromStr, U:FromStr>() -> (S, T, U) {
    let v: Vec<String> = read_tokens();
    return (
        v[0].parse().unwrap_or_else(|e| panic!("ohmygod")),
        v[1].parse().unwrap_or_else(|e| panic!("ohmygod")),
        v[2].parse().unwrap_or_else(|e| panic!("ohmygod"))
    )
}

fn read_tokens<T: std::str::FromStr>() -> Vec<T> {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).expect("failed to read line");
    let mut buffer = buffer.split_whitespace();
    let mut tokens = vec![];
    loop {
        match buffer.next() {
            Some(token) => tokens.push(token.to_string().parse().unwrap_or_else(|e| panic!("ohmygod"))),
            None        => break
        }
    }
    tokens
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <tuple>
#include <numeric>
using namespace std;

#if 0
#define DEBUG(x) do{cerr << #x << "=" << x << endl;}while(0);
#else
#define DEBUG
#endif

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);

  for(int i=0; i<n+1; ++i){
        cin >> a[i];
  }
  for(int i=0; i<n; ++i){
        cin >> b[i];
  }

  long long sum = 0;
  for(int i=0; i<n; ++i){
        if( a[i] < b[i] ){
          sum += a[i];
          b[i] -= a[i];
          a[i] = 0;

          // 余力で右側も倒しておく
          if( a[i+1] < b[i] ){
            sum += a[i+1];
            b[i] -= a[i+1];
            a[i+1] = 0;
          }
          else{
            sum += b[i];
            a[i+1] -= b[i];
            b[i] = 0;
          }


        }
        else{
          sum += b[i];
          a[i] -= b[i];
          b[i] = 0;
        }
  }

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


Measured memory_bytes: 1024
import * as fs from "fs";

let input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");

const n = +input[0];
const a0 = input[1].split(" ").map((x: string): number => +x);
const a1 = input[2].split(" ").map((x: string): number => +x);

const s0: number[] = [];
for (let i = 0; i < n; i++) {
	if (i === 0) s0[i] = a0[i];
	else s0[i] = a0[i] + s0[i - 1];
}

const s1: number[] = [];
for (let i = n - 1; i >= 0; i--) {
	if (i === n - 1) s1[i] = a1[i];
	else s1[i] = a1[i] + s1[i + 1];
}

let result = -1;
for (let i = 0; i < n; i++) {
	const sum = s0[i] + s1[i];
	if (sum > result) result = sum;
}
console.log(result);

Measured memory_bytes: 7500
n = gets.to_i
s = []
n.times { s << gets.to_i }

zero = s.select {|v| v % 10 == 0}
collect = s.select {|v| v % 10 != 0}.sort
if collect.empty?
  puts 0
  exit
end

val = s.inject(:+)
if val % 10 != 0
  puts val
  exit
end

puts collect[1..-1].inject(:+) + zero.inject(:+)


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
    static int input;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        input = Integer.parseInt(sc.next());


        System.out.println(dfs(0L));
    }


    public static int dfs(long s) {
        if (s > input) return 0;

        String strVal = String.valueOf(s);

        int val = 0;
        if (strVal.contains("3") && strVal.contains("5") && strVal.contains("7")) val = 1;

        val += dfs(s * 10 + 3);
        val += dfs(s * 10 + 5);
        val += dfs(s * 10 + 7);

        return val;
    }
}



Measured memory_bytes: 27476
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double p[n];
    for(int i=0;i<n;i++)cin>>p[i];
    double a[n+1][n+1]={0};
    a[0][0] = 1;
    for(int i=0;i<n;i++)
        for(int j=0;j<=i;j++)
            a[i+1][j] += a[i][j]*(1-p[i]),
            a[i+1][j+1] += a[i][j]*p[i];
    double ans=0;
    for(int j=n/2+1;j<=n;j++)
        ans += a[n][j];
 
    cout <<fixed<<setprecision(10)<<ans;
    return 0;
}

Measured memory_bytes: 70528
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n,d;
    cin >> n >> d;
    ll cnt = 0;
    while(n--){
        ll x,y;
        cin >> x >> y;
        ll r = x*x + y*y;
        if(d*d >= r) cnt++;

    }
    cout << cnt << endl;

}

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

#define INF 1000000005
int ifcnt=0;
void merge(int *A,int l,int m,int r){
  int n1,n2,i,li,ri,L[300000],R[300000];
  n1=m-l;
  n2=r-m;
  for (i=l;i<m;i++) L[i-l]=A[i];
  for (i=m;i<r;i++) R[i-m]=A[i];
  L[n1]=INF;
  R[n2]=INF;
  li=0;
  ri=0;
  for (i=l;i<r;i++){
    if (L[li]<=R[ri]){
      A[i]=L[li];
      li++;
    }else{
      A[i]=R[ri];
      ri++;
    }
    ifcnt++;
  }
}

void mergeSort(int *A,int l,int r){
  int m;
  if (l+1<r){
    m=(l+r)/2;
    mergeSort(A,l,m);
    mergeSort(A,m,r);
    merge(A,l,m,r);
  }
}

int main(){
  int n,i,S[500005];

  cin >> n;

  for (i=0;i<n;i++) cin >> S[i];

  mergeSort(S,0,n);
  
  for (i=0;i<n;i++){
    cout << S[i];
    if (i<n-1) cout << " ";
  }
  
  cout << endl;
  cout << ifcnt << endl;

  return 0;
}

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

int main(){
  int k;
  cin >> k;
  vector<long long> A(k);
  for (int i = 0; i < k; ++i){
    cin >> A[i];
  }
  long long minv = 2, maxv = 2;
  for (int i = k - 1; i >= 0; --i){
    long long tmp1;
    if (minv % A[i] == 0){
    	tmp1 = minv;
    }else{
    	tmp1 = A[i]*(minv / A[i] + 1);
    }
    if (tmp1 > maxv){
      cout << -1 << endl;
      return 0;
    }
    long long tmp2 = (maxv/A[i])*A[i];
    if (tmp2 < minv){
    	cout << -1 << endl;
      	return 0;
    }
    minv = tmp1;
    maxv = tmp2 + A[i] - 1;
  }
  cout << minv << " " << maxv << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<vector>
#include <algorithm>
#include <complex>
using namespace std;

typedef long long int lli;
const double EPS = 1e-10;
template<class T>
bool eq(const T& a, const T& b) {return abs(a - b) < EPS;}

typedef  complex<double> point;
// sort/unique用、setではうまく動かないので使うべからず
namespace std {
	bool operator==(const point &a, const point &b){
		return eq(a, b);
	}
	bool operator<(const point& a, const point& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const point& a, const point& b) {
	return imag(conj(a)*b);
}
double dot(const point& a, const point& b) {
	return real(conj(a)*b);
}

int ccw(point a, point b, point c) {
	b -= a; c -= a;
	if (cross(b, c) > 0)   return +1;  // counter clockwise
	if (cross(b, c) < 0)   return -1;  // clockwise
	if (dot(b, c) < 0)     return +2;  // c--a--b on line
	if (norm(b) < norm(c)) return -2;  // a--b--c on line
	return 0;  // a--c--b on line or a----bc
}


typedef vector<point> polygon;

//凸包
//点集合 ps に対してその凸包を求める．
//O(n log n)
polygon  convex_hull(polygon ps) {
  int n=ps.size(), k=0;
  sort(ps.begin(), ps.end());
  polygon ch(2*n);
  for (int i=0; i < n; ch[k++]=ps[i++]) // lower-hull
    while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  for (int i=n-2, t=k+1; i >= 0; ch[k++]=ps[i--]) // upper-hull
    while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
  ch.resize(k-1);
  return ch;
}

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      polygon a;
      for(int i=0;i<n;i++)
	{
	  double x,y;
	  char aa;
	  cin>>x>>aa>>y;
	  a.push_back(point(x,y));
	}
      cout<<n-convex_hull(a).size()<<endl;
    }

}

Measured memory_bytes: 1268
//gcc -o program test.c
//./program
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=4609152#2
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
    char suit;//記号
    int value;//数
};
struct Card L[MAX/2+2],R[MAX/2+2];//カード情報を書くのする箱を作る

void merge(struct Card Do_merge[],int left,int mid,int right){
    int i,j,k;
    int left2mid=mid-left;
    int right2mid=right-mid;
    for(i=0;i<left2mid;i++){
        L[i]=Do_merge[left+i];
    }
    for(i=0;i<right2mid;i++){
        R[i]=Do_merge[mid+i];
    }
    L[left2mid].value=R[right2mid].value=SENTINEL;
    i=j=0;
    for(k=left;k<right;k++){
        if(L[i].value<=R[j].value){
            Do_merge[k]=L[i++];
        }else{
            Do_merge[k]=R[j++];
        }
    }
}

void mergeSort(struct Card Do_merge[],int left ,int right){
    int mid;
    if(left+1<right){
        mid=(left+right)/2;
        mergeSort(Do_merge,left,mid);
        mergeSort(Do_merge,mid,right);
        merge(Do_merge,left,mid,right);
    }
}

int partition(struct Card Do_quick[],int p,int r){//配列の分離
    int i,j;
    struct Card t,x;
    x=Do_quick[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(Do_quick[j].value<=x.value){
            i++;
            t=Do_quick[i];//値の交換
            Do_quick[i]=Do_quick[j];
            Do_quick[j]=t;
        }
    }
    t=Do_quick[i+1];//値の交換
    Do_quick[i+1]=Do_quick[r];
    Do_quick[r]=t;
    return i+1;
}

void quickSort(struct Card Do_quick[],int p,int r){
    int q;
    if(p<r){
        q=partition(Do_quick,p,r);
        quickSort(Do_quick,p,q-1);
        quickSort(Do_quick,q+1,r);
    }
}

int main(void){
    int card_num;//カードの枚数n
    int card_value;//カードの値v
    struct Card Do_merge[MAX],Do_quick[MAX];
    char Suit[10];//記号を入力させる。間違って複数の文字を書いても止めないために配列にしている？
    int stable=1;//安定か否かのbool型

    scanf("%d",&card_num);//カードの枚数入力
    for(int i=0;i<card_num;i++){//カード情報入力
        scanf("%s %d",Suit,&card_value);
        Do_merge[i].suit=Do_quick[i].suit=Suit[0];
        Do_merge[i].value=Do_quick[i].value=card_value;
    }

    mergeSort(Do_merge,0,card_num);
    quickSort(Do_quick,0,card_num-1);
    for(int i=0;i<card_num;i++){
        //マージソートとクイックソートの結果を比較して安定か否の判定
        if(Do_merge[i].suit!=Do_quick[i].suit){
            stable=0;
        }
    }
    if(stable==1){
        printf("Stable\n");
    }else{
        printf("Not stable\n");
    }
    for(int i=0;i<card_num;i++){
        printf("%c %d\n",Do_quick[i].suit,Do_quick[i].value);
    }
    return 0;
}


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

int main(){

    int X, Y , A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<int> p(A);
    vector<int> q(B);
    vector<int> r(C);

    for (int i = 0; i < A; i++) cin >> p.at(i);
    for (int i = 0; i < B; i++) cin >> q.at(i);
    for (int i = 0; i < C; i++) cin >> r.at(i);

    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());

    vector<int> vec;
    for (int i = 0; i < X; i++) vec.push_back(p.at(i));
    for (int i = 0; i < Y; i++) vec.push_back(q.at(i));
    for (int i = 0; i < C; i++) vec.push_back(r.at(i));
    sort(vec.rbegin(), vec.rend());
    long long ans = 0;
    for (int i = 0; i < X + Y; i++) ans += vec.at(i);
    cout << ans << endl;

    return 0; 
}

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

int main()
{
	vector<int> a;
	int q;

	cin >> q;

	for (int i = 0; i < q; i++) {
		int t;
		cin >> t;

		if (t == 0) {
			int x;
			cin >> x;
			a.push_back(x);
		}
		else if (t == 1) {
			int p;
			cin >> p;
			cout << a[p] << endl;
		}
		else if (t == 2) {
			a.pop_back();
		}
	}

	return 0;
}


Measured memory_bytes: 3876
// **** WHEN THE GOING GETS TOUGH, THE TOUGH GETS GOING. ****

#include<bits/stdc++.h>
using namespace std;
#define fi              first
#define se              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pll             pair<ll,ll>
#define vll              vector<int>
#define mll             map<ll,ll>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define md             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
void hi()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
void bye()
{
    #ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    #endif
}

void solve()
{
    ll n,ans=0; cin>>n;
    string s; map<string,ll> m;
    m["AC"]=0,m["WA"]=0,m["TLE"]=0,m["RE"]=0;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<"\n";
    cout<<"WA x "<<m["WA"]<<"\n";
    cout<<"TLE x "<<m["TLE"]<<"\n";
    cout<<"RE x "<<m["RE"]<<"\n";
}
int main()
{
    hi();
    ll test_cases=1; //cin>>test_cases;
    for(ll t=1;t<=test_cases;t++)
    {
        solve();
    }
    bye();
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<int, int> pint;



vstr str;

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




int main() {
	int N;
	string strl;
	bool ok = true;
	cin >> N;

	rep(i, N) {
		cin >> strl;
		str.push_back(strl);
	}


	rep(i, N) {
		rep(j, i) {
			if (str[j] == str[i])
				ok = false;
	    }

		if (i < N - 1 && str[i][str[i].size()-1] != str[i+1][0]) {
			ok = false;
		}




	}

	if (ok == true) {

		cout << "Yes" << endl;
	}

	else
		cout << "No" << endl;





	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
   ll n;
   cin>>n;
   ll ans=n;
   for(ll i=2;i*i<=n;i++){
       if(n%i==0){
           n/=i;
           ans -=ans/i;
           while(n%i==0){
               n/=i;
           }
       }
   }
   if(n>1){
       ans-=ans/n;
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;


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

	return 0;
}


Measured memory_bytes: 3812
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int x;
	cin>>x;
	if(x==3||x==5||x==7) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ABCD = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var (A, B, C, D) = (ABCD[0], ABCD[1], ABCD[2], ABCD[3]);
            var answer = Math.Max(A * B, C * D);
            Console.WriteLine(answer);
        }
    }
}


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

int main(){
    int n; cin >> n;
    int w[n];

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

    int sub = 99999;

    for (int t=0;t<=n;t++) {
        int w_a = 0;
        int w_b = 0;

        // 1<=Tの重さ
        for (int s=0;s<=t;s++) {
            w_a+=w[s];
        }

        // T<Nの重さ
        for (int u=t+1; u<n;u++) {
            w_b+=w[u];
        }

        int tmp_sub = abs(w_a - w_b);

        if (sub > tmp_sub) {
            sub = tmp_sub;
        }
    }

    cout << sub << endl;

    return 0;   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Accepted 0
using namespace std;
int n,m,mp[555][555],dp[555][555];
bool used[111][111];
char s[555];
void bfs(int x,int y,int &z)
{
	if (x==1 && y==1)
	{
		z=1;
		return;
	}
	z=min(z,dp[x-1][y]+1);z=min(z,dp[x][y-1]+1);
	used[x][y]=1;
	if (x-1>=1 && !mp[x-1][y] && !used[x-1][y]) bfs(x-1,y,z);
	if (y-1>=1 && !mp[x][y-1] && !used[x][y-1]) bfs(x,y-1,z);
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",s);
		for (int j=1;j<=m;j++)
		{
			mp[i][j]=(s[j-1]=='.');
		}
	}
	dp[1][1]=(!mp[1][1]);
	for (int i=1;i<=max(n,m);i++)
	{
		dp[i][0]=dp[0][i]=1e9;
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if (i==1 && j==1) continue;
			if (mp[i][j])
			{
				dp[i][j]=min(dp[i][j-1],dp[i-1][j]);
			}
			else 
			{
				memset(used,0,sizeof(used));
				dp[i][j]=1e9;
				bfs(i,j,dp[i][j]);
			}
		}
	}
	printf("%d\n",dp[n][m]);
	return 0;
}

Measured memory_bytes: 640