akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] x = new int[n];
        int min = Integer.MAX_VALUE;
        x[0] = 0;
        for (int i=0;i<n;i++){
            x[i]=sc.nextInt();
        }

        for (int i=k-1;i<n;i++){
            int abs = Math.abs(x[i]-x[i-k+1]);
            min = Math.min(min,Math.min(Math.abs(x[i])+ abs,Math.abs(x[i-k+1])+ abs));
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 50496
#include<bits/stdc++.h>
using namespace std;
int n,h,x;
string st;
int main()
{
    cin>>n>>st;
    for(int i=0; i<n; i++)
    {if(st[i]=='I')h++; else h--;x=max(x,h);}
    cout<<x;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		int w[301];
		for(int i = 0; i < n; i++){
			cin >> w[i];
		}
		vector<vector<bool> > canerase(n + 1, vector<bool>(n + 1, false));
		// canerase[i][j] = i番目のやつから数えてj個(i番目を含む)を落とせるか
		for(int i = 0; i < n - 1; i++){
			canerase[i][2] = (abs(w[i] - w[i + 1]) <= 1);
		}
		for(int i = 4; i <= n; i++){
			for(int j = 0; i + j <= n; j++){
				canerase[j][i] = (abs(w[j] - w[i + j - 1]) <= 1) && canerase[j + 1][i - 2];
				for(int k = 2; k <= i; k++){
					canerase[j][i] = canerase[j][i] || (canerase[j][k] && canerase[j + k][i - k]);
					// cout << canerase[j][i] << endl;
				}
				// cout << j << " " << i << " " << (canerase[j][i]?1:2) << endl;
			}
		}
		int maxnum[301][301] = {};
		int ans = 0;
		for(int i = 2; i <= n; i++){
			for(int j = 0; i + j <= n; j++){
				if(canerase[j][i]) maxnum[j][i] = i;
				for(int k = 2; k <= i; k++){
					maxnum[j][i] = max(maxnum[j][i], maxnum[j][k] + maxnum[j + k][i - k]);
				}
				ans = max(ans, maxnum[j][i]);
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <stdlib.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define Rep(i, s, n) for (int i = (int)s; i < (int)n; i++)

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

    int n, l;
    cin >> n >> l;
    int sum = n * l + n * (n-1) / 2;
    int min = abs(sum);
    rep(i, n) {
        int tmp = abs(sum - (sum - (i + l)));
        if (min > tmp) min = tmp;
    }
    if (sum > 0) cout << sum - min << endl;
    else cout << sum + min << endl;
}

Measured memory_bytes: 3684
//define debug for debugging
//#define DEBUG
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define MAX 100000 + 100
#define max3(a,b,c) max(a,max(b,c))
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int n,cevap = -1;
int arr[MAX][3],dp[MAX][3][3];
void dfs(int a,int b,int c){
    if(a == -1){
        dfs(0,0,1);
        dfs(0,1,2);
        dfs(0,2,0);
        cevap = max3(dp[0][0][1],dp[0][1][2],dp[0][2][0]);
    }else if(dp[a][b][c] == 0){
        int mn = 0;
        if(a+1 < n){
            if(c != 0){
                dfs(a+1,c,0);
                mn = dp[a+1][c][0];
            }
            if(c != 1){
                dfs(a+1,c,1);
                mn = max(mn,dp[a+1][c][1]);
            }
            if(c != 2){
                dfs(a+1,c,2);
                mn = max(mn,dp[a+1][c][2]);
            }
        }else
            mn = 0;
        dp[a][b][c] = mn + arr[a][c];
        //cout << a << ' ' <<  b << ' ' << c << ' ' << dp[a][b][c] << ' ' << mn << ' ' << arr[a][c] << '\n';
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef DEBUG
    freopen("i.txt","r",stdin);
    freopen("o.txt","w",stdout);
#endif              
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }
    dfs(-1,-1,-1);
    cout << cevap;
    return 0;
}


Measured memory_bytes: 12800
#include<iostream>
using namespace std;
int main (void)
{
	string S;
	cin >> S;
	int length = S.length ();
	int residue = 0;
	for (int i = 0; i < length; i++)
	{
		residue = (residue + (int)(S[i] - '0')) % 9;
	}
	if (residue == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3692
import sys

#fin = open("test.txt", "r")
fin = sys.stdin

while True:
	[m, f, r] = list(map(int, fin.readline().split()))

	if m == -1 and f == -1 and r == -1:
		break

	sum_mf = m + f
	if m == -1 or f == -1:
		print("F")
	elif sum_mf >= 80:
		print("A")
	elif sum_mf >= 65:
		print("B")
	elif sum_mf >= 50:
		print("C")
	elif sum_mf >= 30:
		if r >= 50:
			print("C")
		else:
			print("D")
	else:
		print("F")

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

long long sum(int size,int ary[]);		//????¨?????±?????????¢??°???????????????????????£?¨?
int min(int size,int ary[]);			//????°????????±?????????¢??°???????????????????????£?¨?
int max(int size,int ary[]);			//?????§???????±?????????¢??°???????????????????????£?¨?


int main(){
	int size=0;
	cin >>size;
	int nums[size];
	for(int i=0;i<size;i++){
		cin >> nums[i];
	}
	
	int a=0,b=0;
	long long c=0;
	a=min(size,nums);
	b=max(size,nums);
	c=sum(size,nums);
	cout <<a<<" "<<b<<" "<<c<<endl;		//????????????

	return 0;	
}

long long sum(int size,int ary[]){		//????¨??°??????¨??¢??°
	long long ret=0;
	for(int i=0;i<size;i++){			//??????????´??????????????????????
		ret +=ary[i];
	}
	return ret;
}

int min(int size,int ary[]){			//????°?????°??????¨??¢??°
	int ret=ary[0];
	for(int i=1;i<size;i++){
		if(ary[i]<ret) ret = ary[i];	//??????????´??????????????????????
	}
	return ret;
}

int max(int size,int ary[]){			//?????§????°??????¨??¢??°
	int ret=ary[0];
	for(int i=1;i<size;i++){
		if(ary[i]>ret) ret = ary[i];	//??????????´??????????????????????
	}
	return ret;
}

Measured memory_bytes: 1204
const log = console.log;

const createScanFunctions = (input: string) => {
  const str = input.trim();
  const len = str.length;
  let index = 0;

  const scan = () => {
    const startIndex = index;

    while (index < len) {
      const char = str[index];

      if (char === " " || char === "\n")
        return str.substring(startIndex, index++);

      index++;
    }

    return str.substr(startIndex);
  };

  const scanInt = () => parseInt(scan());

  return { scan, scanInt };
};

// ----

function Main(input: string): void {
  const { scanInt } = createScanFunctions(input);
  const [n, m] = [scanInt(), scanInt()];

  const cityRoadCountArray = Array<number>(n + 1).fill(0);

  for (let i = 0; i < m; i++) {
    cityRoadCountArray[scanInt()]++;
    cityRoadCountArray[scanInt()]++;
  }

  for (let i = 1; i <= n; i++) log(cityRoadCountArray[i]);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

struct segtree{
    int n;
    vector<int> dat;
    segtree(int size,int x){
        n=1;
        while(n<size) n*=2;
        dat.assign(2*n-1,x);
    }
    // update k th element
    void update(int k,int a) {
        k+=n-1; // leaf
        dat[k]=a;
        while(k>0) {
            k=(k-1)/2;
            dat[k]=min(dat[k*2+1],dat[k*2+2]);
        }
    }
    // min [a, b)
    int query(int a,int b) { return query(a,b,0,0,n); }
    int query(int a,int b,int k,int l,int r) {
        if(r<=a or b<=l) return inf;
        if(a<=l and r<=b) return dat[k];
        int m=(l+r)/2;
        return min(query(a,b,k*2+1,l,m),query(a,b,k*2+2,m,r));
    }
};

void solve(){
    int w;
    cin >> w;
    vector<int> a(w);
    rep(i,0,w) cin >> a[i];

    vector<int> out;
    segtree seg1(w,inf),seg2(w,inf);
    out.emplace_back(-1);
    rep(i,0,w){
        if(a[i]==0) out.emplace_back(i);
        if(a[i]<0){
            seg1.update(i,-a[i]+i);
            seg2.update(i,-a[i]-i);
        }
    }
    out.emplace_back(inf);

    int ans=0;
    rep(i,0,w){
        if(a[i]<=0) continue;
        const int pos=i,num=a[i];
        const int left_out=*(upper_bound(out.begin(),out.end(),pos)-1),right_out=*(upper_bound(out.begin(),out.end(),pos));
        const int left_shutter=seg1.query(left_out,pos),right_shutter=seg2.query(pos,right_out);
        auto ok=[&](const int x){
            if(left_shutter==inf and left_out!=-1) return true;
            if(right_shutter==inf and right_out!=inf) return true;
            if(left_out!=-1 and x-1+pos<left_shutter) return true;
            if(right_out!=inf and x-1-pos<right_shutter) return true;
            return false;
        };
        int lb=0,ub=num+1;
        while(ub-lb>1){
            const int mid=(lb+ub)/2;
            if(ok(mid)) lb=mid;
            else ub=mid;
        }
        ans+=lb;
    }
    cout << ans << endl;
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		String[] s = nextStrings();
		
		String ans ="A"+s[1].substring(0,1).toUpperCase()+"C";
		System.out.println(ans);

	}

	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22484
#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,l;
    cin >> n >> l;
    vector<int> vec(n);
    rep(i,n) vec[i]=l+i;
    int sum=0;
    rep(i,n) sum+=vec[i];
    if(l>=0) sum-=vec[0];
    else if(l+n-1<0) sum-=vec[n-1];
    cout << sum << endl;
}

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


int main(){
  int a;
  cin >> a;
  cout << a*a*a+a*a+a << endl;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define INF (1LL << 60)
#define int long long
#define magic 100000
using namespace std;

int dp[3001][3001]; // i, j
// dp[i][j] : lcs of s[1:i] and t[1:j]

string ans;
int32_t main(){
	string s, t;
	cin >> s >> t;
	for(int i = 0; i < (int) s.size(); i++){
		for(int j = 0; j < (int) t.size(); j++){
			dp[i + 1][j + 1] = max(dp[i+1][j], dp[i][j+1]);
			if(s[i] == t[j]){
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
			}
		}
	}
	int i = s.size() - 1, j = t.size() - 1;
	while(i != -1 && j != -1){
		if(s[i] == t[j] && dp[i+1][j+1] == dp[i][j] + 1){
			ans.push_back(s[i]);
			i--; j--;
		}else if(dp[i+1][j+1] == dp[i+1][j]){
			j--;
		}else{
			i--;
		}
	}
	for(int i = (int) ans.size() - 1; i >= 0; i--){
		cout << ans[i];
	}
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


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

    ll sum = 0;
    for(ll i = n - 1; i >= 1; i--){
        sum += i;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3596
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


template <typename integer>
integer _gcd(integer a, integer b) {
    if (b != 0) return _gcd(b, a%b);
    else return a;
}

template <typename integer>
integer gcd (integer a, integer b) {
    if (a > b) return _gcd(a, b);
    return _gcd(b, a);
}

template<typename integer>
integer lcm(integer a, integer b) {
    return (a * b) / gcd(a, b);
}

int f(int a) {
    int ret = 0;
    while (a%2 == 0) {
        a /= 2;
        ret++;
    }
    return ret;
}


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

    vector<long long> a(n);
    for (int i=0; i<n; i++) {
        cin >> a[i];
        a[i] /= 2;
    }

    int t = f(a[0]);
    for (int i=0; i<n; i++) {
        if (f(a[i]) != t) {
            cout << 0 << endl;
            return 0;
        }
        a[i] >>= t;
    }
    m >>= t;


    long long l = 1;
    for (int i=0; i<n; i++) {
        l = lcm(l, a[i]);
        if (l > m) {
            cout << 0 << endl;
            return 0;
        }
    }

    m /= l;
    cout << (m+1)/2 << endl;

    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define vi vector<int>
#define pb push_back
#define log(x,b) (log(b)/log(x))
#define rep(i,x,y) for(int i=(x);i<(y);i++)
using namespace std;


int32_t main()
{
    int n,m;
    cin>>n>>m;
    string s[n],t[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<m;i++){
        cin>>t[i];
    }
    rep(i,0,n-m+1)rep(j,0,n-m+1){
        bool flg=1;
        rep(h,0,m)rep(w,0,m){
            if(s[i+h][j+w]!=t[h][w])flg=0;
        }
        if(flg){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";

    return 0;
}


Measured memory_bytes: 3564
#include <stdio.h>

int main(void){
	int a, b, i, j, hit, blow;
	while (1){
		hit = 0; blow = 0;
		scanf("%d%d", &a, &b);
		if (a == 0) break;
		for (i = 1000; i >= 1; i/= 10){
			for (j = 1000; j >= 1; j /= 10){
				if ((a/i)%10 == (b/j)%10){
					if (i == j) hit++;
					else blow++;
				}
			}
		}
		printf("%d %d\n", hit, blow);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;

ll mpow(ll base,ll exp);
void solve();
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);

int32_t main(){
    SpeedForce
    ll i = 0,j = 0;

    int t;
    t=1;
    //cin >> t;
    while (t--){
        //cout << fixed << setprecision(10);
        solve();
    }
}

void solve(){
    string s;
    cin >> s;
    cout << s.substr(0,3);

}

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

Measured memory_bytes: 3612
/*input
*/
#define debug 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; typedef double db;
const int N = 1e5 + 5, M = 998244353; const db eps = 1e-8;
typedef vector<ll> vi; typedef vector<vi> vii;
void solve();
void print(){cout<<'\n';}template<class T,class ...U>void print(T x, U ...y){cout<<x<<' ';print(y...);}
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  cout << setprecision(3) << fixed;
  if(debug){freopen("main.cpp","r",stdin);string x;cin>>x;}
  solve();
}
//
int a[10], b[10];
void solve() {
  int n; cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int j = 0; j < n; j++) cin >> b[j];
  int cnt = 0, flg = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == b[i]) continue;
    if (a[i] > b[i]) flg = 1;
    else flg = -1;
    break;
  }
  if (!flg) {
    cout << 0 << endl;
    return;
  }
  if (flg == -1) {
    for (int i = 0; i < n; i++) {
      swap(a[i], b[i]);
    }
  }
  do {
    bool flg = 1;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) flg = 0;
    }
    if (flg) break;
    cnt++;
  } while (next_permutation(b, b + n));
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
#include<deque>
#include<iostream>
#include<algorithm>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define all(a)  (a).begin(),(a).end()
#define elif else if


int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}

signed main(){
  int n,x;
  cin>>n>>x;
  V<int> a(n);
  fo(i,n){
    cin>>a[i];
  }
  int ans=abs(x-a[0]);
  for(int i=1; i<n; i++){
    ans=gcd(ans,abs(x-a[i]));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int a;
	int count[7];
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		for (i = 0; i < 7; i++){
			count[i] = 0;
		}
		for (i = 0; i < n; i++){
			scanf("%d", &a);
			if (a >= 60){
				count[6]++;
			}
			else if (a >= 50){
				count[5]++;
			}
			else if (a >= 40){
				count[4]++;
			}
			else if (a >= 30){
				count[3]++;
			}
			else if (a >= 20){
				count[2]++;
			}
			else if (a >= 10){
				count[1]++;
			}
			else {
				count[0]++;
			}
		}
		
		for (i = 0;i < 7; i++){
			printf("%d\n", count[i]);
		}
		
	}
	
	return (0);
}

Measured memory_bytes: 596
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a,b = [0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans,j = 0,M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)

Measured memory_bytes: 47692
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n)  for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define ld long double
#define ull unsigned long long int


void solve()
{
	//freopen("input.txt","r",stdin);

	int n;cin>>n;
	
	if(n%1000==0)
		cout<<to_string(0)<<endl;
	else if(n<1000)
		cout<<to_string(1000-n)<<endl;
	else
	{
		int r=n/1000;
		int u;
		//cout<<r<<endl;
         u=(r+1)*1000;
         cout<<u-n<<endl;
     }
	
}


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

solve();

	return 0;
}

Measured memory_bytes: 3708
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map { it.toInt() }
    var cnt = 0
    for (i in 0 until n) {
        if (p[i] != i + 1 && p[p[i] - 1] != i + 1) return println("NO")
        if (p[i] != i + 1) cnt++
    }
    println(if (cnt <= 2) "YES" else "NO")
}


Measured memory_bytes: 37804
#include <iostream>

using namespace std;
int a[30],b[30],c[30];
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i]; a[i]--;
	}
	for(i=0;i<n;i++){
		cin >> b[i];
	}
	for(i=0;i<n - 1;i++){
		cin >> c[i];
	}
	int res = 0;
	for(i=0;i<n;i++){
		res += b[a[i]];
		if(i!=0){
			if(a[i] - a[i - 1]==1){
				res += c[a[i - 1]];
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        dts: [usize; 3],
    }
    let d = dts[0];
    let t = dts[1];
    let s = dts[2];

    if d <= t * s {
        println!("Yes");
    } else {
        println!("No");        
    }
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
typedef struct node
{
	int left,right,value;
	bool operator < (const struct node & t)const
	{
		return right<t.right;
	}
}EDGE,*PEDGE;
long long lazy[1<<19];
EDGE arr[1<<18];
long long tree[1<<19];
long long search(int index,int lb,int rb,int lq,int rq)
{
	if(lb==rb||lb==lq&&rb==rq)
		return tree[index];
	if(lazy[index])
	{
		tree[index<<1]+=lazy[index];
		tree[index<<1|1]+=lazy[index];
		lazy[index<<1]+=lazy[index];
		lazy[index<<1|1]+=lazy[index];
		lazy[index]=0;
	}
	int mid=(lb+rb)>>1;
	if(rq<=mid)
		return search(index<<1,lb,mid,lq,rq);
	else if(lq>mid)
		return search(index<<1|1,mid+1,rb,lq,rq);
	else
		return max(search(index<<1,lb,mid,lq,mid),search(index<<1|1,mid+1,rb,mid+1,rq));
}
void update(int index,int lb,int rb,int lq,int rq,long long value)
{
	if(lb==lq&&rb==rq)
	{
		tree[index]+=value;
		lazy[index]+=value;
		return;	
	}
	if(lazy[index])
	{
		tree[index<<1]+=lazy[index];
		tree[index<<1|1]+=lazy[index];
		lazy[index<<1]+=lazy[index];
		lazy[index<<1|1]+=lazy[index];
		lazy[index]=0;
	}
	int mid=(lb+rb)>>1;
	if(rq<=mid)
		update(index<<1,lb,mid,lq,rq,value);
	else if(lq>mid)
		update(index<<1|1,mid+1,rb,lq,rq,value);
	else
	{
		update(index<<1|1,mid+1,rb,mid+1,rq,value);
		update(index<<1,lb,mid,lq,mid,value);
	}		
	tree[index]=max(tree[index<<1],tree[index<<1|1]);
}
int main()
{
	int i,n,m;
	int cnt=0;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)
	{
		scanf("%d %d %d",&arr[i].left,&arr[i].right,&arr[i].value);
	}
	sort(arr,arr+m);
	for(i=1;i<=n;i++)
	{
		update(1,0,n,i,i,search(1,0,n,0,i-1));
		while(i==arr[cnt].right&&cnt<m)
		{
			update(1,0,n,arr[cnt].left,arr[cnt].right,arr[cnt].value);
			cnt++;
		}
	}
	printf("%lld",search(1,0,n,0,n));
	return 0;
}

Measured memory_bytes: 11648
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val r = in.readLine().toDouble

    out.println(Math.PI * 2 * r)
    out.flush()
  }
}


