akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n, k;
  cin >> n >> k;
  int h, ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> h;
    if (h >= k) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] input =Console.ReadLine().Split(' ');
      int A=int.Parse(input[0]);
	int B=int.Parse(input[1]);
      int C=int.Parse(input[2]);
    int K=int.Parse(input[3]);
      if(A>=K){
        Console.WriteLine(K);
      }else if((A+B)>=K){
      Console.WriteLine(A);
      }else{
        Console.WriteLine(A-(K-A-B));
      }
  }

}
}


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

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

using namespace std;

int main() {
  int k, s;
  cin >> k >> s;

  int result = 0;
  rep(x, k + 1) {
    rep(y, k + 1) {
      int z = s - x - y;
      if (0 <= z && z <= k) {
        result++;
      }
      if (x + y > s) break;
    }
    if (x > s) break;
  }

  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}

// ***<ここから>****************************************************************



int main(void) {

	int N;
	cin >> N;
	int ans = 0;

	rep(i, N + 1) {
		if (i % 2 == 0) continue;

		int cnt = 0;
		repr(j, 1, N + 1) {
			if (i % j == 0) {
				cnt++;
			}
		}

		if (cnt == 8) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

ll n;

ll dfs(ll x, bool A, bool B, bool C) {
  if (x > n) return 0;
  ll ret = 0;
  if (A && B && C) ret++;
  ret += dfs(x * 10 + 7, true, B, C);
  ret += dfs(x * 10 + 5, A, true, C);
  ret += dfs(x * 10 + 3, A, B, true);
  return ret;
}

int main() {
  cin >> n;
  cout << dfs(0, false, false, false) << endl;
  return 0;
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){

    ll a,b,c;
    cin >> a >> b >> c;

    ll A,B;
    A = 4*a*b;
    B = (c - (a+b));
    if(B < 0){
        cout << "No" << endl;
        return 0;
    }
    B *= B;


    if(B > A){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}  

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

int main(){
    char a,b;
    cin>>a>>b;
    if(a=='H'){
        if(b=='H'){
            cout<<"H"<<endl;
        }
        else{
            cout<<"D"<<endl;
        }
    }
    else{
        if(b=='H'){
            cout<<"D"<<endl;
        }
        else{
            cout<<"H"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int k = scanner.nextInt();
			for (int i = getMin(a, b); i >= 1; i--) {
				if ((0 == (a % i)) && (0 == (b % i))) {
					k--;
					if (0 == k) {
						System.out.println(i);
						break;
					}
				}
			}
		}
	}

	private static int getMin(int a, int b) {
		if (a == b) {
			return a;
		} else if (a > b) {
			if (b > (a - b)) {
				return a - b;
			} else {
				return b;
			}
		} else {
			if (a > (b - a)) {
				return b - a;
			} else {
				return a;
			}
		}
	}
}

Measured memory_bytes: 23636
n = input()

op_cnt = len(n)-1

for i in range(2**op_cnt):
    op = ["-"]*op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt-1-j] = "+"
    op += [""]
            
    formura = ""
    for i,j in zip(n,op):
        formura += i+j
    if eval(formura) == 7:
        print(formura + "=7")
        break

Measured memory_bytes: 8976
#include <cstdio>

using namespace std;

int main()
{
  char input[4];
  int ans = 0;
  for (int i=0; i<4; i++) {
    scanf("%c", &input[i]);
    if(input[i] == '2') {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

using ll = long long;

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int s,w;
	cin>>s>>w;

	if(w>=s)
	{
		cout << "unsafe" << endl;

	}

	else
	{
		cout << "safe" << endl;
	}
}

Measured memory_bytes: 3648
import java.util.*;
public class Main{
	public static void main(String[] args){
		int ans = 0;
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();

		if(x < a){
			System.out.println(0);
		}
		else{
			System.out.println(10);
		}
		
	}
}


Measured memory_bytes: 22100
// abc131_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, K;
    cin >> N >> K;

    int c = (N-1) * (N-2) / 2;
    if (K > c) {
        print(-1);
        return 0;
    }

    int M = N - 1 + c - K;
    print(M);
    REPN(i, 2, N+1){
        print(1, i);
    }
    M -= N-1;

    REPN(i, 2, N){
        REPN(j, i+1, N+1){
            if (M-- > 0){
                print(i, j);
            }
        }
    }


    return 0;
}


Measured memory_bytes: 256
f,g = list(map(int,input().split()))

a = list(map(int,input().split()))

c = 0
p = 1
if a[0] > g:
    c += a[0] - g
    a[0] = g
while p <= f-1:
    if a[p-1] + a[p] > g:
        eat = a[p-1] + a[p] - g
        c += eat
        a[p] -= eat
    p += 1
print(c)


Measured memory_bytes: 14132
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
//#include "atcoder/fenwicktree.hpp"
using namespace std;
//using namespace atcoder;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

template<typename T>
class BIT{
public:
    int n;
    vector<T> bit; // 1-indexed

    BIT():n{0}{}
    BIT(int n_in):n{n_in}{
        bit.assign(n+1,0);
    }

    void init_u(){
        for(int i=1;i<n;i++) bit[i+(i&-i)]+=bit[i];
    }

    void add(int k,T w){
        if(k<=0) return;
        for(int i=k;i<=n;i+=i&-i) bit[i]+=w;
    }

    //(0,k]
    T sum(int k) const{
        T res=0;
        for(int i=k;i>0;i-=i&-i) res+=bit[i];
        return res;
    }

    //(l,r] 累積和区間と同じ
    T secsum(int l,int r) const{
        return sum(r)-sum(l);
    }

    //各要素は非負整数とする
    //w->w+1でupper_bound
    int lower_bound(T w) const{
        if(sum(n)<w) return n+1; //範囲外
        int idx=0,r=1;
        while(r<n) r<<=1;
        for(int len=r;len>0;len>>=1){
            if(idx+len<n && bit[idx+len]<w){
                w-=bit[idx+len];
                idx+=len;
            }
        }
        return idx+1;
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
        
    int n,q; cin>>n>>q;
    BIT<ll> bit{n};
    rep(i,n){
        int a; cin>>a;
        bit.add(i+1,a);
    }
    
    rep(_,q){
        int t,l,r; cin>>t>>l>>r;
        if(t==0){
            bit.add(l+1,r);
        }
        else{
            printf("%lld\n",bit.secsum(l,r));
        }
    }
}


Measured memory_bytes: 8244
#include <stdio.h>

int main(void) {
	int k, a, b;
	
	scanf("%d", &k);
	scanf("%d%d", &a, &b);
	
	int largest = (b / k) * k;
	if (a <= largest) {
		puts("OK");
	} else {
		puts("NG");
	}
	return 0;
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
    
using namespace std;
using ll = long long;
using pii = pair<int, int>;
    
const int oo = 1e9 + 7;
const int mod = 1e9 + 7;
const double PI = acos(-1);

long double f(long double& x){
    return ((x*(x+1))/2.0)/x;
}

int main(){
    cout << fixed << setprecision(10);
    int n, k;
    cin >> n >> k;

    vector <long double> v(n), ps(n+1, 0.0);

    for (auto& x: v) cin >> x, x = f(x);


    long double ans = -1.0;
    for (int i=1; i<=n; i++){
        ps[i] = ps[i-1] + v[i-1];
        if (i >= k) ans = max(ans, ps[i] - ps[i-k]);
    }


    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <climits>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <deque>
#include <list>
#include <map>
#include <set>
using namespace std;

/*** typedef ***/
typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ULL;
typedef pair < int , int > ii;
typedef pair < LL  , LL  > ll;
typedef vector <int>  vint;
typedef vector <bool> vbool;
typedef vector <long> vlong;

/*** define ***/
#define sz(x)			((int)x.size())
#define tin(x)			scanf("%d",&x)
#define all(x)			x.begin(),x.end()
#define Set(b,a)		memset(b,a,sizeof b)
#define print1(x)		printf("Case %d:",x++)
#define tin2(x,y)		scanf("%d%d",&x,&y)
#define tin3(x,y,z)		scanf("%d%d%d",&x,&y,&z)
#define loop(i,i0,in)	for(int i=i0 ; i<in ; i++)
#define rep(i,n)		for(int i=0 ; i<(n) ; i++)
#define _rep(i,n)		for(int i=n-1 ; i>=0 ; i--)
#define _loop(i,in,i0)	for(int i=in-1 ; i>=i0 ; i--)
#define Fore(it, x)		for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
     
int main()  
{  
#ifdef Online_Judge
	freopen("a.in","r",stdin);
#endif
	LL a,b;
	cin >> a >> b;
	cout << a*b << ' ' << (a+b)*2 << endl;
	return 0;
}

Measured memory_bytes: 1156
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		String x = "";
		for(int i=0; i<str.length();i++) {
			x+="x";
		}
		System.out.println(x);
	}
}

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

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    long long int n, a, b, sum, rem;
    cin>>n>>a>>b;
    sum = a+b;
    rem = n%sum;
    long long int ans = a*(n/sum);
    if (rem<a){
        ans+=rem;
    }
    else {
        ans+=a;
    }
    cout<<ans;

}


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

typedef long long ll;

int n;
ll d,x[200005],y[200005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>d;
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        if(x[i]*x[i]+y[i]*y[i]<=d*d)ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6776
#include<bits/stdc++.h>
using namespace std;
const int maxn=2010;
struct node{
	int s,t;
}a[maxn];
int beg[maxn],tto[maxn<<1],nex[maxn<<1],e=1;
void putin(int s,int t){
	tto[++e]=t;
	nex[e]=beg[s];
	beg[s]=e;
}
vector<int> vec[maxn],edg[maxn];
int cnt[maxn];
bool color(int u,int t,int id,int fa){
	if(u==t) return 1;
	for(int i=beg[u];i;i=nex[i]){
		if(tto[i]==fa) continue;
		if(color(tto[i],t,id,u)){
			vec[i>>1].push_back(id);
			edg[id].push_back(i);
			return 1;
		}
	}
	return 0;
}
bool ok[maxn<<1],vis[maxn];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int s,t;
	for(int i=1;i<n;i++){
		scanf("%d%d",&s,&t);
		putin(s,t);
		putin(t,s);
	}
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a[i].s,&a[i].t);
		color(a[i].s,a[i].t,i,-1);
	}
	int ans=0;
	for(int i=1;i<n;i++){
		cnt[i]=vec[i].size();
		ans+=cnt[i]<=2?cnt[i]:2;
	}
	int p;
	bool rev;
	while(1){
		for(p=1;p<n;p++){
			if(cnt[p]==1&&ok[p<<1]!=ok[p<<1|1])
				break;
		}
		if(p==n){
			for(p=1;p<n&&!cnt[p];p++);
			if(p==n) break;
		}
		while(vis[vec[p].back()]) vec[p].pop_back();
		int x=vec[p].back();
		rev=0;
		for(vector<int>::iterator it=edg[x].begin();it!=edg[x].end();it++){
			if((*it)/2==p){
				if(ok[*it]){
					rev=1;
					swap(a[x].s,a[x].t);
				}
				break;
			}
		}
		for(vector<int>::iterator it=edg[x].begin();it!=edg[x].end();it++){
			ok[(*it)^rev]=1;
			cnt[(*it)>>1]--;
		}
		vis[x]=1;
	}
	printf("%d\n",ans);
	for(int i=1;i<=m;i++)
		printf("%d %d\n",a[i].s,a[i].t);
	return 0;
}


Measured memory_bytes: 13824
#include <iostream>
#include <random>
#include <cstring>

using namespace std;

#ifdef LOCAL
#define fre() freopen("in", "r", stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

#define IOS std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

#define repi(a,b) for(int i=a;i<b;i++)
#define repj(a,b) for(int j=a;j<b;j++)
#define mst(a,b) memset(a,b,sizeof(a))

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;


char s[10010];
int main() {
    int n;cin>>n>>s;
    repi(0, strlen(s))
        s[i] = (s[i]-'A'+n)%26+'A';
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())
F = [list(map(int, input().strip().split())) for i in range(N)]
P = [list(map(int, input().strip().split())) for i in range(N)]
maxProfit = -1000000000



for i in range(1,1024):
    openTime = list(map(int, list("{:0>10}".format(bin(i)[2:]))))
    thisProfit = 0
    for n in range(N):
        shopOpneTime = F[n]
        shopProfit = P[n]
        counter = 0
        for j in range(10):
            if((shopOpneTime[j])and(openTime[j])):
                 counter += 1
        thisProfit += shopProfit[counter]
    maxProfit = max(thisProfit, maxProfit)

print(maxProfit)


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

using namespace std;

using LL = long long;
using PII = pair<int, int>;
using ll = long long;
using DBL = double;
using VI = vector<int>;
using VD = vector<DBL>;
using VVI = vector<VI>;
using VVD = vector<VD>;
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define REP(i,n) FOR(i,0,n)
#define SZ(a) ((int)((a).size()))
#define ALL(x) (x).begin(), (x).end()
#define SET(a,v) memset((a), (v), sizeof(a))
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define ST first
#define ND second

#define trace(...) {__f(#__VA_ARGS__, __VA_ARGS__);}
template<typename Arg> void __f(const char* name, Arg&& arg) {
  cerr << name << " = " << arg << std::endl;
} template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1<<" | ";__f(comma+1, args...); }
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds; // OST: find_by_order, order_of_key
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// #pragma GCC optimize("Ofast")
// optimize("unroll-loops")
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// /*** RNGS ***/
// SEED=chrono::steady_clock::now().time_since_epoch().count();
// // or high_resolution_clock
// mt19937 rng(SEED); /*or*/ random_device rd; mt19937 rng(rd());
// uniform_int_distribution<> dis(MIN, MAX);// usage: dis(rng)
// struct chash {int operator()(int x) const {return x^SEED;}};
// gp_hash_table<int,int,chash>m;//use cc if very less updates
// /*** FAST IO ***/
// inline int scan(){ bool y=0; int x=0; char c=getchar_unlocked();
// while(c<'0'||c>'9'){ if(c=='-')y=1; c=getchar_unlocked();} 
// while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar_unlocked();}
// return y?-x:x; }

