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

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next(), t = sc.next();
		for(int i = 0; i < s.length(); i++) {
			String x =  s.substring(s.length() - i, s.length()) + s.substring(0, s.length() - i);
			if(x.equals(t)) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back

int n, k;
vector<int> nxt;
vector<int> c;

int test(int s, int f)
{
    if (f == 0) assert(false);
    int ret = 0;
    int now = s;


    int mx = LLONG_MIN;
    forn(_, f)
    {
        now = nxt[now];
        ret += c[now];
        mx = max(mx, ret);
    }
    return mx;
}
pair<int,int> test(int s)
{
    pair<int,int> ret = mp(0, 0);
    int now = s;
    do
    {
        now = nxt[now];
        ret.f += c[now];
        ret.s++;
    } while (now != s);
    return ret;
}
void solve()
{
    cin>>n>>k;
    nxt.resize(n);
    c.resize(n);
    forn(i, n) cin>>nxt[i], --nxt[i];
    forn(i, n) cin>>c[i];
    // if (k <= n)
    // {
    //     int r = LLONG_MIN;
    //     forn(i, n) r = max(r, test(i, k));
    //     cout << r<< '\n';
    //     return;
    // }
    // else
    {
        int r = *max_element(c.begin(), c.end());
        forn(i, n)
        {
            pair<int,int> p = test(i);
            
            r = max(r, test(i, min(n, k)));

            if (p.s < k)
            {            
                int now = p.first * (k/p.s - 1);
                r = max(r, now);
                int rm = k%p.s + p.s;
                if (rm)
                {
                    now += test(i, rm);
                    r = max(r, now);
                }
            }
        }
        cout << r << '\n';
        
    }
    
}

signed main(void)
{
    int T = 1;
    cout << fixed;
    cout.precision(3);
    ios_base::sync_with_stdio(0); cin.tie(0);

    //cin>>T;
    while (T--) solve();
    return 0;
}


Measured memory_bytes: 3728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.swing.*;

import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 1000000007;


    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        String s = in.next();
        List<Integer> ans = new ArrayList<>();
        int i, j;
        for (i = n; i > 0; i--) {
            for (j = Math.max(0, i - m); j < i; j++) {
                if (s.charAt(j) == '0') {
                    ans.add(i - j);
                    i = j + 1;
                    break;
                }
            }
            if (i == j) {
                break;
            }
        }
        if (i != 0) {
            out.println(-1);
        } else {
            for (i = ans.size() - 1; i >= 0; i--) {
                out.print(ans.get(i) + " ");
            }
            out.println();
        }

    }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

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

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

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

}


Measured memory_bytes: 40456
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

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

  cout << max(a - 2 * b, 0) << endl;

  return 0;
}

Measured memory_bytes: 256
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------


int main()
{
	boost
	ll n,a,b;
 	cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
	return 0;
}


Measured memory_bytes: 256
'use strict'
function Main(input) {
  const inputArray = input.split(' ').map(n => Number(n));
  const a = inputArray[0];
  const b = inputArray[1];
  const plus = a + b;
  const minus = a - b;
  const times = a * b;
  
  console.log(Math.max(plus, minus, times));
}

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

Measured memory_bytes: 22080
#!/usr/bin/env python3
import sys
from collections import Counter