Measured memory_bytes: 54540
import Control.Applicative
main = do
    list <- getLine
    let (a, op, b) = toExpression list
    if op == "?"
        then return ()
        else do
        print $ solve a b op
        main
solve :: Int -> Int -> String -> Int
solve a b op
    | op == "+" = a + b
    | op == "-" = a - b
    | op == "*" = a * b
    | op == "/" = a `div` b
    | otherwise = 0
toExpression :: String -> (Int, String, Int)
toExpression = (\ws -> (read (head ws) :: Int, ws!!1, read (last ws) :: Int)) . words

Measured memory_bytes: 3964
n = int(input())
a = list(map(int, input().split()))

a_sorted=sorted(a)
ans = 1

if a_sorted[len(a_sorted)-1] == 0:
  ans = 0
else:
  for i in range(len(a_sorted)):
    ans = ans * a_sorted[i]
    if ans > 1000000000000000000:
      ans = -1
      break

print(ans)

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

using namespace std;
typedef long long ll;

int N, A, B;
string S;

int main()
{
	ios_base::sync_with_stdio(0);

	cin >> N >> A >> B;
	cin >> S;

	int passed = 0, over_p = 0;
	for (int i = 0; i < N; i++)
	{
		switch(S[i])
		{
			case 'a':
				if (passed < A + B)
				{
					cout << "Yes\n";
					passed++;
				}
				else
				{
					cout << "No\n";
				}
				break;
			case 'b':
				if (passed < A + B && over_p < B)
				{
					cout << "Yes\n";
					passed++;
					over_p++;
				}
				else
				{
					cout << "No\n";
				}
				break;
			case 'c':
				cout << "No\n";
				break;
		}
	}
}

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

