akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  using ll = long long;
  int n;
  cin >> n;

  vector<pair<ll, ll>> va;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    va.push_back({a, i});
  }

  sort(va.begin(), va.end(), greater<pair<ll, ll>>());

  vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 0));
  ll ans = 0;
  for (int l = 0; l < n; l++) {
    for (int r = 0; r < n; r++) {
      if (l + r == n) {
        ans = max(ans, dp[l][r]);
        break;
      }

      auto [a, idx] = va[l + r];
      dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + abs(idx - l) * a);
      dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + abs(idx - (n - 1 - r)) * a);
    }
  }

  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 34440
#include<bits/stdc++.h>
using namespace std;
const int N = 5050;
int main(){
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	printf("%lld\n",min(a,b)+min(c,d));
	return 0;
}

Measured memory_bytes: 256
(defun split (x str &optional (l nil))
  (let ((pos (search x str))
	(size (length x)))
    (if (null pos) (nreverse (cons str l))
      (split x (subseq str (+ pos size)) (cons (subseq str 0 pos) l)))))

(defun acgt2y (l)
  (map 'string
       #'(lambda (c)
	   (if (find c "ACGT") #\y #\space))
       l))

(princ (reduce 'max (map 'list #'length (split " " (acgt2y (read-line))))))

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n, x;
  cin >> n >> x;

  vector<ll> a(n);
  REP(i, n)
    cin >> a[i];

  ll ans = 0;
  if(a[0] >x){
    ans += a[0] - x;
    a[0] = x;
  }

  REP1(i, n){
    if(a[i]+a[i-1] > x){
      ll margin = a[i]+a[i-1]-x;
      ans += margin;
      a[i] -= margin;
    }
  }

  cout << ans << endl;
      
  
  
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <map>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)	
using namespace std;
long double t,x; 
int main ()
{
	cin>>t>>x;
	cout<<t/x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int INF = 1LL << 30;
int H, W;
string s[110];
int dis[110][110];

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

    cin >> H >> W;
    REP (i, H) cin >> s[i];
    fill_n((int*)dis, 110 * 110, INF);
    REP (i, H) REP (j, W) {
        if (i == 0 && j == 0) {
            dis[i][j] = (s[i][j] == '#');
        } else if (s[i][j] == '.') {
            if (i - 1 >= 0) dis[i][j] = min(dis[i][j], dis[i - 1][j]);
            if (j - 1 >= 0) dis[i][j] = min(dis[i][j], dis[i][j - 1]);
        } else {
            if (i - 1 >= 0) dis[i][j] = min(dis[i][j], dis[i - 1][j] + (s[i - 1][j] == '.'));
            if (j - 1 >= 0) dis[i][j] = min(dis[i][j], dis[i][j - 1] + (s[i][j - 1] == '.'));
        }
    }
    cout << dis[H - 1][W - 1] << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;

struct P{
   char c;
   int n;
   P() {}
   P(char c, int n): c(c), n(n) {}

   bool operator < (const P& rhs) const {
      return( n < rhs.n );
   }

   bool operator > (const P& rhs) const {
      return( n > rhs.n );
   }

   bool operator == (const P &rhs) const {
      return( c == rhs.c && n == rhs.n);
   }
};

void bubble(P *a, int N){
   bool f = true;
   for(int i=0; f; ++i){
      f = false;
      for(int j = N-1; j > i; --j){
         if( a[j-1] > a[j] ){
            swap(a[j-1], a[j]);
            ++f;
         }
      }
   }
   return;
}

void selection(P *a, int N){
   rep(i, N){
      int minp = i;
      for(int j = i+1; j < N; ++j)
         if( a[j] < a[minp] )minp = j;
      if(i != minp)
         swap(a[i], a[minp]);
   }
   return;
}

void print(P *a, int N){
   rep(i, N){
      printf("%c%d%c", a[i].c, a[i].n, i+1 < N ? ' ' : '\n' );
   }
}

bool isStable(P *a, P *b, int N){
   int i = 0;
   a[N].c = '#';  //番兵
   b[N].c = '$';

   while(a[i] == b[i]) ++i;

   return(i == N);
}

int main()
{
   int N;
   char s[4];
   P a[40], b[40];

   scanf("%d", &N);
   rep(i, N){
      scanf("%s", s);
      b[i] = a[i] = P( s[0], s[1] - '0' );
   }

   bubble(a, N);
   selection(b, N);

   print(a, N);
   puts("Stable");

   print(b, N);
   puts( isStable(a, b, N) ? "Stable" : "Not stable" );

   return(0);
}




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

int main()
{
  string S ;
  cin>>S ;
  
  int num_1=0,num_0=0 ;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='1') num_1++ ;
    else num_0++ ;
  }
  cout<<2*(num_1>num_0?num_0:num_1)<<endl ;
  
  return 0 ;
}


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

double c (double sum, double n, int t) {
    if (t >= 10) return sum;
    if ((t+1) % 2 == 1) {
        sum += n;
        n *= 2.0;
        return c(sum, n, t+1);
    } else {
        sum += n;
        n /= 3.0;
        return c(sum, n, t+1);
    }
}

int main ()
{
    double n;
    while (cin >> n) {
        printf("%.7f\n", c(0.0, n, 0));
    }

    return 0;
}

Measured memory_bytes: 1228
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] a = new int[N];
		sc.fill(a);

		int min = Integer.MAX_VALUE;
		for (int i = 0; i <= N - K; i++) {
			int left = a[i];
			int right = a[i + K - 1];
			if (left > 0) {
				left = 0;
			}
			if (right < 0) {
				right = 0;
			}
			debug(left, right);

			min = Math.min(min, Math.abs(left) + right * 2);
			min = Math.min(min, Math.abs(left) * 2 + right);
		}

		System.out.println(min);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 26324
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]
dp = [0] * n
ls = [[] for i in range(n)]
for i in ab:
    ls[i[0]-1].append(i[1]-1)
