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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


struct edge {
    int to, cap, rev;
};


const int MAX_V = 110;
vector<edge> G[MAX_V];
bool used[MAX_V];


void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
}


int dfs(int v, int t, int f) {
    if (v == t) return f;
    used[v] = true;
    rep(i, G[v].size()) {
        edge &e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}


int max_flow(int s, int t) {
    int flow = 0;
    while (true) {
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if (f == 0) return flow;
        flow += f;
    }
}


int main() {
    int V, E; cin >> V >> E;
    rep(i,E) {
        int u, v, c;
        cin >> u >> v >> c;
        add_edge(u, v, c);
    }

    int ans = max_flow(0, V-1);
    cout << ans << endl;    
    return 0;
}



Measured memory_bytes: 3196
import java.io.DataInputStream;
	import java.io.FileInputStream;
	import java.io.IOException;
	import java.util.ArrayList;
	import java.util.Arrays;
	import java.util.PriorityQueue;
	import java.util.*;
	
	public class Main {
		public static class pair implements Comparable<pair> {
			int id;
			int ans;
	
			pair(int x, int y) {
	
				id = x;
				ans = y;
	
			}
	
			public pair() {
	
			}
	
			public int compareTo(pair o) {
				// TODO Auto-generated method stub
	
				return this.ans - o.ans;
			}
		}
	
	//	static int mod = (int) 998244353.;
		static int mod=(int)1e9+7;
		static ArrayList<Integer> gr[];
		static int  ar[];
		static Scanner sc = new Scanner(System.in);
		static int pri[] = new int[(int) 1e6 + 5];
		static StringBuilder out = new StringBuilder();
	
		static int[] dp;
	
		public static void main(String[] args) throws IOException {
			int t =1;// sc.nextInt();
			
			while (t-- > 0) {
				
				int n=sc.nextInt();
				n%=10;
				if(n==2 || n==5 || n==4 || n==7 || n==9) {
					out.append("hon");
				}
				else if(n==3) {
					out.append("bon");
				}
				else out.append("pon");
				
			}
			
			System.out.println(out);
		}
    }

Measured memory_bytes: 39648
#include <iostream>
#include <algorithm>
int main() {
  int data[10];
  for (int i = 0; i < 10; i++) {
    std::cin >> data[i];
  }
  std::sort(data,data+10,std::greater<int>());
  for (int i = 0; i < 3; i++) {
    std::cout << data[i] << std::endl;
  }
}

Measured memory_bytes: 1176
#include <stdio.h>

int mem[25], s, n;
int min = -1;

void solve(int x, int A)
{
	int B;
	int sa;
	
	if (x == n){
		B = s - A;
		if( A > B){
			sa = A - B;
		}
		else {
			sa = B - A;
		}
		if (min == -1){
			min = sa;
		}
		if (min > sa){
			min = sa;
		}
		return;
	}
	
	solve(x + 1, A + mem[x]);
	solve(x + 1, A);
}

int main(void)
{
	int i;
	
	while (1){
		
		s = 0;
		
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		for (i = 0; i < n; i++){
			scanf("%d", &mem[i]);
			s += mem[i];
		}
		solve(0, 0);
		printf("%d\n", min);
		min = -1;
	}
	return (0);
}

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

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

    int count = 0;

    for (int i = 1; i <= n; i += 2) {
        int num = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) num++;
        }
        if (num == 8) count++;
    }

    cout << count << endl;
}

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

int main(void){
	int n, k, i;
	int p[200000];
	int a[200000];
	scanf("%d%d", &n, &k);
	for(i=0; i<n; i++){
		scanf("%d", p+i);
	}
	a[0]=p[0];
	for(i=1; i<k; i++){
		a[i] = a[i-1]+p[i];
	}
	int max=a[k-1];
	for(i=k; i<n; i++){
		a[i] = a[i-1]+p[i]-p[i-k];
		if(a[i]>max) max=a[i];
	}
	long ans = ((long)max)+k;
	if(ans%2==0) printf("%ld\n", ans/2);
	else printf("%ld.5\n", ans/2);
}


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

int main() {
	int j, tmp, ans = 0,min;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> n;
	pair<int, int> tmpair;
	cin >> j;
	for (int i = 1; i < (j + 1); i++) {
		cin >> tmp;
		n.push(make_pair(tmp, i));
	}
	for (int i = 0; i < j; i++) {
		tmpair = n.top();
		n.pop();

		if (i == 0) {
			min = tmpair.second;
			ans++;
		}
		else {
			if (min < tmpair.second) {
				continue;
			}
			else {
				min = tmpair.second;
				ans++;
			}
		}
	}
	cout << ans << endl;
	//<数値、順番>のpairにする
	//数値に基づいてpriority_queue(昇順)
	//queueから出した順番をpriority_queueに入れて自分より小さい値があればアウト

}

Measured memory_bytes: 5368
H, W = map(int, input().split())
HW_list = [list(input()) for i in range(H)]
import copy

tmp = copy.deepcopy(HW_list)
h_index = 0
for i, HW in enumerate(HW_list):
    is_all_shiro = True
    for hw in HW:
        if hw == '#':
            is_all_shiro = False
            h_index += 1
            break
    if is_all_shiro:
        tmp.pop(h_index)
