akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <random>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define inf (int)(1e9)
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<string,int> psi;

bool dpx[8888][8888*2];
bool dpy[8888][8888*2];

int main(void){
  string s;
  int x,y;
  cin>>s>>x>>y;
  vector<int> dx,dy;
  bool is_x=true;
  int tmp=0;
  dy.pb(0);
  for(int i=0;i<s.size();i++){
    if(s[i]=='T') {
      if(is_x) dx.pb(tmp);
      else dy.pb(tmp);
      is_x=!is_x;
      tmp=0;
    }
    else{
      tmp++;
    }
  }
  if(is_x) dx.pb(tmp);
  else dy.pb(tmp);
  /*
  for(int i=0;i<dx.size();i++){
    cout<<dx[i]<<" ";
  }
  cout<<endl;
  for(int i=0;i<dy.size();i++){
    cout<<dy[i]<<" ";
  }
  cout<<endl;
  */
  dpx[0][dx[0]+8000]=true;
  for(int i=1;i<dx.size();i++){
    for(int j=0;j<=8000*2;j++){
      dpx[i][j]|=dpx[i-1][max(j-dx[i],0)];
      dpx[i][j]|=dpx[i-1][j+dx[i]];
    }
  }
  dpy[0][8000]=true;
  for(int i=1;i<dy.size();i++){
    for(int j=0;j<=8000*2;j++){
      dpy[i][j]|=dpy[i-1][max(j-dy[i],0)];
      dpy[i][j]|=dpy[i-1][j+dy[i]];
    }
  }/*
  for(int i=0;i<dx.size();i++){
    for(int j=0;j<=)
    }*/
  if(dpx[dx.size()-1][x+8000]&dpy[dy.size()-1][y+8000]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 139520
import java.util.Arrays;

public class Main {
  private static void solve() {
    int n = ni();
    int[][] p = ntable(n, 3);
    Arrays.sort(p, (o1, o2) -> (o1[0] + o1[1]) - (o2[0] + o2[1]));
    
    int wmax = 20010;
    long[] dp = new long[wmax + 1];
    Arrays.fill(dp, Integer.MIN_VALUE / 2);
    dp[0] = 0;
    for (int i = 0; i < n; i ++) {
      for (int j = wmax; j >= 0; j --) {
        if (j >= p[i][0] && j - p[i][0] <= p[i][1]) {
          dp[j] = Math.max(dp[j], dp[j - p[i][0]] + p[i][2]);
        }
      }
    }
    
    System.out.println(Arrays.stream(dp).max().getAsLong());
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 28500
#include <stdio.h>
#include <ctype.h>
#define STACK 100
int main(void)
{
  int stack[STACK];
  int stack_n; 
  int sum;
  int digit_f;
  int k;
  char ch;
  stack_n = 0;
  digit_f = 0;
  while( (ch = getchar()) != '\n' ) { 
    if( isdigit(ch) ) { 
      if( digit_f ) { 
        stack[stack_n] = stack[stack_n] * 10 + (ch - '0');
      } else {
        stack[stack_n] = (ch - '0');
        digit_f++;
      }
    }
    if( isspace(ch) ) {
      if( digit_f ) {
        stack_n++;
        digit_f = 0;
      }
    }
    if( ch == '+' ) {
      if( stack_n > 1 ) {
        stack_n--;
      }
      stack[stack_n-1] += stack[stack_n];
      stack[stack_n] = 0;
    }
    if( ch == '-' ) {
      if( stack_n > 1 ) {
        stack_n--;
      }
      stack[stack_n-1] -= stack[stack_n];
      stack[stack_n] = 0;
    }
    if( ch == '*' ) {
      if( stack_n > 1 ) {
        stack_n--;
      }
      stack[stack_n-1] *= stack[stack_n];
      stack[stack_n] = 0;
    }
    if( ch == '/' ) { 
      if( stack_n > 1 ) {
        stack_n--;
      }
      stack[stack_n-1] /= stack[stack_n];
      stack[stack_n] = 0;
    }
  }
    printf("%d\n",stack[0]);
  return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  int k; cin >> k;
  vector<int> a(n);
  for (int& x: a) cin >> x;

  vector<bool> win(k + 1);
  for (int y = 1; y <= k; y++) {
    for (int x: a) {
      if (x <= y && !win[y - x]) {
        win[y] = true;
        break;
      }
    }
  }
  cout << (win[k] ? "First" : "Second") << endl;

  return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int a[1000],b[1000],m[1000],u[1000],x[1000],y[1000],min[1000],w[1000],e[1000];
int main(void)
{
	int i,n,k;
	scanf("%d %d",&n,&k);
	for(i=0;i<k;i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	for(i=0;i<k;i++){
		m[i]=a[i]; u[i]=n+1-a[i];
		x[i]=b[i]; y[i]=n+1-b[i];
		if(m[i]<u[i]){
			w[i]=m[i];
		}
		else{
			w[i]=u[i];
		}
		if(x[i]<y[i]){
			e[i]=x[i];
		}
		else{
			e[i]=y[i];
		}
		if(w[i]<e[i]){
			min[i]=w[i];
		}
		else{
			min[i]=e[i];
		}
	}
	for(i=0;i<k;i++){
		if(min[i]%3==0){
			min[i]=3;
			printf("%d\n",min[i]);
		}
		else{
			printf("%d\n",min[i]%3);
		}	
	}
	return 0;
}



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

namespace Sorting
{
    class Sorting
    {
        public static void Main()
        {
            string[] s = Console.ReadLine().Split(' ');
            int[] i = s.Select(str => int.Parse(str)).ToArray();
            Array.Sort(i);
            Console.WriteLine("{0}", string.Join(" ", i));
        }
    }
}



Measured memory_bytes: 16488
#include <iostream>

using namespace std;

void ans148(){
    int a,b;
    int c[3] = {1,2,3};
    cin >> a >> b;
    for(int i:c){
        if(i==a||i==b)continue;
        cout <<i << endl;
        return;
    }
}

int main()
{
    ans148();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();
	int n, d, cnt = 0;
	cin >> n >> d;
	FOR(i, 0, n) {
		int x, y;
		cin >> x >> y;
		if (d >= sqrt(pow(x, 2) + pow(y, 2))) cnt++;
	}
	cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,a,ans=0,data[101]={};
  scanf("%d %d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d",&a);
    data[a] = 1;
  }
  scanf("%d",&m);
  for(int i=0;i<m;i++){
    scanf("%d",&a);
    data[a] |= 2;
  }
  scanf("%d",&m);
  for(int i=0;i<m;i++){
    scanf("%d",&a);
    data[a] |= 4;
  }
  
  for(int i=1;i<=n;i++){
    if(data[i] ==  4 || data[i] == 6 || data[i] == 7) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3244
N=int(input())
csf=[list(map(int,input().split())) for _ in range(N-1)]

for i in range(N):
  t=0
  for j in range(i,N-1):
    if t>=csf[j][1]:
      if t%csf[j][2]!=0:
        t+=csf[j][2]-t%csf[j][2]+csf[j][0]
      else:
        t+=csf[j][0]
    else:
      t=csf[j][1]+csf[j][0]
  print(t)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll n, d, a; cin >> n >> d >> a;
    vector<pair<ll, ll>> xh(n); cin >> xh;
    SORT(xh);
    VL r(n+1), x(n), h(n);
    FOR(i, 0, n) {
        x[i] = xh[i].first;
        h[i] = xh[i].second;
    }
    x.push_back(LLINF);
    h.push_back(LLINF);
    ll ans = 0;
    FOR(i, 0, n) {
        if (0 < i)r[i] += r[i - 1];
        h[i] -= r[i];
        if (h[i] <= 0)continue;
        ll cnt = (h[i] + a - 1) / a;
        ans += cnt;
        r[i] += cnt * a;
        int itr = upper_bound(all(x), x[i] + d * 2) - x.begin();
        r[itr] -= cnt * a;
    }
    cout << ans << "\n";
}


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

using namespace std;

#define IO ios_base::sync_with_stdio(0);cin.tie(0);

const int INF = 1e9;

int main()
{
  IO;
  int h, w; cin >> h >> w;
  vector <vector <int>> g(10, vector <int> (10));
  for (int i = 0; i < 10; ++i)
  for (int j = 0; j < 10; ++j)
  cin >> g[i][j];

  vector <int> digits(10);

  for (int digit = 0; digit < 10; ++digit) {
    vector <int> dist(10, INF);
    vector <bool> used(10, false);
    dist[digit] = 0;
    int next = digit, min_dist = 0;
    while (min_dist < INF) {
      for (int u = 0; u < 10; ++u)
      dist[u] = min(dist[u], dist[next] + g[next][u]);

      min_dist = INF;
      used[next] = true;
      for (int i = 0; i < 10; ++i)
      if (!used[i] && dist[i] < min_dist) {
        min_dist = dist[i];
        next = i;
      }
    }
    digits[digit] = dist[1];
  }

  int ans = 0;
  for (int i = 0; i < h; ++i)
  for (int j = 0; j < w; ++j) {
    int k; cin >> k;
    if (k != -1)
    ans += digits[k];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        M: usize,
        D: usize,
    }
    let mut ans = 0;
    for m in 1..M + 1 {
        for d in 1..D + 1 {
            let d1 = d % 10;
            let d2 = d % 100 / 10;
            if d1 >= 2 && d2 >= 2 && d1 * d2 == m {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int H=stdIn.nextInt();
		int N=stdIn.nextInt();
		int A[]=new int[N];
		int B[]=new int[N];
		int dp[]=new int[H];
		for(int i=0;i<N;i++){
			A[i]=stdIn.nextInt();
			B[i]=stdIn.nextInt();
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<N;j++){
				int x=0;
				if(i-A[j]<0)
					x=B[j];
				else
					x=B[j]+dp[i-A[j]];
				if(x<dp[i]||dp[i]==0)
					dp[i]=x;
			}
		}
		System.out.println(dp[H-1]);
	}
}


Measured memory_bytes: 26136
#include<stdio.h>
int main(void)
{
	int a, b ;
	scanf("%d %d", &a, &b);
	if(a < b)
	{
		printf("a < b\n");
	}
	else if(a > b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2584
while True:
    try:
        a=float(input())
        if a<=48:
            print("light fly")
        elif a>48 and a<=51:
            print("fly")
        elif a>51 and a<=54:
            print("bantam")
        elif a>54 and a<=57:
            print("feather")
        elif a>57 and a<=60:
            print("light")
        elif a>60 and a<=64:
            print("light welter")
        elif a>64 and a<=69:
            print("welter")
        elif a>69 and a<=75:
            print("light middle")
        elif a>75 and a<=81:
            print("middle")
        elif a>81 and a<=91:
            print("light heavy")
        elif a>91:
            print("heavy")
    except:break


Measured memory_bytes: 5572
#include <bits/stdc++.h>
#define cool 1000000000000000000
using namespace std;

void ini() {

}

void Solve() {
    long long n, m;
    cin >> m;
    n = m;
    map<long long, long long> mp;
    map<long long, long long> :: iterator itr;
    while(n % 2 == 0) {
        n /= 2;
        mp[2]++;
    }
    for(long long i = 3; i <= sqrt(n); i += 2) {
        if(n % i == 0) {
            mp[i]++;
            n /= i;
            i -= 2;
        }
    }
    if(n > 2) {
        mp[n]++;
    }
    n = m;
    long long ans = 0;
    for(itr = mp.begin(); itr != mp.end(); itr++) {
        long long i;
        for(i = 1; i <= 100; i++) {
            if((i * (i + 1) / 2) > itr->second) {
                break;
            }
        }
        ans += (i - 1);
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ini();
    Solve();
    return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll cnt;

int main(){
	ll a,b,c;
	cin >> a >> b >> c;
	if(a==b&&a==c){
		cout << "1" << endl;
		return 0;
	}else if(a==b||a==c ||b==c){
		cout << "2" << endl;
		return 0;
	}else{
		cout << "3" << endl;
		return 0;
	}
}

Measured memory_bytes: 3600
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
  int n;
  int a[5000], color[9] ={};

  scanf("%d", &n);
  for(int i = 0; i < n; i++)
    scanf("%d", &a[i]);

  for(int i = 0; i < n; i++){
    if(a[i] < 400)
      color[0]++;
    else if(a[i] < 800)
      color[1]++;
    else if(a[i] < 1200)
      color[2]++;
    else if(a[i] < 1600)
      color[3]++;
    else if(a[i] < 2000)
      color[4]++;
    else if(a[i] < 2400)
      color[5]++;
    else if(a[i] < 2800)
      color[6]++;
    else if(a[i] < 3200)
      color[7]++;
    else
      color[8]++;
  }

  int count = 0;
  for(int i = 0; i < 8; i++)
    if(color[i] != 0)
      count++;

  if(count)
    printf("%d %d\n", count, count + color[8]);
  else
    printf("1 %d\n",  count + color[8]);
  
  return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_E main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

vvi es;
vvi games;

int get_game_id(int i, int j) {
    if (i > j) swap(i,j);
    return games[i][j];
}

vb vis;
vb done;
vi dp;
int M;
int dfs(int n) {
    if (n >= M) return -1;
    // Found a cycle
    if (vis[n] && !done[n]) return -1;

    if (dp[n] >= 1) return dp[n];    

    vis[n] = true; // visitting
    dp[n] = 1; // day 1

    for (int i : es[n]) {
        int res = dfs(i);
        if (res == -1) return -1;

        dp[n] = max(dp[n], res + 1);
    }

    done[n] = true; // visited

    return dp[n];
}


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

    int N; cin >> N;
    vvi A(N, vi(N-1));
    REP(i,N) {
        REP(j,N-1) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }

    games = vvi(N, vi(N));
    int gm_id = 0;
    REP(i,N) {
        REP(j,N) {
            if (i < j) {
                games[i][j] = gm_id;
                gm_id++;
            }
        }
    }

    M = gm_id;
    vvi prog(N, vi(N));
    set<pii> st;
    es = vvi(M);
    REP(i,N) {
        REP(j,N-1) {
            prog[i][j] = get_game_id(i, A[i][j]);
        }

        REP(j,N-2) {
            int g1 = prog[i][j];
            int g2 = prog[i][j+1];

            if (st.count(pii(g1, g2)) == 0) st.insert(pii(g1, g2));
            else continue;

            es[g1].push_back(g2);
        }
    }

    int ans = 0;
    vis = vb(M, false);
    done = vb(M,false);
    dp = vi(M, -1);
    // dp[i] := Max path length from i

    REP(i, M) {
        int res = dfs(i);

        if (res == -1) {
            ans = -1;
            break;
        }

        ans = max(ans, res);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 88320
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();

		for(int i = 0; i < h; i++){
			String str = sc.next();

			System.out.println(str + "\n" + str);
		}
    }
}

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

int main() {
    string s,t;
    cin >> s >> t;
    int count = 0;
	int res = 2000;
    for(int i=0;i<=s.size()-t.size();i++){
        count=0;
        for(int j=0; j<t.size(); j++){
            if(s[i+j] != t[j]){
				count++;
			}
        }
        res = min(res,count);
    }
    cout << res;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n,k,x,y;
int main()
{
	scanf("%d%d%d%d",&n,&k,&x,&y);
	if(n>k)
		printf("%d\n",x*k+y*(n-k));
	else
		printf("%d\n",x*n);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>
inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll n;cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }else{
        ll a,b;cin>>a>>b;
        cout<<a+b<<endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
//#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
//using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e17+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

llint fib(llint in){
	in++;
	llint a=0,b=1;//0項め
	for(int h=35;h>=0;h--){
		//*2操作
		llint xa=(a*(b*2-a))%mod;
		llint xb=(b*b+a*a)%mod;
		a=xa;b=xb;
		//+1操作
		if(in&(1LL<<h)){llint c=a+b;a=b;b=c;}
	}
	b%=mod;b+=mod;b%=mod;
	return b;
}
int main(void){
	llint K,i,j;cin>>K;
	llint s=sqrt(K-1)+0.2;
	if(s*s>=K){s--;}
	llint d=s+s-1;
	llint ama=K-s*s;
	if(s*s+s<K){d++;ama=K-s*s-s;}
	ama--;
	llint e=ama*2;
	if(e*2>d){
		if(d%2==1){e=d-e;}
		else{e=d+1-e;}
	}
	//cerr<<"d="<<d<<"e="<<e<<endl;
	cout<<fib(d-e)*fib(e)%mod<<endl;
	/*
	vector<tuple<llint,int,int>>suu;
	for(i=0;i<20;i++){
		for(j=i;i+j<20;j++){
			suu.pub(mt(fib(i)*fib(j),i+j,i));
		}
	}
	SO(suu);
	int aaa=1;
	for(auto it:suu){
		cout<<get<0>(it)<<" "<<get<1>(it)<<" "<<get<2>(it)<<"\t"<<aaa<<endl;
		aaa++;
	}*/
	return 0;
}
/*
0 1 2 3 4 5 6
1 1 2 3 5 8 13

*/


Measured memory_bytes: 3096
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;
    cin >> n >> a >> b;
    int p[n];
    int first = 0, second = 0, third = 0;
    rep(i, n){
        cin >> p[i];
        if(p[i] <= a){
            first++;
        }else if(p[i] <= b){
            second++;
        }else{
            third++;
        }
    }
    /*
    first /= 3;
    second /= 3;
    third /= 3;
    */
    int ans = min(first, second);
    ans = min(ans, third);
    cout << ans << endl;
    
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
ball = [0]*(n) #入ってたら１

#ｎからn//2+1まで、Ａが１ならballも１
for i in reversed(range(n//2+1, n+1)):
    if A[i-1] == 1:
        ball[i-1] = 1

#n//2から１まで、その倍数をピックアップし、Ｂａｌｌを見る
for i in reversed(range(1, n//2+1)):
    s = n//i
    now = 0
    for j in range(2,s+1):
        if ball[i*j-1] == 1:
            now += 1
    if A[i-1] != now%2:
        ball[i-1] = 1

ans = []
for i in range(n):
    if ball[i] == 1:
        ans.append(i+1)
print(len(ans))
print(*ans)

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

#define endl             '\n' 
#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define EPS              10E-8
#define ff               first
#define ss               second
#define sqr(x)           (x)*(x)
#define D(x)             cout<<#x " = "<<(x)<<endl
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define stlloop(v)       for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
#define PRINT_CASE       printf("Case #%d: ",z)
#define LINE_PRINT_CASE  printf("Case %d:\n",z)
#define CASE_PRINT       cout<<"Case "<<z<<": "
#define all(a)           a.begin(),a.end()
#define intlim           2147483648
#define infinity         (1<<28)
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
 
using namespace std;
 
 
const int fx[]= {+1,-1,+0,+0};
const int fy[]= {+0,+0,+1,-1};
// const int N = 1e5 + 5;
#define piii pair<int, pair<int,int> >

const int N = 1e6 + 5;
vector<int> G[N],aux;
int arr[N*2],occ[N],vis[N];
int main(){
  // CIN;
  int t,n,i,j,k,a,b;
  while(cin >> a >> b)
  {
    string x="",y="";
    loop(i,b)x += (char)('0'+a);
    loop(i,a)y += (char)('0'+b);
    // cout << x << ' ' << y << endl;
    cout << (x<=y?x:y) << endl;
  }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }


int main(){
    ll x; cin>>x;
    
    ld ans = 0;
    ld c = 100;
    while(c<x){
        c *= 1.01;
        c = (ll)c;
        ++ans;
    }
    cout << ans <<"\n";
}

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

int N, K;
map<int, bool> D;

bool in_D(int x) {
	return D.find(x) != D.end();
}

bool pass(int x) {
	string s = to_string(x);
	for (int i = 0; i < s.size(); i++) {
		if (in_D(s[i] - '0')) {
			return false;
		}
	}

	return true;
}

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

	int tmp;
	for (int i = 0; i < K; i++) {
		cin >> tmp;
		D[tmp] = true;
	}

	string ans;
	for (int i = N; i <= 10 * N; i++) {
		if (pass(i)) {
			ans = to_string(i);
			break;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  string s;
  cin>>s;
  rep(i, s.size()) {
    rep(j, s.size()) {
      if(i != j && s[i] == s[j]) {
        cout << "no" << endl;
        return 0;
      }
    }
  }
  cout << "yes" <<endl;

  return 0;
}


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

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

  vector<int> A(N);

  for(int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  cout << A[N - 1] - A[0] << endl;
}

Measured memory_bytes: 256
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = l()
alf = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(s)):
	alf = alf.replace(s[i],'')
if alf == "":
	print("None")
else:
	print(alf[0])

Measured memory_bytes: 9812
// Aizu 1045: Split Up!
// 2017.9.6 bal4u@uu

#include <stdio.h>
#include <string.h>

#define MAX 1048600  // > 2^20
#define HASHSIZ 2000081
int hash[HASHSIZ + 5], *hashend = hash + HASHSIZ;

int lookup(int n)
{
	int *p = hash + n % HASHSIZ;
	while (*p) {
		if (*p == n) return 1;
		if (++p == hashend) p = hash;
	}
	return 0;
}

int insert(int n)
{
	int *p = hash + n % HASHSIZ;
	while (*p) {
		if (*p == n) return 0;
		if (++p == hashend) p = hash;
	}
	*p = n;
	return 1;
}

int q[MAX], *top, *end, qlen;

int a[22], alen;

int main()
{
	int n, i, k, s, v, v2, ans;
	int t[22];

	while (scanf("%d", &n) && n) {
		for (s = 0, i = 0; i < n; i++) scanf("%d", t+i), s += t[i];
		ans = s / 2;
		for (alen = 0, i = 0; i < n; i++) {
			if (t[i] == ans) goto Done;
			if (t[i] < ans) a[alen++] = t[i];
		}
		memset(hash, 0, sizeof(hash));
		top = end = q; *end++ = 0, qlen = 1;
		for (i = 0; i < alen; i++) {
			v = a[i];
			top = q, k = qlen;
			while (k--) {
				if ((v2 = v + *top++) == ans) goto Done;
				if (v2 < ans && insert(v2)) *end++ = v2, qlen++;
			}
		}
		while (--ans) {
			if (lookup(ans)) break;
		}
Done:	printf("%d\n", s - 2*ans);
	}
	return 0;
}

Measured memory_bytes: 9584
//"I'll live the focused life, because it's the best kind there is" - Winifred Gallagher
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl
#define ll long long
struct BIT{
private:
	vector<ll> node;
	int n;
public:
	void init(int _n){
		n = _n;
		node.resize(n, 0);
	}
	
	void add(int a, ll w){
		for(int i = a; i < n; i |= i + 1) node[i] += w;
	}
	
	//[0, a)
	ll sum(int a){
		ll ret = 0;
		for(int i = a - 1; i >= 0; i = (i & ( i + 1)) - 1) ret += node[i];
		return ret;
	}
	
	//[a, b)
	ll sum(int a, int b){
		return sum(b) - sum(a);
	}
};
int main(){
	cin.tie(0);	ios::sync_with_stdio(false);
	int n; cin>>n;
	BIT b[26];
	for(int i =0 ; i < 26; i++){
		b[i].init(n);
	}
	string s; cin>>s;
	for(int i = 0; i <n; i++){
		b[s[i] - 'a'].add(i, 1);
	}
	int q; cin>>q;
	while(q--){
		int t; cin>>t;
		if(t== 1){
			int x; char c; cin>>x>>c; x--;
			b[s[x] -'a'].add(x, -1);
			b[c - 'a'].add(x, 1);
			s[x] = c;
		}
		else{
			int l, r; cin>>l>>r; l--; r--;
			int ans = 0;
			for(int j = 0; j < 26; j++){
				if(b[j].sum(l, r + 1) > 0) ans++;
			}
			cout<<ans<<endl;
		}
	}
}


Measured memory_bytes: 102804
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define COUT(x) cout << (x) << endl
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */


int main() {
    int n;
    cin >> n;
    vector<LP> vec;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        vec.emplace_back(b, a);
    }
    sort(ALL(vec));
    ll sum = 0;
    bool check = true;
    for(auto v : vec) {
        sum += v.second;
        if(sum > v.first) {
            check = false;
            break;
        }
    }
    COUT(check ? "Yes" : "No");
    
    return 0;
}

Measured memory_bytes: 6384
#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 A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left;k<right;k++){
    if(L[i].value <= R[j].value){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
    }
  }
}


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

int partition(struct Card A[], int n, int p, int r){
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for(j=p;j<r;j++){
    if(A[j].value <= x.value){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  return i+1;
}

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

int main(){
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d",&n);

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

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);

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

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

  return 0;
}



Measured memory_bytes: 4096
a,b,k = gets.split.map(&:to_i) 
while k > 0 do
    if k < a then
        a = a - k
        k = 0
        break
    else
        k = k - a
        a = 0
    end
    if k < b then
        b = b -k
        k = 0
        break
    else
        k = k - b
        b = 0
    end
    if a = 0 && b = 0 then
        break
    end
end
puts "#{a} #{b}"

Measured memory_bytes: 1788
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <deque>
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


const ll MOD=998244353;
const int N=510000;

main(){
    int h=in(),w=in();
    int d=in();
    if(d%2){
        rep(i,h){
            rep(j,w){
                cout<<((i+j)&1 ? 'R' : 'B');
            }
            cout<<endl;
        }
    }
    else{
        vector<char> c={'R','G','Y','B'};
        rep(i,h){
            rep(j,w){
                if((i+j)&1){
                    int x=i+j,y=i-j;
                    int t=(((x-1)/2%d+d)%d < d/2 ? 2 : 0) + (((y-1)/2 %d +d)%d <d/2 ? 1:0);
                    cout<<c[t];
                }
                else{
                    int x=i+j,y=i-j;
                    int t=((x/2%d+d) % d < d/2 ? 2 : 0) + ( ( y/2 % d + d) % d < d/2 ? 1 : 0 );
                    cout<<c[t];
                }
            }
            cout<<endl;
        }
    }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

ll rep_pow(ll a, ll b){//繰り返し2乗法
    if(b==0) return 1;
    else if(b%2==0){
        ll memo = rep_pow(a, b/2);
        return memo*memo%mod;
    }else{
        return rep_pow(a, b-1)*a%mod;
    }
}
ll nCr(ll n, ll r){//mod逆元使ったnCr
    ll ret=1;
    rep(i,r){
        ret *= n-i;//分子
        ret %= mod;
        ret *=rep_pow(r-i, mod-2);//mod逆元によりr!で割ると同値
        ret %= mod;
    }
    return ret;
}
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
bool isPrime(int x){
    if(x==1) return false;
    else if(x==2) return true;
    else if(x%2==0) return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0){
            return false;
        }
    }
    return true;
}

int main(){
    fast_io
    
    ll n;
    cin>>n;
    ll sum=n*(n-1)/2;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N = int(read())

c_mat = [[0] * 10 for _ in range(10)]

for i in range(1, N + 1):
    acc = str(i)
    c_mat[int(acc[0])][int(acc[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += c_mat[i][j] * c_mat[j][i]
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};

int main(){
    ll K,T,n=0,sum=0;
    cin>>K>>T;
    ll A[T];
    for(ll i=0;i<T;i++){
        cin>>A[i];
        sum+=A[i];
    }
    sort(A,A+T);
    reverse(A,A+T);
    if(A[0]-1<=sum-A[0]) cout<<"0"<<endl;
    else cout<<2*A[0]-1-sum<<endl;
}


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

using namespace std;

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

vector<int> edges[100005];
int dp[100005];
int par[100005];
int q[100005];
void solve() {
  int n, m;
  cin >> n >> m;
  while(m--) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    par[b]++;
  }
  int ql = 0;
  int qr = 0;
  for(int i = 1; i <= n; i++) {
    if(par[i] == 0) q[qr++] = i;
  }
  int ret = 0;
  while(ql < qr) {
    int curr = q[ql++];
    ret = max(ret, dp[curr]);
    for(int out: edges[curr]) {
      dp[out] = max(dp[out], 1 + dp[curr]);
      if(--par[out] == 0) {
        q[qr++] = out;
      }
    }
  }
  cout << ret << endl;
}

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


Measured memory_bytes: 6912
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string w;
    string t;
    int count=0;
    
    cin>>w;
    for(int i=0; i<w.size(); i++){
        if('A'<=w[i] && w[i]<='Z') w[i]+='a'-'A';
    }
    
    cin>>t;
    while(t!="END_OF_TEXT"){
        for(int i=0; i<t.size(); i++){
            if('A'<=t[i] && t[i]<='Z') t[i]+='a'-'A';
        }
        if(w==t) count++;
        cin>>t;
    }
    cout<<count<<endl;
}


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

int main() {
  int h, w, k; cin >> h >> w >> k;
  vector<string> s(h);
  rep(i,h){
    cin >> s[i];
  }

  int ans = 0;
  rep(is,1<<h)rep(js,1<<w){
    int cnt = 0;
    rep(i,h)rep(j,w){
      if(is>>i&1) continue;
      if(js>>j&1) continue;
      if(s[i][j] == '.') continue;
      cnt++;
    }
    if(cnt == k) ans++;
  }

  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 3592
const main = (input) => {
  const s = input.trim()

  return console.log(s === '0' ? 1 : 0)
}

process.env.MYTEST
  ? (process.env.MYTEST === 'test' ? test() : main(require('fs').readFileSync('dev/stdin', 'utf8')))
  : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 29680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll X, Y;
    cin >> X >> Y;
    ll ans = 0;
    ll mx = X;
    while(mx <= Y){
        mx *= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>

using namespace std;
typedef long long int ll;

bool used[100000][11]={};
int ans[100000]={};
vector<int> G[100000];

void func(int v, int d, int c){
	if(used[v][d]==1) return;
	used[v][d]=1;
	if(d==0){
		ans[v]=c;
	}else{
		func(v, d-1, c);
		for(int i=0; i<G[v].size(); i++){
			func(G[v][i], d-1, c);
		}
	}
	return;
}
	

int main()
{
	int n, m, q;
	scanf("%d %d", &n, &m);
	for(int i=0; i<m; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
  	scanf("%d", &q);
	int vq[100000], dq[100000], cq[100000];
	for(int i=0; i<q; i++){
		scanf("%d %d %d", &vq[i], &dq[i], &cq[i]);
		vq[i]--;
	}
	for(int i=q-1; i>=0; i--){
		func(vq[i], dq[i], cq[i]);
	}
	for(int i=0; i<n; i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 9080
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
	FIO
	
	string s;cin >> s;
	for(int i = 0; i <(int)s.size(); i += 2){
		if(s[i] == 'h' && s[i + 1] == 'i');
		else{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 256