const int MAXN = 4010;
char ch[MAXN];
int a[MAXN];
int dp[MAXN/2][MAXN/2], dp2[2][MAXN][MAXN/2];
map<pair<char, int>, int> pos;

int cost(char cur, int pos, int k) {
	// trace(cur, pos, k);
	int &y = dp2[cur=='B'][pos][k];
	if(y!=-1) return y;
	if(k == 0) return y = 0;
	return y = (::pos[MP(cur, k)] > pos) + cost(cur, pos, k-1);
}

int calc(int pos, int b, int w) {
	int &y = dp[b][w];
	if(y!=-1) return y;
	if(pos == 0) return y = 0;
	y = INT_MAX;
	if(b) {
		y = min(y, cost('B', ::pos[MP('B', b)], b-1) + cost('W', ::pos[MP('B', b)], w) + calc(pos-1, b-1, w));
	}
	if(w) {
		y = min(y, cost('B', ::pos[MP('W', w)], b) + cost('W', ::pos[MP('W', w)], w-1) + calc(pos-1, b, w-1));
	}
	return y;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	SET(dp, -1);
	SET(dp2, -1);
	int n;
	cin >> n;
	for(int i=1; i<=(n+n); ++i) {
		cin >> ch[i] >> a[i];
		pos[MP(ch[i], a[i])] = i;
	}
	cout << calc(2*n, n, n) << endl;
	return 0;
}

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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

