akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("-O3")
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#include<cmath>
#define LL long long
#define ui unsigned int
#define ull unsigned long long
using namespace std;
 
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void Out(int x){
    if(x>9) Out(x/10);
    putchar('0'+x%10);
}
int gcd(int x,int y){
    if(!y) return x;
    return gcd(y,x%y);
}
LL qpow(LL x,LL y,LL P){
    LL re=1;
    while(y){
        if(y&1) re=re*x%P;
        x=x*x%P;y>>=1;
    }
    return re;
}
const int N=550;
const int inf=2e9;
int a[550][550];
int main(){
	int k;
	scanf("%d",&k);
	if(k<=500){
		cout<<k<<endl;
		for(int i=1;i<=k;++i)
			for(int j=1;j<=k;++j)
				printf("%d%c",i,j==k?'\n':' ');
		return 0;
	}
	int n=((k+3)/4)<<1;
	cout<<n<<endl;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j){
			a[i][j]=(i+j)%n+(i&1?0:n)+1;
			if(a[i][j]>k) a[i][j]-=n;
			printf("%d%c",a[i][j],j==n?'\n':' ');
		}
	return 0;
}
/*
3 3 0
1 2
1 3
2 3
1 2
*/

Measured memory_bytes: 2304
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]

m = [[0] * n for i in range(n)]

for l in range(2, n + 1):
  for i in range(n - l + 1):
    j = i + l - 1
    m[i][j] = float('inf')
    for k in range(i, j):
      cost = m[i][k] + m[k + 1][j] + p[i][0] * p[k][1] * p[j][1]
      m[i][j] = min(m[i][j], cost)

print(m[0][n - 1])

Measured memory_bytes: 7748
#include<stdio.h>
#include<math.h>

int main(void) {
	int N, D,n=0,i=0;
	double X, Y;
	scanf("%d", &N);
	scanf("%d", &D);

	for (i = 1; i <= N; i++) {
		scanf("%lf", &X);
		scanf("%lf", &Y);
		if (sqrt(X * X + Y * Y) <= D) {
		n++;
	}
	}
	printf("%d", n);
	return 0;
}

Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  map<string, int> mp;
  mp["SUN"] = 7;
  mp["MON"] = 6;
  mp["TUE"] = 5;
  mp["WED"] = 4;
  mp["THU"] = 3;
  mp["FRI"] = 2;
  mp["SAT"] = 1;
  string s;
  cin >> s;
  cout << mp[s] << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();
    let v: Vec<u16> =
        line.split_whitespace().map(|n| n.parse().unwrap()).collect();
    let r = v[0];
    let g = v[1];
    let b = v[2];
    let made = 100*r+10*g+b;
    let ans =
        if made%4==0 {
            "YES"
        } else {
            "NO"
        };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	int n;
	cin >> n;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		a.push_back(t);
	}
	vector<int> b = a;
	sort(b.begin(), b.end());
	int lm = b[n / 2 - 1];
	int rm = b[n / 2];
	for (int i = 0; i < n; i++) {
		if (a[i] > lm) {
			cout << lm << endl;
		} else if (a[i] < rm) {
			cout << rm << endl;
		} else {
			cout << lm << endl;
			assert(lm == rm);
		}
	}
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 4748
N = int(input())

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

ans = 0

def factorization(n):
  lis = []
  if n % 2 == 0:
    c = 0
    while n%2 == 0:
      n //= 2
      c += 1
    lis.append([2, c])
  k = 3
  while k*k <= n:
    if n%k == 0:
      c = 0 
      while n%k == 0:
        n //= k
        c += 1
      lis.append([k, c])
    else:
      k += 2
  if n > 1:
    lis.append([n, 1])
  return lis

list1 = factorization(N-1)
ans1 = 1
for k in range(len(list1)):
  ans1 *= list1[k][1]+1
ans += ans1-1

def operation(K):
  n = N
  while n%K == 0:
    n //= K
  if n%K == 1:
    return True
  else:
    return False

list2 = factorization(N)
factorlist = [1]
for l in range(len(list2)):
  list3 = []
  for j in range(list2[l][1]):
    for k in range(len(factorlist)):
      list3.append(factorlist[k]*list2[l][0]**(j+1))
  factorlist += list3
factorlist = factorlist[1:-1]
ans += 1
for item in factorlist:
  if operation(item):
    ans +=1
print(ans)

Measured memory_bytes: 69264
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, m;
string u;
vector<string> vs;

int main(){
	bool f = 0;
	cin >> n;
	REP(i, n){
		cin >> u;
		vs.push_back(u);
	}
	cin >> m;
	REP(i, m){
		cin >> u;
		if (find(ALL(vs), u) == vs.end()){
			cout << "Unknown " << u << endl;
		}
		else{
			if (!f)cout << "Opened by " << u << endl;
			else cout << "Closed by " << u << endl;
			f = !f;
		}
	}
}

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

