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

using namespace std;

int main(){
  
    int veces;
    int num;
    
    char letra;
    string a ="";
    string b ="";
    
    cin >> veces >> num;
    
    
    letra = (char)(num + 48);
    for(int i = 0; i < veces; i++)
        a += letra;
      
    letra = (char)(veces + 48);
    for(int i = 0; i < num; i++)
      b += letra;
    
    if(a <= b)
      cout << a;
    else
      cout << b;

return 0;
}

Measured memory_bytes: 256
a = 2, 3, 5

def f(n):
  m = memo.get(n)
  if m is None:
    nd = m = n * d
    for p, c in zip(a, b):
      p *= d
      k, r = divmod(nd, p);
      m = min(m, f(k) + r + c, f(k + 1) + p - r + c if r else m)
    memo[n] = m
  return m

t = int(input())
for _ in range(t):
  n, *b, d = map(int, input().split())
  memo = {0: 0, 1: d}
  print(f(n))


Measured memory_bytes: 10948
#define _USE_MATH_DEFINES //M_PI???????????????

#include<iostream>
#include<cmath>
using namespace std;

struct Point { double x, y; };

void makeKoch(int n, Point p1, Point p2) {
	if (n <= 0) return;
	
	Point s, t, u;

	s = { p1.x + (p2.x - p1.x) / 3, p1.y + (p2.y - p1.y) / 3 };
	t = { p1.x + 2 * (p2.x - p1.x) / 3, p1.y + 2 * (p2.y - p1.y) / 3 };
	u = { s.x + (t.x - s.x)*cos(M_PI / 3) - (t.y - s.y)*sin(M_PI / 3), s.y + (t.x - s.x)*sin(M_PI / 3) + (t.y - s.y)*cos(M_PI / 3) }; //?????¢??????

	makeKoch(n - 1, p1, s);
	cout << s.x << " " << s.y << endl;
	makeKoch(n - 1, s, u);
	cout << u.x << " " << u.y << endl;
	makeKoch(n - 1, u, t);
	cout << t.x << " " << t.y << endl;
	makeKoch(n - 1, t, p2);

}



int main(void) {
	int n;
	cin >> n;
	Point a = { 0,0 };
	Point b = { 100,0 };

	cout << a.x << " " << a.y << endl;
	makeKoch(n, a, b);
	cout << b.x << " " << b.y << endl;

	return 0;

}

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

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int ans = 0;
    for (int i = 0; i * R <= N; ++i)
        for (int j = 0; i * R + j * B <= N; ++j)
            if ((N - (i * R + j * B)) % G == 0)
                ++ans;

    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 256
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int,input().split()))
    s = input()
    check = True
    l = [0]*61
    for i in range(n-1,-1,-1):
        x = a[i]
        for j in range(60,-1,-1):
            if x & (1<<j):
                x ^= l[j]

        if s[i] == "0":
            if x:
                l[x.bit_length()-1] = x
        else:
            if x:
                print(1)
                check = False
                break
    if check:
        print(0)
                




Measured memory_bytes: 9012
#include<bits/stdc++.h>
using namespace std;
int flag=0,pd;
int main(){
	int k,t;
	int a[1001];
	cin>>k>>t;
	for(int i=0;i<t;i++) cin>>a[i],flag+=a[i];
	for(int i=0;i<t;i++){
		pd=a[i]*2-flag-1;
		if(pd>=0){
			cout<<pd<<endl;
			return 0;
		}
	}
	cout<<"0"<<endl;
	return 0;
} 

