akhauriyash/Code-Regression huggingface dataset:
import java.lang.Math.*

operator fun Int.plus(other: Boolean) = this + if (other) 1 else 0

fun main(args: Array<String>) {
  val k = readLine()!!.toInt()
  var (x, y) = readLine()!!.split(" ").map { it.toInt() }

  if (k % 2 == 0 && abs(x + y) % 2 == 1) {
    println(-1)
    return
  }
  if (abs(x) + abs(y) == k) {
    println(1)
    println("${x} ${y}")
    return
  }

  val f = (x < y)
  if (x < y) run { val tmp = x; x = y; y = tmp }

  val (gu, gv) = arrayOf(x - y, x + y)
  var s = arrayOf((abs(gu) + k - 1) / k, (abs(gv) + k - 1) / k).max()!!
  if (s == 1) s += (gu < k || gv < k)
  if (k % 2 == 1 && s % 2 != gu % 2) s++
  println(s)

  var (u, v) = arrayOf(0, 0)
  for (i in 1..s) {
    val du = if (u < gu) 1 else -1
    val dv = if (v < gv) 1 else -1
    if (i == s) {
      u += du * k
      v = gv
    } else if (i == s - 1) {
      u = gu - du * k
      v += dv * k
    } else {
      u += du * k
      v += dv * k
    }

    x = (v + u) / 2
    y = (v - u) / 2
    if (f) {
      println("${y} ${x}")
    } else {
      println("${x} ${y}")
    }
  }
}


Measured memory_bytes: 42924
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int M = 200;
int N[201];

void Ndivs(){
  for(int i=0;i<=M;i++) N[i] = 0;
  for(int i=1;i<=M;i++){
    for(int j=i;j<=M;j+=i) N[j]++;
  }
}

int main(){
  Ndivs();
  int n;
  cin >> n;
  int cnt= 0;
  for(int i=1;i<=n;i++){
    if(N[i]==8 && i%2==1) cnt++;
  }
  cout << cnt <<endl;

  return 0;
}

Measured memory_bytes: 256
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
s = "No War"
if max(x) >= min(y) or min(y) < X + 1 or Y < max(x) + 1:
    s = "War"
print(s)


Measured memory_bytes: 2940
import sys
readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readints():return list(map(int,readline().split()))

from collections import deque

h,w = readints()

start = readints()
start = (start[0]-1)*w + start[1]-1

goal = readints()
goal = (goal[0]-1)*w + goal[1]-1

maze = [readstr() for i in range(h)]

dist = [10**10]*(h*w)

dq = deque()
dq.append((start,0))
dist[start] = 0

while dq:
    p,d = dq.popleft()
    if dist[goal] <= dist[p]:
        break
    if d>dist[p]:
        continue
    y = p//w
    x = p%w
    for dy in range(-2,3):
        for dx in range(-2,3):
            if 0<=y+dy<h and 0<=x+dx<w and maze[y+dy][x+dx]=='.':
                q = (y+dy)*w + x+dx
                if abs(dy)+abs(dx)==1:
                    if dist[q]>dist[p]:
                        dist[q] = dist[p]
                        dq.appendleft((q,dist[q]))
                else:
                    if dist[q]>dist[p]+1:
                        dist[q] = dist[p] + 1
                        dq.append((q,dist[q]))

print(-1 if dist[goal]==10**10 else dist[goal])


Measured memory_bytes: 89128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		List<String> l = Arrays.asList(sc.nextLine().split(" "));
		ArrayList<Integer> nl = new ArrayList<Integer>();
		ArrayList<Integer> ansl = new ArrayList<Integer>();
		int front=0;
		int back=0;
		for(String s:l) {
			nl.add(Integer.parseInt(s));
		}
		for(int i=0;i<n;i++) {
			front=0;
			back=0;
			for(int j=0;j<i;j++) {
				front+=nl.get(j);
			}
			for(int k=0;k<n-i;k++) {
				back+=nl.get(n-k-1);
			}
			ansl.add(Math.abs(front-back));
		}
		int min = ansl.get(0);
		for(int a:ansl) {
			if(a<min) {
				min=a;
			}
		}
		System.out.println(min);
	}
}

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

