akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
signed main(){
    int h0,h1,k0,k1,a,b,c,d;cin>>h0>>h1>>k0>>k1>>a>>b>>c>>d;
    int hiroshi=h0*a+(h0/10)*c+h1*b+(h1/10)*d;
    int kenjiro=k0*a+(k0/10)*c+k1*b+(h1/10)*d;
    if(hiroshi>kenjiro)cout<<"hiroshi"<<endl;
    if(hiroshi==kenjiro)cout<<"even"<<endl;
    if(hiroshi<kenjiro)cout<<"kenjiro"<<endl;
}




Measured memory_bytes: 3084
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n;
  int y;
  int b[55];
  int r[55];
  int t[55];
  int max;
  int ans; 
  double q;
  while(true){
    cin>>n;
    if(n==0)break;
    cin>>y;
   max=0;
    for(int i=0;i<n;i++){
      cin>>b[i];
      cin>>r[b[i]]>>t[b[i]];
      if(t[b[i]]==1){
	q=100+y*r[b[i]];
     }
      else{
	double in = 100+r[b[i]];
	q=in;
     	for(int s=0;s<y-1;s++){
	  q*=in;
	}
    	for(int s=0;s<y-1;s++){
	  q/=100;
	}

     }
      if(max<q){
	max=q;
	ans=b[i];
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

#define INF 1010001000
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef pair<int, int> i_i;
typedef long long int llong;
typedef pair<llong, llong> ll_ll;
typedef struct edge {int f, t;}Edge;


int main()
{
    int n, m, t;
    cin >> n >> m >> t;
    vector<bool> time(t, true);
    m++;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        rep(i, m) {
            if (tmp + i <= t) {
                time[tmp + i - 1] = false;
            }
            if (0 <= tmp - i) {
                time[tmp - i] = false;
            }
        }
    }
    int ret = 0;
    rep(i, t) {
        if (time[i]) {
            ret++;
        }
    }
    cout << ret << endl;
    return 0;
}

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

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

  vector<string> vecN(N);
  vector<string> vecM(M);

  for (int i = 0; i < N; i++) {
    cin >> vecN[i];
  }

  string linM;
  for (int i = 0; i < M; i++) {
    cin >> vecM[i];
    //確認用の一行を作っとく
    linM += vecM[i];
  }

  //確認したい箇所を一行にする。
  // N行の選択
  for (int i = 0; i <= N - M; i++) {
    // N列の選択
    for (int j = 0; j <= N - M; j++) {
      string linN = {};
      // 取得行の範囲
      for (int k = 0; k < M; k++) {
        linN += vecN[i + k].substr(j, M);
      }
      if (linM == linN) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll fl[N];
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,n,l;
	cin>>n;

	ll ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
		k=ar[i]-1; l=ar[i]+1;
		if(k>=0) fl[k]++;
		fl[l]++; fl[ar[i]]++;
	}

	ll mx=0;
	for(i=1;i<=1e5;i++){
		mx=max(mx,fl[i]);
	}
	cout<<mx;
	return 0;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int w;
string s;

signed main() {
	cin >> s >> w;
	int n = s.size();
	string res;
	rep(i,n) if (i%w==0) res.pb(s[i]);
	cout << res << ln;
}

Measured memory_bytes: 256
while True :
    m, n_min, n_max = map(int, input().split())
    if m == 0 and n_min == 0 and n_max == 0 :
        break
    
    P = list(int(input()) for _ in range(m))
    gap = 0
    for i in range(n_min-1, n_max) :
        x = P[i] - P[i+1]
        if x >= gap :
            gap = x
            n = i
    print(n+1)


Measured memory_bytes: 5620
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

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

int h, w, n;
char in[100][101];
bool v[100][100][4][11][11];

int main(){
	m[0][3] = m[1][2] = m[3][0] = m[2][1] = 1;
	
	cin >> h >> w >> n;
	int y, x;
	rep(i, h){
		cin >> in[i];
		rep(j, w) if(in[i][j] == 'S') y = i, x = j;
	}
	priority_queue<pair<int, pi> > Q;
	Q.push(mp(0, mp(2 * h * w + y * w + x, n * 11 + n)));
	
	while(!Q.empty()){
		int co = -Q.top().first;
		int cd = Q.top().second.first / h / w;
		y = Q.top().second.first / w % h; x = Q.top().second.first % w;
		int p = Q.top().second.second / 11, q = Q.top().second.second % 11;
		Q.pop();
		
		if(v[y][x][cd][p][q]) continue;
		v[y][x][cd][p][q] = 1;
		
		//cerr<<y<<" "<<x<<" "<<cd<<" "<<p<<" "<<q<<" "<<co<<endl;
		
		if(in[y][x] == 'G'){
			cout << co << endl;
			return 0;
		}
		rep(d, 4) if(d != (cd ^ 2)){
			if(in[y][x] == 'S' && cd != d) continue;
			if(in[y][x] == 'S' && co && dy[d]) continue;
			
			int ny = y + dy[d], nx = x + dx[d];
			if(ny < 0 || ny >= h || nx < 0 || nx >= w || in[ny][nx] == '#') continue;
			int np = p - 1 + m[cd][d], nq = q - m[cd][d], nc = co;
			
			if(d == cd) np = p, nq = q;
			else nc++;
			if(np < 0 || nq < 0) continue;
			
			if(!v[ny][nx][d][np][nq]) Q.push(mp(-nc, mp(d * h * w + ny * w + nx, np * 11 + nq)));
		}
	}
	cout << -1 << endl;
	
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	rep(i, n - 2) {
		if (s.substr(i, 3) == "ABC") ans++;
	}
	cout << ans << endl;
	return 0;
}


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

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    int n, t, a, h;
    cin >> n >> t >> a;
    int ans = -1;
    double dis = -1;
    for (int i = 0; i < n; i++){
        cin >> h;
        if (i == 0){
            ans = 1;
            dis = abs(a - (t - h * 0.006));
        }
        else if (dis > abs(a - (t - h * 0.006))){
            ans = i + 1;
            dis = abs(a - (t - h * 0.006));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))
ans = 10000000000
for i in range(1, n):
    #print(i)
    tmp1 = 0
    tmp2 = 0
    for j in range(i):
        #print(j)
        tmp1 += w[j]
    for j in range(i, n):
        tmp2 += w[j]
    ans = min(abs(tmp2 - tmp1), ans)

print(ans)

Measured memory_bytes: 38896
import java.util.Scanner;
public class Main {
        public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
          
   int handred = N/100;
   int ten = (N/10)%10;//例)123/100=1と23、23%10(23の10の位抽出)=2
   int one = N%10;
                  
        if(handred ==7 ){
          System.out.println("Yes");
        }else if(ten ==7){
          System.out.println("Yes");
        }else if(one ==7){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
    }
}

Measured memory_bytes: 35524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
string s;
int main(){
  cin >> s;
  int n = s.size();
  ll sum=0;
  for (size_t bit = 0; bit < (1 << n-1); bit++) {
    string t;
    t += s[0];
    for (size_t i = 0; i < n; i++) {
      if(bit & (1<<i)){
        sum += stoll(t);
        t = "";
      }
      t += s[i+1];
    }
    sum += stoll(t);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output(vector<int> s)
{
    int n = s.size();
    for (int i = 0; i < n; i++)
    {
        if (i != 0)
            cout << " ";
        cout << s[i]; //<<endl;
    }
    cout << endl;
}

int MOD = pow(10, 9) + 7;

//各要素で最低操作回数を数える
pair<int,int> count(vector<int> a,vector<int> b){
    int n=a.size();
    int a_cnt=0,b_cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]>b[i]){
            b_cnt+=(a[i]-b[i]);
        }
        if(a[i]<b[i]){
            if((b[i]-a[i])%2==0){
                a_cnt+=(b[i]-a[i])/2;
            }else{
                a_cnt+=(b[i]-a[i])/2 +1;
            }
        }
    }

    return make_pair(a_cnt,b_cnt);
}

signed main(){
    int n;cin>>n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];

    int sum_a=accumulate(all(a),0LL);
    int sum_b=accumulate(all(b),0LL);

    if(sum_a>sum_b) cout<<"No"<<endl;
    else{
        pair<int,int> cnt=count(a,b);
        if(cnt.first>sum_b-sum_a) cout<<"No"<<endl;
        else if(cnt.second>sum_b-sum_a) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define range(x,s,t) (s<=x&&x<t)
#define popcount(n) (__builtin_popcountll(n))

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

using namespace std;

int memo[55][55][55][55];
int ans[55][55];

int h,w;
string board[55];
using state=tuple<int,int,int,int,int>;

const int inf=1<<29;
const int dx[4]={-1,0,1,0};
const int dy[4]={0,-1,0,1};


int rec(int a,int b,int c,int d){
	if(h<=a||w<=b||c<0||d<0) return -inf;
	if(board[a][b]=='#'||board[c][d]=='#') return -inf;
	
	if(a==c&&b==d) return 0;
	if(a-1==c&&b==d) return 0;
	if(a==c&&b-1==d) return 0;
	
	if(a>c||b>d) return -inf;

	int &ret=memo[a][b][c][d];
	if(ret!=-1) return ret;

	ret=-inf;
	chmax(ret,rec(a+1,b,c,d));
	chmax(ret,rec(a,b+1,c,d));
	chmax(ret,rec(a,b,c-1,d));
	chmax(ret,rec(a,b,c,d-1));
	
	if(islower(board[a][b]) && toupper(board[a][b])==board[c][d]){
		chmax(ret,rec(a+1,b,c-1,d)+1);
		chmax(ret,rec(a+1,b,c,d-1)+1);
		chmax(ret,rec(a,b+1,c-1,d)+1);
		chmax(ret,rec(a,b+1,c,d-1)+1);
	}

	if(islower(board[a][b])){
		char tar=board[a][b]-'a'+'A';
		rep(y,a,c+1)rep(x,b,d+1){
			if(y==c&&x==d) continue;
			if(board[y][x]==tar)
				chmax(ret,rec(a,b,y,x)+rec(y,x,c,d));
		}
	}
	
	return ret;
}

int main(void){
	while(cin >> h >> w,h){
		rep(i,h) cin >> board[i];
		clr(memo,-1);
		cout << max(-1,rec(0,0,h-1,w-1)) << endl;
	}
	return 0;
}

Measured memory_bytes: 38860
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int main() {
    int n,ans = 0;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
ans=0
for i in range(1,n+1):
  cnt=0
  for x in range(1,101):
    if x**2>i:
      break
    for y in range(1,x+1):
      if x**2+y**2>i:
        break
      for z in range(1,y+1):
        if x**2+y**2+z**2+x*y+y*z+z*x==i:
          if x==y==z:
            cnt+=1
          if (x>y and y==z) or (x==y and y>z):
            cnt+=3
          if x>y>z:
            cnt+=6
  ans=cnt
  print(ans)   

Measured memory_bytes: 69548
#include<iostream>

using namespace std;
const int INF=1e12;

int main(){
    int N,W;
    int v[100],w[100];
    long long dp[101][10001];
    cin>>N>>W;
    for(int i=0;i<N;i++){
        cin>>v[i]>>w[i];
    }
    for(int i=0;i<=N;i++){
        for(int j=0;j<=N*100;j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<=N*100;j++){
            if(j<v[i]){
                dp[i+1][j]=dp[i][j];
            }
            else{
                dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
            }
        }
    }
    int res=0;
    for(int i=0;i<=N*100;i++){
        if(dp[N][i]<=W)res=i;
    }
    cout<<res<<endl;
    
    return 0;
    
    
    
    
    
}



Measured memory_bytes: 11004
import math
import collections
import sys

input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]

a,b=MI()
L=[a,a-1,b,b-1]
L=sorted(L,reverse=True)
print(L[0]+L[1])

Measured memory_bytes: 3316
#include<iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
  	int A[N], B[N], C[N-1];
    int manzoku=0;
  	for (int i=0;i<N;i++)cin >> A[i];
  	for (int j=0;j<N;j++){
      cin >> B[j];
      manzoku += B[j];
    }
  	for (int k=0;k<N-1;k++)cin >> C[k];
  
    for (int l=0; l<N-1;l++){
        if(A[l+1]-A[l]==1){manzoku += C[A[l]-1];}
    }
  	cout << manzoku;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int a[3005][3005];
ll dp[3005][3005][4];
//配列はグローバルで定義した方がいい？
int main(){
    int r,c,k;cin >> r >> c >> k;
    rep(i,k){
        int ri,ci,vi;cin >> ri >> ci >> vi;
        --ri;--ci;
        a[ri][ci] = vi;
    }

    rep(i,r)rep(j,c){
        for(int k = 2;k >= 0;k--){
            chmax(dp[i][j][k+1],dp[i][j][k]+a[i][j]);
        }
        rep(k,4){
            chmax(dp[i+1][j][0],dp[i][j][k]);
            chmax(dp[i][j+1][k],dp[i][j][k]);
        }
    }
    ll ans = 0;
    rep(i,4) ans = max(ans,dp[r-1][c-1][i]);
    cout << ans << endl;
}

Measured memory_bytes: 320416
#include<stdio.h>
int main(void)
{
	int N, M,count=0;
	char A[60][60], B[60][60];
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++) {
		scanf("%s", A[i]);
	}
	for (int i = 0; i < M; i++) {
		scanf("%s", B[i]);
	}
	for (int i = 0; i < N - M + 1; i++) {
		count = 0;
		for (int j = 0; j < N - M + 1; j++) {
			count = 0;
			for (int k = 0; k < M; k++) {
				for (int l = 0; l < M; l++) {
					//printf("A=%c B=%c ", A[k + i][l + j], B[k][l]);
					if (A[k + i][l + j] == B[k][l]) {
						count++;
					}
					if (count == (M * M)) {
						printf("Yes");
						return 0;
					}
				}
				//puts("");
			}
		}
	}
	printf("No");
	return 0;
}

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

int main(){
    string s ;
    cin >> s ;
    if (s=="Sunny")
    {
        cout << "Cloudy" << endl ;
    }
    if (s=="Cloudy")
    {
        cout << "Rainy" << endl ;
    }
    if (s=="Rainy")
    {
        cout << "Sunny" << endl ;
    }
}

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

int main(void)
{
  int n = 0;
  int k = 0;
  std::cin >> n >> k;
  
  std::vector<int> dis(k);
  for(int index = 0; k > index; ++index)
  {
    std::cin >> dis[index];
  }
  
  int base = 1;
  int upper = 10;
  bool upperFlag = false;
  for(int digit = 0; 5 > digit; ++digit)
  {
    while(dis.end() != std::find(dis.begin(), dis.end(), (n / base) % 10))
    {
      n += base;
      upperFlag = true;
    }
    if(upperFlag && 10 <= base)
    {
      n -= (n % base - n % (base / 10));
      while(dis.end() != std::find(dis.begin(), dis.end(), (n / (base / 10)) % 10))
      {
        n += base / 10;
      }
    }
    if(upper > n)
    {
      break;
    }
    base *= 10;
    upper *= 10;
    upperFlag = false;
  }
  std::cout << n;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
struct node{
	int s,t,c;
}a[100001];
 
bool cmp(node a,node b){
	return a.s<b.s;
}
 
pair<int,int> b[100001];
int main()
{
	ios::sync_with_stdio(false);
	int n,c,ans=1;
	cin>>n>>c;
	for(int i=1;i<=n;i++) cin>>a[i].s>>a[i].t>>a[i].c;
	sort(a+1,a+n+1,cmp);
	b[1].first=a[1].t,b[1].second=a[1].c;
	for(int i=2;i<=n;i++){
		bool f=0;
		for(int j=1;j<=ans;j++)
			if((b[j].second==a[i].c&&a[i].s>=b[j].first)||(b[j].second!=a[i].c&&a[i].s>b[j].first)){
				b[j].first=a[i].t,b[j].second=a[i].c;
				f=1;
				break;
			}
		if(!f) ans++,b[ans].first=a[i].t,b[ans].second=a[i].c;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1408
/*
	@・ω・@ <だれだろうね
*/

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<long long>;
using pll = pair<long long, long long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << (x) << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << (h) << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << (h) << " : " <<  (x) << "\n")

#define str(n)	(n.toString())

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; --i)
#define rrep1(i, n) for(ll i=(n); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool cmp_2nd(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/

ll N;
vec<pr<ll>> R;

void Main()
{
	cin >> N;
	R.resize(N);
	rep(i, N)
	{
		ll x, l;
		cin >> x >> l;
		R[i].first = x - l;
		R[i].second = x + l;
	}

	sort(all(R), cmp_2nd<ll>);

	ll ret = 0, end = -INF;
	rep(i, N)
	{
		if (R[i].first >= end)
		{
			end = R[i].second;
			ret++;
		}
	}

	cout << ret;
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);

	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/

	Main();
	cout << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <algorithm>
#define mp make_pair

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;

const int MAXN = 105;
const int MAXW = 1e5 + 7;

template<typename T> inline T read() {
	T res = 0, flag = 1; char in = getchar();
	while(!isdigit(in)) { if(in == '-') flag = -1; in = getchar(); }
	while(isdigit(in)) { res = (res << 1) + (res << 3) + in - '0'; in = getchar(); }
	return res * flag;
}

template<typename T> inline void chkmax(T &a, T b) { if(a < b) a = b; }
template<typename T> inline void chkmin(T &a, T b) { if(a > b) a = b; }

int N, W;
int w[MAXN], val[MAXN];
LL dp[MAXN][MAXW], ans;

inline void solve() {
	N = read<int>(); W = read<int>();
	for(int i = 1; i <= N; ++i) {
		w[i] = read<int>();
		val[i] = read<int>();
	}
	for(int i = 1; i <= N; ++i) {
//		for(int j = 0; j < w[i]; ++j) dp[i][j] = dp[i - 1][j];
		for(int j = 0; j <= W; ++j) {
			if(j >= w[i]) chkmax(dp[i][j], dp[i - 1][j - w[i]] + val[i]);
			chkmax(dp[i][j], dp[i - 1][j]);
			//printf("%d %d %d\n", i, j, dp[i][j]);
		}
	}
	for(int i = 0; i <= W; ++i) chkmax(ans, dp[N][i]);
	printf("%lld\n", ans);
}

int main() {

	solve();

	return 0;
}



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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    cout << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    cout << ']';
    return s;
}

int main(){

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

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

    if(x == 1 or x == 2*n-1){
        No();
        return 0;
    }

    Yes();
    if(n == 2){
        ppp(1);
        ppp(2);
        ppp(3);
        return 0;
    }

    vector<int> ans(2*n-1);
    ans[n-2] = x-1;
    ans[n-1] = x;
    ans[n] = x+1;
    ans[n+1] = x-2;

    vector<int> num;
    if(x == 2){
        ans[n-2] = x+1;
        ans[n-1] = x;
        ans[n] = x-1;
        ans[n+1] = x+2;
        for(int i = 1; i <= 2*n-1; ++i){
            if(x-1 <= i and i <= x+2) continue;
            num.push_back(i);
        }
        int cnt = 0;
        for(int i = 0; i < 2*n-1; ++i){
            if(i < n-2 or n+1 < i){
                ans[i] = num[cnt];
                ++cnt;
            }
        }
    }
    else{
        for(int i = 1; i <= 2*n-1; ++i){
            if(x-2 <= i and i <= x+1) continue;
            num.push_back(i);
        }
        int cnt = 0;
        for(int i = 0; i < 2*n-1; ++i){
            if(i < n-2 or n+1 < i){
                ans[i] = num[cnt];
                ++cnt;
            }
        }
    }

    for(int x : ans){
        ppp(x);
    }

    return 0;
}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define mkp(a,b) make_pair(a,b)
#define PI 3.14159265359
#define mset(arr,val) memset(arr,val,sizeof arr)
#define MAXN (ll)2e5+1
#define eb emplace_back
#define mod (long long)(1e9+7)
#define FILE_READ freopen("input.txt","r",stdin)
#define FILE_WRITE freopen("output.txt","w",stdout)
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long ul;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
//    FILE_READ;
//    FILE_WRITE;

    int a,b;
    cin>>a>>b;
    if(a>b) swap(a,b);
    int ans=b;
    b--;
    ans+=max(a,b);
    cout<<ans;

    return 0;
}

Measured memory_bytes: 256
let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let dfs vs n =
  let d = Array.make (n + 1) 0 in
  let f = Array.make (n + 1) 0 in
  let time = ref 1 in
  let rec doit i =
    d.(i) <- !time;
    incr time;
    List.iter (fun e -> if d.(e) = 0 then doit e) vs.(i);
    f.(i) <- !time;
    incr time in
  for i = 1 to n do
    if d.(i) <> 0 then ()
    else
      doit i;
  done;
  (d, f)

let () =
  let n = read_int () in
  let vs = Array.make (n + 1) [] in
  for _ = 0 to n - 1 do
    match read_line () |> split_on_char ' ' |> List.map int_of_string with
    | u :: _ :: l -> vs.(u) <- l
    | _ -> assert false
  done;
  let (d, f) = dfs vs n in
  for i = 1 to n do
    Printf.printf "%d %d %d\n" i d.(i) f.(i)
  done

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

int main(){
    int l,r,d;
    cin >> l >> r >> d;
    int a,b,c;
    a=r/d;
    b=(l-1)/d;

    cout << a-b << endl;
    

    return 0;
}

Measured memory_bytes: 3616
import itertools
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
INF = float("inf")

Q = int(input())
l = [0]*Q
Sum = [0]*(10**5+1)
for i in range(Q):
    l[i] = list(map(int,input().split()))

def is_prime(n):
    for i in range(2,int(math.sqrt(n))+1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1
for i in range(3,10**5+1,2):
    if is_prime(i) and is_prime((i+1)//2):
        Sum[i] = Sum[i-2]+1
    else:
        Sum[i] = Sum[i-2]

for i in range(Q):
    if l[i][1] ==1:
        print(0)
    elif l[i][0] == 1:
        print(Sum[l[i][1]])
    else:
        print(Sum[l[i][1]]-Sum[l[i][0]-2])

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

using namespace std;

int main(){
    int a,b,t,c=0;
    cin >>a >>b;
    t=1;
    for(int i=	1; i>0;i++){
      	if(b==1){
          break;
        }else if(t>=b){
            
            break;
        }
        t= t+a-1;
        c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define ACL
#ifdef ACL
#include <atcoder/all>
using namespace atcoder;
#endif
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
using LD = long double;
using VI = vector<int>;
using VVI = vector<vector<int> >;
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T> >;
template <typename T> using VVV = vector<vector<vector<T> > >;
void print() {cout << endl;}
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <typename T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <typename T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> void SORT (T &v) {sort(v.begin(), v.end());}
template <typename T> void SORTR (T &v) {sort(v.begin(), v.end(), greater<>());}
template <typename T> T GCD(T x,T y) {return __gcd(x,y);}
template <typename T> T LCM(T x,T y) {return x/__gcd(x,y)*y;}
template <typename T> int SZ(T v) {return v.size();}
template <typename T> T PCNT(T x) {return __builtin_popcountll(x);}
template <typename T> T BIT(T x) {return 1LL<<(x);}
int INF = 2000000000;
long double PI = acosl(-1);
int MOD = 1000000007;


int32_t main() {
    chrono::system_clock::time_point start_time, end_time;
    start_time = chrono::system_clock::now();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0, res = 0;
    
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    ans = a*c;
    chmax(ans, a*d);
    chmax(ans, b*c);
    chmax(ans, b*d);
    cout << ans << endl;

    
    



    end_time = chrono::system_clock::now();
    assert(chrono::duration_cast<chrono::milliseconds>(end_time-start_time).count() < 2500);
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc178/abc178_b && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc178/abc178_b && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc178/abc178_b && sh shellscripts/submit_cpp.sh
*/


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

void Main()
{
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i,N) {cin >> h[i];}
  sort(h.begin(), h.end());
  int minSize = 1e10;
  rep(i, N-K+1){
    minSize = min(minSize, abs(h[i]-h[i+K-1]));
  }
  cout << minSize << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	p := make([]int, N)

	for i := 0; i < len(p); i++ {
		fmt.Scan(&p[i])
	}

	sort.Ints(p)

	p[len(p)-1] /= 2

	var ret int
	for _, v := range p {
		ret += v
	}
	fmt.Println(ret)
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int n,m,k;
    cin>>n>>m>>k;
    REP(i,n+1){
        REP(j,m+1){
            int cnt=i*(m-j)+(n-i)*j;
            if(cnt==k){
                Yes(1);
                return 0;
            }
        }
    }
    Yes(0);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T&a,T b){if(a>b){a=b;return 1;}return 0;}
using ll = long long;

ll n,m,k;
string s,t;

ll solve(ll n, ll p){
  if(!(n/p)) return 0;
  return n/p + solve(n,p*5);
}

int main() {
  cin >> n;
  cout << (n%2==0 ? solve(n/2,5) : 0) << endl;     
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int p[110];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	c-=min(c,a-b);
	printf("%d\n",c);
}

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

const int NM=405;
const ll oo=1e18;

ll dp[NM][NM],s[NM];

int main()
{   int n;
    cin>>n;
    for(int i=1; i<=n; i++)
        for(int j=i; j<=n; j++)
            dp[i][j]=oo;
    for(int i=1; i<=n; i++)
    {   ll x;
        cin>>x;
        s[i]=s[i-1]+x;
    }
    for(int i=1; i<=n; i++)
    {   dp[i][i]=0;
        dp[i][i+1]=s[i+1]-s[i-1];
    }
    for(int k=2; k<n; k++)
        for(int i=1,j; i+k<=n; i++)
        {   j=i+k;
            for(int l=i; l<j; l++)
                dp[i][j]=min(dp[i][j],dp[i][l]+dp[l+1][j]);
            dp[i][j]+=s[j]-s[i-1];
        }
    cout<<dp[1][n];
    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll k,a,b;
    ll i,j;
    cin>>k>>a>>b;
    for(i=a;i<=b;i++)
    {
        if(i%k==0) {cout<<"OK";return 0;}
    }
    cout<<"NG";
}

Measured memory_bytes: 3652
#include<stdio.h>
main(){
  int i,n,m;
  for(i=1;;i++){
    scanf("%d %d",&n,&m);
    if(n==0 && m==0)break;
    if(n>m)printf("%d %d\n",m,n);
    else printf("%d %d\n",n,m);
  }
  return 0;
}



Measured memory_bytes: 2048
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

string s;
int ans;

int main(){
    cin >> s;
    s += "PPP";
    REP(i, (int)s.size() - 1){
        int pos = i;
        while(s[pos] == 'A' || s[pos] == 'C' || s[pos] == 'G' || s[pos] == 'T')pos++;
        ans = max(ans, pos - (int)i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int h[n+1];
  int ma[n+1];
  for(int i=1;i<=n;i++)
  {
    cin>>h[i];
    ma[i]=0;
    
    
  }
  int a,b;
  while(m--)
  {
    cin>>a>>b;
    ma[a]=max(ma[a],h[b]);
    ma[b]=max(ma[b],h[a]);
    
    
    
  }
  int count=0;
  for(int i=1;i<=n;i++)
  {
    if(h[i]>ma[i])
      count++;
    
    
  }
  cout<<count<<endl;
  
  
}

Measured memory_bytes: 4408
#include <iostream>
using namespace std;
int main() 
{
	int m, f, r;
	while(1) {
		cin >> m >> f >> r;
		if(m == -1 && f == -1 && r == -1) {
            		break;
		}
		if(m == -1 || f == -1) {
            		cout << "F" << endl;
		}
		else if(m + f >= 80) {
            		cout << "A" << endl;
		}
		else if(m + f >= 65 && m + f < 80) {
            		cout << "B" << endl;
		}
		else if(m + f >= 50 && m + f < 65) {
            		cout << "C" << endl;
		}
		else if(m + f >= 30 && m + f < 50) {
            		if(r < 50) {
            			cout << "D" << endl;
            		}
            		else {
            			cout << "C" << endl;
            		}
		}
		else if(m + f < 30) {
            		cout << "F" << endl;
		}
	}
	return 0;
}


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

const int MAX_N = 21;
int N, M;
double L[MAX_N], a[MAX_N], b[MAX_N], ans;

double D(int i, int j){
	return (L[i] - L[j]) * (L[i] - L[j]) + (a[i] - a[j]) * (a[i] - a[j]) + (b[i] - b[j]) * (b[i] - b[j]);
}

void solve(int pos, vector<int> &v){
	
	if( pos == N ){
		if( v.size() == M ){
			double dist = 0.0;
			for(int i=0 ; i < v.size() ; i++ ){
				for(int j = i+1 ; j < v.size() ; j++ ){
					dist += D(v[i], v[j]);
				}
			}
			ans = max(ans, dist);
		}
	}else{
		solve(pos+1, v);
		v.push_back(pos);
		solve(pos+1, v);
		v.pop_back();
	}
}

int main(){
	cin >> N >> M;
	for(int i=0 ; i < N ; i++ ){
		cin >> L[i] >> a[i] >> b[i];
	}
	ans = 0.0;
	vector<int> v;
	solve(0, v);
	printf("%.20f\n", ans);
}

Measured memory_bytes: 1268
solve :: [Int] -> String
solve [w,h,x,y,r]
    | 0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h = "Yes"
    | otherwise = "No"

main :: IO ()
main  = getLine
    >>= return . map read . words
    >>= return . solve
    >>= putStrLn

Measured memory_bytes: 3648
# ABC127C - Prison
# l-max < i < r-min -> max(0, r - l + 1)
import sys
input = sys.stdin.readline

n, m = list(map(int, input().rstrip().split()))
lst = [list(map(int, input().rstrip().split())) for _ in range(m)]
l, r = lst[0][0], lst[0][1]
for i in lst[1:]:
    l = max(l, i[0])
    r = min(r, i[1])
print(max(0, r - l + 1))

Measured memory_bytes: 28100
///╔══╗
///╚╗╔╝
///╔╝╚(¯`v´¯)
///╚══╝`.¸.´farzin


#include <bits/stdc++.h>

#define int int64_t
#define pb push_back
#define ibsws ios_base::sync_with_stdio
#define gcd __gcd
#define s second
#define f first
#define mp make_pair
typedef std::pair<int,int> pii ;

using namespace std;

const int N=310;
int n,s,t[5];
double dp[N][N][N];

int32_t main(){
	ibsws(true==false);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        t[s]++;
    }
    for(double k=0;k<=n;k++){
        for(double j=0;j<=n;j++){
            for(double i=0;i<=n;i++){
                if(i==0 && j==0 && k==0){
                    continue;
                }
                if(i>0){
                    dp[int(i)][int(j)][int(k)]+=i*(dp[int(i)-1][int(j)][int(k)]);
                }
                if(j>0){
                    dp[int(i)][int(j)][int(k)]+=j*(dp[int(i)+1][int(j)-1][int(k)]);
                }
                if(k>0){
                    dp[int(i)][int(j)][int(k)]+=k*(dp[int(i)][int(j)+1][int(k)-1]);
                }
                dp[int(i)][int(j)][int(k)]+=n;
                dp[int(i)][int(j)][int(k)]/=i+j+k;
            }
        }
    }
    cout<< setprecision(12) <<dp[t[1]][t[2]][t[3]];
}


Measured memory_bytes: 227584
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint a(n+1), b(n);
    rep(i, n+1) cin >> a[i];
    rep(i, n) cin >> b[i];

    ll ans = 0;
    rep(i, n) {
        ans += min(a[i], b[i]);
        if (a[i]>b[i]) {
            a[i] -= b[i];
            b[i] = 0;
        }
        else {
            b[i] -= a[i];
            a[i] = 0;
        }
        
        ans += min(a[i+1], b[i]);
        if (a[i+1]>b[i]) {
            a[i+1] -= b[i];
            b[i] = 0;
        }
        else {
            b[i] -= a[i+1];
            a[i+1] = 0;
        }
    }

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

Measured memory_bytes: 1024