def solve(N: int, S: "List[str]"):
    counter = Counter(S).most_common()

    most_value = counter[0][1]
    answer_list = []

    for key,value in dict(counter).items():
        if value == most_value:
            answer_list.append(key)
    
    answer_list = list(set(answer_list))
    answer_list.sort()

    for i in range(len(answer_list)):
        print(answer_list[i])

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 57592
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  int H, W; cin >> H >> W;
  char s[50][50];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> s[i][j];
    }
  }
  queue<pair<pair<int, int>,int>> Q;
  Q.push(make_pair(make_pair(0, 0), 0));
  bool visit[50][50];
  for (int i = 0; i < 50; i++) {
    for (int j = 0; j < 50; j++) {
      visit[i][j] = false;
    }
  }
  while (Q.front().first != make_pair(H-1, W-1) && !Q.empty()) {
    pair<int, int> now = Q.front().first;
    /*cout << Q.front().first.first << " "
      << Q.front().first.second << " "
        << Q.front().second << endl;*/
    if (now.first > 0 && s[now.first-1][now.second] != '#' && !visit[now.first-1][now.second]) {
      Q.push(make_pair(make_pair(now.first-1, now.second), Q.front().second+1));
      visit[now.first-1][now.second] = true;
    }

    if (now.first < H-1 && s[now.first+1][now.second] != '#' && !visit[now.first+1][now.second]) {
      Q.push(make_pair(make_pair(now.first+1, now.second), Q.front().second+1));
      visit[now.first+1][now.second] = true;
    }
    if (now.second > 0 && s[now.first][now.second-1] != '#' && !visit[now.first][now.second-1]) {
      Q.push(make_pair(make_pair(now.first, now.second-1), Q.front().second+1));
      visit[now.first][now.second-1] = true;
    }
    if (now.second < W-1 && s[now.first][now.second+1] != '#' && !visit[now.first][now.second+1]) {
      Q.push(make_pair(make_pair(now.first, now.second+1), Q.front().second+1));
      visit[now.first][now.second+1] = true;
    }
    Q.pop();
  }
  if (Q.empty())
    cout << -1 << endl;
  else {
    int dotCount = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        dotCount += (s[i][j] == '.');
      }
    }
    cout << dotCount - Q.front().second - 1 << endl;
  }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	A, B, C := ReadInt(), ReadInt(), ReadInt()
	if C <= A+B {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1840
#include <iostream>

using namespace std;

int main(){
    int d,n;
    cin>>d>>n;
    if(d==0){
        if(n==100)cout<<101<<endl;
        else cout<<n<<endl;
    }else if(d==1){
        if(n==100)cout<<10100<<endl;
        else cout<<100*n<<endl;
    }else{
        if(n==100)cout<<1010000<<endl;
        else cout<<10000*n<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
tot = abs(A[0])
for i in range(1,N):
    tot += abs(A[i]-A[i-1])
tot += abs(A[N-1])
for i in range(N):
    if i==0:
        cnt = tot-(abs(A[0])+abs(A[1]-A[0]))
        cnt += abs(A[1])
    elif i==N-1:
        cnt = tot-(abs(A[N-1]-A[N-2])+abs(A[N-1]))
        cnt += abs(A[N-2])
    else:
        cnt = tot-(abs(A[i]-A[i-1])+abs(A[i+1]-A[i]))
        cnt += abs(A[i+1]-A[i-1])
    print(cnt)

Measured memory_bytes: 82700
import sys
f = 1
n,y = map(int,input().split())
for s in range(2001):
    for t in range(2001):
        z = n-s-t
        if y-(10000*s+5000*t+1000*z) == 0 and z >= 0 :
            print(s,t,z)
            f = 0
            sys.exit()
if f == 1:
    print(-1,-1,-1)

Measured memory_bytes: 40300
#include<cstdio>
#include<cstring>
char s[1000],t[1000];
int n;
int main()
{
	int ok;
	scanf("%s%s",s+1,t+1);
	n=strlen(s+1);
	for (int i=1;i<n;i++) s[n+i]=s[i];
	for (int i=1;i<=n;i++)
	{
		ok=1;
		for (int j=1;j<=n;j++)
			if (t[j]!=s[i+j-1])
			{
				ok=0;
				break;
			}
		if (ok)
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
}

Measured memory_bytes: 128
H, W, K = map(int, input().split())
s = []
for i in range(H):
    s.append(list(input()))

si = 0
paint_h = []
for h in range(H):
    if not('#' in s[h]):
        paint_h.append(h)
        continue
    else:
        for w in range(W):
            if s[h][w] == '#':
                si += 1
                s[h][w] = si
                paint_h.append(h)
                wi = w
                while True:
                    wi += 1
                    if (wi<0)or(wi>=W)or(s[h][wi]!='.'):
                        break
                    s[h][wi] = si
                wi = w
                while True:
                    wi -= 1
                    if (wi<0)or(wi>=W)or(s[h][wi]!='.'):
                        break
                    s[h][wi] = si
        paint_h = []
cnt_non_s = 1
for i in s:
    if '.' in i:
        cnt_non_s += 1
    else:
        tmp = i
        for j in range(cnt_non_s):
            print(*i)
        cnt_non_s = 1

for j in range(cnt_non_s-1):
    print(*tmp)

Measured memory_bytes: 7504
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll a,b,c; cin >> a >> b >> c;
    cout << min({a+b,b+c,c+a}) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
template<typename T>
T ncr(T left, T right) {
	right = min(left - right, right);
	T ans = 1;
	for (T i = 1; i <= right; i++) {
		ans = ans * (left - right + i) / i;
	}
	return ans;
}

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int N;
	cin >> N;
	vector<int> v(N), b(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> b[i];
		if (v[i] > b[i]) {
			sum += v[i];
			sum -= b[i];
		}
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
// E - Handshake

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int MOD = 1e9 + 7;

const ll MAX_N = 100005;
const ll MAX_A = 100005;

ll A[MAX_N];
ll A_csum[MAX_N]; // 値が大きい側からの累積和
ll N, M;

// t <= Ax + Ay となる組み合わせの数を求める
// Ax = A[i]ごとに二分探索で数を求めて合計する -> O(NlogN)

ll get_n_comb(ll t) {
	ll result = 0;
	for (int i=0; i<N; i++) {
		ll Ay = t - A[i];
		ll idx = lower_bound(A, A+N, Ay) - A; // t <= Ax + Ay となる最初のインデックス
		result += (N - idx);
	}

	//cout << "t=" << t << " -> comb=" << result << endl;

	return result;
}

// t <= Ax + Ay となる組み合わせの数がk以上となる最大のtを求める
ll get_max_t(ll k) {
	ll ok = 0;
	ll ng = 2 * MAX_A + 1;

	while(ng - ok > 1) {
		ll trying = (ok + ng) / 2;

		if (get_n_comb(trying) >= k) {
			ok = trying;
		} else {
			ng = trying;
		}
	}

	return ok;
}

// t <= Ax + Ay となる組み合わせについて総和を求める
ll get_sum_ge(ll t) {
	ll result = 0;
	for (int i=0; i<N; i++) {
		ll Ay = t - A[i];
		ll idx = lower_bound(A, A+N, Ay) - A; // t <= Ax + Ay となる最初のインデックス
		result += (A[i] * (N - idx)) + A_csum[idx]; // Axの和 + Ayの和
	}

	//cout << "t=" << t << " sum=" << result << endl; // **** debug ****

	return result;
}

int main() {

	cin >> N >> M;

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

	sort(A, A+N);

	// 値が大きい側からの累積和を作成（get_sum_ge()で用いる）
	A_csum[N-1] = A[N-1];
	for (int i=N-2; i>=0; i--) {
		A_csum[i] = A[i] + A_csum[i+1];
	}

	// t <= Ax + Ay となる組み合わせの数がM以上となる最大のtを求める
	ll max_t = get_max_t(M);
	//cout << "max_t = " << max_t << endl; // **** debug ****

	// get_sum_ge(t)では t == Ax + Ay となる握手が複数存在する場合に余分な握手が含まれてしまうので
	// （(t == max_t) の和） + （(t >= max_t + 1) の和）で求める
	ll n_max_t = M - get_n_comb(max_t + 1); // t == max_t となる場合の数
	ll ans = (max_t * n_max_t) + get_sum_ge(max_t + 1);

	cout << ans << endl;

	return 0;
}

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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while(1){
        C -= B;
        if (C <= 0){
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0){
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int a, b, k; std::cin >> a >> b >> k;
  bool t = true;
  auto process = [](int &x, int &y) {
    if (x & 1)
      x--;
    y += x / 2;
    x /= 2;
  };
  rep(i, k) {
    if (t) {
      process(a, b);
    } else {
      process(b, a);
    }
    t ^= 1;
  }
  std::cout << a << ' ' << b << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll n, k;
    cin >> n >> k;
    ll div = n / k;
    cout << min(abs(n - k * div), abs(n - k * (div + 1))) << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100010
#define INF 1e18
using namespace std;
long long n,k,x[N],v[N],a[N]={},b[N]={},c[N]={},d[N]={};
long long vtl=0,vtr=0,ans=-INF,i;
int main()
{
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>x[i]>>v[i];
	}
	for(i=0;i<n;i++)
	{
		vtl+=v[i];
		vtr+=v[n-i-1];
		a[i+1]=max(a[i],vtl-x[i]);
		b[i+1]=max(b[i],vtl-x[i]*2);
		c[n-i-1]=max(c[n-i],vtr-(k-x[n-i-1]));
		d[n-i-1]=max(d[n-i],vtr-(k-x[n-i-1])*2);
	}
	for(i=0;i<=n;i++)
	{
		ans=max(ans,max(a[i]+d[i],b[i]+c[i]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb emplace_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const int mod = 998244353;
int n;
string s;
ll res = 1, cn[7];

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> s;
	cn[0] = n;
	for (int i = 0; i < 3 * n; i++) {
		if (s[i] == 'R') {
			if (cn[5]) {
				(res *= cn[5]) %= mod;
				cn[5]--;
			} else if (cn[2]) {
				(res *= cn[2]) %= mod;
				cn[2]--;
				cn[4]++;
			} else if (cn[3]) {
				(res *= cn[3]) %= mod;
				cn[3]--;
				cn[6]++;
			} else {
				(res *= cn[0]) %= mod;
				cn[0]--;
				cn[1]++;
			}
		} else if (s[i] == 'G') {
			if (cn[6]) {
				(res *= cn[6]) %= mod;
				cn[6]--;
			} else if (cn[1]) {
				(res *= cn[1]) %= mod;
				cn[1]--;
				cn[4]++;
			} else if (cn[3]) {
				(res *= cn[3]) %= mod;
				cn[3]--;
				cn[5]++;
			} else {
				(res *= cn[0]) %= mod;
				cn[0]--;
				cn[2]++;
			}
		} else if (s[i] == 'B') {
			if (cn[4]) {
				(res *= cn[4]) %= mod;
				cn[4]--;
			} else if (cn[1]) {
				(res *= cn[1]) %= mod;
				cn[1]--;
				cn[6]++;
			} else if (cn[2]) {
				(res *= cn[2]) %= mod;
				cn[2]--;
				cn[5]++;
			} else {
				(res *= cn[0]) %= mod;
				cn[0]--;
				cn[3]++;
			}
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 720
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;

const int maxn = 200005;
int n, ed, stm, he[maxn], siz[maxn], sta[maxn];
struct Edge{
	int v, nx;
	Edge(){;}
	Edge(int _v, int _nx){v = _v, nx = _nx;}
}e[maxn << 1];
inline void Add(int u, int v){
	e[++ed] = Edge(v, he[u]);he[u]  =ed;
}

bool Dfs(int x, int fa){
	siz[x] = 1;
	bool flag = 0;
	for(int i = he[x], v;i;i = e[i].nx){
		v = e[i].v;
		if(v == fa)continue;
		if(!Dfs(v, x))siz[x] += siz[v];
		else flag = 1;
	}
	if(flag || x == n){
		siz[x]--;
		sta[++stm] = x;
		return 1;
	}
	return 0;
}

int main(){
	scanf("%d", &n);
	for(int i = 1, u, v;i < n;++i){
		scanf("%d%d", &u, &v);
		Add(u, v);Add(v, u);
	}
	Dfs(1, 0);
//	int a = siz[1] - 1, b = siz[n] - 1, c;
//	c = n - 2 - a - b;
	if(n == 2){
		puts("Snuke");
		return 0;
	}
	/*
	for(int i = 1;;++i){
		if(i & 1){
			if(!a && !c){
				puts("Snuke");
				return 0;
			}
			if(c)c--;
			else a--;
		}
		else{
			if(!b && !c){
				puts("Fennec");
				return 0;
			}
			if(c)c--;
			else b--;
		}
	}*/
//	cerr<<"stm "<<stm<<endl;while(1);
	//for(int i = 1;i <= stm;++i)cerr<<st
	int a = 0, b = 0;
	for(int i = stm, j = 1;i >= j;--i, ++j){
		if(i == j){
			a += siz[sta[i]];
			if(!a)puts("Snuke");
			else if(a >= b)puts("Fennec");
			else puts("Snuke");
			return 0;
		}
		else a += siz[sta[i]], b += siz[sta[j]];
	}
	if(!a)puts("Snuke");
	else if(a > b)puts("Fennec");
	else puts("Snuke");
	return 0;
}
/*
7
1 2
2 3
3 4
4 5
5 7
2 6
*/


Measured memory_bytes: 10752
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        while (scanner.hasNext()) {
            int n =scanner.nextInt();
            int result = 0;

            for (int i = 0; i < 10; i++) {
                for (int j = 0; j < 10; j++) {
                    for(int k = 0; k < 10; k++) {
                        for(int l = 0; l < 10; l++) {
                            if (i+j+k+l == n) {
                                result++;
                            }
                        }
                    }
                }
            }
            System.out.println(result);
        }
    }
}

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

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

int N,n,d,x[200],y[200],dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
    while(cin>>N&&N){
	int Mx=0,mx=0,My=0,my=0;
	rep(i,N-1){
	    cin>>n>>d;
	    x[i+1]=x[n]+dx[d];y[i+1]=y[n]+dy[d];
	    Mx=max(Mx,x[i+1]);mx=min(mx,x[i+1]);
	    My=max(My,y[i+1]);my=min(my,y[i+1]);
	}
	cout<<Mx-mx+1<<" "<<My-my+1<<endl;
    }
}

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

int main() {
    int n,k;cin>>n>>k;
    int p[n];
    double e[n],s[n];
    rep(i,n) cin>>p[i];
    rep(i,n){
        e[i] = p[i]*(p[i]+1.0)/(2.0*p[i]);
        if(i>=1)s[i] = s[i-1]+e[i];
        else s[i] = e[i];
    }
    double mx=0;
    rep(i,n-k+1){
        double sum;
        sum = s[i+k-1]-s[i]+e[i];
       // cout<<p[i]<<" "<<p[i+k-1]<<endl;
        if(mx<sum)mx = sum;
    }
    printf("%.10lf",mx);
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    int N,K;
    cin >> N >> K;
    vint p(N);
    vector<double> q(N+1);
    rep(i,N)cin >> p[i];
    q[0] = 0.0;
    rep(i,N) q[i+1] =q[i] + (double)(p[i]+1)/2;
    
    double ans =0;
    rep(i,q.size()-K){
        ans = max(q[i+K]-q[i],ans);
    }
    cout << fixed << setprecision(5);
    cout << ans;
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

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

    int N, K;
    cin >> N >> K;
    vi A(N);
    for(int i=0;i<N;i++) cin >> A[i];

    vb win(K+1, false);
    for(int i=1;i<=K;i++) {
        for(int a : A){
            if (i-a >=0 && !win[i-a]) {
                win[i] = true;
                break;
            }
        }
    }

    if (win[K]) cout << "First" << endl;
    else cout << "Second" << endl;


    return 0;
}

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

using namespace std;

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

  string s;
  cin >> s;
  if (s == "AAA" || s == "BBB")
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))
v.sort(reverse=True)
count = 0
for i in range(n):
  if i == n-1:
    count += v[i] / 2**(n-1)
  else:
    count += v[i] / 2**(i+1)
print(count)


Measured memory_bytes: 2940
N = list(input())
setN = set(N)
D = list('abcdefghijklmnopqrstuvwxyz')
if len(N) < 26:
    for d in D:
        if not d in setN:
            N.append(d)
            print(''.join(N))
            exit()
else:
    N.reverse()
    for i in range(25):
        if N[i] < N[i+1]:
            continue
        else:
            tmp = N[i+1]
            ans = N[i+2:]
            ans.reverse()
            for n in N[:i+2]:
                if ord(n) - ord(tmp) > 0:
                    ans.append(n)
                    print(''.join(ans))
                    exit()
print(-1)

Measured memory_bytes: 38256
package main

import(
	"fmt"
  	"bufio"
  	"os"
  	"strings"
  	"strconv"
  	"sort"
)

func main(){
  var sc = bufio.NewScanner(os.Stdin)
  sc.Scan()
  num := strings.Split(sc.Text()," ")
  sort.Strings(num)
  A, _ := strconv.Atoi(num[0])
  B, _ := strconv.Atoi(num[1])
  C, _ := strconv.Atoi(num[2])
  var num1,total int
  if A > C{
    num1 = A
  	total = B + C
  }else{
    num1 = C
    total = A + B
  }
  if num1 == total{
    fmt.Println("Yes") 
  }else{
    fmt.Println("No") 
  }
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef unsigned long long ll;

template<typename T>
T gcd(T a, T b) {
	if (a % b == 0) {
		return(b);
	}
	else {
		return(gcd(b, a % b));
	}
}

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


int main(void) {
	string s;
	cin >> s;
	if (s == "ABC") {
		cout << "ARC";
	}
	else {
		cout << "ABC";
	}
}

/*

*/


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n;
  cin>>n;
  vector<int> G[5555];
  int dp[2][5555];
  function<int(int,int)> dfs=[&](int x,int v){
    if(G[v].empty()) return 0;
    if(~dp[x][v]) return dp[x][v];
    int res=0;
    for(int u:G[v]) res+=dfs(0,u);
    if(x) return dp[x][v]=res;
    int tmp=res;
    for(int u:G[v])
      res=max(res,tmp-dfs(0,u)+dfs(1,u)+1);
    return dp[x][v]=res;
  };
  for(int i=1;i<=n;i++){
    int p;
    cin>>p;
    G[p].push_back(i);
    memset(dp,-1,sizeof(dp));
    cout<<dfs(0,0)<<endl;
  }
  return 0;
}

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

int main() {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  ll dis;
  if(a<b) dis=b-a+(w-v)*t;
  else dis=a-b+(w-v)*t;
  if(dis<=0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

int main (int argc, char* argv[]) {
	int a, b;
	cin >> a >> b;
	
	int res = 0;
	for (int i = 0; i < 2; i++) {
		if (a >= b) {
			res += a;
			a--;
		} else {
			res += b;
			b--;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

// 2^n
mint f(int n){
	if(n == 0) return 1;
	mint x = f(n/2);
	x *= x;
	if(n%2 == 1) x *= 2;
	return x;
}

// nCa
mint choose(int n, int a){
	mint x = 1, y = 1;
	rep(i,a){
		x *= n-i;
		y *= i+1;
	}
	return x / y;
}

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(n < 0 || k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
};

mint dp[100005][4];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    dp[0][0] = 1;
    rep(i,n){
        if(s[i] == 'A'){
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][1] + dp[i][0];
            dp[i+1][2] = dp[i][2];
            dp[i+1][3] = dp[i][3];
        }
        else if(s[i] == 'B'){
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][1];
            dp[i+1][2] = dp[i][2] + dp[i][1];
            dp[i+1][3] = dp[i][3];
        }
        else if(s[i] == 'C'){
            dp[i+1][0] = dp[i][0];
            dp[i+1][1] = dp[i][1];
            dp[i+1][2] = dp[i][2];
            dp[i+1][3] = dp[i][3] + dp[i][2];
        }
        else{
            dp[i+1][0] = dp[i][0] * 3;
            dp[i+1][1] = dp[i][1] * 3 + dp[i][0];
            dp[i+1][2] = dp[i][2] * 3 + dp[i][1];
            dp[i+1][3] = dp[i][3] * 3 + dp[i][2];
        }
        //rep(j,4) cout << dp[i+1][j].x << " ";
        //cout << endl;
    }
    cout << dp[n][3].x << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

#define INF (1LL << 60)

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vector<ll> h(N);
    REP(i,0,N) cin >> h[i];

    vector<ll> dp(N, INF);
    dp[0] = 0;

    dp[1] = MIN(dp[1],dp[0]+abs(h[0]-h[1]));
    REP(i,2,N) {
        dp[i] = MIN(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
    }

    _PR(dp[N-1]);

    return 0;
}

/*



*/

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi(number)
文字列からllに変換　stoll(number)*/

//ここから書き始める
int main(){
	int n; cin >> n;// aの配列の個数
	vector<ll> a(n);
	rep(i,n) cin>> a[i];

	int k; cin >> k; // bの配列のっこすう
	vector<ll> b(k);
	rep(i,k) cin>>b[i];
	
	ll ans = 0;
	rep(i,k){
		rep(j,n){
			if(b[i]==a[j]) {
				ans++;
				break;
			}
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 3072
k,n=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]


maxdis=0
for i in range(n):
    one=a[i]
    if i==n-1:
        two=a[0]
        maxdis=max(maxdis,(two+k-one))
    else:
        two=a[i+1]
        maxdis=max(maxdis,(two-one))        
print(k-maxdis)
    

Measured memory_bytes: 26444
#include <stdio.h>

int main (){
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int a[n];
	for(long long int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
	}
	for (long long int i = k; i < n;i++){
		if(a[i-k] < a[i]){
			puts("Yes");
		}else{
			puts("No");
		}
	}
	
	return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	ll N = 1<<n;
	multiset<ll> se;
	rep(i,N){
		ll s; cin >> s;
		s = -s;
		se.insert(s);
	}
	vl v;
	v.push_back(*se.begin());
	se.erase(se.begin());
	rep(i,n){
		vl vv;
		for(auto j : v){
			auto itr = se.upper_bound(j);
			if(itr == se.end()){
				puts("No");
				return 0;
			}
			vv.push_back(*itr);
			se.erase(itr);
		}
		for(auto j : vv){
			v.push_back(j);
		}
	}
	puts("Yes");
}

Measured memory_bytes: 15432
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

    int a,b,c;
    cin >> a >> b >> c;
    if (a + b + c <= 21) {
        cout << "win" << endl;
    }else {
        cout << "bust" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}




void test_case() {

    int n , r;
    cin>>n>>r;

    if(n >= 10) {
        cout<<r<<endl;
        return;
    }

    int ans = r + 100*(10-n);

    cout<<ans<<endl;






}


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

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


    int t = 1;
    //cin >> t;
    while(t--)
    {   
        test_case();
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    for (int i = 0; ; i++) {
        if (i % 2 == 0) {
            c -= b;
            if (c <= 0) {
                cout << "Yes";
                break;
            }
        } else {
            a -= d;
            if (a <= 0) {
                cout << "No";
                break;
            }
        }
    }
    return 0;
}

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

int s[35][35];

signed main(){
  
  while(1){
    
    int w, h, t, p;
    cin>>w>>h>>t>>p;
    
    if( !w && !h && !t && !p ) break;
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++) s[i][j] = 1;
    }
    
    while(t--){
      
      int d, c;
      cin>>d>>c;
      
      int t[35][35] = {};
                  
      if( d == 1 ){
	
	for(int i=0;i<h;i++){
	  
	  for(int j=0;j<c;j++){
	    
	    t[i][j] = s[i][c-j-1];
	    
	  }
	  
	}
	
	for(int i=0;i<h;i++){
	  
	  for(int j=c;j<w;j++){
	    
	    t[i][j-c] += s[i][j];
	    
	  }
	  
	}
	
	w = max( c, w - c );
	
	for(int i=0;i<h;i++){
	  for(int j=0;j<w;j++) s[i][j] = t[i][j];
	}
	
      }
      else{
	
	for(int i=0;i<c;i++){
	  
	  for(int j=0;j<w;j++){
	    
	    t[i][j] = s[c-i-1][j];
	    
	  }
	  
	}
	
	for(int i=c;i<h;i++){
	  
	  for(int j=0;j<w;j++){
	    
	    t[i-c][j] += s[i][j];
	    
	  }
	  
	}
	
	h = max( c, h - c );
	
	for(int i=0;i<h;i++){
	  for(int j=0;j<w;j++) s[i][j] = t[i][j];
	}
	
      }      
      
    }
    
    while(p--){
      
      int x, y;
      cin>>x>>y;
      
      cout<<s[y][x]<<endl;
      
    }
    
  }
  
  return 0;
}



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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> s(M), c(M);
    vector<int> ans(N, -1);
    bool flag = true;
    for(int i = 0; i < M; i++) {
        cin >> s.at(i) >> c.at(i);
        if(ans.at(s.at(i) - 1) == -1 || ans.at(s.at(i) - 1) == c.at(i)) {
            ans.at(s.at(i) - 1) = c.at(i);
        } else {
            flag = false;
        }
    }
    if(ans.at(0) == 0 && N != 1) flag = false;
    if(flag) {
        for(int i = 0; i < N; i++) {
            cout << (ans.at(i) != -1 ? ans.at(i) : i == 0 ? N == 1 ? 0 : 1 : 0);
        }
        cout << endl;
    } else {
        cout << -1 << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    mp[s]++;
  }

  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
  return 0;
}


Measured memory_bytes: 3632
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
using namespace std;
int a[MAXN];

int main()
{
    int n;
    ni(n);
    for (int i = 0; i < n; i++)
    {
        ni(a[i]);
    }
    int ans = 0;
    for (int i = 0; i + 1 < n; i++)
    {
        if (a[i] == a[i + 1])
            ans++, i++;
    }
    pri(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll a,b;
int main(){
	cin >> a >> b;
	cout << (a-1) * (b-1) << endl;
	return 0;
}


Measured memory_bytes: 256
//#include "stdc++.h"
#include <bits/stdc++.h>
#define int long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;



int32_t main()
{
    int n,m;
    cin>>n;
    int a[n];
    for(int i=0;i<n;++i)cin>>a[i];

    int max_so_far=a[0],count=0;
    for(int i=0;i<n;++i){
        if(a[i]<=max_so_far){ count++; }

        max_so_far=min(a[i],max_so_far);
    }
    

    cout<<count<<'\n';
    
}

Measured memory_bytes: 1792
A, B = map(int, input().split())


def f(n):
    if n % 2 == 1:
        if ((n + 1) // 2) % 2 == 1:
            return 1
        else:
            return 0
    else:
        if (n // 2) % 2 == 1:
            return 1 ^ n
        else:
            return 0 ^ n


print(f(B) ^ f(A - 1))


Measured memory_bytes: 2940
#include <stdio.h>

int main(){
    int in[4];
    scanf("%d %d %d", &in[0], &in[1], &in[2]);

    for(in[3] = 0; in[3] < 10; in[3]++)
        printf("%d\n", (in[2] = in[2]*in[0] - in[1]));
     
    return 0;
}

Measured memory_bytes: 128
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};const isPrime=(n:number):boolean=>{if(n<2)return false;const suq=Math.sqrt(n);for(let i=2;i<=suq;i++){if(n%i==0){return false;}}return true;};
const main=()=>{
  let [n,m]=tnn(2),s=ts(),arr=new Array(n)
  arr.fill(0)
  for(let i=0;i<n;i++){
    if(s[i]=='A'&&s[i+1]=='C'){
      if(i==0)arr[i]=0
      else arr[i]=arr[i-1]
      arr[i+1]=arr[i]+1
      i++
    }else{
      if(i==0)arr[i]=0
      else arr[i]=arr[i-1]
    }
  }
  for(let i=0;i<m;i++){
    let [a,b]=tnn(2)
    to(arr[b-1]-arr[a-1])
  }
}
main()


Measured memory_bytes: 56592