akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#define ll long long
using namespace std;

ll Solve(ll Q, ll N) {
    return 4*Q*N;
}

ll Solve(ll Q, ll H, ll N) {
    return min(Solve(Q,N),2*H*N);
}


ll Solve(ll Q, ll H, ll S, ll N) {
    if (N==0)
        return 0;
    return min(Solve(Q,H,N),S*N);
}


ll Solve(ll Q,ll H,ll S,ll D,ll N) {
    
    return min(Solve(Q,H,S,N),(N/2)*D+Solve(Q,H,S,N%2));
    
    
    
    
}

int main() {
    ll Q,H,S,D,N;
    cin>>Q>>H>>S>>D>>N;
    cout << Solve(Q,H,S,D,N) << endl;
    
}

Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), W = ip[0], a = ip[1], b = ip[2];
	if(abs(a-b) < W) {
		0.writeln;
		return;
	}
	(abs(a-b)-W).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <string>
#include <sstream>
int fix()
{
    //example to format floating point numbers.
    double pi = 3.141592653589793;
    double r = 3.141592653589793 * 128;
    std::ios_base::fmtflags f(std::cout.flags()); //[1]
    std::cout << "default:\n  " << pi << " " << r << "\n";
    std::cout << std::setprecision(4) << "setprecision(4):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setiosflags(std::ios::fixed) << "setiosflags(std::ios::fixed):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout << std::setprecision(5) << "setprecision(5):\n  " //[2]
              << pi << " " << r << "\n";
    std::cout.flags(f);
    std::cout << "reset:\n  " << pi << " " << r << "\n";
    //[1] https://stackoverflow.com/questions/2273330/restore-the-state-of-stdcout-after-manipulating-it
    //[2] https://stackoverflow.com/questions/4217510/how-to-cout-the-correct-number-of-decimal-places-of-a-double-value
    return 0;
}
void multipleLines()
{
    //example to parse multiple lines input.
    std::istringstream isin("1 2 3\n3 2 4\n0 0 0");

    for (std::string str; std::getline(isin, str);)
    {
        std::istringstream tisin(str);
        int a, b, c;
        tisin >> a >> b >> c;
        std::cout << a << " " << b << " " << c << "\n";
    }
    //[1]  https://stackoverflow.com/questions/19767644/c-parsing-input-string-to-variables
}
#include <vector>
#include <set>
#include <map>