int main(){
	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;++i) {
		cin>>v[i];
	}
	int cnt=0;
	for(int i=0;i<n;++i){
		while(v[i]%2==0){
			cnt++;
			v[i]/=2;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

bool b[3][3];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int a[3][3];
	rep(i,0,3)rep(j,0,3)cin >> a[i][j];
	int n;
	cin >> n;
	while(n--){
		int x;
		cin >> x;
		rep(i,0,3)rep(j,0,3)if(a[i][j] == x)b[i][j] = 1;
	}
	bool ans = false;
	rep(i,0,3){
		ans |= (b[i][0] && b[i][1] && b[i][2]);
	}
	rep(j,0,3){
		ans |= (b[0][j] && b[1][j] && b[2][j]);
	}
	ans |= (b[0][0] && b[1][1] && b[2][2]);
	ans |= (b[0][2] && b[1][1] && b[2][0]);
	cout << (ans ? "Yes" : "No") << '\n';
}


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

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> a(n);
	for (int& x : a) {
		scanf("%d", &x);
	}
	vector<bool> dp(k + 1);
	for (int stones = 0; stones <= k; ++stones) {
		for (int x : a) {
			if (stones >= x && !dp[stones - x]) {
				dp[stones] = true;
			}
		}
	}

	puts(dp[k] ? "First" : "Second");
	return 0;
}

