akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ll              long long
#define endl            '\n'
#define cd              cout << '\n';
#define ys              cout << "YES"; return;
#define no              cout << "NO"; return;
#define pii             pair<int,int>
#define IOS             ios::sync_with_stdio(0);
#define vi              vector<int>
#define vll             vector<long long int>
#define vpii            vector<pair<int,int>>
#define pb              push_back
#define in              insert
#define mp              make_pair
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define fr              first
#define sc              second
#define sz(a)           a.size()
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define buga(i,n,a)     cout << endl; for(i = 0; i < n; ++i) cout << a[i] << " "; cout << endl;
#define bugv(i,n,v)     cout << endl; for(i = 0; i < n; ++i) cout << v[i].first << " " << v[i].second << endl; cout << endl;

using namespace std;

void solve()
{
    int n, i, ans = 0;
    cin >> n;
    int a[n], b[n], c[n - 1];
    for(i = 0; i < n; ++i)
        cin >> a[i];
    for(i = 0; i < n; ++i) {
        cin >> b[i];
        ans+= b[i];
    }
    for(i = 1; i < n; ++i) {
        cin >> c[i];
    }
    //cout << ans << endl;
    for(i = 0; i + 1 < n; ++i) {
        if(a[i] + 1 == a[i + 1]) {
            ans+= c[a[i]];
        }
    }
    cout << ans;
}



int main()
{
    IOS;
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3564
import std.stdio, std.string, std.array, std.algorithm, std.conv;

struct Record {
  int t;
  int n;
  int m;
  int s;

  int opCmp( Record r ) {
	if ( t != r.t ) {
	  return t - r.t;
	} else {
	  if ( s == 0 && r.s == 0 ) {
		return r.n - n;
	  } else if ( s == 1 && r.s == 1 ) {
		return n - r.n;
	  }	else {
		return 0;
	  }
	}
  }

  bool opEquals( Record r ) {
	return t == r.t && n == r.n && m == r.m && s == r.s;
  }
}

void main()
{
  int count = 0;
  while ( true ) {
	// stderr.writeln( ++count, " th try start." );
	auto token = array( map!( to!int )( split( strip( readln ) ) ) );
	int N = token[ 0 ];
	int M = token[ 1 ];
	if ( N == 0 && M == 0 ) break;
	int r = to!int( strip( readln ) );
	Record[] rs = new Record[]( r );
	foreach ( i; 0 .. r ) {
	  auto record = array( map!( to!int )( split( strip( readln ) ) ) );
	  rs[ i ] = Record( record[ 0 ], record[ 1 ], record[ 2 ], record[ 3 ] );
	}
	int q = to!int( strip( readln ) );
	foreach ( i; 0 .. q ) {
	  auto question = array( map!( to!int )( split( strip( readln ) ) ) );
	  writeln( solve( rs, question ) );
	}
  }  
}

int solve( Record[] rs, int[] question ) {
  Record[] rrs = new Record[]( rs.length + 2 );
  rrs[ 2 .. $ ] = rs[];
  auto start = Record( question[ 0 ], -1, -1, 1 );
  auto end = Record( question[ 1 ], -1, -1, 0 );
  rrs[ 0 ] = start;
  rrs[ 1 ] = end;
  sort( rrs );
  int ans = 0;
  int count = 0;
  bool ok = false;
  Record prev = Record( 540, -1, -1, -1 );
  // stderr.writeln( rrs );
  foreach ( i, r; rrs[ 0..$-1 ] ) {
	// stderr.writeln( r );
	if ( r == start ) {
	  // stderr.writeln( "start" );
	  ok = true;
	} else if ( r == end ) {
	  // stderr.writeln( "end" );
	  ok = false;
	  break;
	} 
	if ( r.m == question[ 2 ] && r.s == 1 ) {
	  // stderr.writeln( "count++, ", count + 1 );
	  count++;
	} else if ( r.m == question[ 2 ] && r.s == 0 ) {
	  // stderr.writeln( "count--, ", count - 1 );
	  count--;
	}
	if ( ok && count > 0 ) {
	  // stderr.writeln( "add time, ", rrs[ i + 1 ].t - rrs[ i ].t );
	  ans += rrs[ i + 1 ].t - rrs[ i ].t;
	}
  }
  return ans;
}

Measured memory_bytes: 2556
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = INT_MAX;
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
	// cin >> tc;
	while (tc--) {

		ll n, m, l, r;
		ll i, j;
		ll x, y;

		ll w, s;
		cin >> s >> w;

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

Measured memory_bytes: 3612
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
#mod = 10**9 + 7
#mod = 9982443453
mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
A = readInts()
ans = float('inf')
for i in range(1,101):
    diff = 0
    for j in range(n):
        diff += pow(A[j]-i,2)
    ans = min(ans,diff)
print(ans)


Measured memory_bytes: 77516
#include<stdio.h>
int main()
{
	int n;
	long long a[100];
	scanf("%d",&n);
	a[0]=2;
	a[1]=1;
	for(int i=2;i<=n;i++)a[i]=a[i-1]+a[i-2];
	printf("%lld\n",a[n]);
} 

Measured memory_bytes: 888
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();

		for (int i=0; i<20; i++) {
			if (x > 105*i && x < 100*(i+1)) {
				System.out.println("0");
				System.exit(0);
			}
		}
		System.out.println(1);
	}
}

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

