akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


int main(){

  ll N, M;
  cin >> N;
  cin >> M;
  vector<ll> p;
  vector<string> S;
  ll temp;
  string tem;
  REP(i, 0, M) {
    cin >> temp;
    p.push_back(temp-1);
    cin >> tem;
    S.push_back(tem);
  }

  ll ac[N];
  ll wa[N];
  REP(i, 0, N) {
    ac[i] = 0;
    wa[i] = 0;
  }

  REP(i, 0, M) {
    if (S[i] == "AC") {
      if (ac[p[i]] == 0) {
        ac[p[i]]++;
      }
      else {
        // nothing
      }
    }
    else { // S[i] == "WA"
      if ((ac[p[i]] == 0)) {
        wa[p[i]]++;
      }
      else {
        // nothing
      }
    }
  }

  REP(i, 0, N) {
    if (ac[i] == 0) {
      wa[i] = 0;
    }
  }

  ll ans_ac = 0;
  ll ans_wa = 0;
  REP(i, 0, N) {
    ans_ac += ac[i];
    ans_wa += wa[i];
  }

  // cout << "ac[i] : ";
  // REP(i, 0, N) {
  //   cout << ac[i] << " ";
  // }
  // cout << endl;
  // cout << "wa[i] : ";
  // REP(i, 0, N) {
  //   cout << wa[i] << " ";
  // }
  // cout << endl;

  cout << ans_ac << " " << ans_wa << endl;

  return 0;
}


Measured memory_bytes: 8040
n = int(input())
s = [input() for _ in range(n)]
s.sort()
se = sorted(set(s))
j = 0
count = 0
l = [0] * len(se)
for i in s:
    if i == se[j]:
        count += 1
    else:
        l[j] = count
        j += 1
        count = 1
l[j] = count
ma = max(l)
ans = [i for i, x in enumerate(l) if x == ma]
for i in ans:
    print(se[i])


Measured memory_bytes: 30260
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <tr1/unordered_map>

using namespace std;
typedef unsigned long long ULL;

int arr[10];
int N;
ULL hashval() {
    ULL val = 0;
    for(int i = 0; i < N; ++i) {
        val <<= 4;
        val += arr[i];
    }
    return val;
}
void restorehash(ULL hash) {
    for(int i = N-1; i >= 0; --i) {
        arr[i] = hash & 0x0f;
        hash >>= 4;
    }
}

void enumerate(tr1::unordered_map<ULL,int> &seen) {
    queue<pair<ULL,int> > q;
    q.push(make_pair(hashval(),0));
    while(!q.empty()) {
        ULL hash = q.front().first;
        int turn = q.front().second;
        q.pop();
        seen[hash] = turn;
        if(turn == 4) continue;
        restorehash(hash);
        for(int left = 0; left < N; ++left) {
            for(int right = left+1; right < N; ++right) {
                reverse(arr+left, arr+right+1);
                ULL new_hash = hashval();
                if(seen.count(new_hash)) {
                    reverse(arr+left, arr+right+1);
                    continue;
                }
                seen[new_hash] = turn+1;
                q.push(make_pair(new_hash, turn+1));
                reverse(arr+left, arr+right+1);
            }
        }
    }
}