int main() {
  int n, x; scanf("%d %d",&n, &x);
  if (x==1 || x==2*n-1) {
    puts("No");
  } else {
    puts("Yes");
    for (int i = 0; i < 2*n-1; i++) {
      printf("%d\n", (x-n+2*n+i-1)%(2*n-1)+1);
    }
  }
  return 0;
}


Measured memory_bytes: 1536
/*
ID: dorijan1
TASK: tu napisi ime zadatka molim te molim te ali samo ako si na usaco training
LANG: C++11
*/
#include <bits/stdc++.h>

using namespace std;

const int MOD=1000000007;
typedef long long int ll;
const ll LLINF=1ll<<60;

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

ll mult(ll a,ll b)
{
	return (a*b)%MOD;
}

ll pot(ll n,ll k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

ll divide(ll a,ll b)
{
	return mult(a,pot(b,MOD-2));
}

ll sub(ll a,ll b)
{
	return (a-b+MOD)%MOD;
}

ll add(ll a,ll b)
{
	return (a+b)%MOD;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

ll n;
string h;

int main()
{
	std::ios_base::sync_with_stdio(false);
	cin>>n;
	++n;
	h=its(n);
	cout<<(h.size()-1)*9+(h[0]-'1')<<endl;
}



Measured memory_bytes: 764
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
    ll n,k;cin>>n>>k;
    string s;cin>>s;
    //初めの幸福
    ll num=0;
    //ラグレングス圧縮
    vector<ll>v;
    rep(i,s.size()){
        if(s[i]!=s[i+1]){
            v.push_back(num);
            num=0;
        }else num++;
    }
    ll ans=0;
    for(auto&&i:v)ans+=i;
    cout<<min(n-1,ans+2*k)<<endl;
    
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 1480
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<ll, ll>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<< "\n";
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

int h, w;
string s[50];
int score[50][50];

void dfs(int y, int x, int sc) {
    //OUT(y); SP; OUT(x); SP; OUTL(sc);
    if(score[y][x] <= sc) return;
    score[y][x] = sc;
    int dy[] = {-1, 0, 1, 0};
    int dx[] = {0, 1, 0, -1};
    REP(i, 4) REP(j, 4){
        int my = y + dy[i];
        int mx = x + dx[i];
        if(IN(my, 0, h) && IN(mx, 0, w) && s[my][mx] != '#'){
            dfs(my, mx, sc + 1);
        }
    }
}
signed main(){ INIT;
    cin >> h >> w;
    REP(i, h) cin >> s[i];
    REP(i, h) REP(j, w) score[i][j] = INF;
    
    dfs(0, 0, 1);
    if(score[h - 1][w - 1] == INF){
        OUTL(-1); RET;
    }
    int cnt = 0;
    REP(i, h) REP(j, w){
        cnt += s[i][j] == '.';
    }
    OUTL(cnt - score[h - 1][w - 1]);
RET;}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll a, b;
  cin >> a >> b;
  
  if(a>b) swap(a, b);
  
  rep(_, b) cout << a;
  cout << newl;
  return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            string temp;
            cin >> temp;
            if (temp == "snuke") {
                cout << (char)('A' + j) << (i + 1);
            }
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int s;
    while (cin >> s)
    {
        int opt = 1;
        while(s!=1 && s!=2 && s!=4)
        {
            if(s%2)
                s=3*s+1;
            else
                s/=2;
            opt++;
        }
        cout <<opt+3 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int vis[101001];
vector <int> path1;
vector <int> path2;
vector <int> ve[101001];
void dfs(int i)
{
    vis[i]=1;
    path1.push_back(i);
    for(int j=0;j<ve[i].size();++j)
    {
        if(!vis[ve[i][j]])
        {
            dfs(ve[i][j]);
            return ;
        }
    }
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;++i)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        ve[u].push_back(v);
        ve[v].push_back(u);
    }
    dfs(1);
    swap(path1,path2);
    dfs(1);
    printf("%d\n",path1.size()+path2.size()-1);
    for(int i=(int)path2.size()-1;i>=1;--i)
        printf("%d ",path2[i]);
    for(int i=0;i<path1.size();++i)
        printf("%d ",path1[i]);
    return 0; 
}


Measured memory_bytes: 9976
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#define ll long long

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int nos[3] = {a, b, c};
    sort(nos, nos + 3);
    int biggest = nos[2];
    int smaller1 = nos[1];
    int smallest = nos[0];
    int no_ops = 0;
    if (smaller1 % 2 != smallest % 2) {
        //different parity
        smallest++;
        biggest++;
        no_ops++;
    }
    while (smaller1 < biggest) {
        smaller1++;
        smallest++;
        no_ops++;
    }
    no_ops += (biggest - smallest) / 2;
    cout << no_ops;
}