int main(void) {
    int a[5];
    char c;
    while (cin >> a[0] >> c >> a[1] >> c >> a[2] >> c >> a[3] >> c >> a[4]) {
        int b[14] = {};
        for (int i = 0; i < 5; ++i) ++b[a[i]];
        sort(a, a+5);
        sort(b, b+14, greater<int>());


        if (b[0] == 4 || b[0] == 5)
            cout << "four card" << endl;
        else if (b[0] == 3 && b[1] == 2)
            cout << "full house" << endl;
        else if (((a[0]+1 == a[1]) && (a[1]+1==a[2]) && (a[2]+1==a[3]) && (a[3]+1==a[4])) ||
                 (a[0] == 1 && a[1]==10 && a[2]==11 && a[3]==12 && a[4]==13))
            cout << "straight" << endl;
        else if (b[0] == 3)
            cout << "three card" << endl;
        else if (b[0] == 2 && b[1] == 2)
            cout << "two pair" << endl;
        else if (b[0] == 2 )
            cout << "one pair" << endl;
        else
            cout << "null" << endl;
    }
    return 0;
}



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

int main(){
    string s;
    cin >> s;
    vector<int> ans((int)s.length(), 0);

    /*
    for(int i = 0; i < (int)s.length(); i++){
        int ch = 0, j;
        if(s[i] == 'R'){
            for(j = i + 1; ; j++){
                if(s[j] == 'L') break;
                ch++;
            }
            if(ch % 2 == 0) ans[j-1]++;
            else ans[j]++;
        }
        else{
            for(j = i - 1; ; j--){
                if(s[j] == 'R') break;
                ch--;
            }
            if(ch % 2 == 0) ans[j+1]++;
            else ans[j]++;
        }
    }
    */

    for(int i = 0; i < (int)s.length(); i++){
        if(s[i] == 'R' && s[i+1] == 'L'){
            for(int j = i; j >= 0; j--){
                if(s[j] == 'L') break;
                if((i - j) % 2 == 0) ans[i]++;
                else ans[i+1]++;
            }
            for(int j = i + 1; j < (int)s.length(); j++){
                if(s[j] == 'R') break;
                if((j - i) % 2 == 0) ans[i]++;
                else ans[i+1]++;
            }
        }
    }

    for(auto it : ans) cout << it << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;
ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 2e5+9;
const ll inf = 1e18+9;
// ll a[N];
// f[i][j] = min height acheived if amongst i ppl j ppl put 
// f[i][j] = min(f[i-1][j], f[i-1][j-1] + ppl[i].second)
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int n; cin >> n;
    vector<pair<int, int>> people(n+1);
    for(int i = 1; i <= n; i++) {
        cin >> people[i].first >> people[i].second;
    }
    sort(people.begin() + 1, people.end(), [&](auto l, auto r) {
        return make_pair(l.first + l.second, l.first) < make_pair(r.first + r.second, r.first);
    });
    /*for(int i = 1; i <= n; i++) {
        cout << people[i].first << " " << people[i].second << "\n";
    }
    cout << endl;*/
    vector<vector<long long>> f(n+2, vector<long long>(n+2, inf));
    f[0][0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= i; j++) {
            f[i][j] = min(f[i-1][j], j && people[i].first >= f[i-1][j-1] ? f[i-1][j-1] + people[i].second : inf);
        }
    }
    /*for(int i = 1; i <= n; i++) {
        cout << i << ": ";
        for(int j = 1; j <= n; j++) {
            cout << f[i][j] << " ";
        }
        cout << "\n";
    }*/
    for(int i = n; i >= 0; i--) {
        if(f[n][i] < inf) {
            cout << i << "\n";
            break;
        }
    }

    return 0;
    
}

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