w_index = 0
ans = copy.deepcopy(tmp)
for w in range(W):
    is_all_shiro = True
    for t in tmp:
        if t[w] == '#':
            is_all_shiro = False
            w_index += 1
            break
    if is_all_shiro:
        for a in ans:
            a.pop(w_index)
for A in ans:
    print(''.join(A))


Measured memory_bytes: 9468
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;

int main(){
    string a,b;
    std::cin >> a>>b;
    string aa,bb;
    rep(i,stoi(a)){
        bb+=b;
    }
    rep(i,stoi(b)){
        aa+=a;
    }
    if(aa<bb)std::cout << aa << std::endl;
    else std::cout << bb << std::endl;
}

Measured memory_bytes: 256
z = int(input())
x = 0
y = 0
t = 0
for i in range(z):
    s,a,b = map(int,input().split(" "))
    if s - t < abs(a-x) + abs(b-y):
        print("No")
        exit()
    elif (s - t) % 2 == 1 and (abs(a-x) + abs(b-y)) % 2 == 0:
        print("No")
        exit()
    elif (s - t) % 2 == 0 and (abs(a-x) + abs(b-y)) % 2 == 1:
        print("No")
        exit()
    else:
        x = a
        y = b
        t = s
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int n;
map<string, int> mp;
int main() {
	cin>>n;
	for(int i = 0; i < n; ++i) {
		string s;
		cin>>s;
		mp[s]++;
	}
	int mx = 0;
	for(auto i : mp) {
		mx = max(mx, i.second);
	}
	vector<string> vs;
	for(auto i : mp) {
		if(i.second == mx)
			vs.emplace_back(i.first);
	}
	// cout<<(int) vs.size()<<endl;
	for(auto i : vs)
		cout<<i<<endl;
	return 0;
}


Measured memory_bytes: 26868
#include<cstdio>
#include<vector>
#include<set>
#include<algorithm>


using namespace std;
using vi=vector<int>;
using si=set<int>;
using vsi=vector<si>;


const int vmax=55555;


int is_prime(int x)
{
	static vi p;
	if(p.size()<100)
	{
		int pmax=vmax*5;
		p.resize(pmax);
		p[0]=p[1]=1;
		for(int i=2;i<pmax;i++)
		{
			if(p[i]) continue;
			for(int j=i*2;j<pmax;j+=i)
			{
				p[j]=1;
			}
		}
	}
	return p[x]==0;
}

int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi a, p;
		vsi s(6);

		for(int i=vmax-4;i>0;i-=5)
		{
			if(is_prime(i)) p.push_back(i);
		}

		s[0].insert(0);
		for(int i=0;i<n;i++)
		{
			while(p.size())
			{
				int x=p.back();
				int is_ok=1;

				p.pop_back();
				for(auto it=s[4].begin();it!=s[4].end();++it)
				{
					if(is_prime(x+*it))
					{
						is_ok=0;
						break;
					}
				}
				if(is_ok)
				{
					for(int i=3;i>=0;i--)
					{
						for(auto it=s[i].begin();it!=s[i].end();++it)
						{
							s[i+1].insert(x+*it);
						}
					}
					a.push_back(x);
					break;
				}
			}

		}
		if(a.size()==n)
		{
			printf("%d", a[0]);
			for(int i=1;i<n;i++) printf(" %d", a[i]);
			printf("\n");
		}
		else
		{
			printf("No\n");
		}
	}
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << a + a * a + a * a * a << endl;

    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll a, b, c, n, ss[110000], now = 1, ans = 0;
string s;
int main() {
	cin >> n;
	REP(i, n)cin >> ss[i];
	REP(i, n - 1) {
		if (ss[i] == ss[i + 1]) {
			now++;
		}
		else {
			ans += now / 2;
			now = 1;
		}
	}
	ans += now / 2;
	now = 1;
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
  int sum, A, B;
  cin >> A >> B;
  sum = A+B;
  
  if(A % 3 == 0 || B % 3 == 0 || sum % 3 == 0)cout << "Possible" << endl;
  else cout<< "Impossible" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    static Scanner sc;
    static int[] input;

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

        int n = sc.nextInt();
        input = new int[n];
        for(int i = 0; i < n; i++) {
            input[i] = sc.nextInt();
        }

        int index = partition(0, n-1);
        StringBuilder builder = new StringBuilder();
		for (int i = 0; i < n-1; i++) {
            if(i == index)
                builder.append("[" + input[i] + "] ");
            else
                builder.append(input[i] + " ");
        }
		System.out.println(builder.append(input[n-1]));
    }

    static int partition(int p, int r) {
        int x = input[r];
        int i = p-1;
        for(int j = p; j < r; j++) {
            if(input[j] <= x) {
                i++;
                swap(i, j);
            }
        }
        swap(i+1, r);
        return i+1;
    }

    static void swap(int i, int j) {
        int tmp = input[i];
        input[i] = input[j];
        input[j] = tmp;
    }
}



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

using namespace std;

vector<int> g[1024];
char s[1024][64];

void show(int v, int depth)
{
	for (int i = 0; i < depth; i++) printf(".");
	printf("%s\n", s[v]);

	for (int i = 0; i < g[v].size(); i++) show(g[v][i], depth + 1);
}