Measured memory_bytes: 256
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long K = sc.nextLong();
    long[] A = new long[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextLong();
    }
    
    long ans = 0;
    for (int a = 60; a >= -1; a--) {
      long maskA = 1L<<a;
      if (a != -1 && (K&maskA) == 0) continue;
      long tmp = 0;
      for (int b = 60; b >= 0; b--) {
        long maskB = 1L<<b;
        
        int bitNum = 0;
        for (int i = 0; i < N; i++) {
          if ((A[i]&maskB) != 0) bitNum++;
        }

        if (b > a) {
          if ((K&maskB) != 0) {
            tmp += (N-bitNum)*maskB;
          } else {
            tmp += bitNum*maskB;
          }
        } else if (b == a) {
           tmp += bitNum*maskB;
        } else {
          tmp += bitNum > N-bitNum ? bitNum*maskB : (N-bitNum)*maskB ;
        }
      }
      ans = Math.max(ans, tmp);
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 64176
#include<iostream>
using namespace std;
int main(void){
  int n;
  while(cin>>n&&n!=0){
    int sumA=0,sumB=0,a,b;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      if(a>b) sumA+=a+b;
      else if(a<b) sumB+=a+b;
      else sumA+=a,sumB+=b;
    }
    cout<<sumA<<' '<<sumB<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long int64;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };

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

    int n = 9;
    vi vec(n);
    rep(i, n) {
        cin >> vec.at(i);        
    }
    int N;
    cin >> N;

    vi x;
    int y;
    rep(j, N) {
        cin >> y;
        x.push_back(y);
    }

    rep(i, n) {
        rep(j, N) {
            if (vec.at(i) == x.at(j)) {
                vec.at(i) = 0;
            }
        }
    }

    if (vec.at(0) + vec.at(1) + vec.at(2) == 0)Yes;
    if (vec.at(3) + vec.at(4) + vec.at(5) == 0)Yes;
    if (vec.at(6) + vec.at(7) + vec.at(8) == 0)Yes;
    if (vec.at(0) + vec.at(3) + vec.at(6) == 0)Yes;
    if (vec.at(1) + vec.at(4) + vec.at(7) == 0)Yes;
    if (vec.at(2) + vec.at(5) + vec.at(8) == 0)Yes;
    if (vec.at(0) + vec.at(4) + vec.at(8) == 0)Yes;
    if (vec.at(2) + vec.at(4) + vec.at(6) == 0)Yes;
    No;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    string s;
    cin>>s;
    if(s[s.size()-1] == 's'){
        s+="es";
    } else {
        s+='s';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3684
#include<stdio.h>
#define N 10
int main()
{
int i,j,idx,tmp,data[N];
for(i=0;i<N;i++)
{
scanf("%d",&data[i]);
}

for(i=0;i<3;i++)
{
idx=i;
for(j=i+1;j<N;j++)
{
if(data[j]>data[idx])
idx=j;
}

tmp=data[i];
data[i]=data[idx];
data[idx]=tmp;
}

for(i=0;i<3;i++)
{
printf("%d\n",data[i]);
}
return 0;
}

Measured memory_bytes: 596
import java.text.DecimalFormat;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();

		int[] p = new int[m];
		int[] y = new int[m];
		Map<Integer, Integer> map = new TreeMap<>();
		for(int i = 0; i < m; i++) {
			p[i] = scan.nextInt();
			y[i] = scan.nextInt();
			map.put(y[i], i);
		}
		scan.close();


		DecimalFormat fmt = new DecimalFormat("000000");

		String[] id = new String[m];
		int[] cnt = new int[n+1];//県ごとの入れた市の数をカウント
		Iterator<Integer> itr = map.keySet().iterator();
		while(itr.hasNext()) {
			int i = map.get(itr.next());
			cnt[p[i]]++;
			id[i] = fmt.format(p[i]) + fmt.format(cnt[p[i]]);
		}

		for(int i = 0; i < m; i++) {
			System.out.println(id[i]);
		}

	}

}

Measured memory_bytes: 106144
// let coding = begin

#include<bits/stdc++.h>

#define ll long long
#define pb       push_back
#define all(a)   a.begin(), a.end()

using namespace std;
const int MAX = 1e9+9;
const int MIN = -1e9;
const int N= 1e5+9;
const double PI = 3.14159265;
int a,b,c;

int main(){
  clock_t start;
  cin >> a >> b;
  for(int i=1; i<=3; i++){
    if(a*i*b % 2 != 0 ){
      cout << "Yes" << endl;
      return 0;
    }

  }
  cout << "No" << endl;
  cerr << "Time: " << (clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " ms" << endl;
  return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] array=new int[5];
		array[0]=sc.nextInt();
		array[1]=sc.nextInt();
		array[2]=sc.nextInt();
		array[3]=sc.nextInt();
		array[4]=sc.nextInt();
		int bmax=0,max=0;

		for(int i=0;i<5;i++) {
			while(max%10!=0) {
				max++;
			}
			max+=array[i];
			if(array[i]%10==0) {
				array[i]=10;
			}else {
				array[i]=array[i]%10;
			}
			//System.out.println(max);
		}
		while(max%10!=0) {
			max++;
		}
		Arrays.sort(array);
		System.out.println(max-(10-array[0]));
	}
}

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




Measured memory_bytes: 21844
#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()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


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


int main(){
  ll n,m;
  cin >> n >> m;
  VLL a(m,0);
  rep(i,n){
    int x;
    cin >> x;
    rep(j,x){
      int eat;
      cin >> eat;
      eat--;
      a[eat]++;
    }
  }
  ll ans = 0;
  rep(i,m){
    if(a[i] == n) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        long d = sc.nextLong();

        int cnt = 0;
        for (int i=0; i<n; i++) {
            long s = sc.nextLong();
            long t = sc.nextLong();
            long tmp = s*s + t*t;
            if (tmp <= d*d) cnt++;
        }

        System.out.print(cnt);
    }

}



Measured memory_bytes: 60652
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <algorithm>
#include <queue>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