using namespace std;

typedef long long ll;

void cldflm()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w" , stdout);
#endif
}

int main()
{

	cldflm();

	int n;
	cin >> n;

	int arr[n + 1] = {0};

	int x = 1, y = 1, z = 1;
	int flag = 0;
	int mm = 1;

	while (true)
	{
		ll sm = 0;
		sm = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
		if (sm <= n)
			arr[sm]++;
		z++;
		if (sm > n)
		{
			if (mm)
			{
				flag = z;
				mm = 0;
			}
			z = 1;
			y++;
			if (y > flag)
			{
				y = 1;
				z = 1;
				x++;
				if (x > flag)
					break;
			}

		}
	}


	for (int i = 1; i < n + 1; i++)
		cout << arr[i] << '\n';


	return 0;
}



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

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

  vector<vector<int>> dp(n, vector<int>(n));

  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = n - 1; j >= 0; j--) {
      if (s[i] != s[j]) {
        dp[i][j] = 0;
      } else {
        if (i == n - 1 || j == n - 1) {
          dp[i][j] = min(abs(i - j), 1);
        } else {
          dp[i][j] = min(abs(i - j), dp[i + 1][j + 1] + 1);
        }
      }
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
  int x;
  cin>>x;
  
  if(x>=400 && x<600)
    cout<<"8"<<endl;
  else if(x>=600 && x<800)
    cout<<"7"<<endl;
  else if(x>=800 && x<1000)
    cout<<"6"<<endl;
  
 else if(x>=1000 && x<1200)
    cout<<"5"<<endl;
  else if(x>=1200 && x<1400)
    cout<<"4"<<endl;
  else if(x>=1400 && x<1600)
    cout<<"3"<<endl;
  else if(x>=1600 && x<1800)
    cout<<"2"<<endl;
  else
    cout<<"1"<<endl;
  
  
  
  return 0;}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a + b >= 10) puts("error");
  else cout << a+b << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;
struct po{
  int a,b,c;
  bool operator <(const po &q)const{
      if(a!=q.a)return a<q.a;
      if(b!=q.b)return b<q.b;
      return c<q.c;
  }
};
set<po>o;
int n,ans;
int x[3];
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d%d",x,x+1,x+2);
        sort(x,x+3);
        if(o.find(po{x[0],x[1],x[2]})!=o.end())ans++;
        else o.insert(po{x[0],x[1],x[2]});
    }
    printf("%d\n",ans);
}