for i in px:
    dp[i[0]-1] += i[1]
for i in range(n):
    for j in ls[i]:
        dp[j] += dp[i]
print(*dp)


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


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

int gcdTripple(int a, int b, int c){
    int d = gcd(a, b);
    return gcd(d, c);
}

int main() {
    string K;
    cin >> K;

    int k = stoi(K);

    int sum = 0;

    for(int a = 1; a <= k; ++a) {
        for(int b = 1; b <= k; ++b) {
            for(int c = 1; c <= k; ++c) {
                sum += gcdTripple(a, b, c);
            }
        }
    }

    cout << sum;

    return 0;
}


Measured memory_bytes: 3632
def solve():
    n = int(input())
    s = input()

    cnt = [s[1:n].count("E")]

    for i in range(1, n):
        cnt.append(cnt[i-1] - int(s[i] is "E") + int(s[i-1] is "W"))

    print(min(cnt))

if __name__=='__main__':
   solve()

Measured memory_bytes: 15544
#include <cstdio>
#include <ctime>
#include <cstdlib>

int n, h, p = 0;
char data[10][10];

main(){
  scanf("%d", &n);
  getchar();
  for(int i=0;i<n;i++){
    bool f = true;
    for(int j=0;j<n;j++){
      scanf("%c", &data[i][j]);
      if(data[i][j] == 'x') f = false;
    }
    if(f) p = i+1;
    getchar();
  }
  srand((unsigned int)time(NULL));
  for(int i=0;i<1000;i++){
    printf("%d\n", (p ? p : rand()%n+1));
    fflush(stdout);
    scanf("%d", &h);
  }
}

Measured memory_bytes: 0
parseInt(x) = parse(Int, x)
parseFloat(x) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    d=parseInt(readline())
    if d==25
        println("Christmas")
    elseif d==24
        println("Christmas Eve")
    elseif d==23
        println("Christmas Eve Eve")
    elseif d==22
        println("Christmas Eve Eve Eve")
    end
end
main()