Measured memory_bytes: 3732
def resolve():
    a=[list(map(int,input().split())) for _ in range(3)]
    n=int(input())
    b=[int(input()) for _ in range(n)]
    c=[[0,0,0],[0,0,0],[0,0,0]]
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                c[i][j]=1

    ans='No'
    for i in range(3):
        if c[i]==[1,1,1]:
            ans='Yes'
    for i in range(3):
        if [c[0][i],c[1][i],c[2][i]]==[1,1,1]:
            ans='Yes'
    if [c[0][0],c[1][1],c[2][2]]==[1,1,1]:
        ans='Yes'
    if [c[0][2],c[1][1],c[2][0]]==[1,1,1]:
        ans='Yes'
    print(ans)
resolve()

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

#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<ll>>;
template<typename T=ll,typename U=ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
const ll MOD = (ll)1e9+7;
void a(){
    ll k;
    cin >> k;
    v<> s = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << s[k-1];
    return;
}
int main(){
    a();
    return 0;
}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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")
    };
}

fn main() {
    input! {
        n: f64
    }
    let ans = (n - (n / 2.0).floor()) / n;
    println!("{}", ans);
}


Measured memory_bytes: 4352
/** HNUE High School For Gifted Students
 *    author:  Duong Tung
 *    created: 16.11.2018 hh:mm:ss
**/
///------------------------------------------------------------------
#define MyLove "Anime"
///------------------------------------------------------------------
#include <bits/stdc++.h>
///------------------------------------------------------------------
#define IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ifor(i, a, b) for (int i = (a); i <= (b); ++i)
#define dfor(i, a, b) for (int i = (a); i >= (b); --i)
#define zfor(i, n) for (int i = 0; i < (n); ++i)
#define ffor(i, n) for (int i = 1; i <= (n); ++i)
#define ll long long
#define rtr return true
#define go_fuck_yourself return false
#define uc unsigned char
#define NAME "task"
#define NAME1 "ball"
#define UsingFile 0
#define Azusa false
///------------------------------------------------------------------