int N;
const int M = 26;
string S;
vector<string> words{"the","this","that"};

int main()
{
	while(getline(cin,S),S != ""){
		N = S.size();
		FOR(i,0,M){
			bool ok = false;
			FOR(j,0,words.size()){
				ok |= S.find(words [j]) != string::npos;
			}
			if(ok){
				cout << S << endl;
				break;
			}
			FOR(j,0,N) if(S [j] >= 'a' && S [j] <= 'z'){
				S [j] = (S [j] + 1 - 'a') % M + 'a';
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2972
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;

int main() {
    string S, T;
    cin >> S >> T;
    bool TorF = true;
    ll N = S.size();
    REP(i, N){
        if(S[i] != T[i])
            TorF = false;
    }

    if(TorF == true && N+1 == T.size()){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: u32 = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

fn solve() {
	let n = read!(usize);
	let x = read!([i64]);
	let mut ans = INF;
	for p in 0..101 {
		let mut sum = 0;
		for i in 0..n {
			sum += (x[i]-p)*(x[i]-p);
		}
		ans.setmin(sum);
	}
	println!("{}", ans);
}

fn run() {
    solve();
}


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

int main(){
  // NとAの読み込み
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  // Aの値がインデックスで、その個数が値
  vector<int64_t> C(N+1);
  for(int i=0;i<N;i++){
    C.at(A.at(i))++;
  }
  // k番目を抜かない全組み合わせMを求める
  int64_t M = 0;
  for(int i=0;i<N+1;i++){
    if(C.at(i) != 0){
      M += C.at(i)*(C.at(i)-1)/2;
    }
  }
  // 出力
  for(int k=0;k<N;k++){
    cout << M - C.at(A.at(k)) + 1 << endl;
  }
  return 0;
}

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

using namespace std;

int Transport(long long int k, vector<int>A)
{
	int x = 1;
	int loop = 0;
	vector<int>B(size(A), 0);
	while (k != 0)
	{
		k--;
		B[x - 1] += 1;
		if (B[x - 1] == 2)loop++;
		if (B[x - 1] == 3)k = k % loop;
		x = A[x - 1];
	}
	return x;
}
int main()
{
	int N, Arrival;
	int i;
	long long int K;

	cin >> N >> K;

	vector<int>A(N);
	for (i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	Arrival = Transport(K, A);
	cout << Arrival;
	return 0;
}

Measured memory_bytes: 5644
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(int i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(int i = 0; i < n; i++)
 
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 
 
int32_t main()
{
    fast_io;
    int n;
    cin>>n;
    
    vii dp(n,vi(3));
    for(int i=0;i<n;i++)
    cin>>dp[i][0]>>dp[i][1]>>dp[i][2];
    for(int i=1;i<n;i++){
        dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]+=max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]+=max(dp[i-1][1],dp[i-1][0]);

    }
    int ans=-1;
    for(int i=0;i<3;i++)ans=max(ans,dp[n-1][i]);
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 8692
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
  cin>>a>>b>>c;
  if(a== b && b == c && a % 2 != 1 ) 
    cout<<"-1";
  else{
    int count=0;
    while(a % 2 ==0 && b % 2 ==0 && c % 2 ==0){
   int d=b/2+c/2,e=c/2+a/2,f=a/2+b/2;
 	a=d;
  	b=e;
  	c=f;
  
  count++;
 	 }
cout<<count;
	}
}

Measured memory_bytes: 3628
let [| n; k |] = stdin.ReadLine().Split(" ") |> Array.map int64

let rec solve k current : int64 = 
  let absVal = abs(k - current) |> int64
  if current > absVal then
    solve k absVal
  else
    current

n % k 
|> int64
|> solve k 
|> string
|> printfn "%s"

Measured memory_bytes: 29608
#include<iostream>
int main(void){
    int input,top,bot;
    std::cin>>input;
    top=input/100;
    bot=input%10;
    if(top==bot){
        std::cout<<"Yes"<<std::endl;
    }else{
        std::cout<<"No"<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a == b)
        cout << a * 2 << endl;
    else
        cout << max(a, b) * 2 - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
double a[20][3],ans=0,p;int n,m,c[20];
using namespace std;
void dfs(int x,int d){
  if(d==m){
    p=0;
    r(i,0,m)r(j,i+1,m)
    p+=pow(a[c[i]][0]-a[c[j]][0],2)+pow(a[c[i]][1]-a[c[j]][1],2)+pow(a[c[i]][2]-a[c[j]][2],2);
    ans=max(ans,p);
    return;
  }
  else if(x==n)return;
  c[d]=x;dfs(x+1,d+1);dfs(x+1,d);
}
int main(){
  cin>>n>>m;
    r(i,0,n)cin>>a[i][0]>>a[i][1]>>a[i][2];
    dfs(0,0);
    printf("%.6f\n",ans);
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
int u[11];
string str;
ll ans=0;
int col[10];
int num[2001];
vector<int> G[51];
vector<int> seq[51];
P rng[51];
int cnt;
bool used[51];
bool flag[51];
int id[20];
int dp[61][1<<10];

P dfs2(int v,int l,int r){
	if(v>=10)seq[cnt].push_back(v-10);
	if(v<=9){
		l=max(v,l);
		r=min(v,r);
	}else{
		if((v-10)%3==0){
			int v2=(v-10)/3;
			r=min(r,0);
		}
		if((v-10)%3==1){
			int v2=(v-10)/3;
			l=max(l,1);
			if(col[v2]==2){
				if(u[v2]<=9)r=-1;
				if(col[v2]==2)r=min(u[v2]/10,r);
			}else{
				r=min(u[v2],r);
			}
		}
		if((v-10)%3==2){
			int v2=(v-10)/3;
			if(u[v2]<=9){
				r=min(u[v2],r);
			}
		}
	}
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(!used[nv]){
			P p2=dfs2(nv,l,r);
			l=max(p2.first,l);
			r=min(p2.second,r);
		}
	}
	return P(l,r);
}

void solve(){
	int len=0;
	for(int i=0;i<50;i++){
		G[i].clear();
	}
	memset(flag,false,sizeof(flag));
	for(int i=0;i<n;i++){
		if(str[i]>='0' && str[i]<='9'){
			num[len]=(str[i]-'0');
			flag[(str[i]-'0')]=true;
			len++;
		}else{
			int v=id[str[i]-'a'];
			if(col[v]==0){
				num[len++]=10+v*3;
				flag[10+v*3]=true;
			}
			if(col[v]==1){
				num[len++]=10+v*3+1;
				flag[10+v*3+1]=true;
			}
			if(col[v]==2){
				num[len++]=10+v*3+1;
				num[len++]=10+v*3+2;
				flag[10+v*3+1]=true;
				flag[10+v*3+2]=true;
			}
		}
	}
	for(int i=0;i<len/2;i++){
		G[num[i]].push_back(num[len-1-i]);
		G[num[len-1-i]].push_back(num[i]);
	}
	memset(used,0,sizeof(used));
	cnt=0;
	for(int i=0;i<50;i++){
		if(flag[i] && !used[i]){
			seq[cnt].clear();
			P p=dfs2(i,0,9);
			if(p.second-p.first>=0){
				rng[cnt]=p;
				cnt++;
			}
			else{
				return;
			}
		}
	}
	for(int i=0;i<=cnt;i++){
		for(int j=0;j<(1<<m);j++){
			dp[i][j]=0;
		}
	}
	dp[0][0]=1;
	for(int i=0;i<cnt;i++){
		for(int j=0;j<(1<<m);j++){
			if(dp[i][j]==0)continue;
			for(int k=rng[i].first;k<=rng[i].second;k++){
				int nj=j;
				bool fu=true;
				for(int l=0;l<seq[i].size();l++){
					int v=seq[i][l]/3;
					if(seq[i][l]%3==1){
						if(k==(u[v]/10)){
							if(nj>>v & 1){
								fu=false;
								break;
							}else{
								nj+=1<<v;
							}
						}
					}
					if(seq[i][l]%3==2){
						if(k>(u[v]%10)){
							if(nj>>v & 1){
								fu=false;
								break;
							}else{
								nj+=1<<v;
							}
						}
					}
				}
				if(fu){
					dp[i+1][nj]+=dp[i][j];
					if(dp[i+1][nj]>=MOD)dp[i+1][nj]-=MOD;
				}
			}
		}
	}
	int res=0;
	for(int i=0;i<(1<<m);i++){
		res+=dp[cnt][i];
		if(res>=MOD)res-=MOD;
	}
	ans+=res;
	if(ans>=MOD)ans-=MOD;
}

void dfs(int v){
	if(v==m){
		solve();
	}else{
		for(int i=0;i<3;i++){
			col[v]=i;
			dfs(v+1);
		}
	}
}

bool ap[26];

int main(void){
	scanf("%d%d",&n,&m);
	cin >> str;
	int ct=0;
	for(int i=0;i<str.size();i++){
		if(str[i]>='a' && str[i]<='j' && !ap[(str[i]-'a')]){
			id[(str[i]-'a')]=ct++;
			ap[(str[i]-'a')]=true;
		}
	}
	for(int i=0;i<m;i++){
		string s;
		int v;
		cin >> s >> v;
		char c=s[0];
		u[id[(c-'a')]]=v;
	}
	dfs(0);
	printf("%lld\n",ans);
	return 0;
} 


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

int main() {
    string s; cin >> s;
    bool found = false;
    rep(i, 0, s.size()) {
        rep(j, i + 1, s.size()) {
            if (s[i] == s[j]) {
                found = true;
            }
        }
    }
    cout << (found ? "no" : "yes") << endl;
}

Measured memory_bytes: 256
base = 10 ** 9 + 7
h, w, k = map(int, input().split())
wc = [1] * 9

for i in range(2, 9):
    wc[i] = wc[i-1] + wc[i-2]

dp = [0] * (w+2)
dp[1] = 1
for i in range(h):
    tmp = [0] * (w+2)
    for j in range(1, w+1):
        tmp[j] = dp[j] * wc[j-1] * wc[w-j]
        if j > 1:
            tmp[j] += dp[j-1] * wc[j-2] * wc[w-j]
        if j < w:
            tmp[j] += dp[j+1] *wc[j-1] * wc[w-j-1]
        tmp[j] = tmp[j] % base
    dp = tmp
print(dp[k])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll MOD=1000000007;
const ll INF=1000000000LL;
const int MAX=100001;
const double EPS=1e-10;
struct edge{int to,cost;};
typedef pair<int,int> P;
int main(){
    int n;
    cin>>n;
    vector<int> a,b,c;
    ll ans=0;
    for(int i=0;i<n;i++){
        int aa;cin>>aa;
        a.push_back(aa);
    }
    for(int i=0;i<n;i++){
        int bb;cin>>bb;
        b.push_back(bb);
    }
    for(int i=0;i<n;i++){
        int cc;cin>>cc;
        c.push_back(cc);
    }
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    for(int i=0;i<n;i++){
        ll u=lower_bound(a.begin(),a.end(),b[i])-a.begin();
        ll d=c.end()-upper_bound(c.begin(),c.end(),b[i]);
        ans+=u*d;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using pii = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
#define rep(CNT, GOAL) for (int CNT = 0; CNT < (int)(GOAL); CNT++)
#define rep2(CNT, START, GOAL) for (int CNT = (int)(START); CNT < (int)(GOAL); CNT++)
#define rep3(CNT, START, GOAL) for (int CNT = (int)(START); CNT > (int)(GOAL); CNT--)
#define all(CONT) begin(CONT), end(CONT)
template <typename T> void CERR(const T &ELEM) { cerr << ELEM; }
#define dbl(OBJ) cerr << #OBJ << ": "; CERR(OBJ); cerr << "\n"
template <typename T, typename ...Ts> void CERR(const T &FIRST, const Ts &...REST) { CERR(FIRST); cerr << ", "; CERR(REST...); }
#define dbs(...) cerr << "(" << #__VA_ARGS__ << "): ("; CERR(__VA_ARGS__); cerr << ")\n"
#include <atcoder/all>
using namespace atcoder;

struct S { ll zero; ll one; ll inversion; };
S op(S x, S y) {
	return S { x.zero + y.zero, x.one + y.one, x.inversion + y.inversion + x.one * y.zero };
}
S e() { return S{ 0, 0, 0 }; }
using F = bool;
S mapping(F f, S x) {
	auto [zero, one, inversion] = x;
	ll l = zero + one;
	// ll new_inversion = zero * one - inversion;
	ll new_inversion = l * (l - 1) / 2 - zero * (zero - 1) / 2 - one * (one - 1) / 2 - inversion;
	if (f) return S{ one, zero, new_inversion };
	else return x;
}
F composition(F f, F g) { return (f and !g) or (!f and g); }
F id() { return false; }

int N;

void show(lazy_segtree<S, op, e, F, mapping, composition, id> s) {
	cout << endl << "[";
	rep(i, N) {
		cout << s.get(i).one << ", ";
	}
	cout << "]" << endl;
}

int main() {
	int Q; cin >> N >> Q;
	vector<S> A(N);
	rep(i, N) {
		int A_value; cin >> A_value;
		if (A_value == 0) A[i] = S{ 1, 0, 0 };
		else if (A_value == 1) A[i] = S{ 0, 1, 0 };
	}
	lazy_segtree<S, op, e, F, mapping, composition, id> s(A);
	// show(s);
	while (Q--) {
		int T, L, R; cin >> T >> L >> R;
		L--; R--;
		if (T == 1) s.apply(L, R + 1, true);
		else if (T == 2) cout << s.prod(L, R + 1).inversion << endl;
		// show(s);
	}
}

Measured memory_bytes: 20464
import java.util.*;
import java.io.*;
public class Main {
    static InputStreamReader r;
    public static void main(String[] args) throws Exception {
        r = new InputStreamReader(System.in);
        int N = nextInt();
        int min = 200005;
        int ans = 0;
        for (int i = 0; i < N; i++) {
            int Pi = nextInt();
            if (Pi < min) {
                min = Pi;
                ans++;
            }
        }

        System.out.println(ans);
    }

    public static String nextString() throws Exception {
        String res = "";
        while (true) {
            int c = r.read();
            if (c == 32 || c == 10 || c == -1) {
                break;
            }
            res += (char)c;
        }
        return res;
    }

    public static int nextInt() throws Exception {
        return Integer.parseInt(nextString());
    }

    public static long nextLong() throws Exception {
        return Long.parseLong(nextString());
    }

    public static double nextDouble() throws Exception {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 62608
//300
fun ac094(args: Array<String>) {
    val (a, b, c) = args[0].split(" ").map { it.toInt() }.sorted()
    val cMinusA = c - a
    val cMinusB = c - b
    val rest = (cMinusA - cMinusB)
    println(cMinusB + (rest / 2) + if ((cMinusA - cMinusB) % 2 == 0) 0 else 2)
}

fun main(args: Array<String>) {
    ac094(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 38308
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] nums = new int[n];
		
		int count = 0;
		
		for(int i=0; i<n; i++) {
			nums[i] = sc.nextInt();
			
			if(i==0) {
				count = nums[0];
			}else {
				count += Math.max(0, nums[i]-nums[i-1]);
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long
//template
struct Fordfulkerson{
  const int INF = LINF;
  struct edge{
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<int> used;

  Fordfulkerson(){}
  Fordfulkerson(int sz):n(sz),G(n),used(n){}

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

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

  int flow(int s,int t,int lim){
    int fl=0;
    for(;;){
      fill(used.begin(),used.end(),0);
      int f=dfs(s,t,lim);
      if(f==0) return fl;
      fl+=f;
      lim-=f;
    }
  }

  int flow(int s,int t){
    return flow(s,t,INF);
  }

};
int B[60][60];
//main
signed main(){
  int h,w,W;cin>>h>>w>>W;
  for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>B[i][j];
  int ans=0;
  Fordfulkerson fl(10000);
  int x[4]={-1,-1,1,1};
  int y[4]={-1,1,-1,1};
  /*
  スイッチはスイッチの左上の電球の場所にあるとする
  左上の角と同じグループのスイッチはOnならSにつける
  もう片方のグループのスイッチはOffならSにつける
  */
  for(int i=0;i<h-1;i+=2){
    for(int j=0;j<w-1;j+=2){
      if(B[i][j]+B[i+1][j]+B[i][j+1]+B[i+1][j+1]<=W)continue;
      ans+=B[i][j]+B[i+1][j]+B[i][j+1]+B[i+1][j+1]-W;
      fl.add_edge(0,100*i+j+1,B[i][j]+B[i+1][j]+B[i][j+1]+B[i+1][j+1]-W);
      for(int k=0;k<4;k++){
        if(i+x[k]<0||i+x[k]>=h-1||j+y[k]<0||j+y[k]>=w-1)continue;
        if(B[i+x[k]][j+y[k]]+B[i+1+x[k]][j+y[k]]+B[i+x[k]][j+1+y[k]]+B[i+1+x[k]][j+1+y[k]]<=W)continue;
        int a=i,b=j;
        if(k==1)b++;
        if(k==2)a++;
        if(k==3){a++;b++;}
        fl.add_edge(100*i+j+1,100*(i+x[k])+j+y[k]+1,B[a][b]);
      }
    }
  }
  for(int i=1;i<h-1;i+=2){
    for(int j=1;j<w-1;j+=2){
      if(B[i][j]+B[i+1][j]+B[i][j+1]+B[i+1][j+1]<=W)continue;
      ans+=B[i][j]+B[i+1][j]+B[i][j+1]+B[i+1][j+1]-W;
      fl.add_edge(100*i+j+1,9999,B[i][j]+B[i+1][j]+B[i][j+1]+B[i+1][j+1]-W);
    }
  }
  cout<<ans-fl.flow(0,9999)<<endl;
}



Measured memory_bytes: 3616
#include <iostream>
#include <vector>
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    int ans = 0;
    int n, m;
    cin >> n >> m;

    vector<int> x(m);
    rep (i, m) cin >> x[i];
    sort(x.begin(), x.end());

    if (m == 1) {
        cout << 0 << endl;
        return 0;
    }

    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> y(m-1);
    rep (i, m-1) y[i] = x[i+1] - x[i];

    sort(y.begin(), y.end());
    rep (i, m-n) ans += y[i];
    cout << ans << endl;
}



Measured memory_bytes: 1024
from collections import deque

n, q = [ int( val ) for val in raw_input( ).split( " " ) ]
processes = deque( )
for i in range( n ):
    name, time = raw_input( ).split( " " )
    processes.append( ( name, int( time ) ) )
  
qsum = 0
output = []
while len( processes ):
    process = processes.popleft( )
    if process[1] <= q:
        qsum += process[1]
        output.append( "{:s} {:d}".format( process[0], qsum ) )
    else:
        processes.append( ( process[0], process[1]- q ) )
        qsum += q
 
print( "\n".join( output ) )

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

/* 
 * * stuff you should look for
 * * int overflow, array bounds
 * * special cases (n=1?), set tle
 * */

int main(){
    fcin;

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

    if(a > b) swap(a, b);
    if(a == 2) cout << 1 << endl;
    else if(a == 1) cout << (b == 3 ? 2 : 3) << endl;
    return 0;
}



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

const int INF = 1e9 + 5;
            
int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k; cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++)
        cin >> h[i];
    vector<int> dp(n, INF);
    //dp[i] = min cost to reach stone n;
    dp[0] = 0;
    for(int i = 0; i < n; i++)
        for(int j = i + 1; j <= min(i + k, n); j++)
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 4788
#include <stdio.h>

int main(void){
  int n, a[100], i, j, flag, x, sum;

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

  sum = 0;
  flag = 1;
  i = 0;
  while (flag) {
    flag = 0;
    for (j = n - 1; j >= i + 1; j--) {
      if (a[j] < a[j-1]) {
        x = a[j];
        a[j] = a[j-1];
        a[j-1] = x;
        flag = 1;
        sum++;
      }
    }
    i++;
  }

  for ( i = 0; i < n; i++) {
    if ( i < n - 1) {
      printf("%d ", a[i]);
    }
    else if (i == n - 1) {
      printf("%d\n", a[i]);
      printf("%d\n", sum);
    }
  }
}


Measured memory_bytes: 2064
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  char c;
  cin >> c;

  cout << (char)(c+1) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n;
	string s;
	cin >> n >> s;
	set<string> ans;
	rep(i, 10) {
		rep(j, 10) {
			rep(k, 10) {
				string pass;
				pass += i + '0';
				pass += j + '0';
				pass += k + '0';
				for(int x = 0, y = 0; x < n; x++) {
					if (s[x] == pass[y]) {
						y++;
						if (y == 3){
							ans.insert(pass);
							break;
						}
					}
				}
			}
		}
	}
	cout << ans.size() << endl;
}

Measured memory_bytes: 384
//Homework

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
using ll = long long;
#define range(a) (a).begin(),(a).end()
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; }
const int inf = 1000000000;

int main (){
    int N, M, sum = 0;cin >> N >> M;
    vector<int> A(M);
    rep(i,0,M){
        cin >> A[i];
        sum += A[i];
    }
    int Ans = (N-sum);
    if(Ans<0)cout << "-1" << endl;
    else cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>
#define int long long
using namespace std;


signed main(){

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

	if(A == B){
		if(B == C){
			cout << "Yes\n";
			return 0;
		}

		cout << "No\n";
		return 0;

	}

	cout <<"No\n";
	return 0;

	return 0;
}

Measured memory_bytes: 384