Measured memory_bytes: 105924
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let  s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32, a: i32, b: i32
    }
    let mut count = 0;

    for i in 1..n+1 {
        let s: i32 = sep_digit(i).iter().sum();
        if a <= s && s <= b {
            count += i;
        }
    }

    println!("{}", count);

    fn sep_digit(mut i: i32) -> Vec<i32> {
        let mut v: Vec<i32> = Vec::new();
        while i != 0 {
            v.push(i % 10);
            i /= 10;
        }
        v
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
  int a,b,c;
  scanf("%d/%d/%d",&a,&b,&c);
  if(a<2019){
    cout<<"Heisei"<<endl;
  }else if(a==2019){
    if(b<4){
      cout<<"Heisei"<<endl;
    }else if(b==4){
      if(c<=30){
        cout<<"Heisei"<<endl;
      }else{
        cout<<"TBD"<<endl;
      }
    }else{
      cout<<"TBD"<<endl;
    }
  }else{
    cout<<"TBD"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main()
{
	int n; cin>>n;
  	int a,ans=0;
	map<int,int> s;
	rep(i,n){
		cin>>a;
		s[a]++;
		if(s[a]%2==0) ans--;
      	else ans++;
	}
  	cout<<ans<<endl;
  	return 0;
}


Measured memory_bytes: 4864
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
#include<unordered_set>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 4 * 1000 * 1000 + 47;
const int MOD = 1000 * 1000 * 1000 + 7;

bitset<MAX> B;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	//ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	int s = 0;
	B[0] = 1;
	FOR(i, 0, n)
	{
		int x;
		cin >> x;
		s += x;
		B = B | (B << x);
	}

	s = (s + 1) / 2;
	FOR(i, s, MAX)
	{
		if (B[i])
		{
			cout << i << endl;
			return 0;
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned char ubyte;

const ld EPS = 1e-9;
const ld PI = acos(-1.0);
const int INF = (int)1e9 + 5;
const ll LINF = (ll)1e18 + 5;

bool eq(double a, double b) {
	return fabs(a - b) < EPS;
}

template<class T>
T sqr(const T & x) { return x * x; }

template<class T> 
ll abs(const T & x) { return x < 0 ? -x : x; }

template<class T>
ll myround(const T & x) { return x < 0 ? x - 0.5 : x + 0.5; }

template<class T> 
bool chmin(T & x, const T & y) {
	if (y < x) {
		x = y;
		return true;
	}
	return false;
}

template<class T>
ostream & operator <<(ostream & os, const vector<T> & v) {
	os << "{";
	for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); ++it) {
		os << *it;
		if ((it + 1) != v.end()) os << ", ";
	}
	os << "}";
	return os;
}

template<class P, class Q>
ostream & operator <<(ostream & os, const pair<P, Q> & p) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template<class T> 
bool chmax(T & x, const T & y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

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

int main() {
	//srand(time(0));
#ifdef LOCAL 
	freopen("input.txt", "r", stdin);
#else
#endif

	int n;
	scanf("%d", &n);

	vector<int> a(n);

	for (int & x : a) {
		scanf("%d", &x);
	}

	ll res = 0;

	int p = 0;
	for (int & x : a) {
		res += min(x, p);
		x -= min(x, p);
		p = x;
		res += p / 2;
		p -= (p / 2) * 2;
	}

	cout << res << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <memory>
#include <initializer_list>
#include <iomanip>
#include <stack>
#include <bitset>
#include <cstdio>
// #include <complex>
// #include <random>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
const ll INF = 1e9;
//const ll MOD = 1e9 + 7;
//const double EPS = 1e-9;
//const double PI = acos(-1);


void solve() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    for (int i = 0; i < h - b; ++i) {
        for (int j = 0; j < w - a; ++j)
            cout << 1;
        for (int j = 0; j < a; ++j)
            cout << 0;
        cout << "\n";
    }
    for (int i = 0; i < b; ++i) {
        for (int j = 0; j < w - a; ++j)
            cout << 0;
        for (int j = 0; j < a; ++j)
            cout << 1;
        cout << "\n";
    }   
};




int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout); 
    solve();
    return 0;
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> r,g,b;
int rb[4000];
int gb[4000];
int bb[4000];
int main()
{
	int n;
	string s;
	cin>>n>>s;
	for( int i=0; i<n; i++ )
	{
		if(s[i]=='R')
			r.push_back(i),rb[i]=1;
		else if(s[i]=='G')
			g.push_back(i),gb[i]=1;
		else
			b.push_back(i),bb[i]=1;
	}
	ll sum = 0;
	for(int i=0; i<r.size(); i++ )
	{
		int pr = r[i];
		for( int j=0; j<g.size(); j++ )
		{
			int pg = g[j];
			sum += b.size();		
			
			int pb = 2*pr-pg;
			int pb1 = 2*pg-pr;
			int pb2 = (pr+pg)/2;
			if(pb>=0 && pb<4000 && bb[pb]) 
				sum--;
			if(pb1>=0 && pb1!=pb && pb1<4000 && bb[pb1]) 
				sum--;
			if(pb2*2==pr+pg && pb2!=pb && pb2!=pb1 && pb2<4000 && bb[pb2]) 
				sum--;
		}
	}
	cout << sum << endl;			
	
	return 0;
}


Measured memory_bytes: 3632
loop do
  n, k = gets.split.map(&:to_i)
  break if (n|k) == 0

  sum = Array.new(n+1, 0)
  (1..n).each do |i|
    a = gets.to_i
    sum[i] = a + sum[i-1]
  end

  res = 0
  (1..n-k+1).each do |i|
    res = [res, sum[i+k-1] - sum[i-1]].max
  end

  puts res
end

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

int main(void){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> price(n);

    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<n;i++){
        cin >> price[i];
        for(int j=0;j<m;j++) cin >> a[i][j];
    }

    int yen = 1001001001;
    for(int i=0;i<(1<<n);i++){
        bitset<12> bit(i);
        int tmpyen = 0;
        vector<int> us(m,0);
        for(int j=0;j<n;j++){
            if(bit.test(j)){
                tmpyen += price[j];
                for(int k=0;k<m;k++) us[k] += a[j][k];
            }
        }
        bool ok = true;
        for(int j=0;j<m;j++){
            if(us[j]<x) ok = false;
        }
        if(ok){
            yen = min(yen,tmpyen);
        }
    }
    if(yen==1001001001) cout << -1 << endl;
    else cout << yen << endl;
    return 0;
}

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

int main(){
  int n,y,b,t,r;
  while(1){
    cin >> n;
    if(n == 0) break;
    cin >> y;
    double ans=0,tmp;
    int p;
    for(int i=0;i<n;i++){
      cin >> b >> r >> t;
      if(t == 1){
	tmp = (1+y*((double)r/(double)100));
      }
      else if(t == 2){
	tmp = pow(1+((double)r/(double)100),y);
      }
      //cout << tmp << endl;
      if(ans<tmp){
	p = b;
	ans = tmp;
      }
    }
    cout << p << endl;
  }
}

Measured memory_bytes: 1164
a = input()
b = input()
c = input()
countlist = [1, 0, 0]
list = ["a", "b", "c"]
turn = 0
value = ""
for x in range(len(a) + len(b) + len(c)):
    
    if countlist[0] > len(a) or countlist[1] > len(b) or countlist[2] > len(c): break
    if turn == 0: value = a[countlist[turn] - 1]
    elif turn == 1: value = b[countlist[turn] - 1]
    elif turn == 2: value = c[countlist[turn] - 1]
        
    turn = list.index(value)
    countlist[turn] += 1

if countlist[0] > len(a): print("A")
elif countlist[1] > len(b): print("B")
elif countlist[2] > len(c): print("C")


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;


const ll MOD = 998244353;

int N;
ll cnt[100005] = {};
ll pow(ll x, ll p) {
	ll ret = 1;
	while (p != 0)
	{
		if (p & 1) ret *= x;
		x *= x;
		p = p >> 1;
		x %= MOD; ret %= MOD;
	}
	return ret;
}
int main() {
	cin >> N;
	rep(i, N) {
		int d;
		cin >> d;
		cnt[d]++;
		if ((i == 0 && d != 0) || (i!=0&&d==0)) {
			cout << 0 << endl;
			return 0;
		}	
	}

	ll ans = 1;
	for (int i = 1; i < N; i++) {
		ans *= pow(cnt[i - 1], cnt[i]);
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n];
  for(int i = 0 ; i < n ; i++)
    cin >> a[i];
  if(n == 2)
    cout << abs(a[1] - a[0]) << endl;
  else{
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for(int i = 2 ; i < n ; i++)
      dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
    cout << dp[n-1] << endl;
  }
}

Measured memory_bytes: 1024
s = list(input())

flag = True

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "L":
            flag = False
            break
    else:
        if s[i] == "R":
            flag = False
            break

if flag:
    print("Yes")
else:
    print("No")



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

int main() {
  
  int n;
  string s;
  cin >> n >> s;
  int total = 0;
  for(int i = 0; i < n - 2; i++){
    int j = i + 1;
    int k = i + 2;
    if(s.at(i) == 'A' && s.at(j) == 'B' && s.at(k) == 'C') total++;
  }
  
  cout << total << endl;
 
  
  
}



Measured memory_bytes: 3572
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}



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