using namespace std;
const int maxn=1e6+1;
ll a[maxn],b[maxn];

struct T{ll a,b;};

void say(string s) { cout<<s; exit(0); }

long long GCD(ll x,ll y){ return y==0?x:GCD(y,x%y); }

int main(){
    IO;
    if(UsingFile)freopen(NAME1".inp","r",stdin);
    if(UsingFile)freopen(NAME1".out","w",stdout);
    int a,b,c; cin>>a>>b>>c;
    cout<<max(a,max(b,c))*10+a+b+c-max(a,max(b,c));
    return 0;
    /**---------------------------------------**/
    cout<<R"(
)";
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


/*
vvl comb(int n, int r) {
vvl v(n + 1,vl(n + 1, 0));
for (int i = 0; i < v.size(); i++) {
v[i][0] = 1;
v[i][i] = 1;
}
for (int j = 1; j < v.size(); j++) {
for (int k = 1; k < j; k++) {
v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
}
}
return v;
}
*/

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}


int main(){
	int h,w,n;
	int ans=0;
	cin>>h>>w>>n;
	int ma=max(h,w);
	ans=n/ma;
	if(n%ma!=0)ans++;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	
	static final Scanner s=new Scanner(System.in);
	
	public static void main(String args[]){
		Dice d=new Dice();
		for(int i=0;i<6;i++)
			d.v[i]=s.nextInt();
		for(char c:s.next().toCharArray())
			d.roll(c);
		System.out.println(d.v[0]);
	}
}
class Dice{
	public int v[] = {1,2,3,4,5,6};
	/*
	   ####
	  #1 ##
	 #  # #
	####3 #
	#2 # #
	#  ##
	####
	
	*/
	public Dice(){
	}
	