int main() {
    scanf("%d", &N);
    for(int i = 0; i < N; ++i) {
        scanf("%d", arr+i);
    }
    tr1::unordered_map<ULL,int> seen, seen_rev;
    enumerate(seen);
    sort(arr, arr+N);
    enumerate(seen_rev);
    int ans = N-1;
    for(tr1::unordered_map<ULL,int>::iterator it = seen.begin(); it != seen.end(); ++it) {
        if(seen_rev.count(it->first)) {
            //cout << it->second << ' ' << seen_rev[it->first] << endl;
            ans = min(ans, it->second + seen_rev[it->first]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 24888
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <functional>
using namespace std;
#define all(c) (c).begin(), (c).end()

int main(int argc, char **argv)
{
  int cnr, large, small;
  string s;
  cin >> cnr;
  while (cnr--) {
    cin >> s;
    sort(all(s));
    istringstream is(s);
    is >> small;
    sort(all(s), greater<char>());
    istringstream is2(s);
    is2 >> large;
    cout << large - small << endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
 
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b;
    cin >> a >> b;
    cout << a * b;
}


Measured memory_bytes: 3660
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  a = a == 1 ? 14 : a;
  b = b == 1 ? 14 : b;
  cout << (a > b ? "Alice" : a < b ? "Bob" : "Draw")<< endl;
  return 0;
}


Measured memory_bytes: 256
import sys

N = int(input())
H = [list(map(int, input().split())) for i in range(N)]

H.sort(key=lambda x: x[2], reverse=True)

for i in H:
    x, y, h = i
    for c_x in range(101):
        for c_y in range(101):
            Height = h + abs(x-c_x) + abs(y-c_y)
            for j in range(N):
                if H[j][2] != max(Height-abs(H[j][0]-c_x)-abs(H[j][1]-c_y), 0):
                    break
                if j == N-1:
                    print(c_x, c_y, Height)
                    sys.exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
signed main(){
    fast;
   	int n,d,a;
   	cin>>n>>d>>a;
   	vector<pii> vp;
   	for(int i=1;i<=n;i++){
   		int x,h;
   		cin>>x>>h;
   		vp.pb({x,h});
   	}
   	sort(all(vp));
   	int ans = 0;
   	int times = 0;
   	multiset<pii> st; // first-> upper limit of attack
   					  // second-> times of attack
   	int idx = 0;
   	while(idx<n){
   		while(!st.empty() && (*st.begin()).first<vp[idx].first){
   			times-=(*st.begin()).second;
   			st.erase(st.begin());
   		}
   		if(times*a>=vp[idx].second){
   			idx++;
   			continue;
   		}
   		int remHealth = vp[idx].second-(a*times);
   		int more = remHealth/a;
   		if(remHealth%a!=0)
   			more++;
   		st.insert({vp[idx].first+2*d,more});
   		ans+=more;
   		times+=more;
   		idx++;
   	}
   	cout<<ans;

}  


Measured memory_bytes: 10092
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    char S[12];
    char T[12];
    ll l;

    //input
    cin >> S >> T;

    l = strlen(S);
    for(ll i = 0; i < l; i++){
        if(S[i] != T[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    if(strlen(T) != l + 1){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	km := make(map[int]int)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
		km[as[i]] = i
	}
	sort.Ints(as)

	cnt := 0
	for i := 0; i < n; i++ {
		a := as[i]
		k := km[a]
		d := abs(i - k)
		if d%2 == 1 {
			cnt++
		}
	}

	fmt.Println(cnt / 2)
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <set>
#include <string>
#include <math.h>
#include <map>
#include <climits>
#include <iomanip>


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

#define ll long long

using namespace std;

void A();
void B();
void C();
void D();
void E();
void F();

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

	C();


}

void A() {
	string s;
	cin >> s;

	cout << (s == "ABC" ? "ARC" : "ABC") << '\n';

}

void B() {
	int N, K;
	cin >> N >> K;

	set<int> have;

	forn(k, K) {

		int d;
		cin >> d;

		forn(dd, d) {

			int sn;
			cin >> sn;
			have.insert(sn);

		}
	}

	int c = 0;
	forn(i, N) {
		if (have.find(i+1) == have.end()) c++;
	}

	cout << c;

}

void C() {
	
	int N, M;
	cin >> N >> M;

	vector<int> h;
	forn(i, N) {
		int hh;
		cin >> hh;
		h.push_back(hh);
	}

	vector<vector<int>> adj(N);

	forn(m, M) {

		int a, b;
		cin >> a >> b;

		adj[a - 1].push_back(b - 1);
		adj[b - 1].push_back(a - 1);

	}
	
	int r = 0;
	forn(i, N) {

		bool good = true;
		for (int ind : adj[i]) {
			if (h[ind] >= h[i]) good = false;
		}

		if (good) r++;

	}

	cout << r;

}

void D() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void E() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}

void F() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}



Measured memory_bytes: 8764
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

// デバッグを消し忘れるな！！！

int main() {
    Vl v(5);
    rep(i, 0, 5) cin >> v[i];
    rep(i, 0, 5){
        if(v[i] == 0){
            co(i+1);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector< vector<int> > Graph;
 
Graph g;
ll a[100010];
 
ll dfs(int idx, int p) {
	if (g[idx].size() == 1) return a[idx];
 
	ll sum = 0;
	ll c_max = 0;
	for (int nex : g[idx]) {
		if (nex == p) continue;
		ll tmp = dfs(nex, idx);
		if (tmp == -1) return -1;
		sum += tmp;
		c_max = max(c_max, tmp);
	}
 
	ll res = 2 * a[idx] - sum;
	ll x = sum - a[idx];
	if (x < 0 || res < 0) return -1;
    if (c_max >= sum / 2) {
        if (x > sum - c_max) return -1;
        else return res;
    } else {
        if (x > sum / 2) return -1;
        else return res;
    }
}
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	g = Graph(n);
	for (int i = 0; i < n - 1; i++) {
		int s, d;
		cin >> s >> d;
		s--;
		d--;
		g[s].push_back(d);
		g[d].push_back(s);
	}
 
	if (n == 2) {
		cout << (a[0] == a[1] ? "YES" : "NO") << endl;
		return 0;
	}
 
	int root;
	for (root = 0; root < n; root++) {
		if (g[root].size() != 1) break;
	}
	cout << (dfs(root, -1) == 0 ? "YES" : "NO") << endl;
	return 0;
}

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

using namespace std;

int gcd(int a, int b)
{
	return ( a%b ? gcd(b, a%b) : b );
}

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

	int w, h, c;
	cin >> w >> h >> c;
	int sq = gcd(w, h);
	cout << ( w / sq )*( h / sq )*c << endl;

	return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define itrep(it, a) for(it = (a).begin(); it != (a).end; it++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

#define N 1005

char M[N][N];
int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
int cnt = 0;

struct point{
    int x,y;
};

point solve(struct point p, int n, char cheese){
    int dist[N][N];
    queue<point> q;
    rep(i,N) rep(j,N) dist[i][j] = INF;

    dist[p.y][p.x] = 0;
    q.push(p);
    struct point u;
    while(!q.empty()){
        //debug(q.size())
        u = q.front(); q.pop();
        rep(i,4){
            struct point a;
            a.x = u.x + dx[i];
            a.y = u.y + dy[i];
            //debug(M[a.y][a.x])
            if(M[a.y][a.x] != 'X' && dist[a.y][a.x] == INF){
                dist[a.y][a.x]  = dist[u.y][u.x] + 1;
                q.push(a);
                //debug(dist[a.y][a.x])
                if(M[a.y][a.x] == cheese){
                    cnt += dist[a.y][a.x];
                    return a;
                }
            }
        }
    }
    return p;
}

int main(){
    int h, w, n, ans = 0;
    struct point p;
    cin >> h >> w >> n;
    rep(i,N) rep(j,N) M[i][j] = 'X';
    range(i,1,h + 1){
        range(j,1,w + 1){
            cin >> M[i][j];
            if(M[i][j] == 'S'){
                p.x = j;
                p.y = i;
            }
        }
    }
    rep(i,n){
        p = solve(p,n,'1' + i);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
}

int solve(){
    if(N<1200) cout << "ABC" << endl;
    else if(N<2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}   

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll MOD = 1000000007;
ll n, k, a[2020];
ll invall[2020], invback[2020];

int main(){
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  rep(i, n){
    rep(j, n){
      if(a[j] >= a[i]) continue;
      invall[i]++;
      if(j > i)
        invback[i]++;
    }
  }
  //rep(i, n) cerr << invall[i] << " "; cerr << endl;
  //rep(i, n) cerr << invback[i] << " "; cerr << endl;
  
  ll res = 0;
  rep(i, n){
    res += (invback[i] * k) % MOD;
    res %= MOD;
  }
  rep(i, n){
    ll tmp = invall[i];
    tmp *= ((k * (k - 1)) / 2) % MOD;
    res += tmp;
    res %= MOD;
  }
  
  cout << res << endl;
}

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

public class Main {

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

	public Main() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int t = sc.nextInt();
			if(n==0 && m==0 && a==0 && b==0 && c==0 && t==0)
				break;
			
			int[] s = new int[n];
			for(int i=0;i<n;i++)
				s[i] = sc.nextInt();
	
			solve(n, m, a, b, c, t, s);
		}
		sc.close();
	}

	private void solve(int n, int m, int a, int b, int c, int t, int[] s) {
		int[][] mat = new int[n][n];
		
		for(int i=1;i<n;i++)
			mat[i][i-1] = a;
		for(int i=0;i<n;i++)
			mat[i][i] = b;
		for(int i=0;i<n-1;i++)
			mat[i][i+1] = c;
		
		mat = mulMat(mat, t, m);
//		for(int i=0;i<mat.length;i++)
//			System.out.println(Arrays.toString(mat[i]));
		
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<n;i++){
			int sum = 0;
			for(int j=0;j<n;j++){
				sum += mat[i][j]*s[j];
				sum %= m;
			}
			sb.append(sum).append(' ');
		}
		sb.deleteCharAt(sb.length()-1);
		System.out.println(sb.toString());
		
	}
	
	private int[][] mulMat(int[][] mat, int mult, int mod){
		int n = mat.length;
		int[][] retMat = new int[n][n];
		for(int i=0;i<n;i++)
			retMat[i][i] = 1;
		
		int c = 1;
		while(c<=mult){
			if((c&mult) > 0){
				retMat = mulMat(retMat, mat, mod);
			}
			mat = mulMat(mat, mat, mod);
			
			c*=2;
		}
		return retMat;
	}
	
	/** mat1???????????\??? */
	private int[][] mulMat(int[][] mat1, int[][] mat2, int mod){
		int n = mat1.length;
		int[][] retMat = new int[n][n];
		
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				int sum = 0;
				for(int k=0;k<n;k++)
					sum += mat1[i][k]*mat2[k][j];
				retMat[i][j] = sum%mod;
			}
		}
		return retMat;
	}
	
}

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 9 || b >= 9) {
		cout << ":(";
	}
	else {
		cout << "Yay!";
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

map< int64_t, int > prime_factor(int64_t n) {
    map< int64_t, int > ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}
vector<int> cnt(1000001);
signed main() {
SS(ll,n);
SV(ll,a,n);
ll f=a[0];
rep(i,n)f=__gcd(f,a[i]);
rep(i,n){
for (auto p : prime_factor(a[i]))
        {
            cnt[p.first]++;
        }
}
if(*max_element(all(cnt)) <= 1){
 p("pairwise coprime");
}else if(f==1){
 p("setwise coprime");
}else{
 p("not coprime");
}
}

Measured memory_bytes: 15072
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	dim := nextInt()
	//var xlist [n][dim]int
	xlist := make([][]int, n)

	for i := 0; i < n; i++ {
		xlist[i] = make([]int, dim)
		for j := 0; j < dim; j++ {
			xlist[i][j] = nextInt()
		}
	}

	cnt := 0
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			if i == j {
				continue
			}

			tmp := 0
			for di := 0; di < dim; di++ {
				tmp += (xlist[i][di] - xlist[j][di]) * (xlist[i][di] - xlist[j][di])
			}
			dist := math.Sqrt(float64(tmp))

			if isInteger(dist) {
				cnt++
			}
		}
	}

	fmt.Println(cnt)
}

func isInteger(x float64) bool {
	return math.Floor(x) == x
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
n = int(input())
A = list(map(int, input().split()))
d, q, x = 0, 0, 0
for a in A:
    if a % 4 == 0:
        q += 1
    elif a % 2 == 0:
        d += 1
    else:
        x += 1
x += d % 2
d -= d % 2
if q+1 >= x:
    print('Yes')
else:
    print('No')
# print(d,q,x)


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

int gcd(long long int m,long long int n ){
  if(0 == m || 0 == n ) return 0;
  while(m != n){
	if (m > n) m = m - n;
	else n = n - m;
	}
  return m;
}

int main() {
  long long int N,M;
  string S;
  string T;
  cin >> N >> M >> S >> T;
  long long int g = gcd(N,M);
  long long int a=N/g,b=M/g;
  bool t=true;
  for(long long int i=0;i<g;i++){
    if(S[a*i] != T[b*i]){
      t=false;
      cout << -1 << endl;
      return 0;
    }
  }
  if(t) cout << N*M/g << endl;
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int H, W, K, ans=0;
	cin >> H >> W >> K;
	vector<int> T(W), Y(H);
	vector<string> G(H);
	FOR(i, 0, H){
		cin >> G.at(i);
	}
	int a = 0;
	FOR(i, 0, H)
	{
		int c = 0;
		FOR(j, 0, W)
		{
			if(G.at(i).at(j)=='#'){
				c++;
				a++;
			}
		}
		Y.at(i) = c;
	}

	FOR(i,0,W){
		int c = 0;
		FOR(j, 0, H)
		{
			if(G.at(j).at(i)=='#')
				c++;
		}
		T.at(i) = c;
	}

	// {0, 1, ..., n-1} の部分集合の全探索
	for (int bit1 = 0; bit1 < (1 << H); ++bit1)
	{
		for (int bit2 = 0; bit2 < (1 << W); ++bit2)
		{
			int count = 0;
			vector<int> Ta, Yo;
			for (int i = 0; i < H; ++i)
			{
				if (bit1 & (1 << i))
				{ // i が bit1 に入るかどうか
					count += Y.at(i);
					Ta.push_back(i);
				}
			}
			for (int i = 0; i < W; ++i)
			{
				if (bit2 & (1 << i))
				{ // i が bit1 に入るかどうか
					count += T.at(i);
					Yo.push_back(i);
				}
			}
			FOR(i,0,Ta.size()){
				FOR(j,0,Yo.size()){
					if(G[Ta.at(i)][Yo.at(j)]=='#')
						count--;
				}
			}
			if(count==a-K){
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}





Measured memory_bytes: 3608
#define f(x,a) for(x=0;x<a;x++)
#define c i[x][y]
i[15][15];main(a,x,y){while(1){scanf("%d",&a);if(!a)exit(0);f(x,a)i[a][x]=i[x][a]=i[a][a]=0;f(x,a)f(y,a)scanf("%d",&c),i[a][y]+=c,i[x][a]+=c,i[a][a]+=c;f(x,a+1){f(y,a+1)printf("%5d",c);puts("");}}}

Measured memory_bytes: 0
import collections

n, k = map(int, input().split())
nums = list(map(int, input().split()))

counter = collections.Counter()
for num in nums:
    counter[num] += 1
counts = sorted(counter.values())

res = 0
for i in range(0, max(0, len(counts) - k)):
    res += counts[i]
print(res)


Measured memory_bytes: 98896
{-# OPTIONS_GHC -O #-}

import Control.Monad
import Data.List
import qualified Data.ByteString.Lazy.Char8 as B

readIntL :: IO [Int]
readIntL = unfoldr(B.readInt.B.dropWhile(==' '))<$>B.getContents

f (a,b,c) n
    | odd n = (a+1,b,c)
    | n `mod` 4 == 0 = (a,b,c+1)
    | True = (a,1,c)

main=do
    n <- readLn
    (a,b,c) <- foldl' f (0,0,0).take n <$> readIntL
    putStrLn $ if a+b <= c+1 then "Yes" else "No"


Measured memory_bytes: 8572
# ABC 143 D - Triangles
# https://atcoder.jp/contests/abc143/tasks/abc143_d

# 1622 ms, 2040 KB
# https://atcoder.jp/contests/abc143/submissions/12694269

n = gets.chomp.to_i
l = gets.chomp.split(/ /).map(&:to_i).sort

# puts sticks.inspect
# puts ""

count = 0
0.upto(n - 3) do |i|
  a = l[i]
  (i + 1).upto(n - 2) do |j|
    b = l[j]
    c_candidates = l[(j + 1)..(n - 1)]
    t = a + b
    # puts "--------"
    # puts c_candidates.inspect
    # puts "a: #{a}, b: #{b}, a + b: #{t}"
    c_over_index = c_candidates.bsearch_index { |c| c >= t }
    if c_over_index.nil?
      count += (n - 1) - j
    else
      count += c_over_index
    end
  end
end

puts count


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

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

  std::vector<int> X(N);

  for (int i = 0; i < N; i++) {
    std::cin >> X[i];
  }

  std::vector<int> sorted(X);
  sort(sorted.begin(), sorted.end());

  int l = sorted[X.size() / 2 - 1], h = sorted[X.size() / 2];

  for (int i = 0; i < N; i++) {
    if (X[i] <= l) {
      std::cout << h << std::endl;
    } else {
      std::cout << l << std::endl;
    }
  }
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
	int n,l,r,i,j,cnt=0;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>l>>r;
		for(j=l;j<=r;j++)
		{
			a[j]=1;
		}
	}
	for(i=1;i<=100000;i++)
	{
		if(a[i]==1) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 640
use std::vec::Vec;
use std::cmp::min;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let (h, n) = read_touple::<usize>();
    let mut v: Vec<(usize, usize)> = Vec::new();
    for _ in 0..n {
      let t = read_touple::<usize>();
      v.push(t);
    }

    let mut dp = vec![std::usize::MAX/2; h+1];
    dp[0] = 0;
    
    for i in 0..n {
      for j in 0..h+1 {
        let (a, b) = v[i];
          if j + a > h {
              dp[h] = min(dp[h], dp[j] + b);
              continue
          }

          dp[j + a] = min(dp[j + a], dp[j] + b);
      }
    }
    println!("{}", dp[h]);
}


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

const int MOD =1000000007;

signed main() {
int a,b,k;
cin>>a>>b>>k;
if(a>k){
    cout<<a-k<<' '<<b;
    return 0;
}
cout<<0<<' '<<max(0ll,b-(k-a));

    return 0;
}


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

class Program
{
    static bool A(int i, int m, int[] @a)
    {
        if (m == 0)
        {
            return true;
        }
        if (i >= @a.Length)
        {
            return false;
        }
        return A(i + 1, m, @a) || A(i + 1, m - @a[i], @a);
    }
    static void Main(string[] args)
    {
        Console.ReadLine();
        var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        Console.ReadLine();
        foreach (var i in Console.ReadLine().Split(' ').Select(x => int.Parse(x)))
        {
            Console.WriteLine(A(0, i, a) ? "yes" : "no");
        }
        
    }
}


Measured memory_bytes: 18428
n=int(input())
S=input()
ans=0
for i in range(n-1):
    L=S[:i+1]
    R=S[i+1:]
    C=[]
    for l in L:
        if not l in C:
            if l in R:
                C.append(l)
    ans=max(len(C),ans)
print(ans)

Measured memory_bytes: 3060
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 4005;
typedef bitset < maxN > bs;
bs read() {
    string s;
    cin >> s;
    bs f = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') f[s.size() - 1 - i] = true;
    }
    return f;
}
bs a[6];
int get_last(const bs& f) {
    for (int i = maxN - 1; i >= 0; i--) {
        if (f[i] == true) return i;
    }
    return -1;
}
bs bs_gcd(bs x, bs y) {
    while (true) {
        int p1 = get_last(x);
        int p2 = get_last(y);
        if (p1 == -1) return y;
        if (p2 == -1) return x;
        if (p1 < p2) {
            swap(x, y);
            swap(p1, p2);
        }
        x = x ^ (y << (p1 - p2));
    }
}
const int mod = 998244353;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int pw2[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    bs x = read();
    for (int i = 0; i < n; i++) {
        a[i] = read();
    }
    bs gc = a[0];
    for (int i = 1; i < n; i++) {
        gc = bs_gcd(gc, a[i]);
    }
    pw2[0] = 1;
    for (int i = 1; i < maxN; i++) pw2[i] = sum(pw2[i - 1], pw2[i - 1]);
    int ans = 0;
    int p1 = get_last(gc);
    int p2 = get_last(x);
    bs cur_xor = 0;
    if (p1 >= p2) {
        ans = sum(ans, 1);
        bool bad = false;
        for (int i = maxN - 1; i >= 0; i--) {
            if (gc[i] != x[i]) {
                if (gc[i] == true) {
                    bad  = true;
                    break;
                }
                break;
            }
        }
        if (!bad) ans = sum(ans, 1);
        cout << ans << '\n';
        return 0;
    }

    for (int i = p2; i >= p1; i--) {
        if (cur_xor[i] == x[i]) {
            if (x[i] == 1) {
                ans = sum(ans, pw2[i - p1]);
            }
            //i shouldn't take
        }
        else if (x[i] == true) {
            ans = sum(ans, pw2[i - p1]);
            cur_xor ^= (gc << (i - p1));
        }
        else {
            // should xor
            cur_xor ^= (gc << (i - p1));
        }
    }
    if (p2 >= p1) {
        bool bad = false;
        for (int i = p1 - 1; i >= 0; i--) {
            if (cur_xor[i] != x[i]) {
                if (cur_xor[i] == true) {
                    bad  = true;
                    break;
                }
                break;
            }
        }
        if (!bad) ans = sum(ans, 1);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>
#include<map>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
typedef pair<ll,ll> LL_LLP;
#define INF 1000000007
#define MAX_H 20000

#define ARRAY_MAX 100005

int main(){

    int n,maxi = -1;
    cin >> n;
    vector<int> a(ARRAY_MAX);

    REP(i,n){
        cin >> a[i];
        maxi = max(maxi,a[i]);
    }
    vector<int> count(maxi,0);

    REP(i,n){
        count[a[i]-1]++;
    }

    int k = 0;
    REP(i,maxi){
        if(count[i] > 0){
            k++;
        }
    }

    if(k == n){
        cout << n << endl;
    }else{
        if(k % 2 == 0){
            cout << k-1 << endl;
        }else{
            cout << k << endl;
        }
    }
  



    return 0;
}

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

using namespace std;

int main(){
   string S;
   cin >> S;
   for(int i = 0 ; i+1 < (int)S.size();i+=2){
      if(S[i]!='h'||S[i+1]!='i'){
         cout << "No"<<endl;
         return 0;
      }
   }
   if(S.size()%2==0) cout << "Yes" << endl;
   else cout << "No"<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
string s, t;
set<int> x[30], y[30];
int main() {
	int i;
	cin>>s>>t;
	for(i=0; i<s.size(); i++) x[s[i]-'a'].insert(t[i]-'a');
	for(i=0; i<s.size(); i++) y[t[i]-'a'].insert(s[i]-'a');
	for(i=0; i<26; i++) if(x[i].size()>1 || y[i].size()>1) {puts("No"); return 0;}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int A,B;
  cin>>A>>B;

  cout<<max(0,A-2*B)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
typedef long long ll;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

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

    while(1){
        int a = floor(sqrt(n));
        if(a*a==n){
            cout << n << endl;
            return 0;
        }
        n--;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
const int mx = 3e3;
ll dp[mx + 3][mx + 3][5];
ll arr[mx + 3][mx + 3];
int main() {
	ll r, c, k;
	cin >> r >> c >> k;
	while (k--) {
		ll x, y, v;
		cin >> x >> y >> v;
		arr[x][y] = v;
	}
	
	for (int i = 1; i <= r; ++i) {
		for (int j = 1; j <= c; ++j) {
			dp[i][j][0] = dp[i - 1][j][4];
			dp[i][j][1] = max(dp[i][j - 1][1], max(dp[i - 1][j][4], dp[i][j - 1][0]) + arr[i][j]);
            dp[i][j][2] = max(dp[i][j - 1][1] + arr[i][j], dp[i][j - 1][2]);
            dp[i][j][3] = max(dp[i][j - 1][2] + arr[i][j], dp[i][j - 1][3]);

            for (int k = 0; k < 4; ++k)
            	dp[i][j][4] = max(dp[i][j][k], dp[i][j][4]); 
		}
	}

	cout << dp[r][c][4] << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> d(n, vector<int>(2));
    for(int i = 0; i < n; i++) cin >> d[i][0] >> d[i][1];

    string ans = "No";
    for(int i = 0; i+2 < n; i++){
        if(d[i][0] == d[i][1] && d[i+1][0] == d[i+1][1]
        && d[i+2][0] == d[i+2][1]) ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
from collections import deque

def main():
    S = input()
    Q = int(input())

    S = deque(list(S))
    rev = 1  # 正方向: 1, 逆方向: -1
    for _ in range(Q):
        input_line = input().split()
        if len(input_line) == 1:
            rev *= -1
        else:
            _, f, c = input_line
            if f == '1':
                if rev == 1:
                    S.appendleft(c)
                else:
                    S.append(c)
            else:
                if rev == 1:
                    S.append(c)
                else:
                    S.appendleft(c)

    if rev == 1:
        print(''.join(S))
    else:
        print(''.join(list(S)[::-1]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 10084
#include <vector>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <utility>
#include <stack>
#include <numeric>
#include <random>
#include <algorithm>
#include <queue>
#include <functional>
using namespace std;

#define rep(i, b, e) for(i = b; i < e; ++i)
#define repr(i, b, e) for (i = b; i >= e; --i)
#define ull unsigned long long int
#define ll long long int
#define pint pair<int, int>

#define M_DEBUG 1
#define PI 3.141592653589793

#define E '\n'

#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define INF (1e18)

const ll MAX = 1000000000;
const ll MOD = 1e9 + 7;

ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;

int main(void) {
    cin >> n >> k >> s;
    vector<ll> aa(n);
    for (int i = 0; i < k; ++i) 
        aa[i] = s;

    if (s != MAX) 
        for (i = k; i < n; ++i) 
            aa[i] = MAX;
    else 
        for (i = k; i < n; ++i) 
            aa[i] = 9;
    
    printa(aa, n);

    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N, D, A;
    cin >> N >> D >> A;

    vector<pll> X(N);
    REP(i, N) cin >> X[i].first >> X[i].second;
    sort(X.begin(), X.end());

    REP(i, N){
    	X[i].second = ((X[i].second+(A-1))/A);
    }

    ll res = 0;
    vector<ll> S(N+1, 0);
    ll cum = 0;
    REP(i, N){
    	cum += S[i];
    	pll tmp = {X[i].first+2*D, (1ll<<60)};
    	ll pos = upper_bound(X.begin(), X.end(), tmp) - X.begin();
    	pos = min(pos, N);
    	ll val = (X[i].second - cum);
    	if(val<=0) continue;
    	cum += val;
    	res += val;
    	S[pos] -= val;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define mp make_pair
#define p(x) cout<< x << " ";
#define pe(x) cout<< x << endl ;
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define el endl
#define M 998244353 
#define int long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROR(i,a,b) for(int i=a;i>=b;i--)
const int N = 1e5 + 5;

int32_t main() 
{ 
    int n,w;
    cin>>n>>w;
    int dp[n+1][w+1];
    memset(dp,0,sizeof(dp));
    int value[n+1],profit[n+1];
    FOR(i,1,n+1)
    cin>>value[i]>>profit[i];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if (i==0 || j==0) 
             dp[i][j] = 0; 
            else if(value[i]<=j)
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-value[i]]+profit[i]);
            else
            dp[i][j]=dp[i-1][j];
           // cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<dp[n][w];
} 

Measured memory_bytes: 79104
#include<stdio.h>

int main()
{
	int x;
	scanf("%d",&x);
	if(x>=400&&x<=599) printf("8\n");
	if(x>=600&&x<=799) printf("7\n");
	if(x>=800&&x<=999) printf("6\n");
	if(x>=1000&&x<=1199) printf("5\n");
	if(x>=1200&&x<=1399) printf("4\n");
	if(x>=1400&&x<=1599) printf("3\n");
	if(x>=1600&&x<=1799) printf("2\n");
	if(x>=1800&&x<=1999) printf("1\n");
	return 0;
 } 

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

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

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

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

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

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

int main(){
  int elaps=0, c;
  int i, q;
  P u;

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

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

  while(head != tail)
  {
    u=dequeue();
    c=min(q, u.t);
    u.t-=c;
    elaps+=c;

    if(u.t > 0)
    enqueue(u);
    else
    {
    printf("%s %d\n", u.name, elaps);
    }
  }

  return 0;
}



Measured memory_bytes: 11836
#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.at(i);
	}
	int M = pow(10, 5) + 2;
	vector<int> box(M);
	for (int i = 0;i < N;i++) {
		box.at(a.at(i))++;
	}
	int count = 0;
	for (int i = 0;i < M-2;i++) {
			count = max(count, box.at(i) + box.at(i+1)+box.at(i + 2));
	}
	cout << count;
}


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

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,0,N) cin >> A[i];
    sort(all(A));

    long double tmp1 = 1;
    rep(i,0,N) {
        tmp1 *= A[i];
//        cout << tmp1 << endl;
        if (tmp1 > (double)1000000000000000000) {
            cout << -1 << endl;
            return 0;
        }
    }

    ll tmp = 1;
    rep(i,0,N) {
        tmp *= A[i];
    }
    cout << tmp << endl;
}

Measured memory_bytes: 4052
H = 12
W = 6
X = "."
O = "O"

def count!(field, y, x)
  color = field[y][x]
  field[y][x] = X
  nex = [[-1, 0], [1, 0], [0, -1], [0, 1]].map{|dy, dx| [y + dy, x + dx]}
  1 + nex.map{|ny, nx| field[ny][nx] != color ? 0 : count!(field, ny, nx)}.inject(:+)
end

def count(field, y, x)
  count!(Marshal.load(Marshal.dump(field)), y, x)
end

def vanish!(field, y, x)
  color = field[y][x]
  field[y][x] = X
  nex = [[-1, 0], [1, 0], [0, -1], [0, 1]].map{|dy, dx| [y + dy, x + dx]}
  nex.each do |ny, nx|
    field[ny][nx] = X if field[ny][nx] == O
    vanish!(field, ny, nx) if field[ny][nx] == color
  end
end

def uyenimo!(field)
  done = false
  1.upto(H) do |y|
    1.upto(W) do |x|
      next if field[y][x] == X || field[y][x] == O
      next if count(field, y, x) < 4
      vanish!(field, y, x)
      done = true
    end
  end
  done
end

def fall!(field)
  1.upto(W) do |x|
    H.downto(1) do |y|
      next unless field[y][x] == X
      y.downto(1) do |i|
        next if field[i][x] == X
        field[y][x], field[i][x] = field[i][x], field[y][x]
        break
      end
    end
  end
end

gets.to_i.times do
  field = Array.new(H + 2){X * (W + 2)}
  field[1, H] = H.times.map{X + gets.chomp + X}
  chain = 0
  while uyenimo!(field) do
    fall!(field)
    chain += 1
  end
  puts chain
end

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

typedef vector<int> vi;

vector<vi> ans;
int n;

void rec(vi v,vi c){
  if(c.empty()){
    vi res(n-1);
    for(int i=0;i<n-1;i++)res[i] = v[i+1]-v[i];
    ans.push_back(res);
    return;
  }

  int big = c[c.size()-1],tmp;
  vi t1,t2;
  
  for(int i=0;i<v.size();i++){
    t1 = v; t2 = c;
    for(int k=0;k<2;k++){
      tmp = t1[i];
      if(k&1)tmp -= big;
      else tmp += big;

      if(t1[0]<=tmp){
	bool f = true;
	for(int j=0;j<t1.size();j++){
	  vi::iterator ite = find(t2.begin(),t2.end(),abs(tmp-t1[j]));
	  if(ite != t2.end())t2.erase(ite);
	  else{
	    f = false;
	    break;
	  }
	}
	if(f){
	  t1.insert(lower_bound(t1.begin(),t1.end(),tmp),tmp);
	  rec(t1,t2);
	}
      }
    }
  }
}

int main(){
  vi v,c;
  while(cin >> n,n){
    c.resize(n*(n-1)/2);
    for(int i=0;i<n*(n-1)/2;i++)cin >> c[i];
    sort(c.begin(),c.end());
    
    v.clear();
    v.push_back(0);
    v.push_back(c[c.size()-1]);
    c.pop_back();
    
    ans.clear();
    rec(v,c);
    
    sort(ans.begin(),ans.end());
    ans.erase(unique(ans.begin(),ans.end()),ans.end());

    for(int i=0;i<ans.size();i++){
      cout << ans[i][0];
      for(int j=1;j<n-1;j++)cout << " " << ans[i][j]; 
      cout << endl;
    }
    cout << "-----" << endl;
  }
}

Measured memory_bytes: 1324
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String num = sc.nextLine();
        check(num);
    }

    public static void check(String num) {
        String[] strs = num.split(" ");
        int[] nums = new int[strs.length];
        for(int i=0; i<strs.length; i++) {
            nums[i] = Integer.parseInt(strs[i]);
        }
        int result = nums[2]-(nums[0]-nums[1]);
        if(result > 0){
            System.out.println(result);
        } else {
            System.out.println(0);
        }
    }
}

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

int main(){

  int i, j, h, w, c=0, black=0;
  char x,s[60][60];
  bool check = true;

  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++){
    scanf("%c",&x);
    for(j=0;j<w;j++)scanf("%c",&s[i][j]);
  }

  i=0;
  do{
    for(j=0;j<w;j++){
      if(s[i][j]=='#'){
        if((i>0&&s[i-1][j]=='#')||(j>0&&s[i][j-1]=='#')||(i<h-1&&s[i+1][j]=='#')||(j<w-1&&s[i][j+1]=='#')){}
        else check=false;
      }
    }
    i++;
  }while(check==true&&i<h);

  if(check)puts("Yes");
  else puts("No");
}


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

int main(void)
{
    char c;
    int cnt[26] = {};

    while (scanf("%c", &c) != EOF) {
        if (islower(c)) {
            int num = c - 'a';
            cnt[num]++;
        } else if (isupper(c)) {
            int num = c - 'A';
            cnt[num]++;
        }
    }
    for (int i = 0; i < 26; ++i) {
        printf("%c : %d\n", 'a' + i, cnt[i]);
    }
    return 0;
}

Measured memory_bytes: 972