akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<chrono>
#pragma GCC optimize("Ofast")
using namespace std;
using namespace chrono;
#define all(a) a.begin(), a.end()
#define sz(x) (int(x.size()))
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef vector<string> vs;
template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int A, B, C;
	cin >> A >> B >> C;
	cout << max(0, C - (A - B));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
 
using namespace std;
 
long long int mul(long long int ans, long long int x, long long int y){
    while (y){
        if (y%2){
            ans = (ans * x) % MOD;
        }
        x = (x * x) % MOD;
        y >>= 1;
    }
    return ans;
}
 
long long int inv(long long int n){
    return mul(1, n, MOD-2);
}
 
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++){
        cin >> a[i];
    }
    vector<int> prime(1000000, 0);
    for (int i=0; i<n; i++){
        int m = a[i];
        int count = 0;
        while (m%2 == 0){
            m /= 2;
            count++;
        }
        prime[2] = max(prime[2], count);
        for (int j=3; j*j<=m; j+=2){
            count = 0;
            while (m%j == 0){
                m /= j;
                count++;
            }
            prime[j] = max(prime[j], count);
        }
        prime[m] = max(prime[m], 1);
    }
 
    long long int lcm = 1;
    for (int i=2; i<prime.size(); i++){
        if (prime[i] != 0)  lcm = mul(lcm, i, prime[i]);
    }
 
    long long int ans = 0;
    for (int i=0; i<n; i++){
        long long m = a[i], _ans = lcm;
        int count = 0;
        while (m%2 == 0){
            m /= 2;
            count++;
        }
        _ans = mul(_ans, inv(2), count);
        for (int j=3; j*j<=m; j+=2){
            count = 0;
            while (m%j == 0){
                m /= j;
                count++;
            }
            if (count != 0)  _ans = mul(_ans, inv(j), count);
        }
        _ans = mul(_ans, inv(m), 1);
        ans += _ans;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4352
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String b = sc.nextLine();
        String[] a=b.split("");
        
        for(int i=0;i<a.length;i++){
            if(Character.isUpperCase( a[i].charAt(0))){
                a[i]=a[i].toLowerCase();
            }else{
                a[i]=a[i].toUpperCase();
            }
        }
        for(int i=0;i<a.length;i++){
        	System.out.print(a[i]);
        }
        System.out.println();
    }
}



Measured memory_bytes: 27292
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int main(){
  int a[5];
  rep(i,5) cin>>a[i];
  int min1=11,j;
  rep(i,5){
    int one=a[i]%10;
    if(one==0) one=10;
    if(min1>one){
      j=i;
      min1=one;
    }
  }
  int res=0;
  rep(i,5){
    if(i!=j){
      if(a[i]%10!=0){
	res+=(a[i]/10+1)*10;
      }
      else{
	res+=a[i];
      }
    }
    else res+=a[i];
  }

  prin(res);

  
  

  return 0;
}


Measured memory_bytes: 256
N=int(input())
li = list(map(int,input().split()))

import math
av=sum(li)/N
if av-math.floor(av)<0.5:
  m=math.floor(av)
else:
  m=math.floor(av)+1

squaresum=0
for i in li:
  squaresum+=(i-m)**2
  