	public void roll(char direction){
		int buf=v[0];
		switch(direction){
		case 'n':
		case 'N':
			v[0]=v[1];
			v[1]=v[5];
			v[5]=v[4];
			v[4]=buf;
			return;
		case 's':
		case 'S':
			v[0]=v[4];
			v[4]=v[5];
			v[5]=v[1];
			v[1]=buf;
			return;
		case 'e':
		case 'E':
			v[0]=v[3];
			v[3]=v[5];
			v[5]=v[2];
			v[2]=buf;
			return;
		case 'w':
		case 'W':
			v[0]=v[2];
			v[2]=v[5];
			v[5]=v[3];
			v[3]=buf;
			return;
		default:
			throw new IllegalArgumentException("Illeagal direction");
		}
	}
}

Measured memory_bytes: 26276
def f_sum(l, r):
    return (l+r)*(r-l+1)//2

n, k = map(int, input().split())

mod = 10**9 + 7
ans = 0
for i in range(k, n+2):
    l = f_sum(0, i-1)
    r = f_sum(n-i+1, n)
    ans += r-l+1
    
print(ans%mod)

Measured memory_bytes: 9020
let rec solve a b c x y =
    match x, y with
    | 0, 0 -> 0
    | _, 0 -> min (a * x) (2 * c * x)
    | 0, _ -> min (b * y) (2 * c * y)
    | _, _ -> min (a + b) (2 * c) + solve a b c (x - 1) (y - 1)

let () =
    Scanf.scanf "%d %d %d %d %d\n" solve |> Printf.printf "%d\n"


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

using namespace std;

void trace(vector<int> a, int n)
{
    for (int k=0; k<n; k++) {
        if (k>0)
            cout << " ";
        cout << a[k];
    }
    cout << endl;
}