template<class G>
struct Heap {
	int size() const { return (int) hp.size(); }
	long long top() const { return hp.top() + lazy; }
	void pop() { hp.pop(); }
	void push(long long x) { hp.push(x - lazy); }

	long long lazy = 0;
	std::priority_queue<long long, std::vector<long long>, G> hp;

	void print() {
		if(hp.empty()) {
			return;
		} else {
			std::cout << hp.top() + lazy << ' ';
			auto v = hp.top();
			hp.pop();
			print();
			hp.push(v);
		}
	}
};

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	Heap<std::greater<long long>> mn;
	Heap<std::less<long long>> mx;
	long long b = 0;
	for(int rep = 0; rep < n; rep++) {
		long long l, r;
		std::cin >> l >> r;
		if(rep == 0) {
			mx.push(l);
			mn.push(r);
			b -= r;
		} else {
			// shift to left
			mx.lazy -= (r - l);
			//std::cout << b << ", first: "; mx.print(); std::cout << ", "; mn.print(); std::cout << std::endl;
			// do addition
			if(mn.top() <= l) mn.push(l);
			else mx.push(l);
			if(mx.top() <= l) mn.push(l);
			else mx.push(l);
			b -= l;
			while(mn.size() > mx.size()) {
				mx.push(mn.top());
				mn.pop();
			}
			while(mx.size() > mn.size()) {
				mn.push(mx.top());
				mx.pop();
			}
			//std::cout << b << ", second: "; mx.print(); std::cout << ", "; mn.print(); std::cout << std::endl;
			// do shift to right
			b -= mn.size() * (r - l);
			mn.lazy += (r - l);
			//std::cout << b << ", third: "; mx.print(); std::cout << ", "; mn.print(); std::cout << std::endl;
		}
		//std::cout << "after [" << l << ", " << r << "] got b " << b << '\n';
	}
	while(mn.size()) {
		b += mn.top();
		mn.pop();
	}
	std::cout << b << '\n';
}

Measured memory_bytes: 2036
package main

import (
    "fmt"
    "bufio"
    "os"
)
    
func main() {
    old := nextLine()
    new := nextLine()
    //newの最後の文字を取得
    last_new := string(new[len(new)-1])
    if (old + last_new) == new {
        fmt.Printf("Yes\n")
    } else {
        fmt.Printf("No\n")
    }
}

/*----------標準入力用の関数----------*/
var reader = bufio.NewReaderSize(os.Stdin, 1000000)