Measured memory_bytes: 3336
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int N,M;
	int[] T,P,X;
	public void solve() {
		N = nextInt();
		T = new int[N];
		for(int i = 0;i < N;i++){
			T[i] = nextInt();
		}

		M = nextInt();
		P = new int[M];
		X = new int[M];
		for(int i = 0;i < M;i++){
			P[i] = nextInt();
			X[i] = nextInt();
		}

		for(int i = 0;i < M;i++){

			long sum = 0;
			for(int j = 0;j < N;j++){
				if(j == P[i] - 1){
					sum += X[i];
				}else{
					sum += T[j];
				}
			}

			out.println(sum);
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 8276
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#define MAXA 100000
#define MAX 20000000000
#define s(i) scanf("%d", &(i))
#define p(i) printf("%d", (i))
#define ps() printf(" ")
#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))
#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))
using namespace std;
struct{
    int a = 0;
    int b = 0;
}num[101];
int main(){
    int a,b,c,d, i;
    cin >> a >> b >> c >> d;
    rer(i,a,b){
        num[i].a = 1;
    }
    rer(i,c,d){
        num[i].b = 1;
    }
    int Count = 0;
    rer(i,0,101){
        if(num[i].a==1&&num[i].b==1){
//        	cout << i <<endl; 
            Count++;
        }
    }
    cout << Count << endl;
    return 0;
}




Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(n)
	
	string ans="";
	while(n!=0)
	{
		if(n%26==0)
			ans+='z';
		else
		ans+=('a'-1+n%26);
		n--;
		n/=26;
	}
	reverse(all(ans));
	cout<<ans<<'\n';
	printclock;
}

Measured memory_bytes: 3840
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct {
  int to;
  int cost;
};

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

map<int, pair<int, int>> m;
map<pair<int, int>, ll> check;
int main() {
  int H, W, D, Q;
  cin >> H >> W >> D;
  rep(i, H) {
    rep(j, W) {
      int a;
      cin >> a;
      m[a] = make_pair(i, j);
    }
  }
  cin >> Q;
  vector<int> L(Q), R(Q);
  rep(i, Q) cin >> L[i] >> R[i];
  ll cost = 0;
  int nowi = 0;
  int nowj = 0;
  for (int i = 1; i <= H * W; i++) {
    check[make_pair(1, i)] = 0;
  }
  for (int i = D + 1; i <= H * W; i++) {
    check[make_pair(1, i)] = check[make_pair(1, i - D)] +
                             abs(m[i].first - m[i - D].first) +
                             abs(m[i].second - m[i - D].second);
  }
  rep(i, Q) cout << check[make_pair(1, R[i])] - check[make_pair(1, L[i])]
                 << endl;

  return 0;
}

Measured memory_bytes: 13184
while(n = gets.chomp) != '0 0'
  a, b = n.split(' ').map(&:to_i)
  a.times do |x|
    _t = ''
    s = (x % 2).zero? ? '#.' : '.#'
    b.times{ |y| _t += (y % 2).zero? ? s[0] : s[1] }
    puts _t
  end
  puts ''
end

Measured memory_bytes: 9328
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int W, a, b; cin >> W >> a >> b;

  if (a < b) {
    auto c = a + W;
    auto d = b;
    auto ans = std::max(0, d - c);
    cout << ans << CRLF;
  } else if (a == b) {
    cout << 0 << CRLF;
  } else {
    auto c = b + W;
    auto d = a;
    auto ans = std::max(0, d - c);
    cout << ans << CRLF;
  }
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("Os")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(ll i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<pair<int,int>,int> &a, const pair<pair<int,int>,int> &b)
{
    return (a.first.second<b.first.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
}
int main()
{
    vok();
    ll n;
    IN n;
    ll ans=0;
    loop(i,1,n+1)
    {
        loop(j,1,n+1)
        {
            loop(k,1,n+1)
            {
                ans+=gcd(k,gcd(i,j));
            }
        }
    }
    OUT ans;
    return 0;
}

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

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i=0;i<H;i++) cin >> S[i];
    int MAX = 0;
    vector<pair<int, int>> D{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    for(int si=0;si<H;si++){
        for(int sj=0;sj<W;sj++){
            if (S[si][sj] == '#') continue;
            for(int gi=0;gi<H;gi++){
                for(int gj=0;gj<W;gj++){
                    if(si == gi && sj == gj) continue;
                    if(S[gi][gj] == '#') continue;
                    vector<vector<int>> check(H, vector<int>(W));
                    check[si][sj] = 1;
                    vector<vector<int>> dist(H, vector<int>(W));
                    queue<pair<int, int>> Q;
                    bool find_goal = false;
                    Q.push({si, sj});
                    while(!Q.empty()){
                        pair<int, int> P = Q.front();
                        Q.pop();
                        int y = P.first, x = P.second;
                        for (const auto& d : D){
                            int dy = d.first, dx = d.second;
                            if(y+dy < 0 || y + dy >= H || x+dx < 0 || x+dx >= W) continue;
                            if (S[y+dy][x+dx] == '#') continue;
                            if (check[y+dy][x+dx]) continue;
                            check[y+dy][x+dx] = 1;
                            dist[y+dy][x+dx] = dist[y][x] + 1;
                            if ((y+dy) == gi && (x+dx) == gj){
                                MAX = max(MAX, dist[gi][gj]);
                                find_goal = true;
                                break;
                            }
                            Q.push({y+dy, x+dx});
                        }
                        if (find_goal) break;
                    }
                }
            }
        }
    }
    cout << MAX << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int gcd(int a, int b){		//ユークリッドの互除法を用いた最大公約数
	int r = a%b;
	return r?gcd(b, r):b;
}

int main(void){
    int count, x, y;
    scanf("%d %d", &x, &y);
    printf("%d\n", gcd(x, y));
    return 0;
}


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

int main() {
  int n; cin >> n;
  int f[45]; f[0] = 1; f[1] = 1;
  for (int i =2; i<=n; i++) {
    f[i] = f[i-1] + f[i-2];
  }
  cout << f[n] << endl; 
}



Measured memory_bytes: 3132
n, k = map(int,input().split())


mod = 10**9+7
N = 10**4  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N+1):
	fact.append((fact[-1]*i)%mod)
	inv.append((-inv[mod%i]*(mod//i))%mod)
	factinv.append((factinv[-1]*inv[-1])%mod)


if n <= k:
	print(fact[k]*factinv[k-n] % mod)
else:
	print(0)


Measured memory_bytes: 6840
N = int(input())
I = [input().split() for _ in range(N)]

for i in range(N):
    I[i][0] = int(I[i][0])
    I[i][1] = int(I[i][1])
    I[i][3] = int(I[i][3])

I.sort()

for i in I:
    print(*i)



Measured memory_bytes: 57516
#include<stdio.h>

int main(void)
{
	int n,m,l,i,j,k;
	long long int a[101][101],b[101][101],c[101][101]={0};
	scanf("%d %d %d",&n,&m,&l);

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

	for(i=0;i<m;i++)
	{
		for(j=0;j<l;j++)
		{
			scanf("%lld",&b[i][j]);
		}
	}

	for(i=0;i<n;i++)
	{
		for(k=0;k<m;k++)
		{
			for(j=0;j<l;j++)
			{
				c[i][j]+=a[i][k]*b[k][j];
			}
		}
	}

	for(i=0;i<n;i++)
	{
		for(j=0;j<l;j++)
		{
			printf("%lld",c[i][j]);
			if(j!=l-1)
			{
				printf(" ");
			}
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2104
use proconio::{fastout, input};

use rand::prelude::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::time::SystemTime;

#[fastout]

fn calc_score(d: usize, c: &Vec<i64>, s: &Vec<[i64; 27]>, t: &Vec<usize>) -> i64 {
    let mut res = 0;
    let mut last: [usize; 26 + 1] = [0; 26 + 1];
    for day in 1..=d {
        let now_contest = t[day];
        res += s[day][now_contest];
        last[now_contest] = day;
        for contest in 1..=26 {
            res -= c[contest] * (day - last[contest]) as i64;
        }
    }
    res
}

fn get_time(time: SystemTime) -> f64 {
    time.elapsed().unwrap().as_secs_f64()
}

fn main() {
    let time = SystemTime::now();
    let mut rand = rand_pcg::Pcg64Mcg::new(890482);

    // input
    input! {
        d: usize,
        _c: [i64; 26],
        _s: [[i64; 26]; d],
    }

    let mut c = vec![0];
    c.extend(_c.iter());

    let mut s = vec![[0; 26 + 1]; d + 1];
    for day in 1..=d {
        for contest in 1..=26 {
            s[day][contest] = _s[day - 1][contest - 1]
        }
    }

    let mut t = vec![1; d + 1];

    // process
    let mut score = calc_score(d, &c, &s, &t);
    while get_time(time) < 1.95 {
        for _ in 1..=1000 {
            if rand.gen_bool(0.5) {
                let day = rand.gen_range(1, d + 1);
                let contest = rand.gen_range(1, 26 + 1);

                let tmp = t[day];
                t[day] = contest;
                let next_score = calc_score(d, &c, &s, &t);
                if next_score > score {
                    score = next_score;
                } else {
                    t[day] = tmp;
                }
            } else {
                let day = rand.gen_range(1, d);

                let tmp = t[day];
                t[day] = t[day + 1];
                t[day + 1] = tmp;

                let next_score = calc_score(d, &c, &s, &t);
                if next_score > score {
                    score = next_score;
                } else {
                    t[day + 1] = t[day];
                    t[day] = tmp;
                }
            }
        }
    }

    for i in 1..=d {
        println!("{}", t[i]);
    }
}


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

int main()
{
  int64_t A, B, C, ans = 0;
  cin >> A >> B >> C;
  if (A == B && B == C)
  {
    if (A % 2)
      cout << 0 << endl;
    else
      cout << -1 << endl;
  }
  else
  {
    while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0)
    {
      int64_t a = A / 2, b = B / 2, c = C / 2;
      A = b + c;
      B = c + a;
      C = a + b;
      ans++;
    }
    cout << ans << endl;
  }
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> net(n);
    REP(i, m){
        int si, ti;
        cin >> si >> ti;
        si--; ti--;
        net.at(si).push_back(ti);
    }

    vector<double> dp(n, 0);
    for(ll i = n - 2; i >= 0; --i){
        double tmp = 0;
        for(ll j : net.at(i)){
            tmp += dp.at(j);
        }
        dp.at(i) = 1.0 + tmp / net.at(i).size();
    }

    vector<double> prob(n, 0);
    prob.at(0) = 1;
    for(ll i = 0; i < n; ++i){
        for(ll j : net.at(i)){
            prob.at(j) += prob.at(i) / net.at(i).size();
        }
    }

    double ans = dp.at(0);
    for(ll i = 0; i < net.size(); ++i){
        if(net.at(i).size() <= 1){ continue; }
        for(ll j : net.at(i)){
            const double delta = (dp.at(i) - 1.0 - dp.at(j)) / (net.at(i).size() - 1);
            double dp02 = dp.at(0) + prob.at(i) * delta;
            ans = min(ans, dp02);
        }
    }
    printf("%.8f\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
    
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
  	int x,y;
	cin >> x >> y;
	if (x == 2 || y == 2) {
		cout << "No" << endl;
	
	}
	else if (x == 4 || x == 6 || x == 9 || x == 11) {
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			cout << "Yes" << endl;
			
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			cout << "No" << endl;
			
		}
		else {
			cout << "Yes" << endl;
		}
	}


  
 
//////////////////////////////////////////////////////
return 0;}

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

using namespace std;

const int maxn = 2e5+10;

int n,a[maxn],b[maxn],ans=0;

int fin(int x) {
    int lo=0,hi=n;
    while (lo<hi) {
        int mi = (lo+hi+1)/2;
        if (b[mi]<=x) lo=mi;
        else hi=mi-1;
    }
    return lo;
}

int query(int l,int r) {
    return fin(r) - fin(l-1);
}

int main() {
   // freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=1;i<=n;i++) cin>>b[i];
    for (int k=28;k>=0;k--) {
        int tt = 1<<k;
        for (int i=1;i<=n;i++) {
            a[i] = a[i] & (2*tt-1);
            b[i] = b[i] & (2*tt-1);
        }
        sort(b+1,b+n+1);
        for (int i=1;i<=n;i++) {
            int sum = query(tt - a[i], 2*tt-1-a[i]) + query(3*tt-a[i], 4*tt-1-a[i]);
            if (sum%2) ans^=tt;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
     
    int main(void){
      char S[4];
      scanf("%s", S);
     
      if(S[0] == S[1] && S[1] == S[2]){
        printf("No\n");
        return 0;
      }
      if(S[0] == S[1] && S[2] == S[3]){
        printf("Yes\n");
        return 0;
      }
      if(S[1] == S[2] && S[0] == S[3]){
        printf("Yes\n");
        return 0;
      }
      if(S[0] == S[2] && S[1] == S[3]){
        printf("Yes\n");
        return 0;
      }
      if(S[0] == S[1] && S[2] == S[3]){
        printf("Yes\n");
        return 0;
      }
     
      printf("No\n");
     
      return 0;
    }

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

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

    vector<int> aList;
    vector<int> bList;
    vector<int> cList;

    for (int i = 0; i < n; i++)
    {
        int input;
        cin >> input;
        aList.push_back(input - 1);
    }

    for (int i = 0; i < n; i++)
    {
        int input;
        cin >> input;
        bList.push_back(input);
    }

    for (int i = 0; i < n - 1; i++)
    {
        int input;
        cin >> input;
        cList.push_back(input);
    }

    int sum = 0;
    int prev = aList.at(0);
    for (int i = 0; i < n; i++)
    {
        int now = aList.at(i);
        if (now - prev == 1)
        {
            sum += cList.at(prev);
        }
        sum += bList.at(now);
        prev = now;
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
// -----------------------------------------------

//
// Macro debug!
//

#[cfg(debug_assertions)]
include!{"./procon/debug.rs"}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($($arg:expr),*) => {};
}

//
// Macro input!
//

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//
// IteratorExt
//

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}





fn main() {
    input! {
        n: usize,
        xs: [isize; n],
    }
    let s = xs.iter().fold(0, |a, x| a + *x);
    debug!(xs);
    debug!(s);

    let mut min_abs = s;

    for i in 1..n {
        let t = xs.iter().enumerate().fold(0, |a, (j, x)| a + if j <= i { *x } else { 0 });
        min_abs = min(min_abs, (s - 2 * t).abs());
    }

    println!("{}", min_abs);
}


Measured memory_bytes: 4352
s = %w(AKIHABARA KIHABARA AKIHBARA AKIHABRA AKIHABAR KIHBARA AKIHABR AKIHBAR AKIHBRA KIHABRA KIHABAR KIHBRA KIHBAR AKIHBR KIHABR KIHBR)
puts s.include?(gets.chomp) ? "YES" : "NO"

Measured memory_bytes: 14368
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int n; cin>>n;
    bool ok=false;
    string s=to_string(n);
    rep(i,(int)s.size()){
        if(s[i]=='7') ok=true;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


Measured memory_bytes: 3696
import sys
from collections import deque
MOD = 10 ** 9 + 7
def LI(): return map(int, sys.stdin.readline().split())

def main():
    n, k = LI()
    g = [[] for i in range(n+1)]
    for i in range(n-1):
        a, b = LI()
        g[a].append(b)
        g[b].append(a)

    Q = deque([1])
    ans = k
    Qappend = Q.append
    searched = [0] * (n+1)
    searched[1] = 1
    Qp = Q.popleft
    cand = k - 1
    while len(Q) != 0:
        v = Qp()
        for i in g[v]:
            if searched[i] == 1:
                continue
            searched[i] = 1
            ans = ans * cand % MOD
            cand = cand - 1
            Qappend(i)
        cand = k - 2
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 23824
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
#define chmax(x,y) x=max(x,y)

// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/

  int v[3005][3005];
  ll d[3005][3005][4];
int main() {
  int R,C,n;
  cin >> R>>C>>n;
  rep(i,n){
    int r,c,va;
    cin >> r>>c>>va;
    v[r-1][c-1]=va;
  }
  rep(i,R)rep(j,C){
    for(int k=2;k>=0;k--){
      chmax(d[i][j][k+1],d[i][j][k]+v[i][j]);
    }
    rep(k,4){
      chmax(d[i+1][j][0], d[i][j][k]);
      chmax(d[i][j+1][k], d[i][j][k]);
    }
  }
  ll ans=0;
  rep(k, 4){
    chmax(ans, d[R-1][C-1][k]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 320232
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

int main() {
    int n;
    cin >> n;
    int ret = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "E869120")ret++;
    }
    cout << ret << endl;
    return 0;
}



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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    ll n2 = 0;
    ll tmp = 1;
    while(tmp < k){
        tmp <<= 1;
        ++n2;
    }
    vector<vector<ll>> a(n2,vector<ll>(n));
    for(i = 0;i < n;++i){
        cin >> a.at(0).at(i);
        --a.at(0).at(i);
    }
    for(i = 0;i < n2-1;++i){
        rep(j,n){
            a.at(i+1).at(j) = a.at(i).at(a.at(i).at(j));
        }
    }
    ll now = n2-1;
    ll ans = 0;
    while(k){
        if(k & (1ll << now)){
            ans = a.at(now).at(ans);
            k ^= (1ll << now);
        }
        now -= 1;
    }
    cout << ans+1 << endl;
    return 0;
}

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

public class Main {
	private static final byte MASK_RIGHT = 0x0F;
	private static int[][] paper = new int[10][10];

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 128);
		String sLine;
		while ((sLine = reader.readLine()) != null) {
			droppingInk(sLine.charAt(0) & MASK_RIGHT, sLine.charAt(2) & MASK_RIGHT, sLine.charAt(4) & MASK_RIGHT);
		}
		calcResult();
	}

	private static void droppingInk(int x, int y, int size) {
		staining(x, y - 1);
		staining(x - 1, y);
		staining(x, y);
		staining(x + 1, y);
		staining(x, y + 1);
		if (size == 1) {
			return;
		}

		staining(x - 1, y - 1);
		staining(x + 1, y - 1);
		staining(x - 1, y + 1);
		staining(x + 1, y + 1);
		if (size == 2) {
			return;
		}

		staining(x, y - 2);
		staining(x - 2, y);
		staining(x + 2, y);
		staining(x, y + 2);
	}

	private static void staining(int x, int y) {
		if (x >= 0 && x < 10 && y >= 0 && y < 10) {
			paper[x][y]++;
		}
	}

	private static void calcResult() {
		int white = 0;
		int maxnoud = 0;
		for (int[] row : paper) {
			for (int colum : row) {
				if (colum == 0) {
					white++;
				} else if (colum > maxnoud) {
					maxnoud = colum;
				}
			}
		}
		System.out.println(white + System.getProperty("line.separator") + maxnoud);
	}
}

Measured memory_bytes: 16844
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;
bool primes[1000001];vi prime; void seive(); int gcd(int a, int b); int power(int x, int y);

int32_t main(void){
	IOS;
	in2(n, k);
	int arr[n];
	rep(i, 0, n) cin>>arr[i];
	rep(i, k, n)
	{
		if(arr[i-k] < arr[i]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}


Measured memory_bytes: 5176
using System;
using System.Collections.Generic;

class MainClass
	{
		public static void Main (string[] args)
		{
			string str;
			List<int> digit = new List<int> ();
			while (!string.IsNullOrEmpty(str = Console.ReadLine())) {
				string[] input = str.Split(' ');
				int a = int.Parse(input[0]);
				int b = int.Parse(input[1]);
				int c = a + b;
				digit.Add((int)c.ToString().Length);
			}

			for (int i = 0; i < digit.Count; i++) {
				Console.WriteLine (digit[i]);
			}

			Console.Read ();
		}
	}

Measured memory_bytes: 8940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef complex<double> P;  // Point
static const double EPS = 1e-6;

int main() {
	int N;
	while (cin >> N, N) {
		vector<P> points;
		priority_queue<tuple<int, double, double, double>, vector<tuple<int, double, double, double>>> pq;
		rep(n, N) {
			double x, y;
			cin >> x >> y;
			points.push_back(P(x, y));
		}
		tuple<int, double, double, double> s = make_tuple(N, -5.0, 5.0, 5.0);
		pq.push(s);
		while(!pq.empty()) {
			s = pq.top();
			//cout << get<1>(s)<< " " <<get<0>(s) << endl;
			if (-get<1>(s) < EPS) break;
			pq.pop();
			double r = -get<1>(s) / 2;
			rep(i, 2) {
				rep(j, 2) {
					double x1 = get<2>(s) - get<1>(s) / 2 + i * get<1>(s);
					double y1 = get<3>(s) - get<1>(s) / 2 + j * get<1>(s);
					int cnt = 0;
					P p1 = P(x1, y1);
					for(auto p2 : points) {
						if (abs(p1 - p2) < r * sqrt(2) + 1 + EPS) cnt++;
					}
					pq.push(make_tuple(cnt, -r, x1, y1));
				}
			}
		}
		cout << get<0>(s) << endl;
	}
}


Measured memory_bytes: 3240
N = int(input())
A = [0]+list(map(int, input().split()))+[0]

sum = 0
for j in range(len(A)-1):
    sum += abs(A[j]-A[j+1])
for i in range(N):
    print(sum - abs(A[i] - A[i+1]) - abs(A[i+1] - A[i+2]) + abs(A[i] - A[i+2]))
    


Measured memory_bytes: 13916