int main()
{
    std::map<uint8_t, uint8_t> mapAa;
    for(uint8_t a =0;true;a++)
    {
        mapAa[a] = a;   
        if(a == 255)
        {
            break;
        }
    }
    for(uint8_t a=0;a<26;a++)
    {
        mapAa[a+'a'] =  a + 'A';
        mapAa[a+'A'] =  a + 'a';
    }
    std::string str;
    std::getline(std::cin, str);
    for(auto it : str)
    {
        std::cout << mapAa[it];
    }
    std::cout << "\n";
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int res = INT_MAX;
	REP(x, X + 1) {
		int cost = A * x + C * (X - x) * 2;
		int b = min(B, 2 * C);
		if (Y - (X - x) > 0) {
			cost += (Y - (X - x)) * b;
		}
		res = min(res, cost);
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
a = list(map(int,input().split()))
N = a[0]
M = a[1]
if N == 1 and M == 1:
    print("1")
elif N == 1 and M >= 2:
    print(str(M-2))
elif N >= 2 and M == 1:
    print(str(N-2))
else:
    print(str((N-2)*(M-2)))

Measured memory_bytes: 3060
N, M = list(map(int, input().split(' ')))
r = [0] * N
pp = [0] * N

pena = 0
co = 0

for i in range(M):
  pi, Si = input().split(' ')
  p = int(pi)
  if r[p-1] == 0:
    if Si == 'WA':
      pp[p-1] += 1
    else:
      co += 1
      pena += pp[p-1]
      r[p-1] = 1

print (str(co) + ' ' + str(pena))


Measured memory_bytes: 4596
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
	int first, second, tgt;

	cin >> first >> second;

	if(first < 10 && first >= 1 && second < 10 && second >=1){
		tgt = first * second;
		cout << tgt << endl;
	}else{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; 
    cin>>n;
    vector <vector<int>> to(n),cost(n);
    for(int i=0;i<n-1;i++){
        int a,b,w;
        cin>>a>>b>>w;
        a--; b--;
        to[a].push_back(b); cost[a].push_back(w);
        to[b].push_back(a); cost[b].push_back(w);
    }
    vector <int> ans(n,-1);
    queue <int> q;
    ans[0] =0 ;
    q.push(0);
    while(!q.empty()){
        int v =q.front();
        q.pop();
        for(int i=0;i<to[v].size();i++){
            int u = to[v][i];
            int w = cost[v][i];
            if(ans[u] != -1) continue;
            ans[u] = (ans[v] + w) % 2;
            q.push(u);
         }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

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

    ll N;
    cin >> N;
    set<ll> st;
    rep(i, N){
        ll a;
        cin >> a;
        if(st.count(a)) st.erase(a);
        else st.insert(a);
    }

    print(len(st));

    return 0;
}

Measured memory_bytes: 4992
<?php
#include <stdio.h>
# 整数の入力
fscanf(STDIN, "%d", $a);
$array = str_split($a);
$count = 0;
for($i=0;$i<3;$i++){
 if ($array[$i] == "1"){
  $count = $count + 1; 
 }
}
echo $count."\n";

Measured memory_bytes: 3700
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

const int W = 5;

void main() {
    int H;
    int[][] A;
    bool input() {
        scanf("%d\n", &H);
        if (H == 0) return false;
        A = new int[][H];
        foreach (i; 0 .. H) {
            A[i] = readln.chomp.split(" ").map!(to!int).array;
        }
        reverse(A);
        return true;
    }

    bool erase(ref int Ans) {
        auto D = new bool[][](H, W);
        foreach (h; 0 .. H) {
            foreach (i; 0 .. W) {
                int init = A[h][i];
                int c = 0;
                foreach (j; 0 .. W) {
                    if (i + j >= W) break;
                    if (A[h][i + j] != init) {
                        break;
                    }
                    c++;
                }
                if (c < 3) continue;
                foreach (j; 0 .. c) {
                    D[h][i + j] = true;
                }
            }
        }
        int[][] S = new int[][W];
        foreach_reverse (i; 0 .. H) {
            foreach (j; 0 .. W) {
                if (D[i][j]) {
                    Ans += A[i][j];
                } else {
                    S[j] ~= A[i][j];
                }
            }
        }
        auto nA = new int[][](H, W);
        foreach (i; 0 .. H) {
            foreach (j; 0 .. W) {
                if (S[j].empty) nA[i][j] = 0;
                else {
                    nA[i][j] = S[j].back;
                    S[j].popBack;
                }
            }
        }
        //foreach (l; nA.dup.reverse) writeln(l); writeln;
        if (A == nA) return false;
        A = nA;
        return true;
    }

    void solve() {
        int Ans = 0;
        while (erase(Ans)) {}
        writeln(Ans);
    }
    while (input) solve;
}

Measured memory_bytes: 2056
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i,limit;
    
    scanf("%d",&limit);
    
    for(i = 3;i<=limit;i+=1){
        
        if(i%3==0||(i-3)%10==0||i/10==3||((i/10)-3)%10==0||((i/100)-3)%10==0||((i/1000)-3)%10==0){
            printf(" %d",i);
        }
        
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    ll a, b; cin >> a >> b;
    if ((a <= 0 && b >= 0) || (a == 0 || b == 0)) {
        cout << "Zero" << endl;
        return 0;
    }

    if ((a > 0 && b > 0) || (a == b)) {
        cout << "Positive" << endl;
        return 0;
    }
    if (b < 0) {
        if ((b - a) % 2 == 1) {
            cout << "Positive" << endl;
            return 0;
        } else {
            cout << "Negative" << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
#define TST 0
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

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

void printM(vector<vector<int> > &vec, long height, long width){
    F(i, 0, height){
        F(j, 0, width){
            cout << vec[i][j] << space;
        }
    cout << endl;
    }
}

int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int a,b,angle;
    cin >> a >> b >> angle;

    double radian = PI * angle/ 180;
    double s = a * b * sin(radian) / 2;
    double c = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(radian));
    double L = a + b + c;
    double h = s * 2 / a;
    printf("%1.8lf\n", s);
    printf("%1.8lf\n", L);
    printf("%1.8lf\n", h);

#if TST==1
#endif
}



Measured memory_bytes: 3396
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, a[100010];
map<int, int> cnt;

signed main() {
    cin >> N;
    rep(i,0,N) {
        cin >> a[i];
        rep(k,-1,2) {
            int x = a[i] + k;
            cnt[x]++;
        }
    }

    int ans = 0;
    for(auto e : cnt) chmax(ans, e.second);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint ans = 0, a;
	for(int i = 1; i <= n ;i++){
		cin >> a;
		if(i%2 && a%2) ans++;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
using namespace std;
#define MAX 1000000

int main(void)
{
  bool p[MAX + 1];
  int n, ans;

  for(int i = 0 ; i <= MAX ; i++)
    {
      p[i] = (i <= 1)? false : true;
    }

  for(int i = 2 ; i <= sqrt(MAX) + 1 ; i++)
    {
      if(p[i])
	{
	  for(int j = i * 2 ; j <= MAX ; j+=i)
	    {
	      p[j] = false;
	    }
	}
    }

  while(cin >> n)
    {
      ans = 0;
      for(int i = 0 ; i <= n ; i++)
	{
	  if(p[i])
	    {
	      ans++;
	    }
	}
      cout << ans << endl;
    }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main() {
     int a, b, empty, times;
     cin >> a >> b;
     for (times==1;a!=0 || b!=0;times++){
    //swap a & b;
    if (a > b){
        empty = a;
        a = b;
        b= empty;
              }
    cout << a << " " << b << endl;
    cin >> a >> b;
                                     }
     return 0;
}


Measured memory_bytes: 3000
from bisect import bisect_left, bisect_right
n = int(input())
l = list(map(int, input().split()))
l.sort()
# print(l)

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        idx = bisect_left(l, l[i] + l[j])
        ans += idx - (j+1)

print(ans)


Measured memory_bytes: 3188
using System;

namespace A___Infinite_Coins
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());

            Console.WriteLine(A >= N % 500 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11220
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

if ri() >= 30:
  print('Yes')
else:
  print('No')









Measured memory_bytes: 27128
import java.io.*;
 
class Main{
 public static void main(String[] arg) throws IOException{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String str = br.readLine();
 
  int x = Integer.parseInt(str), h=x/3600, m, s;
  x %= 3600;
  m = x/60;
  x %= 60;
  s = x;
 
  System.out.println(h + ":" + m + ":" + s);
 }
}

Measured memory_bytes: 24152
#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 H[100000];

void Main()
{
  int N;
  cin >> N;
  rep(i,N) { cin >> H[i]; }
  int maxCnt = 0;
  int cnt = 0;
  rep(i,N-1) {
    if (H[i] >= H[i+1]) cnt++;
    else cnt = 0;
    if (maxCnt < cnt) maxCnt = cnt;
  }
  cout << maxCnt << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

Measured memory_bytes: 640
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

c = Counter(A)
p = [True]*(10**6+1)

for k, v in c.items():
    t = k*2
    while t <= 10**6:
        p[t] = False
        t += k

ans = 0
for a in A:
    if c[a] == 1 and p[a]:
        ans += 1
print(ans)


Measured memory_bytes: 38708
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
const LL mod=1e9+7;
const LL LL_MAX=9223372036854775807;
using namespace std;
int main()
{
    int x,y;
    scanf("%d%d",&x,&y);
    if(x<y)
        printf("0\n");
    else
        printf("10\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin >> n >> l;
  int answer=0;
  
  if(l >= 0){
    l++;
    for(int i=1; i<n; i++){
      answer += l;
      l++;
    }
  }else if(l < 0 && abs(l) < n){
    for(int i=0; i<n; i++){
      answer += l;
      l++;
    }
  }else{
    for(int i=0; i<n-1; i++){
      answer += l;
      l++;
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	S := sc.nextStr()
	ans := 700
	for _, r := range S {
		if r == 'o' {
			ans += 100
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int x,y,z;
  cin>>x>>y>>z;
  int i=0;
  while(y*(i+1)+z*(i+2)<=x){
    i++;
  }
  cout<<i<<endl;
  return 0;
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1; i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------

ll d,m;
void input(){
    cin>>m>>d;
}
void src(){
    ll ans=0;
    repi(i,1,m+1){
        repi(j,2,10){
            repi(k,2,10){
                if(10*j+k>d){ break;}
                if(j*k==i) ans++;
            }
        }
    }
    cout<<ans;
}    
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    for (int i = 0; i < N; i++) cin >> C[i];
    sort(A.begin(), A.end());
    sort(C.begin(), C.end());

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ll cnt1 = lower_bound(A.begin(), A.end(), B[i]) - A.begin();
        ll cnt2 = C.end() - upper_bound(C.begin(), C.end(), B[i]);
        ans += cnt1 * cnt2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1536
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int rate[10];
int main() {
  int N;cin >> N;
  string s;cin >> s;
  int st=0;
  int l=0;
  rep(i,N) {
    if(s[i] == ')' && st == 0) l++;
    else if(s[i] == '(') st++;
    else if(s[i] == ')') st--;
  }
  rep(i,l) cout << '(';
  rep(i,N) cout << s[i];
  rep(i,st) cout << ')';
  cout << endl;
  
  return 0;
}


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a==b && b==c)
    cout << "No" << endl;
  else {if(a==b)
    cout << "Yes" << endl;
  else if(a==c)
    cout << "Yes" << endl;
  else if(c==b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
       }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,i;
	scanf("%d %d",&a,&b);
	if(a>=b){
      for(i=0;i<a;i++){
        printf("%d",b);
      }
    }else{
      for(i=0;i<b;i++){
        printf("%d",a);
      }
    }
	return 0;
}


Measured memory_bytes: 1724
import math 
N = int(input())
L = list(map(int, input().split()))

L = sorted(L, reverse=True)

Alice = 0
Bob = 0
count = 0

for i in range (0, len(L)):
	if count == 0:
		Alice+=L[i]
		count=1
	else:
		Bob+=L[i]
		count=0

print(Alice-Bob)

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	string s,t;
	cin>>s>>t;
	int n = s .length();
	int cnt = 0;
	for(int i=0;i<n;i++){
		if(s[i] != t[i]) {
			cnt++;
		}
	}

	printf("%d\n",cnt);
	
	return 0;
};

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

unordered_set<long long> divisors(long long n) {
  unordered_set<long long> res;
  for (int i = 1; i < floor(sqrt(n)) + 1; i++) {
    if (n % i == 0) {
      res.insert(i);
      res.insert(n / i);
    }
  }
  res.erase(1);
  return res;
}

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

  long long n;
  cin >> n;

  long long cnt = divisors(n - 1).size();
  for (long long const &i : divisors(n)) {
    long long m = n;
    while (m % i == 0) {
      m /= i;
    }
    cnt += (m - 1) % i == 0;
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ld double
#define ll long long
#define all(x) x.begin(),x.end()
const int mod=1e9+7;
#define fi first
#define se second
#define sync  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf (ll)1e16

const ld pi=(4.0*atan(1));

ll po(ll x,ll y,ll md=mod){
    ll res=1;
    x%=md;
    
    while(y>0){
        if (y&1){
            res=(res*x)%md;
        }
        
        y>>=1;
        x=(x*x)%md;
    }
    return res;
}
void solve(){
   ll n,k;
   cin>>n>>k;
   
   vector<ll> a(n+1,-1);
   for (ll i=1;i<=n;i++){
       cin>>a[i];
   }
   bitset<2*(100000)+5> vis;
   vector<ll> loop;
   loop.pb(-1);
   ll now=1,wch=-1;
   while(true){
       if (!vis[now]){
           loop.pb(now);
           vis[now]=1;
           now=a[now];
       }
       else{
           wch=now;
           break;
       }
   }
   
   ll sz=loop.size(),lim=0;
   sz--;
   k++;
   for (ll i=1;i<=sz;i++){
       if (loop[i]==wch){
           lim=i;
           break;
       }
   }
   
   vector<ll> aux;
   for (ll i=lim;i<=sz;i++){
       aux.pb(loop[i]);
   }
   
   if (k<lim){
       cout<<loop[k]<<"\n";
   }
   else{
       ll lsz=aux.size();
       k-=lim;
       cout<<aux[k%lsz]<<"\n";
   }
}

int main() {
    
    sync
    ll tt=1;
    //cin>>tt;
    cout<<fixed<<setprecision(12);
    for (ll tc=1;tc<=tt;tc++){
       solve();
    }
    
	return 0;
}

Measured memory_bytes: 9212
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	char x;
	cin >> x;

	if (isupper(x)) {
		cout << "A" << endl;
	}
	else {
		cout << "a" << endl;
	}
}


Measured memory_bytes: 3632
k , n = list(map(int,input().split()))
A = list(map(int,input().split()))

X = list()
for i in range(n-1):
    x = A[i+1]-A[i]
    X.append(x)

y = k-A[n-1]+ A[0]

X.append(y)

m = max(X)

print(k-m)

Measured memory_bytes: 26436
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

vector<pair<long long,long long>> prime_factorization(ll N) {
  vector<pair<long long, long long>> res;
  for(ll i=2; i*i <= N; i++) {
	if(N % i != 0) continue;
	int ex = 0;          //represent exponetial part
	while(N%i == 0) {
	  ex++;
	  N/=i;
	}
	res.push_back({i,ex});
  }
  if(N!=1) {
	res.push_back({N,1});
  }
  return res;
}






int main() {
    long long N;
    cin >> N;
    auto pf = prime_factorization(N);
    long long res = 0;
    for (auto p : pf) {
        long long e = p.second;
        long long tmp = 0, cur = 1;
        while (e >= cur) e -= cur++, ++tmp;
        res += tmp;
    }
    cout << res << endl;
}


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

template <typename T>
void print(const T &v);

int main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int start = h1 * 60 + m1;
    int end = h2 * 60 + m2;
    int ans = end - start - k;
    cout << ans << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3632
str = input().split(" ")
S = str[0]
T = str[1]
num = input().split(" ")
NS = int(num[0])
NT = int(num[1])
U = input()

if S == U:
  print(NS - 1, end=" ")
  print(NT)
else:
  print(NS, end=" ")
  print(NT - 1)

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
int a,b,x,y;
int exgcd(int a,int b,int &x,int &y)
{
    if(b==0)
    {
        x=1,y=0;
        return a;
    }
    else
    {
        int d=exgcd(b,a%b,y,x);
        y-=a/b*x;
        return d;
    }
}
int main()
{
    cin>>a>>b;
    exgcd(a,b,x,y);
    cout<<x<<' '<<y<<endl;
    return 0;
}


Measured memory_bytes: 3096
function main(input) {
  input=input.trim();
  const n = parseInt(input.split("\n")[0], 10);
  const m = parseInt(input.split("\n")[n+1].split(" ")[0], 10);
  var arrS=[]
  var arrT=[]
  for(var i=0; i<n; i++){
    var temp=input.split("\n")[i+1];
    arrS.push(temp)
  }
  for(var i=0; i<m; i++){
    var temp=input.split("\n")[i+n+2];
    arrT.push(temp)
  }
  var ansArr=[]
  for(var i=0; i<n; i++){
    var temp=0;
    for(var j=0; j<n; j++){
      if(arrS[j]==arrS[i]){
        temp++
      }
    }
    for(var j=0; j<m; j++){
      if(arrT[j]==arrS[i]){
        temp--
      }
    }
    ansArr.push(temp)
  }
  var maxx=Math.max.apply(null, ansArr)
  if(maxx>0){
    console.log(maxx);
  }else{
    console.log(0);
  }
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;

int main(){
  int N, X;
  int x[100000];
  
  cin >> N >> X;
  for(int i = 0;i < N;i++){
    cin >> x[i];
    x[i] = abs(x[i] - X);
  }
  
  for(int i = 1;i < N;i++) x[0] = __gcd(x[0], x[i]);
  
  cout << x[0] << endl;
  
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            char[] S = sc.next().toCharArray();

            int n0 = (int) '0';

            boolean[] c1 = new boolean[10];
            boolean[][] c2 = new boolean[10][10];
            boolean[][][] c3 = new boolean[10][10][10];

            for (int i = 2; i < N; i++) {
                int n1 = S[i - 2] - n0;
                int n2 = S[i - 1] - n0;
                int n3 = S[i] - n0;

                c1[n1] = true;

                for (int j = 0; j < 10; j++) {
                    if (c1[j]) {
                        c2[j][n2] = true;
                    }
                }

                for (int j = 0; j < 10; j++) {
                    if (!c1[j]) {
                        continue;
                    }

                    for (int k = 0; k < 10; k++) {
                        if (!c2[j][k]) {
                            continue;
                        }

                        c3[j][k][n3] = true;
                    }
                }
            }

            int ans = 0;
            for (int l = 0; l < 10; l++) {
                for (int m = 0; m < 10; m++) {
                    for (int r = 0; r < 10; r++) {
                        if (c3[l][m][r]) {
                            ans++;
                        }
                    }
                }
            }

            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 23892
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
ans = 0
for i in range(n):
    t = int(input())
    if ans==0:
        ans=t
    else:
        ans = (ans*t)//gcd(ans,t)
print(ans)

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

int main() {
    int k, a, b;
    cin >> k >> a >> b;
    int f = 0;
    for(int i = a; i <= b; i++) {
        if(i % k == 0) {
            f = 1;
            break;
        }
    }
    cout << (f == 0 ? "NG" : "OK");
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;

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

const int INF = 1001001001;

int used[100010];

int main(){
    int N;
    cin >> N;
    vector<P> x(N), y(N);
    
    for(int i = 0; i < N; ++i){
        int temp;
        cin >> temp;
        x[i] = P(temp, i);
        cin >> temp;
        y[i] = P(temp, i);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    
    vector<vector<P>> graph(N);     // (cost, to)
    for(int i = 0; i < N - 1; ++i){
        P p1 = x[i];
        P p2 = x[i + 1];
        int temp = p2.first - p1.first;
        graph[p1.second].push_back(P(temp, p2.second));
        graph[p2.second].push_back(P(temp, p1.second));
        
        p1 = y[i];
        p2 = y[i + 1];
        temp = p2.first - p1.first;
        graph[p1.second].push_back(P(temp, p2.second));
        graph[p2.second].push_back(P(temp, p1.second));
    }
    
    ll res = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, 0));          // (現在の部分最小全域木からのcost, coord)
    
    while(!que.empty()){
        P p = que.top();
        que.pop();
        
        // 部分最小全域木に含まれていれば何もしない
        if(used[p.second])      continue;
        
        // 部分最小全域木に入れる(usedのフラグを立てる)
        // priority_queueから部分木からの最小コストは取り出せている
        used[p.second] = true;
        res += p.first;
        
        for(int i = 0; i < graph[p.second].size(); ++i){
            P t = graph[p.second][i];
            // 部分最小全域木からの最小コスト候補をどんどん入れていく
            // 最小全域木に含まれなければcontinueで操作が飛ばされる
            que.push(P(t.first, t.second));
        }
    }
    
    cout << res << endl;
}

Measured memory_bytes: 12020
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 3456;
int dp[MAXN];
vector<int> G[MAXN];
 
int main() {
    int N, T;
    scanf("%d %d", &N, &T);
    vector<pii> V;
    for (int i = 0; i < N; i++) {
        int A, B;
        scanf("%d %d", &A, &B);
        G[A].push_back(B);
    }
    int ans = 0;
    for (int A = 1; A < MAXN; A++) {
        for (int B : G[A]) {
            ans = max(ans, dp[T - 1] + B);
            for (int j = T - 1; j >= A; j--) {
                dp[j] = max(dp[j], dp[j - A] + B);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main(){
  int p, q, r;
  std::cin >> p >> q >> r;
  int a = max(p, q);
  int b = max(a, r);
  cout << p+q+r-b << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

int f(int x) {
    int re = 0;
    while (x > 0) {
        re += x % 10;
        x /= 10;
    }
    RT re;
}

void solve() {
    int N;
    cin >> N;

    int re = INT_MAX;
    for (int i = 1; i <= N / 2; ++i) {
        smin(re, f(i) + f(N - i));
    }
    cout << re << endl;
}

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

Measured memory_bytes: 256
N,K = map(int,input().split())

A = list(map(int,input().split()))

A.sort()


MAX = 10 ** 5 + 1
MOD = 10 ** 9 + 7
fac = [0]*(MAX+1)
fac[0] = 1
fac[1] = 1
for i in range(2,MAX+1):
    fac[i] = fac[i-1]*i%MOD

finv = [0]*(MAX+1)
finv[MAX] = pow(fac[MAX], MOD-2, MOD)

for i in range(MAX, 0, -1):
    finv[i-1] = finv[i] * i % MOD

def comb(n, k):
    if n < k or k < 0:
        return 0
    return (fac[n] * finv[k] * finv[n - k]) % MOD

ans = 0
for i in range(N):
    if K - 1 <= i:
        ans += comb(i,K-1) * A[i]
    if K-1+i < N:
        ans -= comb(N-i-1,K-1)*A[i]
    ans %= MOD
print(ans)
    

Measured memory_bytes: 88000
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int A=a,B=b;
	if(a%c)
		a+=(c-a%c);
	if(b%c)
		b-=(b%c);
	int div1=(b-a)/c+1;
	a=A,b=B;

	// cout<<a<<" "<<b<<"check\n";
	if(a%d)
		a+=(d-a%d);
	if(b%d)
		b-=(b%d);
	int div2=(b-a)/d+1;
	a=A,b=B;

	// cout<<a<<" "<<b<<"check\n";
	int e=(c*d)/(__gcd(c,d));
	if(a%e)
		a+=(e-a%e);
	if(b%e)
		b-=(b%e);
	int div3=(b-a)/e+1;
	a=A,b=B;

	// cout<<a<<" "<<b<<"check\n";
	// cout<<div1<<" "<<div2<<" "<<div3<<"\n";
	cout<<b-a-(div1+div2-div3)+1<<"\n";
}
	

Measured memory_bytes: 256
/////////////////////////////////////////
///        author: matcha1024         ///
/////////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
    int h, w; cin>> h >> w;
    int si, sj; cin>> si >> sj;
    int ti, tj; cin>> ti >> tj;
    si--; sj--; ti--; tj--;
    vector<string> s(h);
    forin(s);
    const int INF=1e+9;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<pair<int, int>> q;
    dist[si][sj]=0;
    q.emplace_back(si, sj);
    while(!q.empty()){
        int i = q.front().first;
        int j = q.front().second;
        q.pop_front();
        int d = dist[i][j];
        rep(v, 4){
            int ni = i + di[v], nj = j + dj[v];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if(s[ni][nj] == '#') continue;
            if(dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni, nj);
        }
        for(int ei = -2; ei <= 2; ei++){
            for(int ej = -2; ej <= 2; ej++){
                int ni = i+ei, nj=j+ej;
                if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if(s[ni][nj] == '#') continue;
                if(dist[ni][nj] <= d+1) continue;
                dist[ni][nj] = d+1;
                q.emplace_back(ni, nj);
            }
        }
    }
    int ans = dist[ti][tj];
    if(ans == INF) ans = -1;
    cout<< ans << endl;
}


Measured memory_bytes: 9444
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def Z_algorithm(s):
        n = len(s)
        z = [0]*n
        z[0] = n
        c = 1
        for i in range(1,n):
            if i+z[i-c] < c+z[c]:
                z[i] = z[i-c]
            else:
                j = max(0,c+z[c]-i)
                while i+j < n and s[j] == s[i+j]:
                    j += 1
                z[i] = j
                c = i
        return z
    n = I()
    a = LI()
    b = LI()
    a_xor = [a[i%n]^a[(i+1)%n] for i in range(2*n)]
    b_xor = [b[i%n]^b[(i+1)%n] for i in range(n)]
    b_xor += a_xor
    z = Z_algorithm(b_xor)
    for k in range(n):
        i = n+k
        x = b[0]^a[k]
        if z[i] >= n:
            print(k,x)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 121036
def bitcount(i): # i < 2^32
    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24

MOD = 10**9+7
n = int(input())
can = [[int(i) for i in input().split()] for j in range(n)]
dp = [0] * (1 << n)
dp[0] = 1
for mask in range((1 << n) - 1):
    #a = bin(mask).count('1')
    a = bitcount(mask)
    for b in range(n):
        if can[a][b] and not (mask & (1 << b)):
            mask2 = mask ^ (1 << b)
            dp[mask2] += dp[mask]
            if dp[mask2] >= MOD:
                dp[mask2] -= MOD
print(dp[(1 << n) - 1])

Measured memory_bytes: 57452
// ARC 83 C
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int a,b,c,d,e,f; cin >> a >> b >> c >> d >> e >> f;
    set<int> water,sugar;
    for(int i = 0; 100*a*i <= f; i++){
        for(int j = 0; 100*a*i+100*b*j <= f; j++){
            if(i != 0 || j != 0) water.insert(100*a*i+100*b*j);
        }
    }
    for(int i = 0; c*i <= f; i++){
        for(int j = 0; c*i + d*j <= f; j++){
            sugar.insert(c*i+d*j);
        }
    }
    double ma = 0;
    int sugarwater, Sugar;
    for(auto w : water){
        for(auto s: sugar){
            if(s > w/100*e || s+w > f) continue;

            if(ma <= (100*(double)s/((double)w+(double)s))){
                ma = (100*(double)s/((double)w+(double)s));
                sugarwater = s+w; Sugar = s;
            }
        }
    }
    cout << sugarwater << " " << Sugar << endl;
    return 0;
}

Measured memory_bytes: 384
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))

sum = 0
for c in T:
    left = 0
    right = n
    mid = 0
    if c == S[left] or c == S[right-1]:
        sum += 1
    else:
        while left+1 < right:
            mid = int(( left + right ) / 2)
            if c == S[mid]:
                sum += 1
                break
            if c > S[mid]:
                left = mid
                mid = 0
            elif c < S[mid]:
                right = mid
                mid = 0
print(sum)

Measured memory_bytes: 18692
#include<bits/stdc++.h>
using namespace std;
int main() {
  int K, X;
  cin >> K >> X;
  vector<int> za;
  int count = 0;
  for(int i= 1-K;i < K;i++){
    za.push_back(X+i);
  }
  for (int j = 0; j < za.size(); j++) {
    if(j != za.size() -1) {
      cout << za.at(j);
      cout << " ";
    }
    else cout << za.at(j) << endl;
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n=int(input())
ab=[[int(i) for i in input().split()] for j in range(n)]
ab=sorted(ab,key=lambda x:x[1])

w=0
t=0
ans='Yes'
for a,b in ab:
    w+=a
    if b<w:
        ans='No'
    
print(ans)

Measured memory_bytes: 42732
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int N; cin>>N;
  vector<ll> A(N), sum(N+1, 0LL);
  REP(i,N) {
    cin>>A[i];
    sum[i+1] = sum[i] + A[i];
    //    cout << i+1 << " " << sum[i+1] << endl;                                                        
  }
  int pos1 = lower_bound(sum.begin(), sum.end(), sum[N]/2LL) - sum.begin();
  int d1 = 300;
  int d2 = 10;
  ll ans = 1LL<<60;
  REP(i,N) {
    if(i<2) continue;
    if(i>N-2) continue;
    int pos2 = lower_bound(sum.begin(), sum.end(), sum[i]/2LL) - sum.begin();
    for(int j = pos2-d2; j <= pos2+d2; j++) {
      if(j<1) continue;
      if(j>i-1) continue;
      int pos3 = lower_bound(sum.begin(), sum.end(), (sum[N]-sum[i])/2LL+sum[i]) - sum.begin();
      for(int k = pos3-d2; k <= pos3+d2; k++) {
        static ll work[4];
        if(k<i+1) continue;
        if(k>N-1) continue;
        //      cout << 0 << " " << j << " " << sum[j]-sum[0] << endl;                                   
        //      cout << j << " " << i << " " <<  sum[i]-sum[j] << endl;                                  
        //      cout << i << " " << k <<  " " << sum[k]-sum[i] << endl;                                  
        //      cout << k << " " << N <<  " " << sum[N]-sum[k] << endl;                                  
        work[0] = sum[j]-sum[0];
        work[1] = sum[i]-sum[j];
        work[2] = sum[k]-sum[i];
        work[3] = sum[N]-sum[k];
        sort(work, work+4);
        ll tmp = work[3] - work[0];
        ans = min(ans, tmp);
        //      cout << tmp << " -------" << endl;                                                       
      }

    }
  }
  //  cout << "Answer=" ;                                                                                
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3328
import sys

lists=[]
for str in sys.stdin:
	lists+=[tuple(str.rstrip().split(' '))]

for i in range(0,len(lists),2):
	hit=0
	blow=0
	for j in range(4):
		if lists[i][j]==lists[i+1][j]:
			hit+=1
	for c in lists[i]:
		if c in lists[i+1]:
			blow+=1
	print '%d %d' % (hit,blow-hit)

Measured memory_bytes: 4220
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;

typedef long long tnum;

int main() {
	tnum n, m, k, v, total;
	tnum* a;
	scanf("%lld %lld", &n, &k);
	
	if (n < 0) {
		printf("%lld", n);
		return 0;
	}
	v = n % k;
	m = k - v;
	if (v <= m) {
		printf("%lld", v);
	}else{
		printf("%lld", m);
	}
	return 0;
}

Measured memory_bytes: 128