Measured memory_bytes: 3608
/* https://codeforces.com/contest/1360/problem/H */
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;

#define f first
#define s second 
#define F0R(i, a) for (int i = 0;i < (a);++i)
#define FOR(i, a, b) for (int i = a; i < (b);++i)
#define FORd(i, a) for (int i = (a)- 1;i >= 0;--i)
#define F0Rd(i, a, b) for (int i = (a)- 1;i >= (a);--i)
#define pb push_back
#define	lb lower_bound
#define	ub upper_bound
#define	sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const ll MAX = 1e9;

int main() {

	int k;
	string s;
	cin>>k>>s;
	if (s.length() <= k) {
		cout<<s<<endl;
	}
	else {
		cout<<s.substr(0, k)<<"..."<<endl;
	}
	return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
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() {
    int N,Y;
    cin >> N >> Y;
    int i,j,k;
    bool ans = false;
    for(i = 0;i<=N;i++) {
        for(j = 0;j<=N;j++) {
            k = N-i-j;
            int sum = 10000*i+5000*j+1000*k;
            if(k >=0 && sum == Y) {
                ans = true;
                break;
            }
        }
        if(ans)break;
    }
    if(ans) cout << i << " " << j<<" "<<k << endl;
    else cout << "-1"<<" " << "-1"<<" "<<"-1"<<endl;
}

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

int A, B;

void func(string s, int a, int b)
{
	if (a > A || b > B) return;
	if (a == A && b == B){
		cout << s << endl;
		return;
	}
	if (a == 5 && b == 5){
		return;
	}
	if ((a <= 3 && b >= 5) || (a >= 5 && b <= 3)){
		return;
	}
	func(s + "A", a + 1, b);
	func(s + "B", a, b + 1);
}

int main()
{
	scanf("%d %d", &A, &B);
	func("", 0, 0);
	return 0;
}

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

int num_to_palindrome(string s) {
  int ret = 0, i;
  int len = s.size();
  rep(i, len/2) {
    if (s.at(i) != s.at(len-1-i))
      ret++;
  }
  return ret;
}
int main() {
  int i, j, k;
  string s, t; cin >> s;
  cout << num_to_palindrome(s)<< endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
   int a,b,c;
   cin>>a>>b>>c;
   if(c>=a && c<=b){
       cout<<"Yes"<<endl;
   }else{
        cout<<"No"<<endl;
   }
    return 0;

}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

k = I()
if k % 2 == 0:
    print((k//2)**2)
else:
    print(((k-1)//2)*(((k-1)//2)+1))

Measured memory_bytes: 63212
#include<bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, m, l[N], r[N], fen[N];
vector<int> queRy[N];

void update(int id, int val){
	for(int i = id; i <= m; i += (i & -i)){
		fen[i] += val;
	}
}
int get(int id){
	int sum = 0;
	for(int i = id; i >= 1; i -= (i & -i)){
		sum += fen[i];
	}
	return sum;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> l[i] >> r[i];
		queRy[r[i] - l[i] + 1].push_back(i);
	}
	int res = n;
	for(int i = 1; i <= m; i++){
		int tmp = 0;
		for(int j = i; j <= m; j += i){
			tmp += get(j);
		}
		cout << res + tmp << "\n";
		for(int j: queRy[i]){
			update(l[j], 1);
			update(r[j] + 1, -1);
			res--;
		}
	}
}

Measured memory_bytes: 14592
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222





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


  ll b = 380000;

  cin >> n;
  double d = 0;
  rep(i, n) {
    double x;
    cin >> x >> s;
    if (s == "JPY") d += x;
    else d += x * b;
  }
  cout.precision(8);
  cout << fixed << d << endl;


  return 0;
}

Measured memory_bytes: 256
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import bisect
import heapq
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15

def main():
    a,b,c = getlist()
    s12 = b - a
    s13 = c - a
    s23 = c - b
    for i in range(2):
        d,e,f = getlist()
        # print(d,e,f)
        # print(s12,s23,s13)
        if e-d != s12:
            # print(e-d)
            print("No")
            return
        if f-d != s13:
            print("No")
            return
        if f-e != s23:
            print("No")
            return

    print("Yes")
    return

if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Measured memory_bytes: 38384
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		int[] alb = new int[26];
		for(int i = 0 ; i<input.length(); i++){
			alb[input.charAt(i)-'a']++;
		}
		for(int i = 0 ; i<26; i++){
			if(alb[i] == 0){
				System.out.println((char)(i+'a'));
				break;
			}
			else if(i == 25){
				System.out.println("None");
			}
		}
	//	System.out.println(Arrays.toString(alb));
	}
}


Measured memory_bytes: 26500
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
   int a[n];
   for(int i=0;i<n;i++) cin>>a[i];
   
   int ans=0;
   for(int i=0;i<n;i+=2)
   {
	if(a[i]%2==1) ans+=1;
   }
   cout<<ans<<endl;
 }


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