print(squaresum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e5+1;
const int M=1e9+7;
const int N1=1e18+1;
typedef pair<int, int> pi;
typedef pair<pair<int, int> , int> pii;
#define F first
#define S second
#define pb push_back
#define endl "\n"


int32_t main(){

  	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  
    
    // int t;cin>>t;
    // while(t--){

    // }

  	int a[6];
  	for(int i=1;i<=5;i++){
  		cin>>a[i];
  	}
  	int ans=0;
  	for(int i=1;i<=5;i++){
  		if(a[i]==0){
  			ans=i;
  		}
  	}
  	cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a > b){
    for(int i = 0; i < a; i++){
      cout << b;
    }
  }
  else if(a <= b){
    for(int i = 0; i < b; i++){
      cout << a;
    }
  }
  return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>

using namespace std;

bool check(string str){
    int len = str.length();
    for(int s = 0, e = len-1; s < len/2; s++, e--){
        if(str[s] != str[e]) return false;
    }
    return true;
}

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

    if(check(str) && check( (str.substr(0, (str.length()-1)/2)) ) && check( (str.substr((str.length()+2)/2)) )){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    

}

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

using namespace std;
using ll = long long;


int main()
{
	string s; cin >> s;
	int n = s.size();
	if(s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}
	if(n != 26) {
		for(char a = 'a'; a <= 'z'; a++) {
			if(count(s.begin(), s.end(), a) == 0) {
				cout << s << a << endl;
				return 0;
			}
		}
	}
	string k = s;
	next_permutation(k.begin(), k.end());

	for(int i = 0; i < n; i++){
		if(s[i] != k[i]) {
			cout << k.substr(0, i + 1) << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def read():
    Q = int(input().strip())
    LR = []
    for i in range(Q):
        l, r = map(int, input().strip().split())
        LR.append((l, r))
    return Q, LR


def sieve(n):
    """
    n以下の素数を昇順に列挙する
    """
    is_prime = [True for i in range(n+1)]
    for i in range(2, n+1):
        if is_prime[i]:
            for j in range(i+i, n+1, i):
                is_prime[j] = False
    return is_prime


def solve(Q, LR, N=10**5+1):
    primes = sieve(N)
    S = [0 for i in range(N+2)]
    for i in range(3, N+2, 2):
        d = 1 if primes[i] & primes[(i+1)//2] else 0
        S[i] = S[i-2] + d
    for l, r in LR:
        ans = S[r] - S[l-2]
        print(ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 25164
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n;
    cin >>n;
    
    ll r = 0;
    vll b(n-1);
    rep(i, n-1) cin >>b[i];
    rrep(i, n-2) {
        r += min(b[i-1], b[i]);
    }
    r += b[0] + b[n-2];

    
    mes(r);
    
    
}


Measured memory_bytes: 3604
h,w,d = map(int,input().split())
A = [[int(x) for x in input().split()] for x in range(h)]
Q = int(input())
LR = [[int(x) for x in input().split()] for x in range(Q)]
num = [[[0,0] for x in range(h*w//d+1)] for y in range(d)]
for i in range(h):
    for j in range(w):
        n = A[i][j]
        num[n%d][n//d] = [i,j]
numsum = [[0 for x in range(h*w//d+1)] for y in range(d)]

for y in range(d):
    for x in range(1,h*w//d+1):
        a,b = num[y][x-1]
        i,j = num[y][x]
        numsum[y][x] = numsum[y][x-1]+abs(a-i)+abs(b-j)
for l,r in LR:
    print(numsum[r%d][r//d]-numsum[l%d][l//d])

Measured memory_bytes: 66160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
    public static void main(String[] args){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String N = reader.readLine();
            int len = (int)N.length()-1;
            String last = N.substring(len);
            if(last.equals("3")){
                System.out.println("bon");
            }else if(last.equals("0") || last.equals("1") || last.equals("6") || last.equals("8")){
                System.out.println("pon");
            }else{
                System.out.println("hon");
            }
        }catch(IOException e){
            System.out.println("aaaa");
        }
    }
}

Measured memory_bytes: 32640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

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

int mem[N][5];
int n;
int a[5][N];

int dp(int i,int t)
{
    int &ret = mem[i][t];
    if (ret != -1) return ret;
    if (i == n) return 0;
    ret = 0;
    REP(j,0,2)
    {
        if (j == t) continue;
        ret = max(ret,dp(i+1,j)+a[j][i]);
    }
    return ret;
}

int main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    memset(mem,-1,sizeof mem);
    scanf("%d",&n);
    REP(i,0,n-1) scanf("%d %d %d",&a[0][i], &a[1][i], &a[2][i]);
    printf("%d\n",dp(0,3));

    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll x1 = max(a * c, a * d);
	ll x2 = max(b * c, b * d);
	cout << max(x1, x2) << endl;
	return 0;
}


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

ll k;

int main(){
    cin >> k;
    if(k%2==0||k%5==0){
        cout << -1 << endl;
        return 0;
    }
    ll memo=0;
    for(ll i=1;i<=100000000;i++){
        memo=memo*10+7;
        if(memo%k==0){
            cout << i << endl;
            return 0;
        }
        memo%=k;
    }
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {
	static int intN =0;
	static int sosuCnt =0;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String n = sc.nextLine();
		//String[] h = sc.nextLine().split(" ");

		int intN = Integer.parseInt(n);

		double sum=0;
		
		if (intN==1) {
			sum=1.0000000000;
		} else if(intN%2==0) {
			sum=0.5000000000;
		} else {
			sum=1-(double)(intN/2)/intN;
		}

		System.out.println(sum);


		//int a = Integer.parseInt("");
		//for (int i = 0;i < intN;i++) {
		//sum=sum+i;
	//}

	}
}


Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

long long cnt;

struct SSS
{
	string str;
	int val;
	SSS(string s = "", int v = 0) :str(s), val(v){};
};

void print(vector<SSS> &data){
	for (int i = 0; i < data.size(); ++i){
		cout << data[i].str << " " << data[i].val << endl;
	}
}

void print(vector<int> &data){
	for (int i = 0; i < data.size(); ++i) {
		cout << data[i];
		if (i == data.size() - 1) cout << endl;
		else cout << " ";
	}
}

void insS(vector<int> &data){
	for (int i = 0; i < data.size(); ++i){
		int v = data[i];
		int j = i - 1;
		while (j >= 0 && data[j] > v){
			data[j + 1] = data[j];
			j--;
		}
		data[j + 1] = v;
		print(data);
	}
}

void bubS(vector<int> &data){
	for (int i = 0; i < data.size(); ++i) {
		int j = data.size() - 1;
		for (; j > i; --j){
			if (data[j] < data[j - 1]) {
				swap(data[j], data[j - 1]);
				cnt++;
			}
		}
	}
	print(data);
	cout << cnt << endl;
}



int main(){
	int n; cin >> n;
	vector<int> data(n);
	for (int i = 0; i < n; ++i) cin >> data[i];
	//insS(data);
	bubS(data);

	return 0;
}

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

// Author - Kevin Mathew
// Birla Institute of Technology, Mesra

ll n, m;
vector<ll> G[100010];
vector<ll> revG[100010];
vector<ll> roots;
ll vis[100010];
unordered_map<ll, ll> um;
ll dp[100010];

ll dfs(ll x){
	if(dp[x] != -1)
		return dp[x];

	ll ans = 0;

	for(ll i=0;i<G[x].size();i++){
		// cout << x << " " << G[x][i] << "-\n";
		ans = max(ans, dfs(G[x][i]));
	}

	dp[x] = ans + 1;

	// cout << x << " " << dp[x] << "\n";
	return dp[x];
}

void te(){
	cin >> n >> m;
	for(ll i=0;i<n;i++){
		vis[i+1] = 0;
		dp[i+1] = -1;
	}
	
	for(ll i=0;i<m;i++){
		ll u, v;
		cin >> u >> v;

		G[u].push_back(v);
		revG[v].push_back(u);
	}

	for(ll i=1;i<=n;i++){
		if(revG[i].size() == 0)
			roots.push_back(i);
	}

	ll ans = 0;
	for(ll i=0;i<roots.size();i++){
		// cout << roots[i] << "\n";
		ans = max(ans, dfs(roots[i]));
	}

	cout << ans - 1 << "\n";
}

int main()
{
	//freopen("input.txt", "r", stdin);		//Comment
	//freopen("output.txt", "w", stdout);		//this out.
	ios::sync_with_stdio(false);			//Not
	cin.tie(NULL);							//this.
	cout.tie(0);							//or this.

	te();

	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char *argv[])
{
	VL a(3);
	cin >> a;
	SORT(a);
	cout << a[0] + a[1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){ 
  string S;
  cin >> S;
  int L = S.size();
  int l = L/2;
  int Ans = 0;
  for(int i = 0; i < l; i++){
    if(S.at(i) != S.at(L - 1 - i)) Ans++;
  }
  
  cout << Ans << endl;    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N, K;
vector<int> h;

int main() {
  cin >> N >> K;
  h.resize(N);
  rep(i, N) cin >> h[i];

  int ans = 0;
  rep(i, N) if (h[i] >= K) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(){
    int W,H,x,y,r;
    scanf("%d%d%d%d%d", &W,&H,&x,&y,&r);
    if(x - r < 0 || x + r > W || y - r < 0 || y + r > H) {
        printf("No\n");
    }else if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H){
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)
#define INF 10000000

typedef long long ll;
typedef pair<ll, ll> P;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z


int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

void solve(void){
    int n, m;
    scanf("%d%d\n", &n, &m);
    char astring[n][n];
    rep(n, i) scanf("%s\n", astring[i]);
    char bstring[m][m];
    rep(m, i) scanf("%s\n", bstring[i]);
    bool flag = false;

    Rep(0, n-m, k) {
        Rep(0, n-m, l) {
            if (flag) break;
            flag = true;
            rep(m, i) {
                rep(m, j) {
                    if (astring[i+k][j+l] != bstring[i][j]) flag = false;
                }
            }
        }
    }
    printf("%s\n", flag ? "Yes" : "No");
}

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


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int x;
    int i = 1;
    while (1) {
        scanf("%d", &x);
        if (x == 0)
            break;
        printf("Case %d: %d\n", i, x);
        ++i;
        if (i > 10000)
            break;
    }
    
    return 0;
}


Measured memory_bytes: 2064
#include <algorithm>
#include <iostream>

using namespace std;

int n, m, k;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m >> k;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (n * m - i * j - (n - i) * (m - j) == k) {
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
}

Measured memory_bytes: 256
import itertools

n, m, x = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(n)]

minnum = (10**5) * 13

for i in range(1, n + 1):
    tmp = list(itertools.combinations(c, i))
    # print(tmp)
    for item in tmp:
        t = list(zip(*item))
        xs = [sum(t[j]) if sum(t[j]) >= x else False for j in range(1, m + 1)]
        if False not in xs and sum(t[0]) < minnum:
            minnum = sum(t[0])
if minnum != (10**5) * 13:
    print(minnum)
else:
    print(-1)

Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    int64_t x;
    cin >> x;

    vector<int64_t> p(200);
    for (auto i = 0; i < 200; i++) {
        p[i] = (int64_t)pow(i, 5);
    }

    for (auto i = 0; i < 200; i++) {
        for (auto j = 0; j < 200; j++) {
            if(p[i] - p[j] == x) {
                cout << i << " " << j << endl;
                return 0;
            }
            if(p[i] + p[j] == x) {
                cout << i << " " << -1 * j << endl;
                return 0;
            }
            if(-1 * p[i] - p[j] == x) {
                cout << -1 * i << " " << j << endl;
                return 0;
            }
            if(-1 * p[i] + p[j] == x) {
                cout << -1 * i << " " << -1 * j << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4116
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<pair<int,int>>v;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;
        v.push_back({a,b});
    }
    for(int i=0;;i++){
        
        string s = to_string(i);
        if(s.size() < n) continue;
        bool ok = false;
        for(int j=0;j<m;j++){
            int x = s[v[j].first] - '0';
            if(v[j].second != x){
                ok = true;
            }
        }
        if(!ok){
            cout<<s<<endl;
            return 0;
        }
        if(s.size() > n){
            break;
        }
    }
    cout<<-1<<endl;
    return 0;
    
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

typedef long long ll;
typedef array<array<char, 10>, 10> Array;
Array A;
int H, W;

bool func(Array A, int h, int w) {
    A[h][w] = '.';

    if (h == H && w == W) {
        for (auto aa : A) {
            for (auto a : aa) {
                if (a == '#') {
                    return false;
                }
            }
        }
        return true;
    }

    bool ret = false;
    if (A[h + 1][w] == '#'){
        ret |= func(A, h + 1, w);
    }
    if (A[h][w + 1] == '#') {
        ret |= func(A, h, w + 1);
    }
    return ret;
}

int main(void) {
    cin >> H >> W;

    for (auto aa : A) {
        aa.fill('.');
    }

    for (int i = 1; i <= H; i++) {
        string s;
        cin >> s;
        for (int j = 1; j <= W; j++) {
            A[i][j] = s[j - 1];
        }
    }

    cout << (func(A, 1, 1) ? "Possible" : "Impossible") << endl;
    return 0;
}


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

int main() {

  int n;
  int v[50], c[50];

  cin >> n;
  for(int i = 0; i < n; i++) cin >> v[i];
  for(int i = 0; i < n; i++) cin >> c[i];

  int ans = 0;
  for(int i = 0; i < n; i++) {
    if((v[i] - c[i]) > 0) ans += v[i] - c[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n >> m;
    if(n<=m){
        cout << n << endl;
    }else{
        cout << n - 1 << endl;
    }
}

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> Si(H);
    for (int i=0;i<H;i++){
        cin >> Si[i];
    }
    vector<vector<int>> L(H,vector<int>(W,0));
    vector<vector<int>> R(H,vector<int>(W,0));
    vector<vector<int>> U(H,vector<int>(W,0));
    vector<vector<int>> D(H,vector<int>(W,0));
    for (int h=0;h<H;h++){
        for (int w=0;w<W;w++){
            if (Si[h][w] == '#') L[h][w] = 0;
            else if (w == 0) L[h][w] = 1;
            else if (w > 0) L[h][w] = L[h][w-1] + 1;
            if (Si[h][w] == '#') U[h][w] = 0;
            else if (h == 0) U[h][w] = 1;
            else if (h > 0) U[h][w] = U[h-1][w] + 1;
        }
    }
    for (int h=H-1;h>=0;h--){
        for (int w=W-1;w>=0;w--){
            if (Si[h][w] == '#') R[h][w] = 0;
            else if (w == W-1) R[h][w] = 1;
            else if (w < W-1) R[h][w] = R[h][w+1] + 1;
            if (Si[h][w] == '#') D[h][w] = 0;
            else if (h == H-1) D[h][w] = 1;
            else if (h < H-1) D[h][w] = D[h+1][w] + 1;
        }
    }

    int ans = 0;
    for (int h=0;h<H;h++){
        for (int w=0;w<W;w++){
            int cnt = L[h][w] + R[h][w] + U[h][w] + D[h][w] - 3;
            ans = max(ans, cnt);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 67200
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b>>c;
	if(b-a==c-b) cout<<"YES"<<endl;
	else  cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int Inf = 1 << 30;
const int maxx = 1e5 + 7;
int n, m;
int ans;

struct PP {
	int a, b;
} p[maxx];

bool Cmp(PP x, PP y) { return x.b < y.b; }

int main() {
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++) scanf("%d %d", &p[i].a, &p[i].b);
	sort(p + 1, p + m + 1, Cmp);
	int t = 0;
	for(int i = 1; i <= m; i++) {
		if(p[i].a >= t){
			t = p[i].b; ans++;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1024
# coding: utf-8
# Your code here!A=int(input())

N=int(input())
S=[]
for i in range(N):
    S.append(input())
M = 0
A = 0
R = 0
C = 0
H = 0
for i in S:
    if i[0] == 'M':
        M += 1
    elif i[0] == 'A':
        A += 1
    elif i[0] == 'R':
        R += 1
    elif i[0] == 'C':
        C += 1
    elif i[0] == 'H':
        H += 1
#    print(i[0])
#print(M,A,R,C,H)
def baai(X, x):
    if x == 0:
        return 1
    if x == 1:
        return X
    else:
        return -1
    


num = 0
for m in range(2):
    for a in range(2):
        for r in range(2):
            for c in range(2):
                for h in range(2):
                    if (m + a + r + c + h) == 3:
                        num += baai(M,m)*baai(A,a)*baai(R,r)*baai(C,c)*baai(H,h)
print(num)                        








Measured memory_bytes: 9776
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define CLR(array) memset( array, 0, sizeof array )
typedef long long int ll;


#define MAXN (100000+5)

char t[MAXN];
int n,k,R,S,P;

int main(){
	std::cin >> n >> k;
	std::cin >> R >> S >> P;
	scanf("%s", t);

	int total = 0;
	for( int i = 0; i < k; ++i ){
		int r,s,p;
		r = s = p = 0;
		for( int j = i; j < n; j += k ){
			if( t[j] == 'r' ){
				int t = p;
				p = std::max(r,s) + P;
				r = std::max(s,t);
				s = std::max(r,t);
			}else if( t[j] == 's' ){
				int t = r;
				r = std::max(s,p) + R;
				s = std::max(t,p);
				p = std::max(t,s);
			}else{
				int t = s;
				s = std::max(r,p) + S;
				r = std::max(t,p);
				p = std::max(r,t);
			}
		}
		total += std::max( r, std::max(s,p) );
		
	}

	printf("%d\n",  total);

	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>

using namespace std;

const int mod = 1'000'000'007;

void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

int mul(int a, int b) {
  return (int)((long long)a * b % mod);
}

int pw(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return res;
}

int get(int b) {
  int res = pw(10, b);
  add(res, mod - pw(10, b - 1));
  return res;
}

int main() {
  int s;
  scanf("%d", &s);
  int ans = 0;
  for (int i = 1; i * i <= s; ++i) {
    if (s % i == 0) {
      {
        int cnt = get(i);
        if (i >= 9 || cnt >= s / i) {
          add(ans, cnt);
          add(ans, mod - s / i + 1);
        }
      }
      if (s / i != i) {
        int cnt = get(s / i);
        if (s / i >= 9 || cnt >= i) {
          add(ans, cnt);
          add(ans, mod - i + 1);
        }
      }
    }
  }
  for (int i = 1; i <= 8; ++i) {
    long long v = 0;
    for (int j = i + 1; j <= 9; ++j) {
      for (int k = 1; k <= get(i); ++k) {
        if (v + i * k >= s) {
          break;
        }
        if ((s - v - i * k) % j == 0 && (s - v - i * k) / j <= get(j)) {
          add(ans, 1);
        }
      }
      v += j * get(j);
      if (v >= s) {
        break;
      }
    }
  }
  for (int i = 9; i <= s / 2; ++i) {
    int v = s / (i + 1);
    if (s % (i + 1) == 0) {
      --v;
    }
    int r = s % i;
    if (v >= r) {
      add(ans, (v - r) / i + (r != 0));
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n, m; cin >> n >> m;
    vector<int> s;
    vector<int> t;
    vector<int> c;
    while(1){
        int i1, i2, i3; cin >> i1 >> i2 >> i3;
        if(i1 == 0) break;
        i1--;
        i2--;
        s.push_back(i1);
        t.push_back(i2);
        c.push_back(i3);
    }

    int l; cin >> l;
    for(int i = 0; i < l; i++){
        vector<int> b(m);
        for(int j = 0; j < m; j++) cin >> b[j];
        vector<int> ans(n, 0);

        for(int j = 0; j < s.size(); j++){
            ans[s[j]] += b[t[j]] * c[j];
        }

        for(int j = 0; j < n; j++){
            if(j == n - 1) cout << ans[j] << endl;
            else cout << ans[j] << " ";
        }
    }
    return 0;
}



Measured memory_bytes: 4204
import numpy as np
n = int(input())
S = [input() for i in range(n)]
mat = [[0 for i in range(26)] for j in range(n)]
mat = np.array(mat)
for i in range(n):
	Sp = S[i]
	for j in range(len(Sp)):
		mat[i][ord(Sp[j])-97] += 1
result = ''
for i in range(26):
	Cnt = min(mat[:,i])
	for j in range(Cnt):
		result += chr(i+97)
print(result)

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

int main() {
    int x;
    cin >> x;
    if (x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int i, j, k, ans = 0, count;

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

            if(count == 8)ans++;
        }

        System.out.println(ans);
    }
}

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

vector<ll> memo(90,0);

ll lucas(int n){
  if(n == 0) return 2;
  if(n == 1) return 1;
  
  if(memo[n] != 0){
    return memo[n];
  }
  
  return memo[n] = lucas(n-2) + lucas(n-1);
}

int main(){
  int N; cin >> N;
  cout << lucas(N) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >>s;
  int a,b;
  if (s[0]=='0')a=s[1]-'0';
  else{
    a=(s[0]-'0')*10+s[1]-'0';
  }
  if (s[2]=='0')b=s[3]-'0';
  else{
    b=(s[2]-'0')*10+s[3]-'0';
  }
  if(a>=1 &&a<=12&& b>=1 && b<=12)cout <<"AMBIGUOUS"<<endl;
  else if(a>=1 && a<=12)cout <<"MMYY"<<endl;
  else if(b>=1 && b<=12)cout <<"YYMM"<<endl;
  else cout <<"NA"<<endl;
}


Measured memory_bytes: 256
n = gets.to_i
arr = []
n.times do
  arr.push(gets.chomp.chars.sort.join)
end
arr.sort!
count = 0
suc_count = 0
i = 0
while i < arr.size-1
  if arr[i] == arr[i+1]
    suc_count += 1
    count += suc_count
  else
    suc_count = 0
  end
  i += 1
end
puts count

Measured memory_bytes: 24356
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <set>
#include <cassert>
using namespace std;
using lint = long long;
const long mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < S.size(); i++){
        for(int j = i; j < S.size(); j++){
            set<char> chars;
            for(int k = i; k <= j; k++){
                chars.insert(S[k]);
            }
            chars.erase('A');
            chars.erase('T');
            chars.erase('C');
            chars.erase('G');
            if(chars.empty()){
                ans = max(ans, j - i + 1);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N = read_a_int()
# ルートNから少しづつ増やして割り切れたらおk
import numpy as np
start = int(np.sqrt(N))
while N % start != 0:
    start -= 1
a, b = start, N//start
print(a+b-2)


# def prime_factorize(n):
#     a = []
#     while n % 2 == 0:
#         a.append(2)
#         n //= 2
#     f = 3
#     while f * f <= n:
#         if n % f == 0:
#             a.append(f)
#             n //= f
#         else:
#             f += 2
#     if n != 1:
#         a.append(n)
#     return a


# print(prime_factorize(N))


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    ll ans = 0;
    ll a = std::min(A, K);
    K -= a;
    ll b = std::min(B, K);
    K -= b;
    ll c = std::min(C, K);
    ans = a - c;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
# C - Switches
#bit全探索の練習問題
import copy

N,M = input().split()
N = int(N)
M = int(M)

ks = []
for l in range(M):
    s = input().split()
    ks.append(s)
p = list(map(int, input().split()))

KS = []
for m in range(M):#列の数はМ
    box = list()
    for n in range(len(ks[m])):#M列の要素を数字に直す処理
        ks[m][n] = int(ks[m][n])
        box.append(ks[m][n])
    KS.append(box)            

swich = []
for o in range(M):#列の数はМ
    swi = list()
    for r in range(1,len(KS[o])):#k以外を取り出す
        swi.append(ks[o][r])
    swich.append(swi)
           
ans = 0
for i in range(1<<N):#全パターンは2**(スイッチの総数)
    SWICH = copy.deepcopy(swich)
    light_on = 0
    for j in range(N):
        mask = 1<< j#1をj個左にずらした2進数
        if i & mask != 0:#スイッチjがonの時
            continue
        else:#スイッチjがoffの時
            for y in range(M):#電球iごとに繰り返し
                if (j+1 in SWICH[y]) == True:#スイッチsiが電球iに接続されているとき
                    SWICH[y].remove(j+1)

    #onのみがSWICHに入っている
    flat_SWICH = []
    for a in range(len(SWICH)):
        for b in range(len(SWICH[a])):
            flat_SWICH.append(SWICH[a][b])
            
    for x in range(M):
        if (len(SWICH[x]) % 2) == p[x]:#onのスイッチの数を2で割った余りがPの値と等しい時
            light_on += 1
    if light_on == M:#onの電球の個数がMと等しい(全てon)時
        ans += 1
print(ans)

Measured memory_bytes: 9284
#include<iostream>
using namespace std;
int main() {
	int h, w;
	int a[110], b[110];
	char s[110][110];
	cin >> h >> w;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> s[i][j];
			if (s[i][j] == '#')
				a[i] = 1, b[j] = 1;
		}
	}
	for (int i = 1; i <= h; i++) {
		if (a[i] == 1) {
			for (int j = 1; j <= w; j++)
				if (b[j] == 1) cout << s[i][j];
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cctype>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,m,b[5010][210],nxt[5010][210];
ll ans,sum[5010],d[5010];
char buffer[20000010],*head;
inline char Getchar(){
	return *head++;
}
inline int rd(){
	register int x=0;
	register char c;
	do c=Getchar();
	while(!isdigit(c));
	do{
		x=(x<<1)+(x<<3)+(c^48);
		c=Getchar();
	}while(isdigit(c));
	return x;
}
signed main(){
	fread(buffer,1,20000000,stdin);
	head=buffer;
	n=rd(),m=rd();
	for(register int i=2;i<=n;i++){
		int x=rd();
		sum[i]=sum[i-1]+x;
	}
	for(register int i=1;i<=n;i++)
		for(register int j=1;j<=m;j++)
			b[i][j]=rd();
	for(register int i=n;i;i--){
		ll now=0;
		for(int j=1;j<=m;j++){
			now+=b[i][j];
			nxt[i][j]=i+1;
			d[i+1]+=b[i+1][j]-b[i][j];
			for(int &k=nxt[i][j];k<=n&&b[k][j]<=b[i][j];k=nxt[k][j]){
				d[k]+=b[i][j]-b[k][j];
				d[nxt[k][j]]+=b[k][j]-b[i][j];
			}
		}
		for(int j=i;j<=n;j++){
			now+=d[j];
			ans=max(ans,now-(sum[j]-sum[i]));
		}
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 19840
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int x = scan.nextInt(),y = scan.nextInt();
		if(n<=k){
			System.out.println(x*n);
		} else {
			System.out.println(x*k+y*(n-k));
		}
 	}

}

Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC085A_cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var diaryDate = Console.ReadLine();
            var updatedDiaryDate = diaryDate.Replace("2017/01/", "2018/01/");
            Console.WriteLine(updatedDiaryDate);
        }
    }
}


Measured memory_bytes: 13140
/*
 * 高橋君は、N 枚のカードを持っています。 i (1≤i≤N) 番目のカードには、整数 xi が書かれています。
 * 高橋君は、これらのカードの中から 1 枚以上を選び、 選んだカードに書かれた整数の平均をちょうど A にしたいと考えています。 そのようなカードの選び方が何通りあるか求めてください。
 */

import java.util.*;
	public class Main{
		public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            // 入力
            int n = Integer.parseInt(sc.next());
            int a = Integer.parseInt(sc.next());
            int[] nums = new int[n];
            int max = 1;

            for(int i=0; i<n; i++){
            	nums[i] = Integer.parseInt(sc.next());
            	if(max<nums[i]){
            		max = nums[i];
            	}
            }
            
            // a番目のカードまでのb枚を使って和をcにするのが何通りあるか = dp[a][b][c]
            long[][][] dp = new long[n+1][n+1][n*max+1];
            
            for(int i=0; i<n+1; i++){
            	for(int j=0; j<n*max+1; j++){
            		dp[0][i][j] = 0;
            		dp[i][0][j] = 0;
            	}
            }
            for(int i=0; i<n+1; i++){
            	dp[i][0][0] = 1;
            }
            
            for(int k=0; k<n*max+1; k++){
            	for(int j=1; j<n+1; j++){
            		for(int i=1; i<n+1; i++){
            			if(i<j){
            				dp[i][j][k] = 0;
            			}else{
            				dp[i][j][k] = dp[i-1][j][k];
            				if(k-nums[i-1] >= 0){
            					dp[i][j][k] += dp[i-1][j-1][k-nums[i-1]];
            				}
            			}
            		}
            	}
            }
            
            long ret = 0;
            
            for(int i=1; i<n+1 && i*a<n*max+1; i++){
            	ret += dp[n][i][i*a];
            }
            
            // 出力
            System.out.println(ret);

            sc.close();
        }
    }
	

Measured memory_bytes: 86868
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int a,b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    auto c = [](bool b) { return (b ? 'W' : 'S'); };

    auto f = [&](char c1, char c2, char c3, char c4) {
        string ans = "";
        char next  = 'A';
        char last;
        for (auto e : s) {
            if (e == 'o' && next == 'A') {
                ans.push_back(c1);
                next = c2;
                if (c1 == 'S') last = c2;
                else
                    last = (c2 == 'S' ? 'W' : 'S');
            } else if (e == 'x' && next == 'A') {
                ans.push_back(c3);
                next = c4;
                if (c3 == 'S') last = (c4 == 'S' ? 'W' : 'S');
                else
                    last = (c4 == 'S' ? 'S' : 'W');
            } else if (e == 'o' && next == 'S') {
                ans.push_back(next);
                next = (ans[ans.size() - 2] == 'S' ? 'S' : 'W');
            } else if (e == 'x' && next == 'S') {
                ans.push_back(next);
                next = (ans[ans.size() - 2] == 'S' ? 'W' : 'S');
            } else if (e == 'o' && next == 'W') {
                ans.push_back(next);
                next = (ans[ans.size() - 2] == 'S' ? 'W' : 'S');
            } else if (e == 'x' && next == 'W') {
                ans.push_back(next);
                next = (ans[ans.size() - 2] == 'S' ? 'S' : 'W');
            }
        };
        if (next == ans[0] && last == ans[ans.size() - 1]) {
            cout << ans << '\n';
            exit(0);
        }
    };

    for (int i = 0; i < (1 << 4); ++i) {
        char c1 = c(i & (1 << 0));
        char c2 = c(i & (1 << 1));
        char c3 = c(i & (1 << 2));
        char c4 = c(i & (1 << 3));
        f(c1, c2, c3, c4);
    }
    cout << "-1" << '\n';
}


Measured memory_bytes: 3844