Measured memory_bytes: 3588
#include<cstdio>
using namespace std;
int upd(int x){
    if(x == 1){
        x = 9;
    }
    else if(x == 9){
        x = 1;
    }
    return x;
}
int main(){
    int n;
    while(~scanf("%d", &n)){
        int x = n/100, y = n%100/10, z = n%10;
        x = upd(x);
        y = upd(y);
        z = upd(z);
        printf("%d\n", x*100 + y*10 + z);
    }
}


Measured memory_bytes: 128
import numpy as np

N, K = map(int, input().split())
x = [int(_) for _ in input().split()]
ans = float('inf')

for i in range(N-K+1):
    left = x[i]
    right = x[i+K-1]
    if np.sign(left) == np.sign(right):
        tmp = max(abs(left), abs(right))
    else:
        tmp = 2*min(abs(left), abs(right))+max(abs(left), abs(right))
    if tmp < ans:
        ans = tmp

print(ans)

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

int main()
{
	int l[10], v1, v2, cnt;
	double n, d, t;
	char ch;
	while (cin>>l[0]>>ch){
		n = l[0];
		for (int i = 1; i < 10; i++)
		{
		    cin >> l[i] >> ch;
		    n += l[i];
		}
		cin >> v1 >> ch >> v2;
		t=n/(v1+v2);
		d=v1*t;    //列車1の動く距離
		cnt=0;
		while(d>0){
			d -= l[cnt];
			cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

print(1000*(-(-N//1000))-N)


Measured memory_bytes: 10032
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include<iomanip>
using namespace std;
typedef long long ll;
int main(void){
    ll n;
    cin >> n;
    if(n%10==3)cout << "bon" << endl;
    else if(n%10==0||n%10==1||n%10==6||n%10==8)cout << "pon" << endl;
    else cout << "hon" << endl;
}


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

signed main() {
	string s;
	cin >> s;

	if (s.size() == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (s.size() == 2) {
		if (s[0] == s[1]) cout << 1 << endl;
		else cout << 2 << endl;
		return 0;
	}

	int sz = s.size();

	s.push_back('A');

	int ans = 0;
	bool flag = true;
	for (int i = 0; i < s.size() - 1; i++) {
		if (i == sz - 2 && flag && s[i] == s[i + 1]) {
			ans++;
			break;
		}
		if (flag) {
			ans++;
			if (s[i + 1] == s[i]) flag = false;
		}
		else {
			ans++;
			i++;
			flag = true;
		}
		
	}

	

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(long long i = a; i < (b); ++i)
typedef long long ll;

int main() {
    ll N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
     
    vector<bool>U(N,false);
    ll ans = 0;
    rep(i, 0, N) {
        ll p = i - K;
        if (p >= 0 && T[i] == T[p] && U[p])
            continue;
        U[i] = true;
        if (T[i] == 'r')
            ans += P;
        else if (T[i] == 's')
            ans += R;
        else
            ans += S;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <valarray>
#include <cmath>
#include <cstring>

using namespace std;

typedef valarray<double> P;

double len(P a){ return sqrt((a*a).sum()); }
double cs(P a, P b){ return (a*b).sum()/(len(a)*len(b)); }

int main(){
	int n;
	P p[500];
	for(int i=0;i<500;i++) p[i].resize(3);
	while(cin >> n, n){
		bool see[500];
		memset(see, false, sizeof(see));
		for(int i=0;i<n;i++)
			for(int j=0;j<3;j++) cin >> p[i][j];
		int res = 0;
		int m; cin >> m;
		for(int i=0;i<m;i++){
			P q(3);
			double s;
			cin >> q[0] >> q[1] >> q[2] >> s;
			for(int j=0;j<n;j++){
				if(see[j]) continue;
				if(acos(cs(p[j],q)) < s){
					see[j] = true;
					res++;
				}
			}
		}
		printf("%d\n", res);
	}
}

Measured memory_bytes: 996
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  int N;
  cin>>N; 
  vector<int>a(N);
  for(int i=0;i<N;++i){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  bool bo=true;
  for(int i=0;i<N;++i){
    if(a.at(i)%10!=0){
      bo=false;
    }
  }
  if(bo){
    cout<<0<<endl;
  }
  else{
    int to=0;
    for(int i=0;i<N;++i){
      to+=a.at(i);
    }
    if(to%10!=0){
      cout<<to<<endl;
    }
    else{
      for(int i=0;i<N;++i){
        if(a.at(i)%10!=0){
          to-=a.at(i);
          break;
        }
      }
      cout<<to<<endl;
    }
  }
}


Measured memory_bytes: 256
N, K, Q = [int(i) for i in input().split()]

A = []
for i in range(Q):
    A.append(int(input()))

counter = [0]*N
for i in range(Q):
    counter[A[i] - 1] += 1

for i in range(N):
    if Q - counter[i] < K:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8592
#include <iostream>
#include <math.h>

using namespace std;

int main() {
    double r, area, circum;
    cin >> r;
    area = M_PI * r * r;
    circum = 2 * M_PI * r;
    printf("%.6f %.6f\n", area, circum);
    return 0;
}


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

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

	if (n % 10 == 9) {
		cout << "Yes" << endl;
		return 0;
	}

	n /= 10;
	
	if (n % 10 == 9) {
		cout << "Yes" << endl;
		return 0;
	}

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

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

int main() {
  int n, m, x, y;
  
  cin >> n >> m >> x >> y;
  
  int x_cities[102], y_cities[102];
  
  for (int i = 0; i < n; i++)
    cin >> x_cities[i];
  for (int i = 0; i < m; i++)
    cin >> y_cities[i];
  x_cities[n] = x;
  y_cities[m] = y;
  
  int max_x = *max_element(x_cities, x_cities + n + 1);
  int min_y = *min_element(y_cities, y_cities + m + 1);
  
  if (max_x < min_y)
    cout << "No War" << endl;
  else
    cout << "War";
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = ii()

if N == 1:
    print(0)
    exit()

f = factorization(N)
ans = 0
for i, j in f:
    cnt = 1
    while True:
        j -= cnt
        ans += 1
        if j <= cnt:
            break
        cnt += 1
print(ans)

Measured memory_bytes: 9552
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, M, C;
  cin >> N >> M >> C;
  vector<vector<int>> A(N,vector<int>(M));
  vector<int> B(M);
  for(int i = 0; i < M; i++){
    cin >> B.at(i);
  }
  
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      cin >> A.at(i).at(j);
    }
  }
  int count = 0;
  for(int i = 0; i < N; i++){
    int ans = 0;
    for(int j = 0; j < M; j++){
      ans = ans + A.at(i).at(j) * B.at(j);
    }
    ans = ans + C;
    if(ans > 0){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
c = [list(map(int, input().split()))for _ in range(a)]
d = [list(map(int, input().split()))for _ in range(b)]
for i in range(len(c)):
    e = 10**9
    f = 0
    for j in range(len(d)):
        g = abs(c[i][0] - d[j][0]) + abs(c[i][1] - d[j][1])
        if e > g:
            e = g
            f = j + 1
    print(f)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;

int main() {
	int A, B, K, count = 0, C[100];
	cin >> A >> B >> K;
	for (int i = 1; i <= min(A, B); i++) {
		if (A % i == 0 && B % i == 0) {
			C[count] = i;
			count++;
		}
	}
	cout << C[count - K] << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# input
a = int(input())
s = 0
bc = 0
ac = 0
tc = 0
for i in range(a):
    t = input()
    s += t.count('AB')
    if t[:1] == 'B':
        bc += 1
    if t[-1:] == 'A':
        ac += 1
    if t[:1] == 'B' or t[-1:] == 'A':
        tc += 1
if min(bc, ac) == tc and tc > 0:
    o = s + min(bc, ac)-1
else:
    o = s + min(bc, ac)
print(o)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll n, m, q;
vvll as;

void generate_a(vll a) {
    if (a.size() == n) {
        as.push_back(a);
        return;
    }

    reprr(i, a[a.size()-1], m + 1) {
        vll b(a.begin(), a.end());
        b.push_back(i);
        generate_a(b);
    }
}

int main()
{
    cin >> n >> m >> q;
    vvll v(q, vll(4));
    rep(i, q) {
        rep(j, 4) {
            cin >> v[i][j];
        }
    }

    reprr(i, 1, m + 1) {
        generate_a({i});
    }

    ll max_num = 0;
    for (auto target : as) {
        //for (auto elem : target) cout << elem << " "; cout << endl;
        ll total = 0;
        for (auto nums : v) {
            if (target[nums[1] - 1] - target[nums[0] - 1] == nums[2]) total += nums[3];
        }

        if (max_num < total) {
            max_num = total;
            //for (auto elem : target) cout << elem << endl;
            //cout << total << endl;
        }
    }

    cout << max_num << endl;
    return 0;
}

Measured memory_bytes: 13996
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)

struct Node{
    int key;
    Node *p, *left, *right;
};

Node *root, *NIL;

void insert(int k)
{
    Node *par = NIL;    //x??????
    Node *now = root;   //root???????§???????
    Node *z;            //?????\?????????????????????????????????

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    //-----??¢?´¢-----
    while(now != NIL){
        par = now;
        if(z->key  <  now->key)
            now = now->left;
        else
            now = now->right;
    }

    z->p = par;     //?????\?????????????????????????¨????
    if(par == NIL){ //Tree???????????´???
        root = z;
    } else {        //???????????????????¨????(?????????????±???????)
        (z->key  <  par->key ? par->left : par->right) = z;
    }
}
Node *find(Node *u, int k)
{
    while(u != NIL && k != u->key){
        if(k < u->key)u = u->left;
        else u = u->right;
    }
    return(u);
}
void inorder(Node *u)
{
    if(u == NIL)return;
    inorder(u->left);
    cout << ' ' << u->key;
    inorder(u->right);
}
void preorder(Node *u)
{
    if(u == NIL)return;
    cout << ' ' << u->key;
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    FAST();
    int N, x;
    string com;
    
    cin >> N;

    while(N--){
        cin >> com;
        if(com[0] == 'i'){
            cin >> x;
            insert(x);
        }
        else if(com[0] == 'f'){
            cin >> x;
            Node *p = find(root, x);
            outl(p == NIL? "no" : "yes");
        }
        else{
            inorder(root);
            cout << '\n';
            preorder(root);
            cout << '\n';
        }
    }
}

Measured memory_bytes: 21964
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------


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

  string s; cin >> s;

  int cnt1=0,cnt2=0;
  rep(i,s.size()){
    if(s[i]=='A') cnt1++;
    else cnt2++;
  }

  if(cnt1==3||cnt2==3){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int INF=2*1e9;
int main()
{
    bool a=0,b=0;
    string s;
    cin>>s;
    rep(i,s.size())
    {
        if(s[i]=='A') a=1;
        if(s[i]=='B') b=1;
    }
    if(a&b) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
/*input
abcdabc
*/
/**
    Author: Kristopher Paul
    Date Created: 08-12-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
#include<stdio.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
//#define MOD 998244353
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    string s;
    cin >> s;
    int n = s.length();
    int ans = 0;
    FOR(i,0,n/2){
        set<char> se;
        se.insert(s[i]);
        se.insert(s[n-i-1]);
        ans += se.size()-1;
    }
    cout << ans << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


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

int main() {
    int a,b,c,tmp;
    cin >> a >> b >> c;
    if ( a > b ) {
    	tmp = a;
    	a = b;
    	b = tmp;
    } 
    if ( b > c ) {
    	tmp = b;
    	b = c; 
    	c = tmp;
    }
    if ( a > b ) {
    	tmp = a;
    	a = b;
    	b = tmp;
    }
    cout << a << " " << b << " " << c << endl;
	return 0;
}


Measured memory_bytes: 3116
N = int(input())
def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
    for c in '753':
        ret += dfs(s + c)
    return ret
print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく


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


int main()
{
    long int n;
    scanf("%ld", &n);
    char str2[n];
    char str[n];
    scanf("%s", str);
    long int j=0;
    
    for(int i=0; i<n; i++) {
        if(str[i] == str[i+1]) {
            continue;
        }
        else {
            char c = str[i];
            str2[j] = c;
            str2[j+1]= '\0';
            j++ ;
            
        }
    }
    
    size_t len = strlen(str2);
    printf("%lu", len); 

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int cnt = 0;
	int n; cin >> n;
	vector<bool> bv;
	for(int i = 0; i < n; i++){
		int p; cin >> p;
		if(p == i+1){
			bv.push_back(1);
		}else{
			bv.push_back(0);
		}
	}

	if(bv[n-1]){
		cnt++;
		bv[n-2] = 0;
		bv[n-1] = 0;
	}


	for(int i = 1; i < n; i++){
		if(bv[i-1]){
			cnt++;
			bv[i-1] = 0;
			bv[i]= 0;
		}
	}
	
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    vector<int> viCount(10001,0);
    for(int i = 1; i <= 100; i++){
        for(int j = 1; j <= 100; j++){
            for(int k = 1; k <= 100; k++){
                int nValue = i*i+j*j+k*k+i*j+j*k+k*i;
                if(nValue <= 10000){
                    viCount[nValue]++;
                }
            }
        }
    }
    
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        printf("%d\n", viCount[i]);
    }
    return 0;
}


Measured memory_bytes: 3116
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int main() {

	char S[212345];

	scanf("%s", S);

	int l = strlen(S);
	ll B_n = 0;

	rep(i, l) {
		if (S[i] == 'B') B_n++;
	}

	ll count = 0;
	for (int i = l - 1; i >= 0; --i) {
		if (S[i] == 'B') count += l - i;
	}


	printf("%lld\n", count - B_n * (B_n + 1) / 2);


	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int Hira[101][101];
int Sawa[101];

void turi(int n){
  int i, j, k=1, Ryo[100], ko, min, kei=0;    
  Ryo[0] = 0;
  Sawa[0] = 1;
  for(i = 1; i < n; i++){
    Sawa[i] = 0;
  }
  for(;;){
    ko = 9999;
    for(i = 0; i < k; i++){
      for(j = 0; j < n; j++){
	if(Hira[Ryo[i]][j] < ko && Hira[Ryo[i]][j] != -1 && Sawa[j] != 1){
	  ko = Hira[Ryo[i]][j]; min = j;
	}}}
    if(k != n){
      Ryo[k] = min;
      Sawa[min] = 1;
      kei += ko;
      k++;
    }
    else break;
  }
  printf("%d\n", kei);
}
    
main(){
  int n, i, j;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &Hira[i][j]);
    }}
  turi(n);
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;

void solve(){
    cin >> n;
    rep(i,n){
        Rep(j,i+1,n){
            int t=1,ans=0;
            while(i%t==j%t) {
                t*=2;
                ans+=1;
            }
            cout << ans << " ";
        }
        cout << "" << endl;
    }
}

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

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

vector<ll> ans;

void DFS(int d, ll val){
  ans.push_back(val);
  if(d==10) return;
  for(int i=-1; i<=1; i++){
    int add = val%10 + i;
    if(add<0 or add>=10) continue;
    //cout << add << endl;
    ll usi = val*10 + add;
    //cout << usi << endl;
    DFS(d+1, usi);
  }
}



int main(){
  int K; cin >> K;
  for(int i=1; i<=9; i++){
    DFS(1, i);
  }
  sort(ans.begin(), ans.end());
  cout << ans[K-1] << endl;
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<15;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N, K;
  string S;
  cin >> N >> S >> K;
  for (int i=0; i<N; i++){
    if (S[i] != S[K-1])
      S[i] = '*';
  }
  
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<deque>
#include<list>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll gcd(ll a2,ll b2){
	ll t;
	while(b2!=0){
		t=a2%b2;
		a2=b2;
		b2=t;
	}
	return a2;
}
ll lcm(ll a1,ll b1){
	if(a1*b1==0){return 0;}
	return (a1*b1/gcd(a1,b1));
}

int d[100001]={};
int s[100001]={};

int main() {

	int q;
	cin>>q;
	d[2]=1;
	for(int i=3; i<100001; i++){
		if(i%2==0)continue;
		int f=0;
		for(int j=3; j<=sqrt(i);j++){
			if(i%j==0){
				f=1;
				break;
			}
		}
		if(f==0)d[i]=1;
		if(f==0&&d[(i+1)/2]==1)s[i]=1;
	}
	for(int i=3; i<100001; i++)s[i]+=s[i-1];
	rep(i,q){
		int l,r;
		cin>>l>>r;
		cout<<s[r]-s[l-1]<<endl;
	}

	return 0;
}


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

int main()
{
    int N;
    cin >> N;
    for (int i = 1; i < 10; i++)
    {
        if (N % i == 0)
        {
            if (N / i < 10)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256