akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = a; i <= b; ++i)
#define ll long long
#define eb emplace_back
#define all(c) (c).begin(), (c).end()
#define vi vector<int>

int main() {
	int n, d;
	int x[1000];
	int y[1000];
	vector<bool>ans;
	cin >> n >> d;
	rep(i,n){
		cin >> x[i] >> y[i];
	}
	two_sat a(n);

	rep(i, n) {
		rep(j, i) {
			if (abs(x[i] - x[j]) < d)a.add_clause(i, 1, j, 1);
			if (abs(x[i] - y[j]) < d)a.add_clause(i, 1, j, 0);
			if (abs(y[i] - x[j]) < d)a.add_clause(i, 0, j, 1);
			if (abs(y[i] - y[j]) < d)a.add_clause(i, 0, j, 0);
		}
	}

	if (a.satisfiable()) {
		cout << "Yes" << endl;
		ans = a.answer();
		rep(i, n) {
			if (ans[i])cout << y[i] << endl;
			else cout << x[i] << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int d = sc.nextInt();

            if ( Math.abs(a - c) <= d || Math.abs(a - b) <= d && Math.abs(b - c) <= d ) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

vector<int> ans;

int func(ll N){
    if(N<=26){
        ans.push_back(N);
        return 0;
    }
    ans.push_back(N%26);
    N--;
    N /= 26;
    return func(N);
}

int main(){
    ll N;
    string moji = "abcdefghijklmnopqrstuvwxyz";
    cin >> N;
    func(N);
    reverse(all(ans));
    for(auto aaa: ans){
        if(aaa==0){
            cout << "z";
            continue;
        }
        cout << moji[aaa-1];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <vector>
using namespace std;
#define pb push_back
const int maxn = 100001;
int N,M,vis[maxn]; vector<int> adj[maxn],adj2[maxn];
bool dfs(int cur,int par) {
    vis[cur] = 1;
    for (int nxt : adj[cur]) {
        if (!vis[nxt]) {
            if (dfs(nxt,cur)) adj2[nxt].pb(cur);
            else adj2[cur].pb(nxt);
        }
        else if (nxt != par && vis[nxt] == 1) adj2[cur].pb(nxt);
    }
    vis[cur] = 2;
    return (int)adj2[cur].size()&1;
}
int main() {
    scanf("%d%d",&N,&M);
    for (int i = 0,A,B;i < M;i++) scanf("%d%d",&A,&B),adj[A].pb(B),adj[B].pb(A);
    if (M&1) return printf("-1\n"),0;
    dfs(1,0); for (int i = 1;i <= N;i++) for (int j : adj2[i]) printf("%d %d\n",i,j);
}


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

int main() {
    ll n, k;
    cin >> n >> k;

    cout << min(n % k, k - n % k) << endl;
    return 0;
}


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

int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    
    int m = s1.length();
    int n = s2.length();
    
    int dp[m+1][n+1];
    for(int i=0;i<=m;i++)
        dp[i][0] = 0 ;
    for(int i=0;i<=n;i++)
        dp[0][i] = 0;
        
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(s1[i-1]==s2[j-1])
                dp[i][j] = 1+dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string res;
    int i=m,j=n;
    
    while(i>0 && j>0)
    {
        if(s1[i-1]==s2[j-1])
        {
            res+=s1[i-1];
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j] > dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    reverse(res.begin(),res.end());
    cout << res << "\n";
}

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

 using namespace std;

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

   vector<tuple<string, int, int>> p(N);

   for (int i = 0; i < N; i++) {
     string tmp_s;
     int tmp_p;
     cin >> tmp_s >> tmp_p;
     p.at(i) = make_tuple(tmp_s, -tmp_p, i);
   }

   sort(p.begin(), p.end());

   for (int i = 0; i < N; i++) {
     cout << get<2>(p.at(i)) + 1 << endl;
   }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N,M;
int G[15][15];
int dp[1<<15][15];

int latte[1<<15];

signed main(){
    cin>>N>>M;
    int ei=0;
    rep(i,M){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[a][b]=G[b][a]=c;
        ei+=c;
    }

    rep(i,1<<N){
        rep(j,N)for(int k=j+1;k<N;k++){
            if(!(i>>j&1))continue;
            if(!(i>>k&1))continue;
            latte[i]+=G[j][k];
        }
    }

    fill_n(*dp,(1<<15)*15,-INF);
    rep(i,1<<N)if(i&1)dp[i][0]=latte[i];

    rep(i,1<<N){
        rep(j,N){
            if(dp[i][j]==-INF)continue;
            int sup=(~i)&((1<<N)-1);
            int sub=sup;
            do{
                rep(k,N){
                    if(!(sub>>k&1))continue;
                    if(G[j][k]==0)continue;
                    chmax(dp[i|sub][k],dp[i][j]+G[j][k]+latte[sub]);
                }
                sub=(sub-1)&sup;
            }while(sub!=sup);
        }
    }

    cout<<ei-dp[(1<<N)-1][N-1]<<endl;
    return 0;
}


Measured memory_bytes: 4352
package main

import "fmt"

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

	ctLimit := 0
	for i := range as {
		if bs[i] > as[i] {
			ctLimit += (bs[i] - as[i]) / 2
		}
	}

	ctRequire := 0
	for i := range bs {
		if as[i] > bs[i] {
			ctRequire += as[i] - bs[i]
		}
	}

	if ctRequire <= ctLimit {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,W,H; cin >> N >> W >> H;
    vector<int> imosx(W+1),imosy(H+1);
    for (int i=0;i<N;++i){
        int x,y,w; cin >> x >> y >> w;
        ++imosx[max(x-w,0)]; --imosx[min(x+w,W)];
        ++imosy[max(y-w,0)]; --imosy[min(y+w,H)];
    }
    int okx=1,oky=1;
    for (int i=0;i<W;++i){
        if (i) imosx[i]+=imosx[i-1];
        if (!imosx[i]) okx=0;
    }
    for (int i=0;i<H;++i){
        if (i) imosy[i]+=imosy[i-1];
        if (!imosy[i]) oky=0;
    }
    cout << (okx||oky?"Yes":"No") << '\n';
}


Measured memory_bytes: 3624
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n a b
 */
int n,a,b;

int main(){
  cin>>n>>a>>b;
  cout<< min(a,b) << " " << max(a+b-n,0)<<endl;

  return 0;
}


Measured memory_bytes: 256
fn main() {
    proconio::input! {
        h: usize,
        w: usize,
        m: usize,
        hws: [(usize, usize); m],
    }
    let hws = hws
        .into_iter()
        .map(|(h, w)| (h - 1, w - 1))
        .collect::<std::collections::HashSet<_>>();
    let mut h_boms = vec![0usize; h];
    let mut w_boms = vec![0usize; w];
    for (h, w) in &hws {
        h_boms[*h] += 1;
        w_boms[*w] += 1;
    }
    let hnum = h_boms.iter().max().unwrap();
    let wnum = w_boms.iter().max().unwrap();
    let max_boms_hs = h_boms
        .iter()
        .enumerate()
        .filter(|x| x.1 == hnum)
        .map(|x| x.0)
        .collect::<Vec<_>>();
    let max_boms_ws = w_boms
        .iter()
        .enumerate()
        .filter(|x| x.1 == wnum)
        .map(|x| x.0)
        .collect::<Vec<_>>();
    for mh in &max_boms_hs {
        for mw in &max_boms_ws {
            if !hws.contains(&(*mh, *mw)) {
                let ans = hnum + wnum;
                println!("{}", ans);
                return;
            }
        }
    }
    let ans = hnum + wnum - 1;
    println!("{}", ans);
}


Measured memory_bytes: 24052
#include<iostream>
using namespace std;
int main()
{
	int n;
	int a,sw[2000][10];
	int omta,omsi,omtn,omcl;
	int i;
	int f;
	cin >> n;
	while(n)
	{
		f=1;
		for(i=1;i<=n;i++)
		{
			cin >> sw[i][0] >> sw[i][1] >> sw[i][2] >> sw[i][3];
			sw[i][4]=sw[i][1]*4+sw[i][2]*9+sw[i][3]*4;
		}
		cin >> omta >> omsi>> omtn >> omcl;
		for(i=1;i<=n;i++)
		{
			if( omta < sw[i][1] )
			{
				continue;
			}
			if( omsi < sw[i][2] )
			{
				continue;
			}
			if( omtn < sw[i][3] )
			{
					continue;
			}
			if( omcl < sw[i][4] )
			{
				continue;
			}
			f=0;
			cout << sw[i][0] << endl;
		}
		if(f) cout << "NA\n";
		cin >> n;
	}
	return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define maxn 0x3f3f3f3f
using namespace std;
typedef long long ll; 
int main()
{
	std::ios::sync_with_stdio(false);
	char ch[100];
	scanf("%s",&ch);
	for(int i=0;i<3;i++) cout<<ch[i];
	return 0;
 } 

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v)                                                            \
  do {                                                                         \
    x = max(x, v);                                                             \
  } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  string s;
  cin >> s;
  cout << (char)(s[0] + 1) << endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)1e3+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        ll a,v,w,b,t;
        cin>>a>>v>>b>>w>>t;
        ll dis=abs(a-b);
        ll t1=t*v;
        ll t2=t*w;
        if(dis+t2<=t1){
                cout<<"YES\n";
        }else{
                cout<<"NO\n";
        }
        
}   
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

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

using namespace std;

int main(int argc, const char *argv[])
{
    int n, x, curMin = INT_MAX, cnt = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        curMin = min(x, curMin);
        if (x == curMin)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n=int(input())\n"
"a=list(map(int,input().split()))\n"
"b=max(a)\n"
"c=b\n"
"d=0\n"
"for i in a:\n"
"  if c>=abs(b/2-i):c=abs(b/2-i);d=i\n"
"print(b,d)\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 14656
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;
ll a[N];
ll ps[3][N];
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    string t = "RGB";
    for (int i = 1; i <= n; i ++) {
    	if (s[i - 1] == 'G') a[i] = 1;
    	if (s[i - 1] == 'B') a[i] = 2;
	}
	for (int k = 0; k < 3; k ++) {
		for (int i = 1; i <= n; i ++) {
			ps[k][i] = ps[k][i - 1] + (a[i] == k);
		}
	}
	for (int i = 1; i <= n; i ++) {
		for (int j = i + 2; j <= n; j ++)  {
			if (a[i] == a[j]) continue;
			ll res = 3 - a[i] - a[j];
			ll t =  (ps[res][j - 1] - ps[res][i]);
			ans += t;
			ll x=  j - i;
			if (x & 1) continue;
			x = (i + j) / 2;
			if (a[x] != a[i] && a[x] != a[j] ) ans --;
		}
	}
	cout << ans;
    return (0);
}

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

int main() {
  int n;
  // 入力
  cin >> n;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  // aから順に全部の文字列に共通してある個数を数えて、それを結合したものが答え
  string ans = "";
  for (char c = 'a'; c <= 'z'; c++) {
    int mini = 100;
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if (s[i][j] == c) cnt++;
      }
      mini = min(mini, cnt);
    }
    // 共通する個数分文字を後ろに追加（後ろに追加することで自然に辞書順になる）
    for (int i = 0; i < mini; i++) {
      ans += c;
    }
  }
  // 解答
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
    string n;
    //n = "1117";

    cin >> n;

    if((n[0] == n[1] && n[1] == n[2] && n[0] == n[2]) || (n[1] == n[2] && n[1] == n[3] && n[2] == n[3]))cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
using coord = pair<int, int>;

int dh[4] = {0, 1, 0, -1};
int dw[4] = {1, 0, -1, 0};

int H, W;

int bfs(int h, int w, vector<string> S) {
    int ret = 0;
    vector<vector<int>> visited(H, vector<int>(W, -1));
    queue<coord> q;
    q.emplace(h, w);
    visited[h][w] = 0;
    while (!q.empty()) {
        int h = q.front().first;
        int w = q.front().second;
        q.pop();

        for (int i = 0; i < 4; i++) {
            if (h + dh[i] < 0 || h + dh[i] >= H || w + dw[i] < 0 ||
                w + dw[i] >= W) {
                continue;
            }
            if (visited[h + dh[i]][w + dw[i]] != -1 ||
                S[h + dh[i]][w + dw[i]] == '#') {
                continue;
            }
            q.emplace(h + dh[i], w + dw[i]);
            visited[h + dh[i]][w + dw[i]] = visited[h][w] + 1;
            if (visited[h + dh[i]][w + dw[i]] > ret) {
                ret = visited[h + dh[i]][w + dw[i]];
            }
        }
    }
    return ret;
}

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

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

    int output = 0;
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            int ret = 0;
            if (S[h][w] == '.') {
                ret = bfs(h, w, S);
            }
            if (ret > output) {
                output = ret;
            }
        }
    }

    cout << output << endl;

    return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int r, d, x;
	cin >> r >> d >> x;
	vector<int> X(2020);
	X[2000] = x;
	rep(i,10){
		X[2000+i+1] = r*X[2000+i] - d;
		cout << X[2000+i+1] << endl;
	}
}


Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;
    ll H, W;
    cin >> H >> W;

    vector<string> S(H);
    rep(i, H) cin >> S[i];

    vector<vector<ll>> cntX(H, vector<ll>(W, 0));
    vector<vector<ll>> cntY(H, vector<ll>(W, 0));

    rep(i, H) {
        ll cnt = 0;
        rep(j, W) {
            if (S[i][j] == '#')
                cnt = 0;
            else
                cnt++;
            cntX[i][j] = cnt;
        }
    }

    repr(i, H - 1) {
        ll max_cnt = 0;
        repr(j, W - 1) {
            if (S[i][j] == '#')
                max_cnt = 0;
            else
                chmax(max_cnt, cntX[i][j]);
            cntX[i][j] = max_cnt;
        }
    }

    // rep(i, H) {
    //     rep(j, W) { cout << cntX[i][j] << " "; }
    //     cout << endl;
    // }

    rep(i, W) {
        ll cnt = 0;
        rep(j, H) {
            if (S[j][i] == '#')
                cnt = 0;
            else
                cnt++;
            cntY[j][i] = cnt;
        }
    }

    repr(i, W - 1) {
        ll max_cnt = 0;
        repr(j, H - 1) {
            if (S[j][i] == '#')
                max_cnt = 0;
            else
                chmax(max_cnt, cntY[j][i]);
            cntY[j][i] = max_cnt;
        }
    }

    // cout << "---" << endl;
    // rep(i, H) {
    //     rep(j, W) { cout << cntY[i][j] << " "; }
    //     cout << endl;
    // }

    ll ans = 0;
    rep(i, H) {
        rep(j, W) { chmax(ans, cntX[i][j] + cntY[i][j] - 1); }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 70248
def main():
    R, G, B, N = [int(x) for x in input().split()]

    ct = 0
    for r in range(N + 1):
        for g in range(N + 1):
            b = (N-R*r-G*g) / B
            if b < 0: break
            if (b % 1) == 0:
                ct += 1

    print(ct)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int K, S;
  cin >> K >> S;
  int X, Y, Z;
  int ans = 0;
  for (X = 0; X <= K; ++X) {
    for (Y = 0; Y <= K; ++Y) {
      int rest = S - X - Y;
      if (0 <= rest and rest <= K) ans += 1;
    }
  }
  cout << ans << endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);

	int n, m;
	cin >> n >> m;

	vector<int> adj[n+1];
	int indeg[n+1];
	memset(indeg, 0, sizeof indeg);
	For(i,m) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		indeg[b]++;
	}

	queue<int> bfs;
	FOR(i,1,n) {
		if (indeg[i] == 0) {
			bfs.push(i);
		}
	}

	int len[n+1];
	memset(len, 0, sizeof len);
	while (!bfs.empty()) {
		int u = bfs.front();
		bfs.pop();
		for (int v : adj[u]) {
			len[v] = max(len[v], len[u] + 1);
			if (--indeg[v] == 0) {
				bfs.push(v);
			}
		}
	}

	int ans = 0;
	FOR(i,1,n) {
		ans = max(ans, len[i]);
	}
	cout << ans << nl;

	return 0;
}


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