int main() {
	int h, w, n;
	cin >> h >> w >> n;
	
	if (h > w) w = h;
	
	if (n%w == 0) cout << n/w << '\n';
	else cout << n/w + 1 << '\n';
	
	return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

int a[200009];
//int ans[200009];
void solve()
{
	int n,i;
	cin>>n;
	int big=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		big^=a[i];
	}
	for(i=0;i<n;i++) cout<<(big^a[i])<<' ';
}

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


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

using namespace std;

#define MAXN 110

typedef long long ll;

int n;
string num;
ll dp[2][4][MAXN];

ll solve(int state, int k, int p) {
	if (p == n) return (k == 0) ? 1 : 0;
	if (k < 0) return 0;
	if (dp[state][k][p] != -1) return dp[state][k][p];
	if (!state) {
		return dp[state][k][p] = 9 * solve(state, k - 1, p+1) + solve(state, k, p+1);
	} else {
		ll dist = num[p] - '0';
		if (dist == 0) {
			return dp[state][k][p] = solve(state, k, p+1);
		} else {
			return dp[state][k][p] = solve(state, k-1, p+1) + (dist - 1) * solve(1 - state, k-1, p+1) + solve(1 - state, k, p + 1);
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	memset(dp, -1, sizeof(dp));
	int k;
	cin >> num >> k;
	n = (int)num.size();
	
	cout << solve(1, k, 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;



int main() {
	cout << fixed << setprecision(18);
	long long int H,A;
	cin>>H>>A;
	cout<<(H+A-1)/A;
	
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
    string str,a,b,c,d,e,f;
    a = "abc";
    b = "bca";
    c = "cab";
    d = "acb";
    e = "bac";
    f = "cba";
    cin >> str;
    if(str == a){
       cout << "Yes" << "\n";
    }else if(str == b){
       cout << "Yes" << "\n";
    }else if(str == c){
       cout << "Yes" << "\n";
    }else if(str == d){
       cout << "Yes" << "\n";
    }else if(str == e){
       cout << "Yes" << "\n";
    }else if(str == f){
       cout << "Yes" << "\n";
    }else{
       cout << "No"  << "\n";
    }
    return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, M, K; cin >> N >> M >> K;
	vector<ll>A(N), B(M + 1);
	rep(i, 0, N)cin >> A[i];
	rep(i, 0, M)cin >> B[i + 1];
	rep(i, 1, N)A[i] += A[i - 1];
	rep(i, 1, M + 1)B[i] += B[i - 1];
	int ans = 0;
	rep(i, 0, N + 1) {
		ll cnt;
		if (i == 0)cnt = 0;
		else cnt = A[i - 1];
		if (cnt > K)continue;

		ll dis = K - cnt;
		int index = upper_bound(all(B), dis) - B.begin() - 1;
		chmax(ans, i + index);
	}
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 6292
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;


int main(void) {
    int n, i, a;
    set<int> s;
    
    cin >> n;
    
    for (i = 0; i < n; i++) {
        cin >> a;
        if (s.find(a) == s.end()) {
            s.insert(a);
        }
        else {
            s.erase(a);
        }
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 4864
def isCLKWISE(ph):
    return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P.sort()
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = []
for i in n:
    P.append([int(x) for x in input().split()])
      
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

Measured memory_bytes: 33788
N, M = gets.split.map(&:to_i)
From1 = []
ToN = []
M.times do
  a, b = gets.split.map(&:to_i)
  From1 << b if a == 1
  ToN << a if b == N
end

puts (From1 & ToN).empty? ? "IMPOSSIBLE" : "POSSIBLE" 

Measured memory_bytes: 9868
import itertools
import math
n = int(input())
pattern = list(itertools.permutations(range(n)))
xy = [list(map(int,input().split())) for _ in range(n)]
n2 = 1

for i in range(1,n+1):
    n2 *=i
ans = 0
for j in pattern:
    for k in range(n-1):
        ans += ((xy[j[k+1]][0] - xy[j[k]][0])**2 + (xy[j[k+1]][1] - xy[j[k]][1])**2)**0.5

print(ans/n2)

Measured memory_bytes: 10020
#include <stdio.h>
#include <stdlib.h>
 #include <limits.h>
 typedef struct{
   int d;
   int pi;
   int color;
 }prim;
int cou = 0;
int MST(prim **,int *,int);
 int main(){
   int i,j,n;
   int *A;
   prim **G;

   scanf("%d",&n);
   A = malloc(n*sizeof(int));
   G = malloc(n*sizeof(prim *));
    for(i=0;i<n;i++)
     {
       G[i]=malloc(n*sizeof(prim));
     }
       
    for(i=0;i<n;i++)
      {
	for(j=0;j<n;j++)
	  {
	    scanf("%d",&G[i][j].d);
	    G[i][j].pi = -1;
	    G[i][j].color = 0;
	  }
      }
    i = MST(G,A,n);
    printf("%d\n",i);
   return 0;
 }
int MST(prim **G,int *A,int n){
  int j,k,num1,num2;
  int tmp;
  static int i=0;

      tmp = INT_MAX;
      A[cou] = i;
      cou++;

      for(j=0;j<n;j++)
	{
	  if(G[A[cou-1]][j].d != -1)
	  G[A[cou-1]][j].color = 1;
	}
      for(i=0;i<cou;i++)
	{
	  
	  for(j=0;j<n;j++)
	    {
	      if(G[A[i]][j].d!=-1 && G[j][A[i]].color!= 1 && G[A[i]][j].d < tmp)
		{
		  if(G[j][A[i]].color == 1) continue;
		  tmp = G[A[i]][j].d;
		  num1 = A[i];
		  num2 = j;
		}
	    }
	}
      
      if(tmp == INT_MAX)
	{
	  return 0;
	}
      
      G[num2][A[cou-1]].color = 1;
      i=num2;
      return MST(G,A,n) + tmp;
}

      









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

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i <= n; i++) {
        if (i * 108 / 100 == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
int n,i,k,sum,mn=0x3f3f3f3f;
int main() 
{
    cin>>n;
    for (i=1; i<=n; i++)
    {
        cin>>k;
        sum+=k;
        if (k<mn && k%10!=0) mn=k;
    }
    if (sum%10!=0) cout<<sum; else if (mn!=0x3f3f3f3f) cout<<sum-mn; else cout<<0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  ll a,b,c;
  cin >> a >> b >> c;
  if(c-a-b > 0 && 4*a*b < (c-a-b)*(c-a-b)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;


clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio
  ll n;
  ll i,j,k,ans = 0;
  cin >> n;
  vl a(n);

  forn(0,n,i){
    cin >> a[i];
  }
  sort(all(a));
  ll mx = a[n - 1];

  forn(1,mx + 1,i){
    auto idx = lower_bound(all(a), i) - a.begin();
    if(idx == n - idx){
      ans++;
    }
  }


  cout << ans << '\n';

  ktj();

}


Measured memory_bytes: 1024
//be name khoda
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const ll mod = 1e9+7;
const ll maxn = 3e3+10;

ll n, m;
ll dp[maxn][maxn], pre[maxn][maxn], suf[maxn][maxn];

string s;

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

    cin>> n >> s;

    ll ans = 0;
    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 1; j <= i; j++)
        {
            if(i == 1){
                dp[i][j] = 1;
                continue;
            }

            if(s[i-2] == '>')
                dp[i][j] = suf[i-1][j];
            if(s[i-2] == '<')
                dp[i][j] = pre[i-1][j-1];
            if(i == n)
                ans = (ans + dp[i][j]) % mod;
        }

        for(ll j = 1; j <= n; j++)
            pre[i][j] = (pre[i][j-1] + dp[i][j]) % mod;
        for(ll j = n; j >= 1; j--)
            suf[i][j] = (suf[i][j+1] + dp[i][j]) % mod;
    }

    cout<< ans;
}




Measured memory_bytes: 212352
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int R, G, B, N;  cin >> R >> G >> B >> N;

    int RMAX = N / R;
    int GMAX = N / G;

    int ans = 0;
    REP(r,RMAX+1) {
        REP(g,GMAX+1) {
            int nb = (N - r*R - g*G);
            if (nb >= 0 && nb%B==0) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

count = 0
for i in range(len(a)):
  if i % 2 == 0:
    count += a[i]
  else:
    count -= a[i]

print(count,end=' ')
count = count //2
for i in range(len(a)-1):
  count = a[i] - count
  print(count * 2,end=' ')
  
print()

Measured memory_bytes: 14092
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	for (long long int i = M + 1; i <= N; i++) {
		long long int box,bag;
		box = N / i;
		bag = N % i;
		K += box*(i - M);
		K += max((long long int)0, bag - M + 1);
		if (!M) {
			K--;
		}
	}
	cout << K << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int number[100];
	int N;
	int j,k,tmp,count;
	int i = 0;

	scanf("%d",&N);

	for(count = 0;count < N; count++){
		scanf("%d",&number[count]);
	}
	

	int flag= 0;
	for(flag = 0;flag < N-1;flag++)
	for(i = 0; i+1 <N-flag;i++){
		if(number[i] > number[i+1]){
			tmp = number[i];
			number[i] = number[i+1];
			number[i+1] = tmp;
			j++;
		}
	}
	for(k=0;k<N;k++){
		printf("%d",number[k]);
		if(k != N-1){
			printf(" ");
		}
		else{
			printf("\n%d\n",j);
		}
	}
	return 0;

}

Measured memory_bytes: 604
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
using namespace std;
map<long long,long long>s;
map<long long,long long>::iterator it;
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        s.clear();
        long long i,x;
        for(i=0;i<n;i++)
        {
            scanf("%lld",&x);
            s[x]++;
        }
        long long y;
        x=y=0;
        for(it=s.begin();it!=s.end();it++)
        {
            if(it->second>=4){
                x=y=it->first;
            }
            else if(it->second>=2){
                x=y;
                y=it->first;
            }
        }
        printf("%lld\n",x*y);
    }
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define ll long long int
#define p 1000000007
#define mx 100000
using namespace std;
ll f[100005],fin[100005],in[100005];	
int ncr(int n,int r)
{
	ll ans=((f[n]*fin[r])%p*fin[n-r])%p;
	return ans;
}
int fun(int a,int b)
{
	return a>b;
}
int main(){
	
	ll i,j,n,k,a[100005];	
	in[0]=in[1]=1;
	fin[0]=fin[1]=1;
	for(i=2;i<=100005;i++)
	in[i]=in[p%i]*(p-p/i)%p;
	
	for(i=2;i<=100005;i++)
		fin[i]=(in[i]*fin[i-1])%p;
	f[0]=1;
	for(i=1;i<=mx;i++)
		f[i]=(f[i-1]*i)%p;	
	cin>>n>>k;
	for(i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	ll ans=0;
	for(i=k-1;i<n;i++)
	{
		ans+=a[i]*ncr(i,k-1);
		ans%=p;
	}
	//cout<<"ans is "<<ans<<endl;
	ll an=0;
	sort(a,a+n,fun);
	for(i=k-1;i<n;i++)
	{
		an+=a[i]*ncr(i,k-1);
		an%=p;
	}
	ans-=an;
	//cout<<"an is "<<an
	ans%=p;
	
	cout<<ans<<endl;
		
	
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int r = 1 << 30;

    auto g = [](const string &a, const string &b, char *p) {
        int n = a.size(), m = b.size();
        for (int i0 = 0; i0 <= n; i0++) {
            int f = 1;
            for (int j = 0; j < m; j++) {
                int i = i0 + j;
                if (i >= n) break;
                if (a[i] != '?' && b[j] != '?' && a[i] != b[j]) {
                    f = 0;
                    break;
                }
            }
            p[i0] = f;
        }
    };

    auto f = [&r, &g](const string &a, const string &b, const string &c) {
        char p[3][2001];
        g(a, b, p[0]);
        g(b, c, p[1]);
        g(a, c, p[2]);

        int n = a.size(), m = b.size(), l = c.size();
        for (int i = 0; i <= n; i++) {
            if (!p[0][i]) continue;
            for (int j = 0; j <= m || i + j < n; j++) {
                if (j <= m && !p[1][j]) continue;
                if (i + j < n && !p[2][i + j]) continue;

                r = min(r, max({ n, i + m, i + j + l }));
            }
        }
    };

    string a[3];
    int p[3];

    for (int h = 0; h < 3; h++) {
        cin >> a[h];
        p[h] = h;
    }

    do {
        f(a[p[0]], a[p[1]], a[p[2]]);
    } while (next_permutation(p, p + 3));

    cout << r << endl;

    return 0;
}

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

int main(){
    vector<int> v(5);
    for (int i = 0; i< 5; i++)
        cin >> v[i];

    int flag = 1, sum = 0, min = 0, sma = 9, tmp = 0;
    for (int i = 0; i< 5; i++){
        if (v[i] % 10 != 0){ 
            flag = 0;
            tmp = v[i] % 10; 
            if (tmp < sma){
                sma = tmp;
                min = i;
            }   
        }   
    }   
    if (flag == 1){ 
        for (int i = 0; i< 5; i++)
            sum += v[i];
        cout << sum << "\n";
        return 0;
    }   

    for (int i = 0; i< 5; i++){
        if (i != min){
            if (v[i] % 10 == 0)
                sum += v[i];
            else
                sum += (v[i] / 10 + 1) * 10; 
        }   
    }    
    sum += v[min];
    cout << sum << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;


int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B;
    int K;
    cin >> K;
    cin >> A >> B;
    bool isValid = false;
    for(int i = A; i <= B; ++i){
        if(i % K == 0){
            isValid = true;
            break;
        }
    }
    if(isValid){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }
    return 0;


}

Measured memory_bytes: 3652
N,M = map(int,input().split())
x = []
y = []
for i in range(M):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
z = min(y)-max(x)
if z < 0:
    print(0)
elif z+1 >= N:
    print(N)
else:
    print(z+1)

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

#define y1 aklsdja
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define t top()
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define oo 1e17
#define ll long long
#define int long long
#define pow poww

const int N = 1e2 + 5;
const int VAL = 1e5 + 5;
int n , W;
int w[N] , v[N];
int dp[N][VAL];

main()
{
    //freopen("D.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> W;
    FOR(i , 1 , n)
        cin >> w[i] >> v[i];
    FOR(i , 1 , W)
        dp[0][i] = -oo;
    FOR(i , 1 , n)
        FOR(j , 0 , W)
        {
            dp[i][j] = dp[i - 1][j];
            if(j >= w[i])
                dp[i][j] = max(dp[i][j] , dp[i - 1][j - w[i]] + v[i]);
        }
    int res = 0;
    FOR(i , 0 , W)
        res = max(res , dp[n][i]);
    cout << res;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,x,y; cin >> n >> k >> x >> y;
  int ans = 0;
  for(int i = 0; i < n; ++i){
    if(i < k)ans += x;
    else ans += y;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}




int main(){
  int N;
  cin>>N;
  int a[N];
  int k=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    if(a[i]%2==1){
      k++;
    }
  }
  if(k>0){
    cout<<"first"<<endl;
  }else{
    cout<<"second"<<endl;
  }

  


  

  



}


  
  


Measured memory_bytes: 888
K, N = list(map(int, input().split()))
an = list(map(int,input().split()))

min_list = []
for i in range(N):
    if i == 0:
        left = an[i] + K - an[-1]
        right = an[i+1] - an[i]
    elif i == N-1:
        left = an[i] - an[i-1]
        right = an[0] + K - an[N-1]
    else:
        left = an[i] - an[i-1]
        right = an[i+1] - an[i]
    min_list.append(min(K-left, K-right))
print(min(min_list))


Measured memory_bytes: 26444
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

const int INF = 100000000;
using namespace std;
typedef long long ll;
string s;
vector<int> st;
void solve(){
    char pre = 'a';
    for(int i = 0;i<s.size();i++){
        if(pre=='S'&&s[i]=='T'){
            st.push_back(i-1);
        }
        pre = s[i];
    }
    int res = s.size();
    for(auto x:st){
        int s_idx = x;
        int t_idx = x+1;
        while(s[s_idx]=='S'&&s[t_idx]=='T'){
//            cout << s_idx <<":"<<t_idx << endl;
            s[s_idx]='a';
            s[t_idx]='a';
            res -= 2;
            s_idx--;
            while (s[s_idx]=='a'){
                s_idx--;
                if(s_idx<0)break;
            }
            t_idx++;
            while (s[t_idx]=='a'){
                t_idx++;
                if(t_idx>=s.size())break;
            }
            if(s_idx<0||t_idx>=s.size())break;
        }
    }
    cout << res << endl;

}

int main() {
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 1336
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int32_t main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    int m, d;
    cin >> m >> d;
    int an = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 10; j <= d; j++){
            int t1 = j / 10;
            int t2 = j % 10;
            if(t1 * t2 == i && t1 > 1 && t2 > 1) ++an;
        }
    }
    cout << an << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int d;
	int l;

	scanf("%d %d", &d, &l);

	if (d % l == 0) {
		printf("%d\n", d / l);
	}
	else {
		printf("%d\n", (d / l) + (d % l));
	}

	return 0;
}


Measured memory_bytes: 2696
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)

fun main() {
    val S= readLine()!!
    val T= readLine()!!
    var ans=T.length

    for (i in 0 until S.length -T.length+1){
        var diff=0
        for (j in 0 until T.length){
            if (S[i+j]!=T[j]){
                diff++
            }
        }
        ans= min(ans,diff)
    }
    println(ans)
}

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

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

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

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

    if(n >= 2) n -= 2;
    if(m >= 2) m -= 2;

    ll ans = n * m;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
f = 0
A = [-1 for i in range(N)]
for i in range(M):
  s, c = map(int, input().split())
  if A[s-1] != -1 and A[s-1] != c:
    print(-1)
    f = 1
    break
  A[s-1] = c
if f == 0:
  if N == 1 and (A[0] <= 0):
    print(0)
  elif N > 1 and A[0] == 0:
    print(-1)
  else:
    ans = 0
    for i in range(N):
      if i == 0:
        ans = ans * 10 + max(A[i], 1)
      else:
        ans = ans * 10 + max(A[i], 0)
    print(ans)

Measured memory_bytes: 61924