vector<int> insertion_sort(vector<int> a, int n)
{
    for (int i=0; i<n; i++) {
        int v = a[i];
        int j = i - 1;
        while (j>=0 && a[j] > v) {
            a[j+1] = a[j];
                j--;
        }
        a[j+1] = v;
        trace(a, n);
    }

    return a;
}

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

    vector<int> a;
    for (int i=0; i<n; i++) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    insertion_sort(a, n);

    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < a; i++){
        if(s[i] < '0' || s[i] > '9'){
            cout << "No" << endl;
            return 0;
        }
    }
    if(s[a] != '-'){
        cout << "No" << endl;
        return 0;
    }
    for(int i = a+1; i <= a+b; i++){
        if(s[i] < '0' || s[i] > '9'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
    const result = [];
    const [n, amount] = input.split(" ").map(str => Number(str));
    for (let x = 0; x <= n; x++) {
        for (let y = 0; y <= n; y++) {
            const z = n - x - y;
            if (z < 0) continue;
            if (amount === 10000 * x + 5000 * y + 1000 * z) {
                console.log(`${x} ${y} ${z}`);
                return;
            }
        }
    }
    console.log("-1 -1 -1");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
 
using namespace std;
 
int MAX = 1001;
 
int main(){
    int N;
    int X[MAX],Y[MAX];
    int odd = -1;
    bool impossible = false;
 
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> X[i] >> Y[i];
 
        if(odd == -1)odd = abs(X[i] + Y[i]) % 2;
        if(odd != abs(X[i] + Y[i]) % 2)impossible = true;
    }
 
    if(impossible){
        cout << -1 << endl;
        return 0;
    }
 
    vector<long long> arms;
 
    if(odd == 0)arms.push_back(1);
 
    for(long long i = 1;i < 1LL << 32;i *= 2){
        arms.push_back(i);
    }    
    
    cout << arms.size() << endl;
    for(int i = 0;i < arms.size();i++){
        cout << arms[i];
        if(i < arms.size() - 1)cout << ' ';
        else cout << endl;
    }
 
    for(int i = 0;i < N;i++){
        long long x = X[i];
        long long y = Y[i];
        stack<char> ans;
 
        for(int i = arms.size()-1;i >= 0;i--){
            long long a = arms[i];
 
            if(abs(x) > abs(y)){
                if(x > 0){
                    ans.push('R');
                    x -= a;
                }else{
                    ans.push('L');
                    x += a;
                }
            }else{
                if(y > 0){
                    ans.push('U');
                    y -= a;
                }else{
                    ans.push('D');
                    y += a;
                }
            }
        }
 
        while(!ans.empty()){
            cout << ans.top();
            ans.pop();
        }
        cout << endl;
    }
 
    return 0;
}

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

int main() {
  int mod=998244353;
  int n;
  cin >> n;
  int ma=0;
  vector<int>x(n),y(n);
  rep(i,n){
    cin>>x.at(i);
    ma=max(ma,x.at(i));
    y.at(x.at(i))++;
  }
  if(x.at(0)!=0||y.at(0)>1){
    cout<<0<<endl;
  }
  else{
    long ans=1;
    rep2(i,1,ma+1){
      int a=y.at(i-1);
      int b=y.at(i);
      long c=1;
      while(b--){
        c=c*a%mod;
      }
      ans=ans*c%mod;
    }
    cout<<ans<<endl;
  }
  
}





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

const double EPS = 1e-12;
inline bool equals(double a, double b) {return fabs(a - b) < EPS;} //判断double相等

struct Point //点
{
	double x, y;
	Point(double x = 0.0, double y = 0.0): x(x), y(y) {}
	void read() {scanf("%lf %lf", &x, &y);}
	
	Point operator + (Point p) {return Point(x + p.x, y + p.y);}
	Point operator - (Point p) {return Point(x - p.x, y - p.y);}
	Point operator * (double a) {return Point(x * a, y * a);}
	Point operator / (double a) {return Point(x / a, y / a);}
	
	double norm() {return x * x + y * y;}
	double abs() {return sqrt(norm());}
	
	bool operator < (const Point &p) const {return !equals(x, p.x) ? x < p.x : y < p.y;}
	bool operator == (const Point &p) const {return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;}
};
struct Segment //线段
{
	Point p1, p2;
	Segment(Point p1 = (Point){0.0, 0.0}, Point p2 = (Point){0.0, 0.0}): p1(p1), p2(p2) {}
	void read() {p1.read(); p2.read();}
};
typedef Point Vector; //向量
typedef Segment Line; //直线

inline double dot(Vector a, Vector b) {return a.x * b.x + a.y * b.y;} //向量内积
inline double cross(Vector a, Vector b) {return a.x * b.y - a.y * b.x;} //向量外积

inline bool check1(Vector a, Vector b) {return equals(dot(a, b), 0.0);} //判断向量正交
inline bool check2(Vector a, Vector b) {return equals(cross(a, b), 0.0);} //判向量断平行

inline Point project(Line s, Point p) //点到直线的投影
{
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / base.norm();
	return s.p1 + base * r;
}
inline Point reflect(Line s, Point p) {return p + (project(s, p) - p) * 2.0;} //点到直线的映像

inline int ccw(Point p0, Point p1, Point p2) //判断线段p0p1和点p2的关系
{
	Vector a = p1 - p0, b = p2 - p0;
	if(cross(a, b) > EPS) return 1; //逆时针
	if(cross(a, b) < -EPS) return -1; //顺时针
	if(dot(a, b) < -EPS) return 2; //p2->p0->p1
	if(a.norm() < b.norm()) return -2; //p0->p1->p2
	return 0; //p0->p2->p1
}
inline bool intersect(Point p1, Point p2, Point p3, Point p4) //判断线段相交
{
	return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
		   ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0;
}

inline double dist1(Point a, Point b) {return (a - b).abs();} //两点距离
inline double dist2(Line l, Point p) {return abs(cross(l.p2 - l.p1, p - l.p1) / (l.p2 - l.p1).abs());} //点到直线的距离
inline double dist3(Segment s, Point p) //点到线段的距离
{
	if(dot(s.p2 - s.p1, p - s.p1) < -EPS) return dist1(p, s.p1);
	if(dot(s.p1 - s.p2, p - s.p2) < -EPS) return dist1(p, s.p2);
	return dist2(s, p);
}
inline double dist4(Segment s1, Segment s2) //线段之间的距离
{
	if(intersect(s1.p1, s1.p2, s2.p1, s2.p2)) return 0.0;
	return min(min(dist3(s1, s2.p1), dist3(s1, s2.p2)), min(dist3(s2, s1.p1), dist3(s2, s1.p2)));
}

inline Point CrossPoint(Segment s1, Segment s2) //线段之间的交点
{
	Vector base = s2.p2 - s2.p1;
	double d1 = abs(cross(base, s1.p1 - s2.p1) / base.abs());
	double d2 = abs(cross(base, s1.p2 - s2.p1) / base.abs());
	double t = d1 / (d1 + d2);
	return s1.p1 + (s1.p2 - s1.p1) * t;
}

int main()
{
	int T;
	Point ans;
	Segment s1, s2;
	scanf("%d", &T);
	while(T--)
	{
		s1.read(), s2.read();
		ans = CrossPoint(s1, s2);
		printf("%.10f %.10f\n", ans.x, ans.y);
	}
	return 0;
}


Measured memory_bytes: 3248
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

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

int main() {

    string S;
    cin >> S;
    ll N = S.length();
    ll L[N+1];
    rep(i,N+1){
        if(i==0) L[0] = 0;
        else{
            if(S[i-1]=='<') L[i] = L[i-1]+1;
            else L[i] = 0;
        }
    }
    ll R[N+1];
    rep(i,N+1){
        if(i==0) R[N] = 0;
        else{
            if(S[N-i]=='>') R[N-i] = R[N-i+1]+1;
            else R[N-i] = 0;
        }
    }
    ll out = 0;
    rep(i,N+1) out += max(L[i],R[i]);
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 8708
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static int	vLim	= 0;
	static int	ｗLim	= 0;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();
		ｗLim = in.nextInt();

		// 1-originにしたいので
		int weight[] = new int[num + 1];
		int value[] = new int[num + 1];
		for ( int i = 1; i <= num; i++ ) {
			weight[i] = in.nextInt();
			value[i] = in.nextInt();
			vLim += value[i];
		}
		in.close();

		long dp[][] = new long[num + 1][vLim + 1];
		for ( long[] ls : dp ) {
			Arrays.fill(ls, Integer.MAX_VALUE);
		}

		for ( int i = 0; i <= num; i++ ) {
			dp[i][0] = 0;
		}

		long ans = 0;
		for ( int n = 1; n <= num; n++ ) {
			for ( int v = 1; v <= vLim; v++ ) {
				dp[n][v] = dp[n - 1][v];

				if ( v - value[n] >= 0 && dp[n - 1][v - value[n]] + weight[n] < dp[n][v] ) {
					dp[n][v] = dp[n - 1][v - value[n]] + weight[n];
				}
			}
		}

//		for ( long[] ls : dp ) {
//			for ( long l : ls ) {
//				System.out.printf("%3d ", l);
//			}
//			System.out.println();
//		}


		for ( int i = 1; i <= vLim; i++ ) {
			if(dp[num][i] <= ｗLim && ans < i) {
				ans = i;
			}
		}
		System.out.println(ans);

	}
}