func nextLine() string {
	buffer := make([]byte, 0)
	for true {
		line, isPrefix, _ := reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

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


int main(){
    ll N, A, B; cin >> N >> A >> B;

    ll ans = 0;
    if((B -  A) % 2 == 0){
        ans = (B - A) / 2;
    }
    else{
        if(A == 1 || B == N){
            ans = 1 + (B - A - 1) / 2;
        }
        else{
            ans = min(A - 1, N - B) + 1 + (B - A - 1) / 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  int q;
  cin>>q;
  int s[8][8]={{1,0,1,0,1,0,1,0},
               {1,1,1,1,1,1,1,1},
               {1,0,1,0,1,0,1,0},
               {1,1,1,1,1,1,1,1},
               {1,0,1,0,1,0,1,0},
               {1,1,1,1,1,1,1,1},
               {1,0,1,0,1,0,1,0},
               {1,1,1,1,1,1,1,1},};
  while(q--){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;b--;
    int res=0;
    for(int i=a;i<c;i++)
      for(int j=b;j<d;j++)
        res+=s[i][j];
    cout<<res<<endl;
  }  
  return 0;
}



Measured memory_bytes: 3108
#include <stdio.h>

int main() {
  int number_a, number_b;
  scanf("%d %d", &number_a, &number_b);
  if(number_a <= 8 && number_b <= 8) {
    printf("Yay!\n");
  } else {
    printf(":(\n");
  }
  return 0;
}


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

int main() {
    rep(i, 2) {
        char c;
        cin >> c;
        if (c == '9') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
c = [list(map(int, input().split())) for i in range(3)]
a = [0 for i in range(3)]
b = [0 for i in range(3)]
a[0] = 0
a[1] = c[1][1] - c[0][1]
a[2] = c[2][2] - c[0][2]
b[0] = c[0][0]
b[1] = c[0][1]
b[2] = c[0][2]
flag = True
for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            flag = False
print("Yes") if flag else print("No")

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

using namespace std;

long double dist(double a, double b) {
    return (a - b) * (a - b);
}

int main() {
    int n; cin >> n;
    long double x[n], y[n];
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];
    long double res = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            res += sqrt(dist(x[i], x[j]) + dist(y[i], y[j]));
        }
    }
    cout << fixed << setprecision(10) << res * 2 / n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(a, b) for (ll i = a; i <= b; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define N 100005
const ll INF = 1000000001;
const ll MOD = 1000000007;

//vector< vector<ll> > g(N);
//vector< pair<ll, pair< ll, ll > > > g(N);
//ll vis[N] = {0}, par[N] = {0}, child[N] = {0}, dp[N] = {0};



void solve(){
    ll n; cin >> n;
    ll a[n];
    f(0, n-1) cin >> a[i];
    ll ans = 0, s = 0;
    f(0, n-1){
        ans = (ans + (a[i] * s) % MOD) % MOD;
        s  = (s + a[i]) % MOD;
    }
    cout << ans % MOD << "\n";
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    //ll t;cin >> t;for(ll index=1; index<=t; index++){
        //cout << "Case #" << index << ": " ;
        solve();
    //}
    return 0;
}


Measured memory_bytes: 5164
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    int n,i,j,cnt=0;
    string str;
    cin>>n>>str;
    i=0,j=n-1;
    while(i<j)
    {
        if(str[i]=='W' && str[j]=='R')
        {
            cnt++;swap(str[i],str[j]);i++;j--;
        }
        if(str[i]=='R')i++;
        if(str[j]=='W')j--;
    }
    cout<<cnt<<endl;


    return 0;
}







Measured memory_bytes: 3760
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(void){
    int A,B;
    cin>>A>>B;
    int ave;
    ave=(A+B+1)/2;

    cout<<ave<<endl;

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const ll MOD = 1e9+7;

ll DP[100100][4];
int main(){
    string S;
    cin >> S;
    int N = S.length();

    char c = S[0];
    if(c == 'A' || c == '?') DP[0][1] = 1;

    if(c == '?') DP[0][0] = 3;
    else DP[0][0] = 1;

    for(int i = 1; i < N; i++){
        c = S[i];
        if(c == 'A')
            DP[i][1] = DP[i-1][0];
        else if(c == 'B')
            DP[i][2] = DP[i-1][1];
        else if(c == 'C'){
            if(i >= 2)
                DP[i][3] = DP[i-1][2];
        }
        else if(c == '?'){
            DP[i][1] = DP[i-1][0];
            DP[i][2] = DP[i-1][1];
            if(i >= 2)
                DP[i][3] = DP[i-1][2];
        }

        for(int j = 0; j < 4; j++){
            if(c == '?')
                DP[i][j] += 3*DP[i-1][j];
            else
                DP[i][j] += DP[i-1][j];
            DP[i][j] %= MOD;
        }

    }

    //for(int i = 0 ; i < N; i++){
    //    for(int j = 0; j < 4; j++){
    //        printf("%lld ", DP[i][j]);
    //    }
    //    printf("\n");
    //}

    ll ans;
    ans = DP[N-1][3];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
// #include "/usr/local/include/cxx_pretty_print/cxx_pretty_print.hpp"

using namespace std;
/* type aliases */
using i32 = int32_t; using ui32 = uint32_t; using i64 = int64_t; using ui64 = uint64_t; using i128 = __int128;
using f32 = float;   using f64  = double;   using f80 = long double;
using PII = pair<i32, i32>; using PLL = pair<i64, i64>; using PFF = pair<f32, f32>; using PDD = pair<f64, f64>;
using VB  = vector<bool>;   using VS  = vector<string>;
using VI  = vector<i32>;    using VL  = vector<i64>;    using VF  = vector<f32>;    using VD  = vector<f64>;
using VVI = vector<VI>;     using VVL = vector<VL>;     using VVF = vector<VF>;     using VVD = vector<VD>;
using VPI = vector<PII>;    using VPL = vector<PLL>;    using VPF = vector<PFF>;    using VPD = vector<PDD>;
/* constants */
constexpr i64 mod = 1000000007;                                // 10^9+7
constexpr i64 inf = 9000000000000000000;                       // 9*10^18
/* macros */
#define MAX(c)        *max_element(ALL(c))
#define MIN(c)        *min_element(ALL(c))
#define SIZE(c)       (i64)((c).size())                        // unsined int (size_t) -> int64_t
#define ALL(c)        (c).begin(), (c).end()
#define RALL(c)       (c).rbegin(), (c).rend()
#define REP(i, n)     for (i64 i=0; i<(i64)(n); ++i)           // 0 to n-1
#define REPD(i, n)    for (i64 i=(i64)(n)-1; i>=0; --i)        // n-1 to 0
/* debug */
#define debug(x)      cerr << #x << ": " << (x) << '\n'
#define debugvec(v)   for (size_t _ = 0; _ < (v).size(); ++_) {cerr << #v << '[' << _ << "]: " << (v)[_] << '\n';}
/* useful output */
auto print = [](auto x) {cout << (x) << '\n';};
template <class T> void printvec(T v, string sep=" ", string end="\n") {REP(i, SIZE(v)-1) cout << v[i] << sep; cout << v[SIZE(v)-1] << end;}
/* useful input */
VS splitstr(string s, char delim=' ') {VS v; string buf; stringstream ss{s}; while (getline(ss, buf, delim)) v.push_back(buf); return v;}




void Main() {
    i32 n;
    cin >> n;
    print((n - 2) * 180);

}


signed main() {
    cin.tie(nullptr);                                         // cin と cout の tie を切り高速化
    cout << fixed << setprecision(15);                        // 浮動小数点数が 1e-006 のように表示されることを防ぐ
    Main();
}

Measured memory_bytes: 3612
#!/usr/bin/env python3

def main():
    (A,B,C,X,Y) = map(int,input().split())
    lim = max(X, Y)
    vmin = min(X, Y)
    minCost = 5000 * 10**5 * 2
    for t in range(lim+1):
        if t <= vmin:
            cost = (X - t) * A + (Y - t) * B + t * 2 * C
        elif X <= Y:
            cost = (Y - t) * B + t * 2 * C
        else:
            cost = (X - t) * A + t * 2 * C
        minCost = min(minCost, cost)
    print(minCost)
    

main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=1e9+7;
const ll inf=1e7;
const ll ms=(1e6)+5;

int ar[ms];

int mm[ms]={0};


int main()
{
    idfc;

    string s;
    cin>>s;
    int n=s.length();
    int i;

    for(i=1;i<=n;i++)
    {
        ar[i]=s[i-1]-48;
    }

    int ss=0;
    mm[0]=1;
    int num=2019;
    int mul=1;
    ll ans=0;
    for(i=n;i>=1;i--)
    {
        ss=(ss+(mul*ar[i]))%num;
        ans+=mm[ss];
        mm[ss]+=1;
        mul=(mul*10)%num;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4528
function Main(input) {
  input = input.split("\n");
  var S = input[0].split("");
  var anssub = new Array(S.length).fill(0);
  cnt=0;
  var lr = new Array(1).fill(-1);
  var rl = new Array();

  for(var i=1;i<S.length;i++){
    if(S[i-1]=="R"&&S[i]=="L"){
      rl.push(i-1);
    }else if(S[i-1]=="L"&&S[i]=="R"){
      lr.push(i-1);
    }
    if(i==S.length-1){
      lr.push(i);
    }
  }
  for(var i=lr.length-1;i>0;i--){
    if((lr[i]-lr[i-1])%2==0){
      anssub[rl[i-1]]=(lr[i]-lr[i-1])/2;
      anssub[rl[i-1]+1]=(lr[i]-lr[i-1])/2;
    }else{
      if((lr[i]-rl[i-1])%2==0){
        anssub[rl[i-1]]=Math.ceil((lr[i]-lr[i-1])/2);
        anssub[rl[i-1]+1]=Math.floor((lr[i]-lr[i-1])/2);
      }else{
        anssub[rl[i-1]]=Math.floor((lr[i]-lr[i-1])/2);
        anssub[rl[i-1]+1]=Math.ceil((lr[i]-lr[i-1])/2);
      }
    }
  }
  ans=anssub.join(" ");

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  int n;
  
  cin >> n;
  
  int n1 = n;
  int n2 = n1/10;
  int n3 = n2/10;
  
  n1 = n1%10;
  n2 = n2%10;
    
  if(n1==7 || n2==7 || n3==7)
    cout << "Yes";
  else
    cout << "No";
    
}

Measured memory_bytes: 3628
//
//  main.c
//  ITP1_4_C
//
//  Created by k16031kk on 2018/05/21.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a = 0, b = 0;
    char op;
    scanf("%d %c %d", &a, &op, &b);
    while(op!='?') {
        if(op=='+') {
            printf("%d\n", a+b);
        } if(op=='-') {
            printf("%d\n", a-b);
        } if(op=='*') {
            printf("%d\n", a*b);
        } if(op=='/') {
            printf("%d\n", a/b);
        }
        scanf("%d %c %d", &a, &op, &b);
    }
    
    return 0;
}



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

vector<long long> kosu(1001);

void divisor(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    while(n % i == 0){
      kosu[i]++;
      n /= i;
    }
  }
  if(n != 1){
    kosu[n]++;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N;
  cin >> N;
  for(int i = 1; i <= N; i++){
    divisor(i);
  }
  long long ans = 1;
  for(int i = 0; i < 1001; i++){
    ans *= kosu[i] + 1;
    ans %= 1000000007;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
main(){
  char str1[10000],str2[10000],str3[10000];
  int i,j,k,l1,l2,n,sign;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  start:
    scanf("%s",str1);
    scanf("%s",str2);
    l1=strlen(str1);
    l2=strlen(str2);
    if(l1>80||l2>80){
    exit:
      printf("overflow\n");
    exit2:
      i++;
      if(i==n)return 0;
      goto start;
    } else if(str1[0]=='0'&&str2[0]=='0'){
      printf("0\n");
      goto exit2;
    }
     else{
      for(j=l1;j<=100;j++)str3[j]='0';
      for(j=l1-1,k=0;j>=0;j--,k++)str3[k]=str1[j];
      for(j=0;j<=100;j++)str1[j]='0';
      for(j=l2-1,k=0;j>=0;j--,k++)str1[k]=str2[j];
      for(j=0,sign=0;j<=99;j++){
	str3[j]+=(str1[j]-'0')+sign;
	sign=0;
	if(str3[j]>'9'){
	  str3[j+1]+=1;
	}
      }
    }
    for(j=80;j<100;j++){
      if(str3[j]!='0'){
	goto exit;
      }
    }
    for(sign=0,j=79;j>=0;j--){
      if(str3[j]!='0'){
	sign++;
      }
      if(sign!=0){
	if(str3[j]>='0'&&str3[j]<='9'){
	  printf("%c",str3[j]);
	}else{
	  printf("%c",str3[j]-10);
	}
      }
    }
     puts("");
  }
  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int A,B;
	A=min(a,b);
	B=min(c,d);
	cout<<A+B<<endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        String[] arr = reader.readLine().split (" ");
        String S, T;
        S = arr[0];
        T = arr[1];
        System.out.println (T + S);
        return;
    }
}

Measured memory_bytes: 37060
#include <stdio.h>

void pr8(int n) {
  if(n==0) return;
  pr8(n/8);
  printf("%c", "01235789"[n%8]);
}

int main() {
  for(;;) {
    int n;
    scanf("%d", &n);
    if(n==0) return 0;
    pr8(n);
    printf("\n");
  }
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
    string s;
    cin>>s;
    int c=0,a=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
           {
               c++;
                
           }
        else{
          a=max(a,c); 
          c=0;
        }
    }
cout<<max(a,c)<<endl;
return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  map<int,int> m;
  rep(i,n){
    int a; cin>>a;
    m[a]++;
  }
  int ans=0;
  for(auto e: m){
    if(e.second%2==1)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<cstring>

using namespace std;

int main(){
  string str,str1;
  cin >> str >> str1;
  str = str + str;
  bool hit = false;
  for(int i=0;i < str.size();i++){
    if(str1 == str.substr(i,str1.size())) {
      hit = true;
      break;
    }
  }
  if(hit) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> & vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b)
{
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b)
{
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num)
{
	return floor(num) == num;
}

Int fact(int num)
{
	if (num == 0)
		return 1;
	else
		return num * fact(num - 1);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

Int binary(Int bina) {
	Int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}

int main() {
	IOS;
	int n,x; cin>>n;
	vector<int> alpha[26];
	for (int i = 0; i < n; i++) {
		string str; cin >> str;
		for (int j = 0; j < 26; j++) {
			int h = count(str.cbegin(), str.cend(), 97 + j);
			alpha[j].push_back(h);
		}
		
	}
	string ans = "";
	for (int j = 0; j < 26; j++) {
		ssort(alpha[j]);
		for (int i = 0; i < alpha[j][0]; i++) {
			ans += j + 97;
		}
	}
	cout << ans;

	cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Main{
	static BufferedReader br;
	static int in() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
    public static void main(String[] args) throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        int[] ar=split();
        int n=ar[0];
        int k=ar[1];
        int[] arr=split();
        for(int i=k;i<n;i++)
        {
        	if(arr[i]>arr[i-k])
        		System.out.println("Yes");
        	else
        		System.out.println("No");
        }
    }
}


Measured memory_bytes: 65068
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

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

	int sum = 0;
	int sol = 0;
	for(int i = 0; i < n; i++)
	{
		if (s[i] == 'I')
		{
			sum++;
		}else
		{
			sum--;
		}

		if (sol < sum)
		{
			sol = sum;
		}
	}

	cout << sol << endl;

	return 0;
}

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

int main() {
  int N, x = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    x += r - l + 1;
  	}
  cout << x << endl;

}



Measured memory_bytes: 256
(defun split-with (string &key (delimiterp #'(lambda (c) (char= c #\Space))))
  (loop :for beg = (position-if-not delimiterp string)
        :then (position-if-not delimiterp string :start (1+ end))
        :for end = (and beg (position-if delimiterp string :start beg))
        :when beg :collect (subseq string beg end)
        :while end))

(defun manhattan-dis (a b c d)
  (declare (fixnum a b c d))
  (+ (abs (- a c)) (abs (- b d))))

(defun read-data (p)
  (loop :for count :from 0 :below p
        :for line = (split-with (read-line t nil nil))        
        :for a = (parse-integer (car line))
        :for b = (parse-integer (car (cdr line)))
        :collect (cons a b)))

(let* ((lst (split-with (read-line)))
       (n (parse-integer (car lst)))
       (m (parse-integer (car (cdr lst))))
       (ab-list (read-data n))
       (cd-list (read-data m)))
  (loop :for (a . b) :in ab-list
        :for min-dis = most-positive-fixnum
        :for min-index = 0
        :do (loop :for (c . d) :in cd-list
                  :for count :upfrom 1
                  :for dis = (manhattan-dis a b c d)
                  :do (when (< dis min-dis)
                        (progn (setf min-index count)
                               (setf min-dis dis)))
                  :finally (format t "~d~%" min-index))))


Measured memory_bytes: 15716
#include<stdio.h>
int main()
{
	int a1,a2,a3;
	int x;
	scanf("%d %d %d",&a1,&a2,&a3);
	x= a1+a2+a3;
	if (x>=22){
		printf("bust");
	}
	else if (x<22){
		printf("win");
	}
	return 0;
}

Measured memory_bytes: 3184
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define MT make_tuple

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL =  unsigned long long;
using MAT = array<array<LL, 2>, 2>;

template<class T> void _R( T &x ) { cin>>x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U>
void R( T& head, U&... tail ) {
    _R(head);
    R(tail...);
}

template<class T> void _print( const T &x ) { cout << x; }
void _print( const int &x ) { printf("%d", x); }
void _print( const LL &x ) { printf("%lld", x); }
void _print( const double &x ) { printf("%.16f\n",x); }
void _print( const char &x ) { putchar(x); }
void _print( const char *x ) { printf("%s",x); }
template<class T> void _print( const vector<T> &x ) { for (auto i = x.begin(); i != x.end(); _print(*i++)) if (i != x.cbegin()) putchar(' '); }
void print() {}
template<class T, class... U> void print( const T& head, const U&... tail ) {
    _print(head);
    putchar(sizeof...(tail) ? ' ' : '\n');
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 300005


int main()
{
    int n;
    R(n);
    int pt = 0, px = 0, py = 0;
    REP(i, n) {
        int t, x, y;
        R(t, x, y);
        int ds = abs(x - px) + abs(y - py);
        int dt = t - pt;
        if(ds > dt or (dt - ds) % 2 == 1) {
            print("No");
            return 0;
        }
        pt = t;
        px = x;
        py = y;
    }
    print("Yes");
    return 0;
}


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

using namespace std;

int k, a, b;

int main(){
	cin >> k >> a >> b;
	for(int i = 0; k*i <= b; ++i){
		if(a <= k*i && k*i <= b){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
}

Measured memory_bytes: 3624
from collections import deque
h,w = map(int,input().split())
maze = [['']*w]*h
wcnt = 0
for i in range(h):
  temp = list(input())
  wcnt += temp.count('.')
  maze[i] = temp
que = deque()
que.append([0,0])
d = [[float('inf')]*w for i in range(h)]
d[0][0] = 0
dx = [0,-1,0,1]
dy = [-1,0,1,0]
while que:
    [px,py] = que.popleft()
    for i in range(4):
        nx = px + dx[i]
        ny = py + dy[i]
        if 0<=nx<h and 0<=ny<w and maze[nx][ny] == '.' and d[nx][ny] == float('inf'):
            d[nx][ny] = d[px][py] + 1
            que.append([nx,ny])
if d[h-1][w-1] == float('inf'):
    ans = -1
else:
    ans = wcnt - d[h-1][w-1] - 1
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <cmath> 
#include <algorithm>
using namespace std; 
inline int gi() {
    register int data = 0, w = 1; 
    register char ch = 0; 
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar(); 
    while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar(); 
    return w * data; 
} 
const int Mod = 1e9 + 7; 
const int T = 2001; 
int N, f[4005][4005], A[200005], B[200005]; 
int fpow(int x, int y) {
	int res = 1; 
	while (y) {
		if (y & 1) res = 1ll * res * x % Mod; 
		x = 1ll * x * x % Mod; 
		y >>= 1; 
	} 
	return res; 
} 
int fac[8005], ifc[8005]; 
int C(int n, int m) { 
	if (n < m) return 0; 
	else return 1ll * fac[n] * ifc[n - m] % Mod * ifc[m] % Mod; 
} 
int main () { 
	N = gi(); 
	for (int i = 1; i <= N; i++) A[i] = gi(), B[i] = gi(), f[T - A[i]][T - B[i]]++; 
	for (int i = 1; i <= 4001; i++) 
		for (int j = 1; j <= 4001; j++) 
			f[i][j] = (f[i][j] + (f[i - 1][j] + f[i][j - 1]) % Mod) % Mod; 
	fac[0] = 1; for (int i = 1; i <= 8000; i++) fac[i] = 1ll * fac[i - 1] * i % Mod; 
    ifc[8000] = fpow(fac[8000], Mod - 2); 
	for (int i = 7999; ~i; i--) ifc[i] = 1ll * ifc[i + 1] * (i + 1) % Mod;
	int ans = 0; 
	for (int i = 1; i <= N; i++) { 
		ans = (ans + f[A[i] + T][B[i] + T]) % Mod; 
		ans = (ans - C((A[i] + B[i]) << 1, A[i] << 1) + Mod) % Mod; 
	} 
	ans = 1ll * ans * fpow(2, Mod - 2) % Mod; 
	printf("%d\n", ans); 
    return 0; 
} 

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

int main(){
  long long int a,b,x;
  cin>>a>>b>>x;
  long long int c,d;
  c=a/x;
  d=b/x;
  if(a%x==0){
    cout<<d-c+1<<endl;
  }else{
    cout<<d-c<<endl;
  }
  
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (a[i][k] == 0 || a[k][j] == 0 || a[i][j] == 0) continue;
					if (a[i][k] + a[k][j] < a[i][j]) {
						System.out.println(-1);
						return;
					}

					if (a[i][k] + a[k][j] == a[i][j]) {
						a[i][j] = 0;
						a[j][i] = 0;
					}
				}
			}
		}

		long answer = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				answer += a[i][j];
			}
		}

		System.out.println(answer / 2);
	}
}


Measured memory_bytes: 51056
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#include <map>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int n;
map<int, int> a;

void input() {
  a.clear();

  cin >> n;

  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;

    a[t]++;
  }
}

void solve() {
  ll sum = 0;

  for (auto&& [key, val] : a)
    sum += key * val;

  int q;
  cin >> q;

  while (q--) {
    int b;
    int c;
    cin >> b >> c;

    sum -= 1ll * b * a[b];
    sum += 1ll * c * a[b];

    a[c] += a[b];
    a[b] = 0;

    cout << sum << '\n';
  }

  cout << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

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

  _times = 3;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 8016
#include <stdio.h>
int main(void){
  int a, b;
  scanf("%d %d", &a, &b);
  if(a + b > a - b){
    if(a + b > a * b){
      printf("%d\n", a + b);
    }else{
      printf("%d\n", a * b);
    }
  }else{
    if(a - b > a * b){
      printf("%d\n", a - b);
    }else{
      printf("%d\n", a * b);
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<vector>
#include<queue>
#include<iostream>

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

using namespace std;

const int INF = 1000000000;
typedef pair<int,int> P;

int main(){
  int h,w,cnt=0;
  char c;
  bool fl = false;
  
  scanf("%d%d",&h,&w);
  int gx = h-1, gy = w-1;
  vector<vector<bool>> vvb(h,vector<bool>(w));
  vector<vector<int>> d(h,vector<int>(w,INF));
  REP(i,h){
    REP(j,w){
      cin >> c;
      if(c=='.'){
        vvb[i][j] = true;
        ++cnt;
      }else vvb[i][j] = false;
    }
  }

  int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
  queue<P> que;
  que.push({0,0});
  d[0][0] = 0;
  while(que.size()){
    P p = que.front(); que.pop();
    if(p.first==gx && p.second == gy){
      fl = true;
      break;
    }
    REP(i,4){
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if(0<=nx && nx<h && 0<=ny && ny<w && vvb[nx][ny] && d[nx][ny] == INF){
        que.push({nx,ny});
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }

  if(fl) printf("%d\n",cnt-d[gx][gy]-1);
  else printf("-1\n");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,k;
int main()
{
       int x,s=0;
       cin>>n>>k;
       for(int i=0;i<n;i++)
         {
              cin>>x;
              if(x>k-x)
                     s=s+2*(k-x);
              else
                     s+=2*x;

         }
         cout<<s;
       return 0;
}


Measured memory_bytes: 256
n = int(input())

list1 = list(map(int,input().split()))
list2 = list(map(int,input().split()))

list = []
for i in range(n):
    for j in range(n):
        ans = sum(list1[:j+1]) + sum(list2[j:])
        list.append(ans)
       
print(max(list))



Measured memory_bytes: 3316
#include <stdio.h>
int main()
{

  int i, j, a, b, m[100][100], n[100], c[100];

  for ( i = 0; i < 100; i++)
    {
      for ( j = 0; j < 100; j++)
	{
	  m[i][j] = 0;
	}
      n[i] = 0;
      c[i] = 0;
    }

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

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

  for ( i = 0; i < a; i++)
    {
      printf("%d\n", c[i]);
    }
  return 0;
}

Measured memory_bytes: 640