int main()
{
	int n;

	scanf("%d", &n);

	for (int i = 0; i < n; i++){
		int par;
		scanf("%d", &par);
		if (par) g[--par].push_back(i);
		scanf("%s", s[i]);
	}

	show(0, 0);

	return (0);
}

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

void Main()
{
    long a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n; cin>>n;
	map<string,ll> mp;
	rep(i,0,n){
		string s; cin>>s;
		sort(all(s));
		mp[s]++;
	}
	ll ans=0;
	for(auto c:mp){
		ans+=c.second*(c.second-1)/2;
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 11344
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        board: [String; 2]
    }
    let is_ok = board[0] == board[1].chars().rev().collect::<String>()
        && board[1] == board[0].chars().rev().collect::<String>();
    println!("{}", if is_ok { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
n, a, b = map(int,input().split())

def inv(a):
    return pow(a, (10**9 + 7) - 2, (10**9 + 7))
    
    
t = pow(2, n, 10**9 + 7) - 1
x = 1
y = 1
for i in range(a):
    x *= (n - i)
    x %= (10**9 + 7)
    y *= (a - i)
    y %= (10**9 + 7)
    
f = (x * inv(y)) % (10**9 + 7)
x = 1
y = 1

for i in range(b):
    x *= (n - i)
    x %= (10**9 + 7)
    y *= (b - i)
    y %= (10**9 + 7)
s = (x * inv(y)) % (10**9 + 7)

print((t - f - s + (10**9 + 7)) % (10**9 + 7))


Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl



int a[200010], b[200010];

signed main() {
    int n;
    while (cin >> n) {
        rep(i, n) cin >> a[i] >> b[i];
        int mini = 1e9;
        int s = accumulate(b, b + n, 0ll);
        rep(i, n) if (a[i] > b[i]) mini = min(mini, b[i]);
        int ans = mini == 1e9 ? 0 : s - mini;
        cout << ans << endl;
    }
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
    	String s1 = sc.next();
        String s2 = sc.next();
        int n1 = (int)s1.charAt(0);
        int n2 = (int)s2.charAt(0);
        if(n1 > n2){
        	System.out.println(">");
        }else if(n1 < n2){
        	System.out.println("<");
        }else{
        	System.out.println("=");
        }
    }
}


Measured memory_bytes: 35488
#include<iostream>
#include<queue>
#include<cmath>

using namespace std;
long long a[100005]={0},b[100005]={0},d[100005]={0},sum,v[100005]={0};
int main(){
	long long n,c,i;
	cin>>n>>c;
	d[0]=0;d[n+1]=c;
	for(i=1;i<=n;i++)
		cin>>d[i]>>v[i];
	for(i=1;i<=n;i++)
	{
	a[i]=a[i-1]+v[i]-(d[i]-d[i-1]);
} 
	for(i=n;i>=1;i--){
		b[i]=b[i+1]+v[i]-(d[i+1]-d[i]);
	}
	for(i=2;i<=n;i++){
		a[i]=max(a[i-1],a[i]); 
	}
	for(i=n-1;i>=1;i--){
		b[i]=max(b[i+1],b[i]);
	}
	long long sum=0;
	for(i=1;i<=n;i++){
		sum=max(sum,a[i]);
		sum=max(sum,b[i]);
		sum=max(sum,a[i]+b[i+1]-d[i]);
		sum=max(sum,a[i-1]+b[i]-(c-d[i]));
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3328
r, c = map(int,input().split())

li = [list(map(int,input().split())) + [0] for _ in range(r)]
li = li+[[0]*(c+1)]

for i in range(c):
    tmp = 0
    for j in range(r+1):
        if j == r:
            li[j][i] = tmp
        tmp += li[j][i]

for i in range(r+1):
    li[i][c] = sum(li[i][:c])

for i in range(len(li)):
    print(*li[i])


Measured memory_bytes: 6260
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ac(n, 0), wa(n, 0);
  while (m--) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (s == "WA") {
      if (!ac[p]) wa[p]++;
    } else {
      ac[p] = 1;
    }
  }
  int a = 0, b = 0;
  for (int i = 0; i < n; i++) {
    if (!ac[i]) continue;
    a++;
    b += wa[i];
  }
  cout << a << " " << b << endl;
  return 0;
} 

Measured memory_bytes: 4060
/*
考虑相对移动，把所有机器人的整体移动变成网格地图和出口的移动。显然，当前哪些机器人爆炸只与网格地图在四个方向上最远移动的距离有关
设F[u][d][l][r]表示在上、下、左、右四个方向最远移动距离为u、d、l、r时最多救了多少机器人
转移考虑，在某个方向上移动到更远的距离。以往上移动到u + 1的情况为例。设p = 机器人所在行 - (u + 1)
把[u][Y - l ~ Y + r]与机器人没有爆炸的范围（显然是一个矩形）求交得到[u][x ~ y]，显然这一个区间内的机器人都可以被营救掉，同时不会影响左右的最远移动距离 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
const int Max_HW(105);

int H, W, X, Y, Sumlr[Max_HW][Max_HW][Max_HW], Sumud[Max_HW][Max_HW][Max_HW];
char V[Max_HW][Max_HW];

void init()
{
	scanf("%d%d", &H, &W);
	for (int i = 1;i <= H;++i)
	{
		scanf("%s", V[i] + 1);
		for (int j = 1;j <= W;++j)
			if (V[i][j] == 'E')
				X = i, Y = j;
	}
	for (int i = 1;i <= H;++i)
		for (int l = 1;l <= W;++l)
			for (int r = l;r <= W;++r)
				Sumlr[i][l][r] = Sumlr[i][l][r - 1] + (V[i][r] == 'o');
	for (int i = 1;i <= W;++i)
		for (int u = 1;u <= H;++u)
			for (int d = u;d <= H;++d)
				Sumud[i][u][d] = Sumud[i][u][d - 1] + (V[d][i] == 'o');
}

int Ans, F[Max_HW][Max_HW][Max_HW];

inline void update(int &a, int b)
{
	a = max(a, b);
}

void dp()
{
	memset(F, -0X3F, sizeof(F)), F[0][0][0] = 0;
	for (int u = 0, p, x, y;u <= H;++u)
		for (int d = 0;d <= H;++d)
			for (int l = 0;l <= W;++l)
				for (int r = 0;r <= W;++r)
				{
					update(Ans, F[d][l][r]);
					if ((p = X + (d + 1)) + u > H)
						x = 1, y = 0;
					else
						x = max(Y - l, 1 + r), y = min(Y + r, W - l);
					if (x <= y)
						update(F[d + 1][l][r], F[d][l][r] + Sumlr[p][x][y]);
					if ((p = Y - (l + 1)) - r < 1)
						x = 1, y = 0;
					else
						x = max(X - u, 1 + d), y = min(X + d, H - u);
					if (x <= y)
						update(F[d][l + 1][r], F[d][l][r] + Sumud[p][x][y]);
					if ((p = Y + (r + 1)) + l > W)
						x = 1, y = 0;
					else
						x = max(X - u, 1 + d), y = min(X + d, H - u);
					if (x <= y)
						update(F[d][l][r + 1], F[d][l][r] + Sumud[p][x][y]);
					if ((p = X - (u + 1)) - d < 1)
						x = 1, y = 0;
					else
						x = max(Y - l, 1 + r), y = min(Y + r, W - l);
					if (x <= y)
						F[d][l][r] = F[d][l][r] + Sumlr[p][x][y];
				}
	printf("%d", Ans);
}

int main()
{
	init();
	dp();
	return 0;
}

Measured memory_bytes: 13568
import numpy as np
N, W = map(int, input().split())
wv = np.array([list(map(int, input().split())) for _ in range(N)])

dp = np.zeros(W+1, dtype=np.int64)

for w, v in wv:
    dp[w:] = np.maximum(dp[w:], dp[:-w]+v)

ans = dp[W]
print(ans)


Measured memory_bytes: 21288
#include <stdio.h>

int main() {
	int r, d, x, a, b, c, d_, e, f, g, h, i, j;

	scanf("%d%d%d", &r, &d, &x);
	a = r * x - d;
	printf("%d\n", a);
	b = r * a - d;
	printf("%d\n", b);
	c = r * b - d;
	printf("%d\n", c);
	d_ = r * c - d;
	printf("%d\n", d_);
	e = r * d_ - d;
	printf("%d\n", e);
	f = r * e - d;
	printf("%d\n", f);
	g = r * f - d;
	printf("%d\n", g);
	h = r * g - d;
	printf("%d\n", h);
	i = r * h - d;
	printf("%d\n", i);
	j = r * i - d;
	printf("%d\n", j);
	return 0;
}


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

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

    long long X, Y, Z;
    X = N / (A + B);
    Y = N % (A + B);

    if (Y <= A){
        Z = A * X + Y;
        cout << Z << endl;
    } else {
        Z = A * X + A;
        cout << Z << endl;
    }

}

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

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n+1; i++) {
		if ((2 * m + 1)*i >=n) {
			printf("%d", i);
			return 0;
		}
	}
}


Measured memory_bytes: 128
#include <stdio.h>
#define MAX 1000000


int H,A[MAX+1];

void maxHeapify(int);
void buildMaxHeap(void);

int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  // for(i=1;i<=H;i++)
  buildMaxHeap();
 
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}


void maxHeapify(int i){
  int l,r,largest,swp;

  l=2*i;
  r=2*i+1;
  if(l<=H && A[l] > A[i]){
    largest=l;
  }
  else largest=i;
  if(r<=H && A[r]>A[largest]){
    largest=r;
  }
  if(largest != i){
    swp = A[i];
    A[i] = A[largest];
    A[largest] = swp;
    maxHeapify(largest);
  }
}
void buildMaxHeap(void){

  int i;
  for(i=(H/2);i>0;i--){
    maxHeapify(i);
  }

}




Measured memory_bytes: 3652
N,K = map(int,input().split())
A = list(map(int,input().split()))

cnt = 0
dic = {1:0}
x = 1
for i in range(N):
    y = A[x-1]
    cnt += 1
    if y in dic:
        x = y        
        break
    else:
        dic[y] = cnt
        x = y

    if cnt == K:
        print(y)
        quit()
       
loop = (K-dic[x]) % (cnt - dic[x])

for i in range(loop):
    x = A[x-1]
print(x)

Measured memory_bytes: 104512
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

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

  if ((A+B)%2)
    cout << "IMPOSSIBLE" << endl;
  else
    cout << (A+B)/2 << endl;

  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vp;

#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



int main()
{
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int n, m; cin>>n>>m;
    vi v;
    ll cnt = 0;
    ll sum = 0;
    rep(i, n)
    {
        int x; cin>>x; v.pb(x);
        sum += x;
    }
    rep(i, n)
    {
        if(v[i] >= sum/float(4*m))cnt++;
    }
    if(cnt >= m) cout<<"Yes";
    else cout<<"No";
    
}



/*before sub
TEST: 0, 1, equal, -ve, bounds(random and ez)
loop vars,1LL in mult, out of bounds, int v ll, endl, finish taking inputs, large doubles, larger INF
*/





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

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

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

    int N; cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<int> gcdFromLeft(N+1, 0), gcdFromRight(N+1, 0);
    for (int i = 0; i < N; ++i) gcdFromLeft[i+1] = Gcd(gcdFromLeft[i], A[i]);
    for (int i = N-1; i >= 0; --i) gcdFromRight[i] = Gcd(gcdFromRight[i+1], A[i]);

    int maxGcd = 0;
    rep(i, N) {
        int left = gcdFromLeft[i];
        int right = gcdFromRight[i+1];
        maxGcd = max(maxGcd, Gcd(left, right));
    }

    cout << maxGcd << "\n";
}

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


int a, b;

int main(void) {
  cin >> a >> b;

  if(a > b) cout << "a > b" << endl;
  if(a < b) cout << "a < b" << endl;
  if(a == b) cout << "a == b" << endl;

  return 0;
}

Measured memory_bytes: 1156
import math
a, b, x = map(int, input().split())

V = (a ** 2) * b

if x <= V / 2:
  t = 2 * x / (a * (b ** 2))
elif x > V / 2 and x != V:
  t = (a ** 3) / (2 * (V - x))

if x != V and t != 0:
  def f(x):
    return math.tan(x) - t
  def g(x):
    return math.tan(x) - 1 / t
  if t < 1:
    S = math.pi / 4
    for i in range(100):
      S = S - f(S) * (math.cos(S) ** 2)
    print(90 - 180 * S / math.pi)
  else:
    S = math.pi / 4
    for i in range(100):
      S = S - g(S) * (math.cos(S) ** 2)
    print(180 * S / math.pi)
elif x == V:
  print(0)

Measured memory_bytes: 3188
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  for(ll a=1;a<n;a++){
    ans += (n-1)/a;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3648
def to_n(x,n,cnt):
    ans=[]
    for _ in range(cnt):
        ans.append(x%n)
        x//=n
    return ans[::-1]

from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())

    alp=[chr(i) for i in range(97,97+26)]

    tmp=26
    cnt=1
    while n>tmp:
        n-=tmp
        tmp*=26
        cnt+=1
    
    n-=1
    m=to_n(n,26,cnt)
    ans="".join([alp[m[i]] for i in range(len(m))])
    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 9172
#幅優先探索(BFS)
import sys
input = sys.stdin.readline

n,x,y = [int(x) for x in input().split()] # nは頂点の数、mは辺の数
g = [[] for _ in range(n)] # 隣接リスト

for i in range(n-1):
    a,b = i,i+1
    g[a].append(b)
    g[b].append(a)
g[x-1].append(y-1)
g[y-1].append(x-1)

from collections import deque

def bfs(u):
    queue = deque([u])
    d = [None] * n # uからの距離の初期化
    d[u] = 0 # 自分との距離は0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                queue.append(i)
    return d

# 0からの各頂点の距離
di = [0]*n
for i in range(n):
    l = bfs(i)
    for j in l:
        if j == 0:
            continue
        di[j-1] += 1
di = di[:-1]
for k in di:
    print(k//2)


Measured memory_bytes: 10000
#include <stdio.h>

int main(void)
{
	int i, j;
	int x=0, y=0, w, h;
	int roop=0;
	char area[100][100];
	char cnt [100][100];

	while(1)
	{
		scanf("%d %d", &h, &w);
		if(w == 0 && h == 0)break;
		
		for(i=0; i<h; i++)
			scanf("%s", area[i]);
		
		x=0; y=0; roop=0;
		for(i=0;i<w;i++)
		for(j=0;j<h;j++)
			cnt[i][j]=0;

		while(area[y][x] != '.')
		{
			if(cnt[x][y] > 0)
			{
				roop = 1;
				break;
			}
			
			cnt[x][y]++;
			switch(area[y][x])
			{
			case '>': x++; break;
			case '<': x--; break;
			case 'v': y++; break;
			case '^': y--; break;
			}
		}
		if(roop)
			puts("LOOP");
		else
			printf("%d %d\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include <algorithm>
using namespace std;
using ll = long long;

typedef pair<int,int> P;
 
int main(void){
    ll K,D;
    ll x;
    cin >> x >>K >>D;
        if(x<0)x *= -1;
        ll X=x;
        if(X/D>K){
            cout << X-D*K<<endl;
            return 0;
        }
        K-=X/D;
        while(X-D>=0){
        X-=D;
        }
        if(K%2==0){
            cout << X;
            return 0;
        }else{
            cout << -1*(X-D);
            return 0;
        }
}

Measured memory_bytes: 3632
from collections import defaultdict
from collections import Counter
S = input()
T = input()
s = Counter(S)
t = Counter(T)
if len(s) != len(t):
    print('No')
else:
    flag = True
    d = defaultdict(int)
    for i in range(len(S)):
        if d[S[i]] == 0:
            d[S[i]] = T[i]
        else:
            if d[S[i]] != T[i]:
                flag = False
    if flag:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4016
n = int(input())
a = list(map(int,input().split()))
sum = 0
for i in range(n):
   a[i] = a[i] -(i+1)
a.sort()
if n % 2 ==1:
    b = a[(n//2)]
else:
    b = (a[n//2]+a[n//2-1]) //2
for i in range(n):
    sum += abs(a[i]-b)
print(sum)

Measured memory_bytes: 86612
use std::io::*;

fn rec(i: usize, x: u64, size: &Vec<u64>, pat: &Vec<u64>) -> u64 {
    if x == 0 {
        return 0;
    }
    if i == 0 {
        return 1;
    }
    if x < (size[i] + 1) / 2 {
        return rec(i - 1, x - 1, &size, &pat);
    }
    pat[i - 1] + 1 + rec(i - 1, x - (size[i] + 1) / 2, &size, &pat)
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let x: u64 = itr.next().unwrap().parse().unwrap();

    let mut size: Vec<u64> = vec![0; n + 1];
    let mut pat: Vec<u64> = vec![0; n + 1];
    size[0] = 1;
    pat[0] = 1;
    for i in 0..n {
        size[i + 1] = size[i] * 2 + 3;
        pat[i + 1] = pat[i] * 2 + 1;
    }
    println!("{}", rec(n, x, &size, &pat));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<sstream>
#include<fstream>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iomanip>
using namespace std;
/*freopen{"input.txt","r",stdin};
freopen{"output.txt","w",stdout};*/
#define mp make_pair
#define pb push_back
const int INF=1000*1000*1000;
const int maxn=2e5; 
typedef long long ll;
typedef long double ld;
typedef pair<int,int>PII;
//priority_queue <int,vector<int>,greater<int> > q1;  //从小到大 
//priority_queue <int,vector<int>,less<int> >q2;  //从大到小 

//set multiset vector queue priority_queue map multimap pair string structure 

//枚举 思维 贪心 搜索 模拟 预处理 二分 排序 

int main(){
	//ios_base::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
	ll a,b,c;
	cin>>a>>b>>c;
	if(a%2==1||b%2==1||c%2==1){
		cout<<0;
	    return 0;
	}
	if(a==b&&b==c){
		cout<<-1;
		return 0;
	}
	ll num=0;
	while(1){
		int a1=b/2+c/2;
		int b1=a/2+c/2;
		int c1=a/2+b/2;
		num++;
		a=a1;
		b=b1;
		c=c1;
		if(a%2==1||b%2==1||c%2==1){
		cout<<num;
	    return 0;
	}
	}
	
	
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int start,end,i,o,sum,temp;
    for(;sum=0,scanf("%d",&start),start;){
        scanf("%d",&end);
        for(i=start;i<=end;i++){
            temp=i;
            while(!(temp%2))temp/=2;
            while(!(temp%3))temp/=3;
            while(!(temp%5))temp/=5;
            if(temp==1)
                sum++;
        }
        printf("%d\n",sum);
    }
    return 0;
}

Measured memory_bytes: 600
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

int union_tree[200];
int union_find(int now) {
	if (union_tree[now] == now) return now;
	return union_tree[now] = union_find(union_tree[now]);
}

int union_merge(int a, int b) {
	a = union_find(a);
	b = union_find(b);
	if (a == b) return 0;
	union_tree[a] = b;
	return 1;
}

void solve() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0) return;
		vector<tuple<int, int, int>> inputs;
		REP(i, m) {
			int a, b, c;
			cin >> a >> b >> c;
			a--; b--;
			inputs.push_back(make_tuple(c, a, b));
		}
		sort(ALL(inputs));
		int ans = 1e9;
		REP(i, inputs.size()) {
			int now = get<0>(inputs[i]);
			REP(q, n) {
				union_tree[q] = q;
			}
			for (int j = i; j < inputs.size(); ++j) {
				if (union_merge(get<1>(inputs[j]), get<2>(inputs[j])) == 1) {
					now = j;
				}
			}
			int ok = 1;
			REP(q, n) {
				if (union_find(0) != union_find(q)) ok = 0;
			}
			if(ok == 1)
			ans = min(ans, get<0>(inputs[now]) - get<0>(inputs[i]));
		}
		if (ans == 1e9) ans = -1;
		cout << ans << endl;
	}
}

#undef int
int main() {
	init();
	solve();
}


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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;
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; }

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

// 繰り返し二乗法
ll power(ll a, ll b){
    if(a==1)return a;
    // if(a==0)re
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

const int MAX=2100000;

ll fact[MAX], fact_inv[MAX];

void init_fact(ll n){
    fact[0]=1;
    // 階乗の計算
    for(ll i=0; i<n; i++) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[n]=power(fact[n], MOD-2);
    // 逆元の計算
    for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}

ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

ll perm(ll n, ll r){
    return (fact[n]*fact_inv[n-r])%MOD;
}

int main() {
    cout<<fixed<<setprecision(10);

     ll n; cin>>n;
     string s; cin>>s;

    map<char,ll> m;
    for(auto e:s) m[e]++;
    ll ans = m['R']*m['G']*m['B'];

    rep(i,n){
        rep(j,n){
            if(i>=j) continue;
            ll k = i+2*(j-i);
            if(k >= n) continue;
            set<char> st;
            st.insert(s[i]);
            st.insert(s[j]);
            st.insert(s[k]);
            if(st.size() == 3) ans--;
        }
    }
    cout<<ans<<endl;



    return 0;

}

Measured memory_bytes: 3648
#include <iterator>
#include <iostream>
#include <cstring>
#include <vector>
#include <map>

using namespace std;

struct Deck
{
	struct Card *card;
	int num;
};

struct Card
{
	char suit;
	int val;
	bool operator<=(const Card &another)
	{
		return val <= another.val;
	}
};

template <typename T> void swap(T *a, T *b)
{
	T tmp;
	tmp = a;
	a = b;
	b = tmp;
}

int partition(Deck A, int p, int r)
{
	Card x = A.card[r];
	int i = p - 1;
	for (int j = p; j < r; j++)
	{
		if (A.card[j] <= x)
		{
			i = i + 1;
			swap(A.card[i], A.card[j]);
		}
	}
	swap(A.card[i + 1], A.card[r]);
	return i + 1;
}

void quickSort(Deck &A, int p, int r)
{
	int q;
	if (p < r)
	{
		q = partition(A, p, r);
		quickSort(A, p, q - 1);
		quickSort(A, q + 1, r);
	}
}

bool isStable(Deck d_after, Deck d_before)
{
	vector<char> a_suitseq;
	vector<char> b_suitseq;
	map<int, int> countval;
	for (int i = 0; i < d_after.num; i++)
	{
		if (countval.find(d_after.card[i].val) != countval.end())
		{
			countval[d_after.card[i].val]++;
		}
		else
		{
			countval[d_after.card[i].val] = 1;
		}
	}
	for (map<int, int>::iterator itr = countval.begin(); itr != countval.end(); itr++)
	{
		int i = countval.at(itr->first);
		if (i > 1)
		{
			a_suitseq.resize(4, '\0');
			b_suitseq.resize(4, '\0');
			for (int j = 0; j < d_after.num; j++)
			{
				for (int k = 0; k < i; k++)
				{
					if (itr->first == d_after.card[j].val)
					{
						a_suitseq[k] = d_after.card[j].suit;
					}
					if (itr->first == d_before.card[j].val)
					{
						b_suitseq[k] = d_before.card[j].suit;;
					}
				}
			}
			if (a_suitseq != b_suitseq)
			{
				return false;
			}
		}
	}
	return true;
}

int main()
{
	int n;
	cin >> n;
	Deck deck, deck_org;
	deck.card = new Card[n];
	deck_org.card = new Card[n];
	deck_org.num = deck.num = n;
	for (int i = 0; i < n; i++)
	{
		cin >> deck.card[i].suit >> deck.card[i].val;
		deck_org.card[i].suit = deck.card[i].suit;
		deck_org.card[i].val = deck.card[i].val;
	}
	quickSort(deck, 0, n - 1);
	if (isStable(deck, deck_org))
	{
		cout << "Stable" << endl;
	}
	else
	{
		cout << "Not stable" << endl;
	}
	for (int i = 0; i < n; i++)
	{
		cout << deck.card[i].suit << ' ' << deck.card[i].val << endl;
	}
	delete deck.card;
	delete deck_org.card;
	return 0;
}


Measured memory_bytes: 5412
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans=0,l=0,r=s.size()-1;
  while(l<r) {
    if(s[l]==s[r]) {
      l++,r--;
    }
    else if(s[l]!=s[r]) {
      if(s[l]=='x') {
        ans++,l++;
      }
      else if(s[r]=='x') {
        ans++,r--;
      }
      else {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  cout << (X - Z) / (Y + Z) << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, ans;

int main()
{
	in >> N;
	std::vector<LL>A(N), B(N), C(N);
	rep(i, N) in >> A[i];
	rep(i, N) in >> B[i];
	rep(i, N) in >> C[i];

	std::sort(A.begin(), A.end());
	std::sort(B.begin(), B.end());
	std::sort(C.begin(), C.end());

	std::vector<LL>can1(N + 1), can2(N + 1);
	rep(i, N)
	{
		auto it1 = std::upper_bound(B.begin(), B.end(), A[i]);
		can1[i + 1] = it1 - B.begin();
		auto it2 = std::upper_bound(C.begin(), C.end(), B[i]);
		can2[i + 1] = C.end() - it2;
	}
	//rep(i, can1.size() - 1) can1[i + 1] += can1[i];
	rep(i, can2.size() - 1) can2[i + 1] += can2[i];
	rep(i, N)
	{
		LL res = can2[can2.size() - 1] - can2[can1[i + 1]];
		ans += res;
	}
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 4224
# AtCoDeer君は、赤、緑、青色のカードを持っています。
# それぞれのカードには 1 以上 9 以下の整数が書かれており、
# 赤色のカードには r、緑色のカードには g、青色のカードには b が書かれています。
# 3 つのカードを左から順に赤、緑、青色の順に並べ、
# 左から整数を読んだときにこれが 4 の倍数であるか判定しなさい。

rgb = gets.chomp.split
r = rgb[0].to_i
g = rgb[1].to_i
b = rgb[2].to_i

num = r * 100 + g * 10 + b
if num % 4 == 0
    puts "YES"
else
    puts "NO"
end

Measured memory_bytes: 1788
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;

int main()
{
    int a, b;
    cin >> a >> b;
    if ((a * b) % 2 == 0) puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a[10000000];
	int s = 0;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		while (a[i] % 2 == 0) {
			a[i] /= 2; s++;
		}
	}
	cout << s;
}

Measured memory_bytes: 2304
n = int(input())
h = [int(e) for e in input().split()]
flg = "Yes"
equal = 0
for i in range(n-1):
    if equal:
        if h[i] > h[i+1]:
            flg = "No"
            break
        elif h[i] != h[i+1]:
            equal = 0


    else:
        h[i] -= 1
   
        if h[i+1] < h[i]:
            flg = "No"
            break
        elif h[i+1] == h[i]:
            equal = 1

        else:
            equal = 0
print(flg)






Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

void mod( ll &n, ll m=MOD ){ n%=m,n+=m,n%=m; }

const int MAXN = 1e5+5;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int digs( int n )
{
    int res = 0;
    while( n )
    {
        res++;
        n /= 10;
    }
    return res;
}

int main() 
{
    fastio();

    int n,cnt=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if( digs(i)%2 ) cnt++;
    }
    cout<<cnt,nl;
    return 0;
}

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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;

namespace Fread{
	const int MAXN=1<<20;
	char buffer[MAXN],*S,*T;
	inline char getchar(){
		if(S==T){
			T=(S=buffer)+fread(buffer,1,MAXN,stdin);
			if(S==T) return EOF;
		}
		return *S++;
	}
}
#ifdef ONLINE_JUDGE
	#define getchar Fread::getchar
#endif
inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MOD=1e9+7;
inline int pow_mod(int x,int i){int y=1;while(i){if(i&1)y=(ll)y*x%MOD;x=(ll)x*x%MOD;i>>=1;}return y;}
inline int mod1(int x){return x<MOD?x:x-MOD;}
inline int mod2(int x){return x<0?x+MOD:x;}
inline void add(int &x,int y){x=mod1(x+y);}
inline void sub(int &x,int y){x=mod2(x-y);}
int n,m,fac[(1<<16)+5],invf[(1<<16)+5],a[17],dp[17][1<<16];
inline int comb(int n,int k){
	if(n<k)return 0;
	return (ll)fac[n]*invf[k]%MOD*invf[n-k]%MOD;
}
int main() {
	fac[0]=1;
	for(int i=1;i<=(1<<16);++i)fac[i]=(ll)fac[i-1]*i%MOD;
	invf[1<<16]=pow_mod(fac[1<<16],MOD-2);
	for(int i=(1<<16)-1;i>=0;--i)invf[i]=(ll)invf[i+1]*(i+1)%MOD;
	assert(invf[0]==1);
	n=read(),m=read();
	for(int i=1;i<=m;++i)a[i]=read();
	if(m)reverse(a+1,a+m+1);
	dp[0][0]=1;
	for(int i=0;i<m;++i){
		for(int j=0;j<(1<<n);++j)if(dp[i][j]){
			add(dp[i+1][j],dp[i][j]);
			for(int k=0;k<n;++k)if(!((j>>k)&1)){
				add(dp[i+1][j|(1<<k)],(ll)dp[i][j]*fac[1<<k]%MOD*comb((1<<n)-j-a[i+1],(1<<k)-1)%MOD);
			}
		}
	}
	int ans=0;
	for(int i=0;i<(1<<n);++i){
		if(__builtin_popcount(i)&1)sub(ans,(ll)dp[m][i]*fac[(1<<n)-1-i]%MOD);
		else add(ans,(ll)dp[m][i]*fac[(1<<n)-1-i]%MOD);
	}
	ans=(ll)ans*(1<<n)%MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4352
nm = input().split(" ")
n = int(nm[0])
m = int(nm[1])
 
a = input().split(" ")
 
total = 0
for v in a:
  total += int(v)
  
mv = total / (4 * m)
q = 0
for e in a:
  e = int(e)
  if e >= mv:
    q += 1
    
if q >= m:
  print("Yes")
else:
  print("No")
 

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

using namespace std;

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

    int A[N][M];

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }

    int c[N];
    for (int i = 0; i < N; ++i) {
        c[i] = 0;
    }
    int d[M];
    bool s[M];

    for (int i = 0; i < M; ++i) {
        s[i] = true;
    }

    int minp = N;
    for (int k = 0; k < M - 1; ++k) {
        for (int i = 0; i < M; ++i) {
            d[i] = 0;
        }
        int m = 0;
        int mi = -1;
        for (int i = 0; i < N; ++i) {
            int top = A[i][c[i]];
            d[top]++;
            if (d[top] > m) {
                mi = top;
                m = d[top];
            }
        }
        s[mi] = false;
        for (int i = 0; i < N; ++i) {
            while (s[A[i][c[i]]] == false) {
                c[i]++;
            }
        }

        if (m < minp) {
            minp = m;
        }
    }

    cout << minp << endl;
}

Measured memory_bytes: 640