Measured memory_bytes: 128852
while True:
    L = int(raw_input())
    if L == 0: break
    ans = 0
    for i in range(1, 13):
        M, N = map(int, raw_input().split())
        L -= (M-N)
        if not ans and L <= 0:
            ans = i
    else:
        if ans:
            print ans
        else:
            print 'NA'

Measured memory_bytes: 4208
#include <iostream>

using namespace std;

int main()
{
	int a, b, c, d;
	
	cin >> a >> b >> c >> d;
	
	cout << (abs(a - b) <= d && abs(b - c) <= d || abs(a - c) <= d ? "Yes" : "No") << endl;
	
	return (0);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>
#include <array>

using namespace std;

template<typename M, typename N>
istream& operator>>(istream&is, pair<M,N> & p){is >> p.fi >> p.se; return is;}
template<typename M>
istream& operator>>(istream&is, vector<M> & v){for(auto &it:v) is >> it; return is; }
template<typename M>
istream& operator>>(istream&is, vector<vector<M>> & v){for(auto &it:v) is >> it; return is; }
template<typename M, typename N>
ostream& operator<<(ostream&os, const pair<M,N> &p){os << p.fi << ' ' << p.se << '\n';return os;}
template<typename M>
ostream& operator<<(ostream&os, const vector<M> &v){for(auto it: v)os << it << ' ';cout << '\n';return os;}
template<typename M>
ostream& operator<<(ostream&os, const vector<vector<M>> &v){for(auto it: v)os << it;return os;}

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
#define acc(x) accumulate((x).begin(),(x).end(),0ll)
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e9;
//const int mod=1000000007;
const int mod=998244353;

int n,m,k;
const int N=2010;






int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n;
    cout << (n^1) << el;
    
    return 0;
}







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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, i, j, w, W;
  cin >> n >> W;
  int weights[n], values[n];
  for (i = 0; i < n; i++)
    cin >> weights[i] >> values[i];

  ll dp[n + 1][100001];
  memset(dp, 0, sizeof(dp));

  for (i = 1; i <= n; i++)
  {
    for (w = 1; w <= W; w++)
    {
      if (w < weights[i - 1])
      {
        dp[i][w] = max(dp[i][w - 1], dp[i - 1][w]);
      }
      else
      {
        dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weights[i - 1]] + values[i - 1]);
      }
    }
  }
  cout << dp[n][W] << endl;
  return 0;
}

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

int main(){
    int a,m=10,s=-10;
    for(int i=0;i<5;i++){
        cin>>a;
        if(a%10!=0) m=min(m,a%10);
        s+=(a+9)/10*10;
    }
    cout<<s+m<<endl;
    return 0;
}

Measured memory_bytes: 256
def kaibun(s):
    n = len(s)
    if s[:int(n/ 2)] == s[:-int(n / 2) - 1:-1]:
        return True
    else:
        return False

s = input()
n = len(s)
# print(s[:int((n - 3) / 4)])
# print(s[int((n - 1) / 2 - 1):int((n + 5) / 4 - 2):-1])
# print(s[:int((n - 1) / 2)])
# print(s[:int((n + 3) / 2 - 2):-1])
if kaibun(s) and kaibun(s[:int((n - 1) / 2)]) and kaibun(s[int((n + 3) / 2 - 1):n]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060