int a[20];

int main()
{
    int n, k;
    cin >> n >> k;
    rep(i,n) cin >> a[i];

    ll ans = ll(1e18)+1;
    rep(bit,1<<n) {
        ll tot = 0;
        int maxv = 0;
        int visible = 0;
        rep(i,n) {
            if (maxv < a[i]) {
                visible++;
                maxv = a[i];
            } else if (bit>>i&1) {
                tot += (maxv - a[i]) + 1;
                visible++;
                maxv++;
            }
        }
        if (visible >= k) ans = min(ans, tot); 
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int cnt[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[100010];
    rep(i, N) cin >> a[i];
    rep(i, N) cnt[a[i]]++;
    int ans = 0;
    rep(i, 100010) if(cnt[i] > 0) ans++;
    int k = 0;
    rep(i, 100010) if(cnt[i] > 1) k += cnt[i] - 1;
    cout << ans - k % 2 << endl;
    


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
bool in_range(int a, int b, int x) {
  if(a <= x && x <= b) {
    return 1;
  }
  else {
    return 0;
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  int L_max = 1;
  int R_min = N;
  for(int i = 0; i < M; i++) {
    int L, R;
    cin >> L >> R;
    if(L > L_max) {
      L_max = L;
    }
    if(R < R_min) {
      R_min = R;
    }
  }
  int ans = 0;
  for(int i = 1; i <= N; i++) {
    if(in_range(L_max, R_min, i)) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define Rep(i, s, n) for (int i = (int)s; i < (int)n; i++)
typedef long long ll;

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

    int n, d;
    cin >> n >> d;
    cout << ceil((double)n / (2*d+ 1)) << endl;
}

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

int main(){
     // N:スイッチの数　M:電球の数
     int N, M;
     cin >> N >> M;
  
  //各スイッチがどの電球とつながっているか
     vector<int>a(N);
     for(int i = 0; i < M; i++){  
          int k;//k:各電球がスイッチにつながってる数
          cin >> k; 
          for(int j = 0; j < k; j++){
             int s; // s:スイッチNo
             cin >> s;
             s--; // zero based
             a.at(s) |= 1 << i; //ここでのiは電球のNo
          }
     }
  
  
    int P = 0; //　Pに１番下段の数字（点灯条件）を2進数でいれる
    for(int i = 0; i < M; i++){ 
         int x;
         cin >> x;
         P |= x << i;
    }

    int ans = 0; 
     for(int s = 0; s < (1 << N); s++){ //スイッチの押すパターンを総当たりする 
          int t = 0;
          for(int i = 0; i < N; i++){ 
               if(s >> i & 1) t ^= a.at(i);
          }
          if(t == P) ans++;
     }

cout << ans << endl;
}

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

ll N, A[MAXN], B[MAXN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> N;
    for (ll i = 1; i <= N; i++) cin >> A[i];
    for (ll i = 1; i <= N; i++) cin >> B[i];
    
    ll ans = 0;
    ll kurang = 0;
    priority_queue<ll> pq;
    for (ll i = 1; i <= N; i++) {
        if (A[i] < B[i]) {
            ans++;
            kurang += B[i]-A[i];
        } else {
            pq.push(A[i]-B[i]);
        }
    }
    
    while (kurang > 0) {
        if (pq.empty()) {
            cout << "-1\n";
            return 0;
        }
        ll now = pq.top(); pq.pop();
        kurang -= now;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2936
#include <stdio.h>

double min(double a, double b){return (a<b)?a:b;}
//0.5刻み
int N;
double sim[100*200*2+1]; //sim[0]: start時の速度
double limit[100*200*2+1]; //sim[0]: start時の速度

int t[101],v[101];
//t[0] = 0, t[i]～t[i+1]の区間でv[i]の速度制限
int main(){
        scanf("%d",&N);

        int tmp;
        t[0] = 0;
        for(int i = 1; i <= N; i++){
                scanf("%d",&tmp);
                t[i] = t[i-1]+tmp;
        }
        for(int i = 0; i < N; i++) scanf("%d",v+i);
        int tsum=t[N];
        v[N]=0;

        for(int i = 0; i < N; i++){
                for(int j = t[i]; j < t[i+1]; j++){
                        limit[2*j + 1]=v[i];
                        limit[2*j + 2]=v[i];
                }
        }

        sim[0] = 0;
        for(int x = 1; x <= tsum*2; x++){
                sim[x] = sim[x-1]+0.5;
                sim[x] = min(limit[x],sim[x]);
                for(int i = 0; i <= N; i++){
                        if(2*t[i]>=x){
                                sim[x] = min(sim[x], v[i]+0.5*(2*t[i]-x));
                        }
                }
        }
#if 0
        printf("tsum=%d\n",tsum);
        puts("t[i]");
        for(int i = 0; i <= N ; i++) printf("%d,",t[i]);
        puts("");
        puts("v[i]");
        for(int i = 0; i <= N; i++) printf("%d,",v[i]);
        puts("");
        puts("sim");
        for(int i = 0; i <= 2*tsum; i++) printf("(%d,%f)\n",i,sim[i]);
        puts("");
        puts("limit");
        for(int i = 0; i <= 2*tsum; i++) printf("(%d,%f)\n,",i,limit[i]);
        puts("");
#endif
        double space = 0;
        for(int i = 1; i <= 2*tsum; i++){
                space += (sim[i-1]+sim[i])*0.5/2.0;
        }
        printf("%f\n",space);
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
struct rec {
	int a,b,d;
};
int s[N],c[N],n,h;
rec a[N];
priority_queue<pair<int,int> > dui1,dui2;
bool cmp(const rec &a, const rec &b){
	return a.d > b.d;
}
int main(){
	scanf("%d%d",&n,&h);
	for (int i = 1; i <= n; i++){
		scanf("%d%d",&a[i].a,&a[i].b);
		a[i].d = a[i].a - a[i].b;
	}
	for (int i = 1; i <= n; i++)
		scanf("%d",&c[i]);
	s[0] = 0;
	for (int i = 1; i <= n; i++)
		s[i] = s[i - 1] + c[i];
	sort(a + 1,a + n + 1,cmp);
//	for (int i = 1; i <= n; i++)
//		printf("%d\n",a[i].d);
//	printf("!!!!\n");
	int len = 1;
	int p = 1;
	int s = 0;
	int ss = a[1].d;
	dui1.push(make_pair(a[1].b,1));
	for (int i = 2; i <= n; i++)
		dui2.push(make_pair(a[i].a,i));
//	printf("!!!!\n");
	while (len <= n){
		if (s > 0 || len == 1){
//			printf("!%d %d %d\n",len,p,s);
			while (! dui1.empty())
				if (dui1.top().second < p)
					dui1.pop();
				else break;
			if ((! dui1.empty()))
				if (dui1.top().first + ss >= h)
					break;
//			printf("!%d\n",len);
			while (! dui2.empty())
				if (dui2.top().second <= len)
					dui2.pop();
				else break;
			if ((! dui2.empty()))
				if (dui2.top().first - a[len].d + ss >= h)
					break;
		}
//		printf("!%d\n",len);
		len++;
		dui1.push(make_pair(a[len].b,len));
//		printf("!! %d\n",s);
		s += a[len].d - c[len - 1];
//		printf("!! %d %d %d %d\n",s,a[len].d,len,c[len - 1]);
		ss += a[len].d;
		while (s <= 0 && p < len){
			s += a[p].d - a[p + 1].d;
			p++;
		}
	}
//	printf("!!!!\n");
	if (len <= n) printf("%d\n",len);
	else printf("-1\n");
}

Measured memory_bytes: 7184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
namespace IO
{
	template <typename T> inline void read(T &x)
	{
		int f = 1; x = 0; char c = getchar();
		for (; !isdigit(c); c = getchar()) if (c == '-') f = -1;
		for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
		x *= f;
	}

	template <typename T> inline void chkmax(T &x, T y) { x = x > y ? x : y; }
	template <typename T> inline void chkmin(T &x, T y) { x = x < y ? x : y; }

	template <typename T> inline void write(T x)
	{
		if (x < 0) putchar('-'), x = -x;
		if (x > 9) write(x / 10);
		putchar(x % 10 + '0');
	}
	template <typename T> inline void writesp(T x) { write(x); putchar(' '); }
	template <typename T> inline void writeln(T x) { write(x); putchar('\n'); }
}
using namespace IO;
const int N = 1e5 + 5;
int n, q, a[N];
int cnt[N];
int main(){
	read(n);
	ll sum = 0; 
	for (int i = 1; i <= n; i++) {
		read(a[i]);
		sum += a[i];
		cnt[a[i]]++;
	}
	
	read(q);
	int b, c;
	for (int i = 1; i <= q; i++)
	{
		read(b); read(c);
		sum += cnt[b] * (c - b);
		cnt[c] += cnt[b];
		cnt[b] = 0;
		writeln(sum);
	}
  return 0;
}

Measured memory_bytes: 4404
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int f[333][333][333];
int m,n,l,r,x,ans,size;
vector < pair < int , int > > rer[333];
inline void update(int &x,int y){ x=((long long)1*x+y+mod)%mod; }
int main()
{
    scanf("%d%d",&n,&m);
    for(register int i=1;i<=m;++i)
    {
        scanf("%d%d%d",&l,&r,&x);
        rer[r].push_back(make_pair(l,x));
    }
    f[1][0][0]=1;
    for(register int i=1;i<=n;++i)
    {
        size=rer[i].size();
        for(register int j=0;j<size;++j)
        {
            l=rer[i][j].first;x=rer[i][j].second;
            for(register int k=0;k<i;++k)
                for(register int p=0;p<=max(0,k-1);++p)
                {
                    if(x==1) { if(l<=k) f[i][k][p]=0; }
                    else if(x==2) { if(k<l||l<=p) f[i][k][p]=0; }
                    else { if(p<l) f[i][k][p]=0; }
                }
        }
        if(i==n) break ;
        for(register int j=0;j<i;++j)
            for(register int k=0;k<=max(0,j-1);++k)
                if(!f[i][j][k]) continue ;
                else
                {
                    update(f[i+1][j][k],f[i][j][k]);
                    update(f[i+1][i][k],f[i][j][k]);
                    update(f[i+1][i][j],f[i][j][k]);
                }
    }
    for(register int j=0;j<n;++j)
        for(register int k=0;k<=max(0,j-1);++k)
            update(ans,f[n][j][k]);
    ans=((long long)3*ans)%mod;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 129280
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    rep(i,n) {
        ll l = (ll)i*c-(ll)(n-1-i)*d;
        ll r = (ll)i*d-(ll)(n-1-i)*c;
        if(l <= b-a and b-a <= r) {
            YES(1);
            return 0;
        }
    }
    YES(0);
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N; string S; cin >> N >> S;
  int64_t ans, r{}, g{}, b{};
  for (auto c : S) {if (c == 'R') ++r; if (c == 'G') ++g; if (c == 'B') ++b;} ans = r * g * b;
  for (int d = 1; d < N; ++d) for (int i = 0; i < N - 2 * d; ++i)
    ans -= (S[i] != S[i + d] and S[i + d] != S[i + 2 * d] and S[i + 2 * d] != S[i]);
  cout << ans << endl;}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define i64 long long
using namespace std;
bool solve(string s){
	int n = s.size();
	int cntC=0, cnt_lowercase=0;
	bool validC = false;
	if(s[0]!='A') return false;
	for(int i=0;i<n;i++){
		if(s[i]=='C') {
			cntC++;
			if(i>=2 and i<n-1) validC = true;
		}
		else if(s[i]>='a' and s[i]<='z') cnt_lowercase++;
	}
	if(cntC==1 and validC and cnt_lowercase==n-2) return true;
	else return false;
}
int main() {
	string s;
	cin>>s;
	printf("%s\n", solve(s) ? "AC" : "WA");
	return 0;
}

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

#define mx 15
#define ll long long

vector<pair<int,int>>g[mx];

int n,m,k,ii;

void solve()
{
   scanf("%d",&n);
   for(int i=0;i<n;i++)
   {
       int x;
       scanf("%d",&x);
       for(int j=0;j<x;j++)
       {
           int u,v;
           scanf("%d%d",&u,&v);
           g[i].push_back({--u,v});
       }
   }
   int re=0;
   for(int i=0;i<(1<<n);i++)
   {
       bool f=true;
       for(int j=0;j<n;j++)
       {
           if(i & (1<<j))
           {
               for(auto it:g[j])
               {
                  // cout<<(i & (1<<it.first))<<endl;
                   if(it.second ^bool(i & (1<<it.first)))
                   {
                       f=false;
                       break;
                   }
               }
           }
           if(!f)break;
       }
       if(f)
       {
           re=max(re,__builtin_popcount(i));
       }
   }

   printf("%d\n",re);
}

int main()
{
   //freopen("in.txt","r",stdin);
   //freopen("out.txt","w",stdout);
   int t=1;
   //scanf("%d",&t);
   while(t--)solve();
   return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <climits>
#include <cmath>

using namespace std;

int main()
{
    int a, b, c, x, y; cin >> a >> b >> c >> x >> y;

    int price = INT_MAX;

    for (int i = 0; i <= 100000; i++) {
        price = min(price, (i * 2 * c + max(0, x - i) * a + max(0, y - i) * b));
    }

    cout << price << endl;
    return 0;
}

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

int main(){
  int a, b, c, x;
  cin>>a>>b>>c>>x;
  int cnt=0;
  for(int i=0;i<=a;++i){
    for(int j=0;j<=b;++j){
      for(int k=0;k<=c;++k){
        if(500*i+100*j+50*k==x) ++cnt;
      }
    }
  }
  
  cout<<cnt<<endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = ((int)a) - 1; i >= ((int)a); --i)
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

void dump_impl(string s) {}
template <class H, class... T>
void dump_impl(string s, H head, T... tail) {
    int p = 0;
    rep(i, 0, sz(s)) {
        char x = s[i];
        if (p == 0 && x == ',') {
            cerr << "=" << head << ", ";
            dump_impl(s.substr(i + 1), tail...);
            return;
        } else {
            cerr << x;
            if (x == '(') p++;
            if (x == ')') p--;
        }
    }
}
#ifdef LOCAL
#define dump(...) do { cerr << "\x1b[33;1m"; dump_impl(#__VA_ARGS__ ",", __VA_ARGS__); cerr << "\x1b[0m" << endl; } while (0) 
#else
#define dump(...)
#endif

constexpr int DY[8] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr int DX[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int decode(string s) {
    string sep = "mcxi";
    vi mul = {1000, 100, 10, 1};
    int ret = 0;
    string tmp;
    rep(i, 0, sz(s)) {
        int idx = sep.find(s[i]);
        if (idx != string::npos) {
            if (tmp.empty()) {
                ret += mul[idx];
            } else {
                ret += mul[idx] * stoi(tmp);
            }
            tmp.clear();
        } else {
            tmp += s[i];
        }
    }
    return ret;
}
string encode(int x) {
    dump(x);
    int d = x % 10;
    x /= 10;
    int c = x % 10;
    x /= 10;
    int b = x % 10;
    x /= 10;
    int a = x % 10;
    x /= 10;
    dump(a, b, c, d);
    
    string ret;
    if (a > 1) ret += to_string(a) + "m";
    if (a == 1) ret += "m";
    if (b > 1) ret += to_string(b) + "c";
    if (b == 1) ret += "c";
    if (c > 1) ret += to_string(c) + "x";
    if (c == 1) ret += "x";
    if (d > 1) ret += to_string(d) + "i";
    if (d == 1) ret += "i";
    return ret;
}

void solve() {
    string a, b;
    cin >> a >> b;
    cout << encode(decode(a) + decode(b)) << endl;
}

signed main() {
    int N;
    cin >> N;
    rep(i, 0, N) {
        solve();
    }
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n, m;
li s[11];
li c[11];


int main() {
    cin >> n >> m;
    rep(i, m) {
        cin >> s[i] >> c[i];
    }

    rep(i, 1000) {
        auto is = to_string(i);
        if (is.size() != n) {
            continue;
        }
        bool ok = true;
        rep(j, m) {
            if (is[s[j] - 1] != c[j] + '0') {
                ok = false;
                break;
            }
        }
        if (ok) {
            cout << i << endl;
            return 0;
        }
    }

    puts("-1");

    return 0;
}

Measured memory_bytes: 3628
import sys
S = input()


if S[0] == "A":
    C = S[2:-1]
    count = 0
    for c in C:
        if c == "C":
            count = count + 1
        if count==2:
            print("WA")
            sys.exit()
    if count==0:
        print("WA")
        sys.exit()
    S = S[1:]

    for s in S:
        if (ord("z") >= ord(s) and ord("a") <= ord(s)):
            continue
        elif s=="C":
            continue
        else:
            print("WA")
            sys.exit()
    print("AC")
    sys.exit()
print("WA")


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>

using namespace std;
const long long P = 1000000007;

int main() {
  int n,m;
  cin >> n >> m;
  int a[n],b[n];
  int c[m],d[m];
  for(int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < m; i++) {
    cin >> c[i] >> d[i];
  }
  int point[n];
  for(int i = 0; i < n; i++) {
    int dist = 500000000;
    for(int j = 0; j < m; j++) {
      if(dist > abs(a[i]-c[j])+abs(b[i]-d[j])) {
        dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
        point[i] = j+1;
      }
    }
  }
  for(int i = 0 ; i < n; i++) {
    cout << point[i] << endl;
  }
  return 0;
}

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

using namespace std;
// #define int long long
mt19937 rnd(time(0));
typedef long long ll;
typedef long double ld;

// #define _GLIBCXX_DEBUG
#define f first
#define s second
#define pb push_back
#define pii pair<int, int> 
#define vi vector<int>

void solve(){
	int n;
	cin >> n;
	cout << 1 - (double) (n / 2) / n << endl;
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int t = 1;
	while(t--){
		solve();
	}
	
	return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

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

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

using namespace std;
#define ll long long

int main(){

    string str;

    cin>>str;

    for(int i = 0; i< str.size();i++)
    {
        if(str[i] == '?')
            str[i] = 'D';
    }

    for(int i=0;i<str.size();i++)
        cout<<str[i];
    
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3724
#include <stdio.h>

int main(void) {
   int X;
   scanf("%d",&X);
   switch(X%7){
   case 0:
	   printf("thu\n");break;
   case 1:
	   printf("fri\n");break;
   case 2:
	   printf("sat\n");break;
   case 3:
	   printf("sun\n");break;
   case 4:
	   printf("mon\n");break;
   case 5:
	   printf("tue\n");break;
   case 6:
	   printf("wed\n");break;
   }
   return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxN = 3e3 + 10;

char s[maxN], t[maxN];
int f[maxN][maxN];

void Trace(int i, int j) {
  if (i == 0 || j == 0) return;
  while (i > 1 && f[i][j] == f[i-1][j]) {
    --i;
  }
  while (j > 1 && f[i][j] == f[i][j-1]) {
    --j;
  }
  Trace(i-1, j-1);
  if (s[i] == t[j]) cout << s[i];
}
int main(){
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> s + 1;
  cin >> t + 1;
  int n = strlen(s+1), m = strlen(t+1);
  for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) {
    if (s[i] == t[j]) {
      f[i][j] = f[i-1][j-1] + 1;
    } else {
      f[i][j] = max(f[i-1][j], f[i][j-1]);
    }
  }
  Trace(n, m);
return 0;
}


Measured memory_bytes: 38944
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#define SIZE 305
#define MOD 998244353

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct Rank
{
	struct P
	{
		vector <int> vec;
		int val;
		P(){}
		P(vector <int> vec,int val=0):vec(vec),val(val){}
	};
	vector <P> express[SIZE];
	bool use[SIZE];
	
	void add(vector <int> vec,int n,int v)
	{
		memset(use,false,sizeof(use));
		for(int i=0;i<vec.size();i++)
		{
			use[vec[i]]=true;
		}
		vector <int> ad;
		int c=-1;
		for(int i=0;i<n;i++)
		{
			if(use[i])
			{
				if(c==-1) c=i;
				ad.push_back(1);
			}
			else ad.push_back(0);
		}
		if(c!=-1) express[c].push_back(P(ad,v));
	}
	ll calc(int n)
	{
		ll ret=1;
		for(int i=0;i<n;i++)
		{
			if(express[i].empty())
			{
				ret*=2;
				if(ret>=MOD) ret-=MOD;
			}
			else
			{
				P p=express[i][0];
				for(int j=1;j<express[i].size();j++)
				{
					P q=express[i][j];
					if(q.vec==p.vec)
					{
						if(p.val!=q.val)
						{
							return 0;
						}
						continue;
					}
					int c=-1;
					for(int j=i;j<n;j++)
					{
						q.vec[j]^=p.vec[j];
						if(c==-1&&q.vec[j]==1)
						{
							c=j;
						}
					}
					q.val^=p.val;
					express[c].push_back(q);
				}
			}
		}
		return ret;
	}
}rnk;
int A[SIZE][SIZE];
ll rt[SIZE*2];

void make()
{
	rt[0]=1;
	for(int i=1;i<SIZE*2;i++) rt[i]=rt[i-1]*2LL%MOD;
}
int main()
{
	make();
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
	{
		vector <int> vec;
		for(int j=0;j<m;j++)
		{
			scanf("%d",&A[i][j]);
			if(A[i][j]==1) vec.push_back(j);
		}
		rnk.add(vec,m,0);
	}
	ll rk=rnk.calc(m);
	ll all=rt[n+m];
	all-=rk*rt[n]%MOD;
	if(all<0) all+=MOD;
	if(all%2==1) all+=MOD;
	all/=2;
	printf("%lld\n",all);
	return 0;
}


Measured memory_bytes: 28544