public class Main {

	public static void main(String[] args) {
		Scanner ob=new Scanner(System.in);
		int n=ob.nextInt();
		int a[]=new int[n];
		for (int i=0; i<n; i++) {
			a[i]=ob.nextInt();
		}
		Arrays.sort(a);
		// for(int i=0;i<=k;i++){System.out.println(a[i]);}
		int count=0;
		out:
		for (int i=0; i<n; i++) {
			for (int j=i+1; j<n; j++) {
				for (int k=j+1; k<n; k++) {
					if (a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]) {
						if ((a[i]+a[j])>a[k]&&a[j]+a[k]>a[i]&&a[i]+a[k]>a[j]) {
							count++;
						}

					}
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 27848
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.IntStream;

public class Main{
	public static void main(String[]$) throws IOException{
		new Main().solve();
	}
	static FastScanner s=new FastScanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static int gInt() throws IOException{return s.nextInt();}
	static long gLong() throws IOException{return s.nextLong();}
	static long gDouble() throws IOException{return s.nextLong();}

	private void solve() throws IOException{
		String v=s.next();
		System.out.println(v.substring(0,v.length()-8));
	}
}
class FastScanner{
	private final BufferedInputStream	in;
	private static final int			bufSize	=1<<16;
	private final byte					buf[]	=new byte[bufSize];
	private int							i		=bufSize;
	private int							k		=bufSize;
	private final StringBuilder			str		=new StringBuilder();

	FastScanner(InputStream in){
		this.in=new BufferedInputStream(in,bufSize);
	}
	int nextInt() throws IOException{
		return (int)nextLong();
	}
	long nextLong() throws IOException{
		int c;
		long x=0;
		boolean sign=true;
		while((c=nextChar())<=32)
			;
		if(c=='-'){
			sign=false;
			c=nextChar();
		}
		if(c=='+'){
			c=nextChar();
		}
		while(c>='0'){
			x=x*10+(c-'0');
			c=nextChar();
		}
		return sign?x:-x;
	}
	int nextChar() throws IOException{
		if(i==k){
			k=in.read(buf,0,bufSize);
			i=0;
		}
		return i>=k?-1:buf[i++];
	}
	String next() throws IOException{
		int c;
		str.setLength(0);
		while((c=nextChar())<=32&&c!=-1)
			;
		if(c==-1){
			return null;
		}
		while(c>32){
			str.append((char)c);
			c=nextChar();
		}
		return str.toString();
	}
	String nextLine() throws IOException{
		int c;
		str.setLength(0);
		while((c=nextChar())<=32&&c!=-1)
			;
		if(c==-1){
			return null;
		}
		while(c!='\n'){
			str.append((char)c);
			c=nextChar();
		}
		return str.toString();
	}
}

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

typedef unsigned long long ull;
const int maxn = 1210;
int n, ans;
char s[maxn][maxn];
ull h[maxn][maxn], hr[maxn][maxn], p[maxn];

ull get_hash1(int i, int j, int k) {
    return h[i][k] - h[i][j - 1] * p[k - j + 1];
}

ull get_hash2(int i, int j, int k) {
    return hr[i][k] - hr[i][j - 1] * p[k - j + 1];
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> s[i][j];
        }
    }
    for (int i = n + 1; i <= 2 * n; i++) {
        for (int j = 1; j <= n; j++) {
            s[i][j] = s[i - n][j];
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = n + 1; j <= 2 * n; j++) {
            s[i][j] = s[i][j - n];
        }
    }
    for (int i = n + 1; i <= 2 * n; i++) {
        for (int j = n + 1; j <= 2 * n; j++) {
            s[i][j] = s[i - n][j - n];
        }
    }
    p[0] = 1;
    for (int i = 1; i <= 2 * n; i++) {
        p[i] = p[i - 1] * 47;
    }
    for (int i = 1; i <= 2 * n; i++) {
        for (int j = 1; j <= 2 * n; j++) {
            h[i][j] = h[i][j - 1] * 47 + s[i][j] - 'a';
        }
    }
    for (int j = 1; j <= 2 * n; j++) {
        for (int i = 1; i <= 2 * n; i++) {
            hr[j][i] = hr[j][i - 1] * 47 + s[i][j] - 'a';
        }
    }
    for (int a = 0; a < n; a++) {
        for (int b = 0; b < n; b++) {
            bool flag = true;
            for (int c = 1; c <= n; c++) {
                if (get_hash1(a + c, b + 1, n + b) != get_hash2(b + c, a + 1, n + a)) {
                    flag = false;
                    break;
                }
            }
            ans += flag;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15104
require 'set'

h = gets.chomp.chars.inject(Set.new) {|r, i| r << i }

if h.size == 4 || (h.size == 2 && ((h.include?('N') && h.include?('S')) || (h.include?('W') && h.include?('E'))))
  puts 'Yes'
else
  puts 'No'
end


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

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

    vector<int> x(N);
    vector<int> p(0);
    vector<int> n(0);
    int ans = 1000000000;
    int i,j,dis;

    for(i=0;i<N;i++){
        cin >> x.at(i);
        if(x.at(i) == 0){
            K--;
        }else if(x.at(i) > 0){
            p.push_back(x.at(i));
        }else{
            n.push_back(-x.at(i));
        }
    }
    if(K == 0){
        ans = 0;
    }else{
        reverse(n.begin(),n.end());
        int p_size = p.size();
        int n_size = n.size();
        for(i = min(K,p_size);i >= 0;i--){
            j = K - i;
            if(j > n_size){
                break;
            }

            if(i == 0){
                dis = n.at(j-1);
            }else if(j == 0){
                dis = p.at(i-1);
            }else if(p.at(i-1) > n.at(j-1)){
                dis = p.at(i-1) + 2 * n.at(j-1);
            }else{
                dis = 2 * p.at(i-1) +  n.at(j-1);
            }

            if(dis < ans){
                ans = dis;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4376
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <map>
#include <cmath>
#define ll long long int 

using namespace std;

int n, m;
int main()
{
    //freopen("a.txt", "r", stdin);
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int n;
int d[52];

bool solve(int diff){
	int st=0;
	int tmp[50];
	tmp[0] = 0;
	for(int i=1;i<=n;i++){
		if(abs(d[st]-d[i]) < diff){
			tmp[i] = 24-d[i];
		} else {
			tmp[i] = d[i];
			st = i;
		}
	}
	tmp[n+1] = 24;
	sort(tmp,tmp+n+2);
	for(int i=1;i<=n+1;i++){
		if(abs(tmp[i-1]-tmp[i]) < diff) return false;
	}
	return true;
}

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

	int ans = 0;
	for(int i=24;i>=0;i--){
		if(solve(i)){
			ans = i;
			break;
		}
	}

	cout<<ans<<endl;

	return 0;

}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc088/tasks/abc088_b

import itertools
import collections
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)

    a_sum = sum([A[a] for a in range(0, len(A), 2)])
    b_sum = sum([A[a] for a in range(1, len(A), 2)])
    print(a_sum - b_sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>
#include <math.h>
 
int main() {
    int m[10];
    int ans[3];
    for(int i=0; i<10; i++) scanf("%d", &m[i]);
 
    ans[0] = 0; ans[1] = 0; ans[2] = 0;
    for(int j=0; j<10; j++) {
        if(m[ans[0]] < m[j]) {
            ans[0] = j;
        }
    }
    if(ans[1] == ans[0]) {
        if(ans[1] == 0) ans[1] = 1;
        else ans[1] = ans[0]-1;
    }
    for(int j=0; j<10; j++) {
        if(m[ans[1]] < m[j] && ans[0] != j) {
            ans[1] = j;
        }
    }
    if(ans[2] == ans[0]) {
        if(ans[2] == 0) ans[2] = 2;
        else ans[2] = ans[0]-2;
    }
    for(int j=0; j<10; j++) {
        if(m[ans[2]] < m[j] && ans[0] != j && ans[1] != j) {
            ans[2] = j;
        }
    }
    printf("%d\n%d\n%d\n", m[ans[0]], m[ans[1]], m[ans[2]]);
    return 0;
}


Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a;
  cin >> n >> a;
  
  if (n%500 <= a){
    cout << "Yes" << endl;
  }
  
  else if ( a > n ){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
 
}

Measured memory_bytes: 256
n = int(input())
happy = 0
if n%500 == 0:
    print(2*n)
else:
    while n > 0:
        if n == 0:
            break
        n-=500
        if n<0:
            n+=500
            n-=5
            if n<0:
                n+=5
                break
            else:
                happy+=5
        else:
            happy+=1000
    print(happy)


Measured memory_bytes: 2940
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b;
    char op;
    while (1) {
        scanf("%d %c %d",&a,&op,&b);
        if(op=='?')break;
        else if(op=='+')printf("%d\n",a+b);
        else if(op=='-')printf("%d\n",a-b);
        else if(op=='*')printf("%d\n",a*b);
        else if(op=='/')printf("%d\n",a/b);
    }
    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int N;  cin >> N;
	map<int, bool> mp;

	REP(i, N){
			int A;  cin >> A;
			if(mp[A]){  cout << "NO" << endl;  return 0;  }
			else        mp[A] = true;
	}

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


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    string s;
    cin >> s;
    int n = s.length();
    int ans = 0;
    for(int i = 0; i + 1 < n; ++i){
        if(s[i] != s[i + 1])    ++ans;
    }
    cout << ans << endl;
}

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


int main() {
    int N, T;
    cin >> N >> T;
    int costs[N];
    int time[N];

    // input
    for (int i = 0; i < N; i++) {
        cin >> costs[i] >> time[i];
    }

    int min_cost = INT_MAX;

    for (int i = 0; i < N; i++) {
        if (time[i] <= T && costs[i] < min_cost) {
            min_cost = costs[i];
        }
    }
    if (min_cost == INT_MAX) {
        cout << "TLE" << endl;
    } else {
        cout << min_cost << endl;
    }
}

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

typedef vector<string> B;

B rot(B b){
	int H = b.size();
	int W = b[0].size();
	B r(W,string(H,' '));
	for(int i = 0 ; i < H ; i++){
		for(int j = 0 ; j < W ; j++){
			r[j][H-i-1] = b[i][j];
		}
	}
	return r;
}

int score(B &b){
	string want = string(b[0].size(),'#');
	return count(b.begin(),b.end(),want);
}

int canset(B &b,B &p,int x,int y,int doit){
	for(int i = 0 ; i < p.size() ; i++){
		for(int j = 0 ; j < p[0].size() ; j++){
			if( p[i][j] == '#' ){
				int tx = j + x;
				int ty = i + y;
				if( tx < 0 || ty < 0 || ty >= b.size() || tx >= b[0].size() ) return false;
				if( b[ty][tx] == '#' ) return false;
				if(doit){
					b[ty][tx] = '#';
				}
			}
		}
	}
	return true;
}


void f(B b){
	for(int i = 0 ; i < b.size() ; i++)
		cout << b[i] << endl;
}
int main(){
	int T;
	cin >> T;
	while(T--){
		int h,w;
		cin >> h >> w;
		B p(h);
		for(int i = 0 ; i < h ; i++) cin >> p[i];
		
		int H,W;
		cin >> H >> W;
		B b(H);
		for(int i = 0 ; i < H ; i++) cin >> b[i];
		
		int ans = -1;
		for(int d = 0 ; d < 4 ; d++){
			for(int j = -h ; j < H ; j++){
				for(int k = -w ; k < W ; k++){
					if( canset(b,p,k,j,0) ){
						B t = b;
						canset(t,p,k,j,1);
						ans = max(score(t),ans);
					}
				}
			}
			swap(h,w);
			p = rot(p);
		}
		cout << ans << endl;
	}
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

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

	if(a>=3200)
		cout<<s<<endl;
	else
		cout<<"red"<<endl;


	return 0;
}


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

int main()
{
    string ss;
    while(cin >> ss)
    {
        for(int i=0;i<ss.size();i++)
        {
            if(ss[i]=='@')
            {
                int num = (int)(ss[i+1]-'0');
                for(int j=0;j<num;j++)
                {
                    cout << ss[i+2];
                }
                i+= 2;
            }

            else cout << ss[i];
        }
        cout << endl;

    }
             
    return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N,M;
LL a[100001];
LL imo[200011];
LL imo2[200011];
int main(){
    REP(i,200011){
        imo[i]=0;
        imo2[i]=0;
    }
    cin>>N>>M;
    REP(i,N){
        cin>>a[i];
    }
    REP(i,N-1){
        int aa=a[i];
        int bb=a[i+1];
        if(aa>bb)bb+=(M);
        imo[aa+1]++;
        imo[bb]--;
        imo2[bb+1]-=(bb-aa-1);
    }


    LL c=0;
    LL s=0;
    REP(i,200011){
        if(i==0)continue;
        imo2[i]+=(imo2[i-1]+c);
        c+=imo[i];
    }
    
   /* REP(i,30){
        cout<<imo[i]<<" ";
    }
    cout<<endl;
    REP(i,30){
        cout<<imo2[i]<<" ";
    }
    cout<<endl;*/

    LL ans=0;
    REP(i,200011){
        ans=max(ans,imo2[i]+imo2[i+M]);
    }
    ans*=-1;
    REP(i,N-1){
        int aa=a[i];
        int bb=a[i+1];
        if(aa>bb)bb+=(M);
        ans+=(bb-aa);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int f1=0,f2=1,sum1=0,sum2=0;
    string s;
    cin>>s;
    for(auto c:s){
        int k=c-'0';
        if(k!=f1)
            sum1++;
        if(k!=f2)
            sum2++;
        f1^=1;
        f2^=1;
    }
    cout<<min(sum1,sum2);
    
}


Measured memory_bytes: 512
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String str = scanner.nextLine();
    String tem[] = str.split(" ",0);
    int num[] = new int[tem.length];

    for(int i = 0;i < tem.length;i++){
        num[i] = Integer.parseInt(tem[i]);
    }

    if(num[0] < num[1] && num[1] < num[2]){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}



Measured memory_bytes: 26116
xy=[]
n=int(input())
for i in range(n):
    x,y = map(int,input().split())
    xy.append([x,y])

renzoku=0
ans=0
for i in xy:
    if i[0]==i[1]:
        renzoku+=1
        if renzoku ==3:
            ans=1
            break
    else :
        renzoku=0
if ans==1:
    print("Yes")
else :
    print("No")
        

Measured memory_bytes: 62388
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;
ll dp[10005]; // dp[i] := HPをi減らす時の最小の魔力消費量
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll H,N;
    cin >> H >> N;
    vector<ll> A(N),B(N);
    rep(i,N){
        cin >> A[i] >> B[i];
    }
    rep(i,1e4+5)dp[i] = 1e18;
    dp[0] = 0;
        for(int j=0;j<=1e4;j++){
            rep(i,N){
                if(j-A[i]>=0)dp[j] = min(dp[j],dp[j-A[i]]+B[i]);
            }
        }

    ll ans = 1e18;
    for(int i=1e4+4;i>=H;i--){
        ans = min(ans,dp[i]);
    }
    cout << ans << endl;
}


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

using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cout.tie(NULL);


int main()
{
	FAST_IO;

	int n;
	cin >> n;

	long long array[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> array[i];
		array[i] -= (i+1);
	}

	sort(array, array+n);

	long long b;

	if (n%2)
	{
		b = array[n/2];
	}
	else
	{
		b = (array[n/2] + array[n/2 - 1])/2;
	}

	long long answer = 0;
	for (int i = 0; i < n; ++i)
	{
		answer += abs(array[i] - (b));
	}
	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
  int i;
  int cnt = 0;
  char str[25];
  scanf("%s", str);

  while (str[cnt] != '\0'){
    cnt++;
  }
  for (i = cnt - 1; i >= 0; i--){
    printf("%c", str[i]);
  }
  printf("\n");

  return (0);
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	map<char,ll> ct;
	while(n-->0) {
		string s; cin>>s;
		ct[s[0]]++;
	}

	string lst="MARCH";
	int sz=lst.size();
	ll ret=0;
	for (int bt=0; bt<(1<<sz); bt++) {
		if(__builtin_popcount(bt)!=3)
			continue;
		ll cur=1;
		for (int i=0; i<sz; i++)
			if(bt&(1<<i))
				cur*=ct[lst[i]];
		ret+=cur;
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,ans=0;
    cin>>n;
    map<int,int>mp;
    while(cin>>a)
        mp[a]++;
    for(auto x:mp)
        ans+=x.second%2;
    cout<<ans<<endl;
}


Measured memory_bytes: 4864
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

bool _countingSort(int *array, int n, int max) {
    int *cnt = malloc((max + 1) * sizeof(int));
    int *buff = malloc(n * sizeof(int));

    if(cnt == NULL || buff == NULL) {
        return false;
    }

    memset(cnt, 0, (max + 1) * sizeof(int));

    for(int i = 0; i < n; i++) {
        cnt[array[i]]++;
    }

    for(int i = 1; i < max + 1; i++) {
        cnt[i] += cnt[i - 1];
    }

    for(int i = n - 1; i >= 0; i--) {
        int insertIdx = cnt[array[i]] - 1;
        buff[insertIdx] = array[i];
        cnt[array[i]]--;
    }

    memcpy(array, buff, n * sizeof(int));

    free(cnt);
    free(buff);
    return true;
}

bool countingSort(int *array, int n) {
    int max = array[0];
    int min = array[0];
    for(int i = 1; i < n; i++) {
        max = MAX(max, array[i]);
        min = MIN(min, array[i]);
    }

    if(min < 0) {
        return false;
    }

    return _countingSort(array, n, max);
}

int main(void) {
    int n;

    scanf("%d", &n);
    int *array = malloc(n * sizeof(int));

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

    countingSort(array, n);
    
    for(int i = 0; i < n; i++) {
        printf("%d", array[i]);
        if(i != n - 1) {
            printf(" ");
        }
    }
    printf("\n");


    free(array);
    return 0;
}


Measured memory_bytes: 17228
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

int solve() {
	ll H, W, K;
	cin >> H >> W >> K;

	ll x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	--x1, --y1, --x2, --y2;

	vector<string> cs(H);
	for (ll i = 0; i < H; ++i) {
		cin >> cs[i];
	}

	vector<vector<ll>> res(H, vector<ll>(W, -1));
	vector<vector<bool>> que_popped(H, vector<bool>(W, false));

	queue<pair<ll, ll>> que;
	que.emplace(x2, y2);
	res[x2][y2] = 0;
	ll x, y;
	while (!que.empty()) {
		tie(x, y) = que.front();
		que.pop();
		que_popped[x][y] = true;
		for (ll i = 1; i <= K; ++i) {
			if (x - i < 0) break;
			if (cs[x - i][y] == '@') break;
			if (que_popped[x - i][y]) break;
			if (res[x - i][y] == -1) {
				que.emplace(x - i, y);
				res[x - i][y] = res[x][y] + 1;
			}
		}
		for (ll i = 1; i <= K; ++i) {
			if (x + i >= H) break;
			if (cs[x + i][y] == '@') break;
			if (que_popped[x + i][y]) break;
			if (res[x + i][y] == -1) {
				que.emplace(x + i, y);
				res[x + i][y] = res[x][y] + 1;
			}
		}
		for (ll i = 1; i <= K; ++i) {
			if (y - i < 0) break;
			if (cs[x][y - i] == '@') break;
			if (que_popped[x][y - i]) break;
			if (res[x][y - i] == -1) {
				que.emplace(x, y - i);
				res[x][y - i] = res[x][y] + 1;
			}
		}
		for (ll i = 1; i <= K; ++i) {
			if (y + i >= W) break;
			if (cs[x][y + i] == '@') break;
			if (que_popped[x][y + i]) break;
			if (res[x][y + i] == -1) {
				que.emplace(x, y + i);
				res[x][y + i] = res[x][y] + 1;
			}
		}
	}

	cout << res[x1][y1] << endl;

	return 0;
}

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

	solve();

	return 0;
}


Measured memory_bytes: 19832
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll K, X;

int main() {
	scanf("%lld %lld", &K, &X);
	if(K * 500 >= X) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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


#define rep(i,n) for(int i = 1; i < (int)n+1; i++)

 int main(){ 

 int n, L;
 int sum,eat,ans;
 cin >> n >> L;

 sum=0;
 rep(i,n){
  sum+=(L+i-1);
 }




 rep(i,n){
  if ((L+i-1) == 0) {
   eat = 0;
   break;
   }
   else { 

    if (sum > 0) {
     eat = abs(L+1-1);
     if (abs(L+i-1) < eat) {
      eat = (abs(L+i-1));
      continue;
      }
      else continue;
     }

     else if (sum == 0) {
     if (abs(L+i-1) < eat) {
      eat = (abs(L+i-1));
      continue;
      }
      else continue;
     }



    else if (sum < 0) {
     if (abs(L+i-1) > eat) {
      eat = (L+i-1);
      continue;
      }
      else continue;
     }
    }
 }

  ans = sum - eat;
  
  cout << ans << endl;

 return 0;
}

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

int main(){
  //string S;
  
  ll N, K;
  
  cin >> K >> N;
  vector<ll> A(N);
  for(int i=0; i<N; i++) cin >> A[i];
  
  vector<ll> B(N);
  for(int i=0; i<N; i++){
    if(i!=N-1) B[i] = abs(A[i+1] - A[i]);
    else{
      if(A[0]<K/2 && A[i]>K/2){
        A[i] = K-A[i];
        B[i] = A[i]+A[0];
      }
      else B[i] = abs(A[i]-A[0]);
    }
  }
  
  //for(int i=0; i<N; i++) cout << B[i] << endl;
  
  sort(B.begin(), B.end());
  ll sum = accumulate(B.begin(), B.end(), 0.0)-B[N-1];
  
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 6424
N=int(input())
D = list(map(int, input().split()))
M=int(input())
T = list(map(int, input().split()))


List = {}
for i in D:
    if List.get(i,None)==None:
        List[i]=1
    else:
        List[i]+=1


for i in T:
    if List.get(i,None)==None:
        print("NO")
        exit()
    else:
        if(List[i]==1):
            del List[i]
        else:
            List[i]-=1
        

print("YES")

Measured memory_bytes: 41816
#include <iostream>

using namespace std;

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

	int r_min = n;
	int l_max = 0;

	for(int i = 0; i < m; ++i){
		int l, r;
		cin >> l >> r;
		if(r < r_min){
			r_min = r;
		}
		if(l > l_max){
			l_max = l;
		}
	}
	if((r_min-l_max+1) <= 0){
		cout << "0" << endl;
	}else{
		cout << (r_min-l_max+1) << endl;
	}
}

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

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pii pair<int, int>


int main() {


   int n, x;cin>>n>>x;

    if(!(x < 2*n-1 and x > 1)) {
        cout<<"No";
        return 0;
    }

    cout<<"Yes"<<endl;

    if(x == n) {
        for(int i=1;i<=2*n-1;i++) {
            cout<<i<<endl;
        }return 0;
    }

    if(x > n) {
        int z = x-n;
        for(int i=z+1;i<=2*n-1;i++) {
            cout<<i<<endl;
        }

        for(int i=1;i<=z;i++) {
            cout<<i<<endl;
        }

        return 0;
    }

    if(x < n) {
        int z = -x+n;
        for(int i=2*n-z;i<=2*n-1;i++) {
            cout<<i<<endl;
        }

        for(int i=1;i<=2*n-z-1;i++) {
            cout<<i<<endl;
        }

        return 0;
    }


    return 0;
}



Measured memory_bytes: 1536
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

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

	if ( ( B - A ) == ( C - B ) )
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	
	return 0;
}


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

int p, q, r;
int mp, mq, mr;
int main(){
	cin >> p >> q >> r;
	mp = q + r;
	mq = p + r;
	mr = p + q;
	cout << min(mp, min(mq, mr)) << endl;






	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int a[5010],n;
vector<int> adj[5010];
void bt(int base,int t,vector<int> v)
{
    vector<int> v2;
    for(auto it:v)
        if(it&1)a[it*base]=t;
        else v2.pb(it/2);
    if(v2.size())bt(base*2,t+1,v2);
}
void solve()
{
    cin>>n;
    vector<int> v;
    for(int i=1;i<=n;i++)v.pb(i);
    bt(1,1,v);
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
            cout<<a[j-i]<<" ";
        cout<<'\n';
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("XORQUERY.inp","r",stdin);
    //freopen("XORQUERY.out","w",stdout);
    //int test;cin>>test;while(test--)
    solve();
    return 0;
}


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

int main()
{
  long long A,B,C,K;
  cin >> A >> B >> C >> K;
  
  int ans=0;
  
  ans += A;

  if(A>=K){
    cout << K << endl;
    return 0;
  }
  
  K-=A;
  
  if(B>=K){
    cout << ans << endl;
    return 0;
  }
  
  K-=B;
  ans-=K;
     
  cout << ans << endl;


return 0;
}

Measured memory_bytes: 3632
while gets do
  a = $_.chomp.chars

  res = nil
  3.times do |i|
    if a[3*i] == a[3*i+1] and a[3*i] == a[3*i+2]
      next if a[3*i] == 's'
      res = a[3*i]
      break
    elsif a[i] == a[i+3] and a[i] == a[i+6]
      next if a[i] == 's'
      res = a[i]
      break
    end
  end

  if res
    puts res
  elsif ((a[0] == a[4] and a[0] == a[8]) or (a[2] == a[4] and a[2] == a[6])) and a[4] != 's'
    puts a[4]
  else
    puts 'd'
  end
end

Measured memory_bytes: 6104
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
struct Point{
    int x, y;
    Point() {x = y = -1;}
    Point(int x, int y): x(x), y(y) {}
    bool operator== (const Point& p) const { return x == p.x && y == p.y; }
    bool operator< (const Point& p) const { return x < p.x || y < p.y; }
    const Point operator+ (const Point& p) const { return Point(x + p.x, y + p.y);}
};
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int H, W;
vector<string> fld;
int dp[51][51][51][51];
vector<Point> holes[26];

bool range_out(Point a){
    return a < Point(0, 0) || Point(W - 1, H - 1) < a ;
}
bool is_Wall(Point a){
    return fld[a.y][a.x] == '#';
}
int dfs(Point a, Point b){
    int& res = dp[a.y][a.x][b.y][b.x];
    if(res != -1) return res;
    if(b.x + b.y - a.x - a.y == -1) return res = 0;
    res = -INF;
    if(range_out(a) || range_out(b) || is_Wall(a) || is_Wall(b) || b < a) return res;
    if(a == b) return res = 0;
    if('a' <= fld[a.y][a.x] && fld[a.y][a.x] <= 'z'){
        int k = fld[a.y][a.x] - 'a';
        for(Point hole : holes[k]){
            if(hole < a || b < hole) continue;
            rep(i, 2) REP(j, 2, 4){
                Point nx1 = a + Point(dx[i], dy[i]), nx2 = hole + Point(dx[j], dy[j]);
                res = max(res, dfs(nx1, nx2) + dfs(hole, b) + 1);
            }
        }
    }
    rep(i, 2)
      res = max(res, dfs(a + Point(dx[i], dy[i]), b));
    return res;
}
bool can_reach[51][51];
bool bfs(){
    memset(can_reach, 0, sizeof(can_reach));
    queue<Point> que;
    que.push(Point(0, 0));
    can_reach[0][0] = true;
    while(!que.empty()){
        Point now = que.front(); que.pop();
        rep(i, 2){
            int nx = now.x + dx[i], ny = now.y + dy[i];
            if(W <= nx || H <= ny || fld[ny][nx] == '#' || can_reach[ny][nx])
              continue;
            can_reach[ny][nx] = true;
            que.push(Point(nx, ny));
        }
    }
    return can_reach[H - 1][W - 1];
}
void find_hole(){
    rep(i, 26) holes[i].clear();
    rep(i, H) rep(j, W)
      if('A' <= fld[i][j] && fld[i][j] <= 'Z')
        holes[fld[i][j] - 'A'].push_back(Point(j, i));
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ifstream ifs("2538_in1.txt");
    while(cin >> H >> W && H){
        fld = vector<string>(H);
        rep(i, H) cin >> fld[i];
        if(!bfs()){
            cout << "-1" << endl;
            continue;
        }
        find_hole();
        memset(dp, -1, sizeof(dp));
        cout << max(0, dfs(Point(0, 0), Point(W - 1, H - 1))) << endl;
    }
}

Measured memory_bytes: 29628
from collections import defaultdict
H,W=map(int,input().split())
A="".join([input() for _ in range(H)])
cnts = defaultdict(lambda: 0)
for c in A:
    cnts[c]+=1
    
n4 = ((H-H%2)*(W-W%2))//4
n2 = (H%2)*(W//2)+(W%2)*(H//2)
n1 = 1 if H%2+W%2 == 2 else 0

for _,cnt in cnts.items():
    n4 -= (cnt//4)
    n2 -= (cnt%4)//2
    n1 -= (cnt%2)

if n4==0 and n2==0 and n1==0:
    print("Yes")
elif n4<0 and n2>0 and (-4)*n4==2*n2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38640
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define inlld(x) scanf("%lld", &x)
#define ind(x) scanf("%d", &x)
#define inlld2(x, y) scanf("%lld%lld", &x, &y)
#define inlld3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z)
#define ind2(x, y) scanf("%d%d", &x, &y)
#define ind3(x, y, z) scanf("%d%d%d", &x, &y, &z)

const int N=1e5+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
    string a, b;
    int ans = 0;
    cin>>a>>b;
    for(int i = 0; i < a.length(); i++) {
        if(a[i] != b[i])
            ans++;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 3896
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

t, x = Is()
print(t/x)

Measured memory_bytes: 63340
using System;
using static System.Console;
using System.Linq;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tmp = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] tmp2 = { tmp[0] + tmp[1], tmp[0] - tmp[1], tmp[0] * tmp[1] };
            Array.Sort(tmp2);
            WriteLine(tmp2[2]);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <sstream>
#include <cstdio>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))           \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char			BYTE;
typedef int						BOOL;
typedef unsigned long			DWORD;
typedef long long				LLONG;

inline int read() {
	int ret = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -f;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
	return ret * f;
}//快读优化

int main(int argc, char* argv[])
{
	int			nLineCount;
	int			nColumnCount;

	cin >> nLineCount >> nColumnCount;

	cout << (nLineCount - 1) * (nColumnCount - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

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; }

ll dp[110][100010];

int main(){
  int N,W;
  cin >> N >> W;
  vector<ll> v(N);
  vector<ll> w(N);
  rep(i,N){
    cin >> w[i] >> v[i];
  }
  rep(j,W+1){
    rep(i,N){
      if(j+w[i]<=W) chmax(dp[i+1][j+w[i]],dp[i][j]+v[i]);
      chmax(dp[i+1][j],dp[i][j]);
    }
  }
  cout << dp[N][W] << endl;
  
}

Measured memory_bytes: 79360
#include<stdio.h>

int main(void){
    int N, L[200];
    int ans = 0;
    scanf("%d", &N);
    //L[i]を昇順ソートしながら格納
    for(int i = 0; i < 2*N; i ++){
        int num;
        scanf("%d", &num);
        int place = 0;
        if (i > 0){
            while(place < i){
                if (num < L[place]) break;
                place ++;
            }
            for(int k = i; k >= place; k --){
                L[k+1] = L[k];
            }
        }
        L[place] = num;
    }
    for(int i = 0; i < 2*N; i += 2){
        ans += L[i];
    }
    printf("%d\n", ans);    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  //Nim:各山の枚数をxorした値が0になると先手の負け
  //各山の枚数のxorを0にしたい
  CIN(n);
  VC1(n,a);
  int xo=0;
  REP(i,n)xo^=a[i];
  //dump(bitset<32>(xo));
  REP(i,n)a[i]^=(a[i]-1);
  sort(ALL(a),greater<ll>());
  //REP(i,n)COUT(bitset<32>(a[i]));
  ll cou = 0;
  REP(i,n){
    if(xo&((a[i]+1)>>1)){
      ++cou;
      xo^=a[i];
    }
  }
  COUT((xo?-1:cou));
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int i,tmp=0,N,M;
	int T[100],X[100],P[100],A[100];

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

	scanf("%d",&M);
	for(i=0;i<M;i++){
		scanf("%d",&P[i]);
		scanf("%d",&X[i]);
	}

	for(i=0;i<M;i++){
		printf("%d\n",tmp+X[i]-T[P[i]-1]);
	}

	return 0;
}

Measured memory_bytes: 128