akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for((i)=1;(i)<=(n);(i)++)
using namespace std;
int n,m,i,j,a[505][505];
int main(){
	cin>>n;
	if(n<=500){
		cout<<n<<endl;
		rep(i,n){
			rep(j,n){
				cout<<(i+j-1)%n+1;
				if(j==n){
					cout<<endl;
				}
				else{
					cout<<' ';
				}
			}
		}
	}
	else{
		cout<<500<<endl;
		rep(i,500){
			rep(j,500){
				cout<<(i+j-1)%500+1+500*(i%2==0&&((i+j-1)%500+1<=n-500));
				if(j==500){
					cout<<endl;
				}
				else{
					cout<<' ';
				}
			}
		}
	}
	return 0;
}

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

template<int MOD> struct Fp {
	long long val;
	constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
		if (val < 0) val += MOD;
	}
	constexpr int getmod() { return MOD; }
	constexpr Fp operator - () const noexcept {
		return val ? MOD - val : 0;
	}
	constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
	constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
	constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
	constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
	constexpr Fp& operator += (const Fp& r) noexcept {
		val += r.val;
		if (val >= MOD) val -= MOD;
		return *this;
	}
	constexpr Fp& operator -= (const Fp& r) noexcept {
		val -= r.val;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr Fp& operator *= (const Fp& r) noexcept {
		val = val * r.val % MOD;
		return *this;
	}
	constexpr Fp& operator /= (const Fp& r) noexcept {
		long long a = r.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr bool operator == (const Fp& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Fp& r) const noexcept {
		return this->val != r.val;
	}
	friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
		return os << x.val;
	}
	friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
		if (n == 0) return 1;
		auto t = modpow(a, n / 2);
		t = t * t;
		if (n & 1) t = t * a;
		return t;
	}
};

// 二項係数ライブラリ
template<class T> struct BiCoef {
	vector<T> fact_, inv_, finv_;
	constexpr BiCoef() {}
	constexpr BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) {
		init(n);
	}
	constexpr void init(int n) noexcept {
		fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);
		int MOD = fact_[0].getmod();
		for(int i = 2; i < n; i++){
			fact_[i] = fact_[i-1] * i;
			inv_[i] = -inv_[MOD%i] * (MOD/i);
			finv_[i] = finv_[i-1] * inv_[i];
		}
	}
	constexpr T com(int n, int k) const noexcept {
		if (n < k || n < 0 || k < 0) return 0;
		return fact_[n] * finv_[k] * finv_[n-k];
	}
	constexpr T fact(int n) const noexcept {
		if (n < 0) return 0;
		return fact_[n];
	}
	constexpr T inv(int n) const noexcept {
		if (n < 0) return 0;
		return inv_[n];
	}
	constexpr T finv(int n) const noexcept {
		if (n < 0) return 0;
		return finv_[n];
	}
};

int main() {
	BiCoef<Fp<MOD>> bc;
	bc.init(2100000);
	ll r1,c1,r2,c2;
	cin>>r1>>c1>>r2>>c2;

	auto g = [&](ll r, ll c){
		return (bc.com(r+c+2,r+2)*(r+2)-c-1)/(c+1);
	};

	Fp<MOD> ans=g(r2,c2)-g(r1-1,c2)-g(r2,c1-1)+g(r1-1,c1-1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 49408
import java.util.*;

public class Main{
	Scanner sc = new Scanner(System.in);
	
	private void doit(){
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int [] data = new int[n];
			for(int i = 0; i  <n; i++){
				data[i] = sc.nextInt();
			}
			int count = 0;
			for(;;){
				boolean flg = false;
				for(int j = 0; j < n-1; j++){
					if(data[j] > data[j + 1]){
						int temp = data[j];
						data[j] = data[j+1];
						data[j+1] = temp;
						count++;
						flg = true;
					}
				}
				if(! flg){
					break;
				}
			}
			System.out.println(count);
		}
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

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

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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<long long> p(n);
    for(int i=0; i<n; i++) cin >> x[i] >> y[i] >> p[i];

    //初期化
    int ax[33000][15];
    int ay[33000][15];
    long long c[20];
    for(int i=0; i<=n; i++) c[i] = 1000000000000000000;

     for(int bit = 0; bit<(1<<n); bit++){
        for(int i=0; i<n; i++){
            ax[bit][i] = abs(x[i]);
            for(int j=0; j<n; j++){
                if((bit >> j) & 1) ax[bit][i] = min(ax[bit][i], abs(x[i]-x[j]));
            }
        }
     }

    for(int bit = 0; bit<(1<<n); bit++){
        for(int i=0; i<n; i++){
            ay[bit][i] = abs(y[i]);
            for(int j=0; j<n; j++){
                if((bit >> j) & 1) ay[bit][i] = min(ay[bit][i], abs(y[i]-y[j]));
            }
        }
     }
     
     //3進数bit全探索
     for (int bit = 0; bit<pow(3,n); bit++){
         int tmp = bit;
         int bitx=0;
         int bity=0;
         int k=0;
         for (int pos = 0; pos<n; pos++){
             if(tmp%3==1){
                 bitx += (1<<pos);
                 k++;
                 }
            if(tmp%3==2){
                 bity += (1<<pos);
                 k++;
                 }
             tmp /= 3;
        }
        long long t=0;
        for(int i=0; i<n; i++){
            t += min(ax[bitx][i],ay[bity][i])*p[i];
        }
        c[k] = min(c[k], t);
     }

    for(int k=0; k<=n; k++) cout << c[k] << endl;
}

Measured memory_bytes: 7964
x = gets.strip.split.map(&:to_i)
ss = gets.strip.split('')
n = 0
sum = 0
ss.each do |s|
  if s == 'A' && ss[n+1] == 'B' && ss[n+2] == 'C'
    sum+=1
  end
  n+=1
end
puts sum


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

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

using namespace std;

int main() {

	long long int x, y;
	cin >> x;
	y = 0;

	if (x <= 6)cout << "1" << endl;
	else {
		if (x % 11 == 0)cout << (x / 11) * 2 << endl;
		else if (x % 11>6)cout << (x / 11) * 2 + 2 << endl;
		else cout << (x / 11) * 2 + 1 << endl;

	}


	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

pair<P,int> t[55];
int wrong[55][15];

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

    int a,b,c,d;
    while(cin>>a>>b>>c>>d,a)
    {
	REP(i,b) t[i]=make_pair(P(0,0),-i-1);
	REP(i,b) REP(j,c) wrong[i][j]=0;

	REP(i,d){
	    int e,f,g,h;
	    cin>>e>>f>>g>>h;
	    f--,g--;
	    if(h==0){
		t[f].first.first--;
		t[f].first.second+=e+20*wrong[f][g];
	    }else{
		wrong[f][g]++;
	    }
	}
	sort(t,t+b);
	cout<<-t[0].second;
	for(int i=1;i<b;i++){
	    if(t[i-1].first.first==t[i].first.first &&
	       t[i-1].first.second==t[i].first.second){
		cout<<"=";
	    } else cout<<",";
	    cout<<-t[i].second;
	}
	cout<<endl;
    }
}


Measured memory_bytes: 3220
open Batteries

let read_two () = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))

let read_three () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c -> (a, b, c))

let read_four () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c d -> (a, b, c, d))

let () =
  let n, a, b = read_three () in
  let s = read_line () in
  let cur_b = ref 0 and cur_a = ref 0 in
  for i = 1 to n do
    let c = s.[i - 1] in
    if !cur_b + !cur_a < a + b then
      match c with
      | 'a' ->
          cur_a := !cur_a + 1;
          print_string "Yes\n"
      | 'b' ->
          if !cur_b < b then (
            cur_b := !cur_b + 1;
            print_string "Yes\n" )
          else print_string "No\n"
      | _ -> print_string "No\n"
    else print_string "No\n"
  done


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a=0,b=0;
	char c;
	while((c=getchar())!=EOF)
	{
		if(a+b+1>15)
			break;
		if(c=='o')
			a++;
		else if(c=='x')
			b++;
	}
	if(a>=8||15-(a+b)+a>=8)
		printf("YES");
	else
		printf("NO");
	return 0;
}

Measured memory_bytes: 256
local h, w, n = io.read("*n", "*n", "*n")
local t = {}

local function add(i_h, i_w)
  local idx = i_h .. ":" .. i_w --(i_h - 1) * 1000000000 + i_w
  local v = t[idx]
  if v then t[idx] = v + 1 else t[idx] = 1 end
end

local function subtask(ah, bw)
  if 3 <= bw then add(ah, bw - 2) end
  if 2 <= bw and bw < w then add(ah, bw - 1) end
  if bw < w - 1 then add(ah, bw) end
end

for i = 1, n do
  local ah, bw = io.read("*n", "*n")
  if 3 <= ah then subtask(ah - 2, bw) end
  if 2 <= ah and ah  < h then subtask(ah - 1, bw) end
  if ah < h - 1 then subtask(ah, bw) end
end

local sum = 0
local tbl = {}
for i = 1, 9 do tbl[i] = 0 end
for k, v in pairs(t) do
  tbl[v] = tbl[v] + 1
  sum = sum + 1
end
local rem = (h - 2LL) * (w - 2LL) - sum
local str = tostring(rem):gsub("LL", "")
print(str)
for i = 1, 9 do print(tbl[i]) end


Measured memory_bytes: 85900
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=a;i<=n;++i)
#define lpd(i,a,n) for(int i=a;i>=n;--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 100002;
int n;
char a[10];

int main(){
    scanf("%s",a);
    cout <<count(a, a+6, '1');
}

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


Measured memory_bytes: 256
sm = [False for i in range(300001)]
for i in range(6, 300000, 7):
    sm[i] = sm[i+2] = True

msprices = []

for i in range(6, 300000, 7):
    if sm[i]:
        msprices.append(i)
        for j in range(2*i, 300000, i):
            sm[j] = False
    if sm[i+2]:
        msprices.append(i+2)
        for j in range(2 * (i+2), 300000, i+2):
            sm[j] = False

while True:
    N = int(input())
    if N == 1:
        break
    ans = []
    for msp in msprices:
        if N % msp == 0:
            ans.append(msp)
    print(N, end=":")
    for a in ans:
        print(" " + str(a), end="")
    print()

Measured memory_bytes: 10972
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

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

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
fast_io
int x,a,b; cin>>x>>a>>b;
if(abs(x-a)<abs(x-b)) cout<<"A";
else cout<<"B";
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		int divideNum = 0;
		for(int i = 0; i < str.length(); i++){
			divideNum = divideNum + str.charAt(i) - '0';
		}
		int num = Integer.parseInt(str);
		if(num%divideNum == 0){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23636
import java.util.Scanner;
import java.util.Stack;

public class Main {
    static int h;
    static int w;
    static int c;
    static int ans;
    static int count;
    static int[] color_order;
    static int[][] map;
    static int[][] tmp;

    public static void main(String[] args) throws java.io.IOException {

        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String ns[] = sc.nextLine().split(" ");
            Stack<Double> stack = new Stack<Double>();
            for (int i = 0; i < ns.length; i++) {
                if (ns[i].length() > 1) {
                    stack.push(Double.parseDouble(ns[i]));
                } else {
                    char sw = ns[i].charAt(0);
                    switch (sw) {
                    case '0':
                    case '1':
                    case '2':
                    case '3':
                    case '4':
                    case '5':
                    case '6':
                    case '7':
                    case '8':
                    case '9':
                        stack.push(Double.parseDouble(ns[i]));
                        break;
                    case '+': {
                        double x = stack.pop();
                        double y = stack.pop();
                        stack.push(x + y);
                    }
                        break;
                    case '-': {
                        double x = stack.pop();
                        double y = stack.pop();
                        stack.push(y - x);
                    }
                        break;
                    case '*': {
                        double x = stack.pop();
                        double y = stack.pop();
                        stack.push(y * x);
                    }
                        break;
                    case '/':
                        double x = stack.pop();
                        double y = stack.pop();
                        stack.push(y / x);
                        break;
                    }
                }

            }
            double ans = stack.pop();
            System.out.printf("%.6f\n",ans);

        }
    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),M = in();
    string S = in<string>();
    reverse(ALL(S));
    vector<int> answer(0);
    bool ok = 1;
    for(int i = 0;i < N;){
        RREPS(l,M){
            if(i+l > N)continue;
            if(S[i+l] == '0'){
                answer.pb(l);
                i += l;
                break;
            }
            if(l == 1){
                ok = 0;
            }
        }
        if(ok == 0)break;
    }
    reverse(ALL(answer));
    if(ok){
        REP(i,answer.size())cout << answer[i] << "\n";
    }else{
        cout << -1 << "\n";
    }
}

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

using namespace std;

int a[10010];

int main()
{
    int n;
    cin >> n;
    long long sum = 0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for(int i =0;i<n;i++){
        sum += a[i];
    }
    cout << a[0] << " " << a[n-1] << " " << sum << endl;


    return 0;
}


Measured memory_bytes: 3284
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

static class CodeJam
{
    class Key
    {
        public readonly int a;
        public readonly int bits;
        public Key(int a, int[] C)
        {
            this.a = a;
            foreach (int c in C)
            {
                bits |= (1 << (c - 1));
            }
        }
    }

    static int Solve(int N, int M, Key[] keys)
    {
        const int INF = 1000000000;
        var dp1 = Enumerable.Repeat(INF, 1 << N).ToArray();
        dp1[0] = 0;
        foreach (var key in keys)
        {
            var dp2 = new int[1 << N];
            Array.Copy(dp1, dp2, 1 << N);
            for (int i = 0; i < dp2.Length; ++i)
            {
                dp2[i | key.bits] = Math.Min(dp1[i] + key.a, dp2[i | key.bits]);
            }
            dp1 = dp2;
        }
        int ans = dp1[(1 << N) - 1];
        return (ans < INF) ? ans : -1;
    }

    static void Main(string[] args)
    {
        var V1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = V1[0], M = V1[1];
        var keys = new Key[M];
        for (int i = 0; i < M; ++i)
        {
            var V2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var C = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            keys[i] = new Key(V2[0], C);
        }
        Console.WriteLine(Solve(N, M, keys));
    }
}


Measured memory_bytes: 29024
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1<<28;
const int maxn=20010;
const int maxm=20010;
const int mod=1e9+7;
const double pi=acos(-1.0);
int n;
int main()
{
    //freopen("in.txt","r",stdin);
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a*100+b*10+c)%4==0)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
 
void Main() {
  int n,p;
  cin >> n >> p;
  int a[n];
  rep(i,n) cin >> a[i];
  ll dp[5555];
  mem(dp);
  dp[0]=1;
  rep(i,n) {
    rrep(j,5555) {
      if(j+a[i]<5555) dp[j+a[i]]+=dp[j];
    }
  }
  ll ans=0;
  rep(i,5555) if(i%2==p) ans+=dp[i];
  pr(ans);
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

Measured memory_bytes: 256
import sys
import subprocess
import re
import datetime
import os

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

A = [a,b,c,d,e]
S = sorted(A)



V = (S[4] - S[0])
if V <= k:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 4692
#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#define M_PI 3.14159265358979323846

main() {
	int a, b;
	char c;

	while (1) {
		scanf("%d %c %d", &a, &c, &b);
		if (a < 0 || a > 20000 || b < 0 || b > 20000) return 1;
		if (c == '?') {
			break;
		}
		else if (c == '+') {
			printf("%d\n", a + b);
		}
		else if (c == '-') {
			printf("%d\n", a - b);
		}
		else if (c == '*') {
			printf("%d\n", a * b);
		}
		else if (c == '/') {
			printf("%d\n", a / b);
		}
	}

	return 0;
}


Measured memory_bytes: 2028
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin>>n>>k;
    vector<int>v(n);
    for(int&t:v)
        cin>>t;
    bool f=1;
    while(f&&k>0)
    {
        k--;
        vector<int>ps(n+1,0);
        for(int i=0;i<n;i++)
        {
            ps[max(i-v[i],0)]++;
            ps[min(i+v[i]+1,n)]--;
        }
        int p=0;
        for(int i=0;i<n;i++)
        {
            p+=ps[i];
            v[i]=p;
        }
        f=0;
        for(int&t:v)
            if(t!=n)
                f=1;
    }
    for(int&t:v)
        cout<<t<<' ';
    cout<<endl;
    return 0;
}

Measured memory_bytes: 4932
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n,uv[N],c[N],sz[N];
ll ans;
vi g[N],rt;

void dfs(int c,int fa) {
    sz[c] = 1;
    int Maxsz = 0;
    for(auto i : g[c]){
        int t = uv[i] ^ c;
        if(t == fa) continue;
        dfs(t , c);
        ans += 2ll * min(sz[t] , n - sz[t]) * ::c[i];
        Maxsz = max(Maxsz , sz[t]);
        sz[c] += sz[t];
    }
    if(Maxsz <= n / 2 && (n - sz[c]) <= n / 2)
        rt.pb(c);
}

int main(){
    scanf("%d",&n);
    rep(i,1,n) {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        uv[i]=a^b;
        ::c[i]=c;
        g[a].pb(i);
        g[b].pb(i);
    }
    dfs(1 , 0);
    if(sz(rt) == 1) {
        int Mn = 1e9;
        for(auto e : g[rt[0]]) {
            Mn = min(Mn , c[e]);
        }
        ans -= Mn;
    } else if(sz(rt) == 2){
        for(auto e : g[rt[0]]) {
            if(uv[e] == (rt[0] ^ rt[1])){
                ans -= c[e];
                break;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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


using namespace std;

typedef long long int ll;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n),b(m),pref_a(n),pref_b(m);
    int i;
    for(i=0;i<n;++i){
        cin>>a[i];
        if(i==0){
            pref_a[i]=a[i];
            
            continue;
        }
        
        pref_a[i]=pref_a[i-1]+a[i];
    }
    
    for(i=0;i<m;++i){
        cin>>b[i];
        if(i==0){
            pref_b[i]=b[i];
            continue;
        }
        pref_b[i]=pref_b[i-1]+b[i];
        
    }

    int max_books=0,j;
    for(i=0;i<n;++i){
        j = upper_bound(pref_b.begin(),pref_b.end(),k-pref_a[i])-pref_b.begin();
        if(j==0){
            break;
        }
        j--;
        max_books=max(max_books,i+j+2);
        
    }

    j = upper_bound(pref_a.begin(),pref_a.end(),k)-pref_a.begin();
    if(j>0){
        --j;
        max_books = max(max_books,j+1);
        
    }

    j = upper_bound(pref_b.begin(),pref_b.end(),k)-pref_b.begin();
    if(j>0){
        --j;
        max_books = max(max_books,j+1);
        
    }
    cout<<max_books;

}

Measured memory_bytes: 9592
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
const int INF = 1e9+5;

int main(){
	int len;
	cin >> len;
	vector<int> n(len);
	vector<int> dp(len,INF);
	for(auto &x:n){ 
		int w;
		cin >> w;
		x = w;
	}
	dp[0] = 0;
	for(int i=0;i<len;i++){
		for(int j :{i+1,i+2}){
			if (j < len){
			  dp[j] = min(dp[j],dp[i] + abs(n[i]-n[j]));
			}
		}
	}
	cout << dp[len-1];
}



Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	public static void main(String[] args) {
		int K = sc.nextInt();
		int N = sc.nextInt();
		int max=0;int f1=0;int past1=0;
		
		
		
		for(int i =0;i!=N;i++) {
			int dis = sc.nextInt();
			if(i==0) {f1=dis;}
			if(dis-past1>max) {max=dis-past1;}
			past1=dis;
			if(i==N-1) {dis=K-dis+f1;if(dis>max)max=dis;}
		}
		p(K-max);
	}

}


Measured memory_bytes: 64400
#include "bits/stdc++.h"
using namespace std;

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

	for (;;) {
		sort(a.begin(), a.end());

		int start = 0;

		for (int i = 0; i < n; ++i) {
			if (a[i] > 0) {
				start = i;
				break;
			}
		}

		if (start == n - 1) {
			break;
		}

		for (int i = start + 1; i < n; ++i) {
			a[i] = a[i] % a[start];
		}
	}

	cout << a[n-1];

	return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll N, ll M, vector<ll> x, vector<ll> y, vector<ll> z) {
    long long ans = 0;
    for (int i = 0; i < (1 << 3); i++) {
        int coef[3];
        for (int j = 0; j < 3; j++)
            coef[j] = i >> j & 1 ? -1 : 1;
        vector<ll> v;
        for (int i = 0; i < N; i++) {
            v.push_back(x[i] * coef[0] + y[i] * coef[1] + z[i] * coef[2]);
        }
        sort(v.rbegin(), v.rend());
        v.resize(M);
        ans = max(ans, accumulate(v.begin(), v.end(), 0ll));

    }
    cout << ans << endl;
}


void main_(istream &cin) {
    ll M;
    ll N;
    cin >> N;
    vector<ll> y(N - 1 + 1);
    vector<ll> x(N - 1 + 1);
    vector<ll> z(N - 1 + 1);
    cin >> M;
    for (int i = 0; i <= N - 1; i++) {
        cin >> x[i];
        cin >> y[i];
        cin >> z[i];
    }
    solve(N, M, x, y, z);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 384
import fractions


if __name__ == '__main__':
  N = int(input())
  A = list(map(int, input().split()))

  gcdl = [0]
  gcdr = [0]
  for i in range(N):
      gcdl.append(fractions.gcd(gcdl[i], A[i]))
      gcdr.append(fractions.gcd(gcdr[i], A[-(i+1)]))
  gcdr = gcdr[::-1]

  ans = []
  for i in range(N):
      ans.append(fractions.gcd(gcdl[i], gcdr[i+1]))
  print(max(ans))

Measured memory_bytes: 16148
S = str(input())
T = str(input())
S = list(S)
list = []
c = 0
for i in range(len(S)):
    S.insert(0,S[len(S)-1])
    S.pop()
    #print(S)
    temp = ""
    for j in range(len(S)):
        temp += S[j]
    #print(temp)
    if temp == T:
        c = 1
        break
if c == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
N, M, X, Y = map(int, input().split())

max_x = max(list(map(int, input().split())))
min_y = min(list(map(int, input().split())))

if min_y - max_x > 0 and max_x+1 <= Y and X+1 <= min_y:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3060
s = [int(i) for i in input()]
n = len(s)
ans = 0

for i in range(pow(2, n-1)):
    tmp = s[0]
    res = 0
    for j in range(n-1):
        if (i >> j) & 1:
            res += tmp
            tmp = s[j+1]
        else:
            tmp = tmp * 10 + s[j+1]
    res += tmp
    ans += res


print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#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, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n,m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;
    return 0;
}


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

int main() {
  int A , B , C , D ;
  cin >> A >> B >> C >> D ;
  
  if (A+B > C+D){
    cout << "Left" << endl ;
  }
  else if (A+B == C+D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl ;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
  int k, x;
  scanf("%d %d", &k, &x);
  
  if(k * 500 >= x)
  {
  	printf("Yes");
  }
  else
  {
  	printf("No");
  }
  
  return 0;
  
}



Measured memory_bytes: 1736
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2002020,mod=998244353;
int tot,n;
int cnt[N],pr[N],vis[N],mu[N],F[N],a[N];
void init(int mx){
	mu[1]=1;
	for(int i=2;i<=mx;i++){
		if(!vis[i])pr[++tot]=i,mu[i]=-1;
		for(int j=1;j<=tot && i*pr[j]<=mx;j++){
			vis[pr[j]*i]=1;
			if(!(i%pr[j]))break;
			mu[pr[j]*i]=-mu[i];
		}
	}
}
int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=1ll*x*x%mod)
		if(y&1)res=1ll*res*x%mod;
	return res;
}
int calcf(int d,int mx){
	int res=0;
	for(int t=1;t<=mx/d;t++)
		res=(res+1ll*F[t*d]*mu[t]%mod)%mod;
	return res;
}
int read(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main()
{
	init(1e6);
	n=read(); int mx=0;
	for(int i=1;i<=n;i++)
		cnt[a[i]=read()]++,mx=max(mx,a[i]);
	for(int i=1;i<=mx;i++){
		for(int j=i;j<=mx;j+=i)
			F[i]=(F[i]+1ll*cnt[j]*j%mod)%mod;
//		cout<<"F["<<i<<"]="<<F[i]<<endl;
		F[i]=1ll*F[i]*F[i]%mod;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=(ans-a[i])%mod;
	for(int i=1;i<=mx;i++)
		ans=(ans+1ll*fpow(i,mod-2)*calcf(i,mx)%mod)%mod;
//	cout<<ans<<endl;
	cout<<(1ll*ans*fpow(2,mod-2)%mod+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 20340
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}




int main() {

  long n ,a , b;

  cin >>  n >>a >> b;
  vector<long> p(n);

  for (int i = 0; i < n; ++i) {
    cin >> p[i];  //反時計
  }

  vector<long> p1;
  vector<long> p2;
  vector<long> p3;

  for (int i = 0; i < n; ++i) {
    if (p[i] <= a){
      p1.push_back(p[i]);
    }
    if (p[i] >= a + 1 && p[i] <= b){
      p2.push_back(p[i]);
    }
    if (p[i] >= b + 1){
      p3.push_back(p[i]);
    }
  }


  long ans = min(min(p1.size(),p2.size()),p3.size() );
  // cout << "YES" <<endl;




  cout << ans << endl;


}




















Measured memory_bytes: 256
using System;

namespace AOJ.Volume3
{
    public class JapaneseCalendar
    {
        public static int Main()
        {
            var input = Console.ReadLine().Split(' ');
            string e = input[0];
            int y = int.Parse(input[1]);

            if(e == "0")
            {
                if (y <= 1911) { Console.WriteLine("M" + (y - 1867)); }
                else if (y <= 1925) { Console.WriteLine("T" + (y - 1911)); }
                else if (y <= 1988) { Console.WriteLine("S" + (y - 1925)); }
                else { Console.WriteLine("H" + (y - 1988)); }
            }
            else
            {
                switch (e)
                {
                    case "1": { y += 1867; break; }
                    case "2": { y += 1911; break; }
                    case "3": { y += 1925; break; }
                    case "4": { y += 1988; break; }
                }
                Console.WriteLine(y);
            }

            return 0;
        }
    }
}

Measured memory_bytes: 9292
K = int(input())
dig1 = K%10
seven = 0
cnt = 1
if dig1 == 1 or dig1 == 3 or dig1 == 7 or dig1 == 9:
    for i in range(1, K+1):
        seven = seven * 10 + 7
        seven %= K
        if seven == 0:
            print(i)
            break
else:
    print(-1) 


Measured memory_bytes: 8976
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  if (N % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  string S;
  cin >> S;
  if (S.substr(0, N / 2) == S.substr(N / 2)) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

s = len(input())
print("x"*s)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)
const ll INF = 1LL << 60;

int main(){
    string s;
    cin >> s;
    for (int i = 0;i < s.size();i++){
        if (i%2 == 0) cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int n,x,i,a;
	int cnt,flg;
	scanf("%d",&n);
	cnt=0;
	for(i=0;i<n;i++)	{
		flg=0;
		scanf("%d",&a);
		for(x=1;2*x*x+2*x<=a;x++)	{
			if((a-x) % (2*x+1) == 0)	{
				flg=1;
				break;
			}
		}
		if(flg==0)	cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a=N/7;
  string s="No";
  for(int i=0;i<a+1;i++){
    if((N-i*7)%4==0) s="Yes";
  }
  cout << s <<endl;
}


Measured memory_bytes: 256
import sys
S = input()
T = []
B = []
A = 'abcdefghijklmnopqrstuvwxyz'
for i in range(len(S)):
   T.append(S[i])
for i in range(len(A)):
   B.append(A[i])
for i in B:
    if not i in T:
        print(i)
        sys.exit()
print('None')

Measured memory_bytes: 3956
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] array = s.split("");

        for(int i = 0; i < s.length(); i += 2){
            System.out.print(array[i]);
        }
        
    }
}

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

int main(void) {
  int H, W; cin >> H >> W;
  vector<string> F(H);
  for (int i=0; i<H; i++) cin >> F[i];
  
  vector<vector<int>> L(H, vector<int>(W));
  vector<vector<int>> R(H, vector<int>(W));
  vector<vector<int>> U(H, vector<int>(W));
  vector<vector<int>> D(H, vector<int>(W));
  
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      // about L
      if (F[i][j] == '#') {
        L[i][j] = 0;
      } else {
        if (j == 0) {
          L[i][j] = 1;
        } else {
          L[i][j] = L[i][j-1] + 1;
        }
      }
      
      // about R
      if (F[i][W-(j+1)] == '#') {
        R[i][W-(j+1)] = 0;
      } else {
        if (j == 0) {
          R[i][W-(j+1)] = 1;
        } else {
          R[i][W-(j+1)] = R[i][W-j] + 1;
        }
      }
      
      // about U
      if (F[i][j] == '#') {
        U[i][j] = 0;
      } else {
        if (i == 0) {
          U[i][j] = 1;
        } else {
          U[i][j] = U[i-1][j] + 1;
        }
      }
      
      // about D
      if (F[H-(i+1)][j] == '#') {
        D[H-(i+1)][j] = 0;
      } else {
        if (i == 0) {
          D[H-(i+1)][j] = 1;
        } else {
		  D[H-(i+1)][j] = D[H-i][j] + 1;
        }
      }
    }
  }
  
  int ans = 0;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      int tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
      if (ans < tmp) ans = tmp;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 73728
n, c = gets.strip.split.map(&:to_i)
ds = c.times.map { gets.strip.split.map(&:to_i) }
cs = n.times.map { gets.strip.split.map(&:to_i) }

numbered_groups = Array.new(3) { [] }
#p numbered_groups

n.times do |i|
  n.times do |j|
    k = ( (i+1)+(j+1) )%3
    numbered_groups[k] << cs[i][j]
  end
end

color_count_with_group = numbered_groups.map {|group|
  group.group_by(&:itself).to_a.inject( [0]*(c+1) ) {|memo, e|
    memo[e.first] = e.last.count
    memo
  }
}

#p numbered_groups
#p color_count_with_group

result = Float::INFINITY

(1..c).each do |c1|
  (1..c).each do |c2|
    next if c1==c2
    (1..c).each do |c3|
      next if c1==c3 || c2==c3
      tmp=0
      tmp+=(1..c).map {|i| color_count_with_group[0][i] * ds[i-1][c1-1] }.inject(:+)
      tmp+=(1..c).map {|i| color_count_with_group[1][i] * ds[i-1][c2-1] }.inject(:+)
      tmp+=(1..c).map {|i| color_count_with_group[2][i] * ds[i-1][c3-1] }.inject(:+)

      result = tmp if tmp < result
    end
  end
end

p result



Measured memory_bytes: 9136
#include <stdio.h>
int isprime(int n) {
  int i;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return 0;
    }
  }
  return 1;
}
int main() {
  int i;
  int k = 0;
  int n[10000] = {1};
  int p1[10000];
  int q1[10000];
  while (1) {
    scanf("%d", &n[k]);
    if (n[k] == 0) {
      break;
    }
    k++;
  }
  for (i = 0; i < k; i++) {
    while (1) {
      if (isprime(n[i]) == 1 && isprime(n[i] - 2) == 1) {
        p1[i] = n[i] - 2;
        q1[i] = n[i];
        printf("%d %d\n", p1[i], q1[i]);
        break;
	  }
      n[i]--;
    }
  }
  return 0;
}

Measured memory_bytes: 648
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    B = inputList()
    C = inputList()
    
    ans = 0
    old = -1
    for i, val in enumerate(A):
        if old != -1 and old+1 == val:
            ans += C[old-1]
        ans += B[val-1]
        old = val
            
    print(ans)
    
if __name__ == "__main__":
	main()


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

using namespace std;

int main()
{
    int X,A,c,d;
    c=0;
    d=10;
    cin>>X;
    cin>>A;
    if(X<A)
    {
       cout << c << endl;
    }
    else{
        cout << d << endl;
    }
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll n,ans;
int main(){
	scanf("%lld",&n);
	ans=INF;
	rep(i,0,n/6+1){
		ll j=(n-6*i)/9;
		ll temp=n-6*i-9*j;
		for(ll t=i;t;t/=6)temp+=t%6;
		for(ll t=j;t;t/=9)temp+=t%9;
		ans=min(ans,temp);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main()
        {
            var r = GetResult();
            var answer = string.Join("\r\n", r);
            Debug.WriteLine(answer); Console.Write(answer);
        }

        private static IEnumerable<string> GetResult()
        {
            var (N, K) = Read2Longs();
            var A = ReadLongs();
            var i = 0;
            for (var j = K; j < N; j++)
            {
                if (A[i] >= A[(int)j])
                {
                    yield return "No";
                }
                else
                {
                    yield return "Yes";
                }
                i++;
            }
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() 
        {
            var sample = Console.ReadLine();

            return sample.Split(' ').Select(x => long.Parse(x)).ToList(); 
        }

        #endregion
    }
}


Measured memory_bytes: 50540
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int n, a, b;
	cin >> n >> a >> b;
	if (n > ll(a) * b || n < a + b - 1) {
		cout << -1 << "\n";
		return 0;
	}
	vector<int> vv;
	for (int i = b; i >= 1; --i)
		vv.push_back(i);
	int cur = b + 1;
	int left = n - b - (a - 1);
	for (int i = 1; i < a; ++i) {
		int go = min(b - 1, left);
		for (int j = cur + go; j >= cur; --j)
			vv.push_back(j);
		left -= go;
		cur += go + 1;
	}
	for (int i: vv)
		cout << i << " ";
	cout << "\n";
	return 0;
}




Measured memory_bytes: 3440
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
typedef long long ll;
#define PB	push_back
#define FOR(i,n) for (int i = 0; i < n; ++i)
#define FORR(i,n) for (int i = n; i >= 0; --i)
#define REP(i,m,n) for (int i = m; i < n; ++i)
#define REPR(i,m,n) for (int i = n; i >= m; --i)
#define COUT(n)   cout << n << " " << flush
#define PI		pair<int,int>
#define ALL(obj)  obj.begin(), obj.end()
using namespace std;

int main() {
	int n, p, cou = 0;
	cin >> n;

	FOR(i, n) {
		cin >> p;
		if (p != i + 1) cou++;
	}

	if (cou <= 2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
l = [int(input()) for _ in range(m)]
q = 10**9+7
memo = [-1]*(n+1)
memo[0]=1
su = 0
if 1 in l:
  memo[1]=0
else:
  memo[1]=1
for j in l:
  memo[j]=0
  
for i in range(2,n+1):
  if memo[i]==0:
    continue
  else:
    memo[i]=((memo[i-1]%q)+(memo[i-2]%q))%q
print(memo[-1]%q)

Measured memory_bytes: 7824
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
		int ans=n*(n-1)/2+m*(m-1)/2;
    
 

    	System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

deque<int> ans1,ans2;

void solve(ll n,int& x){
    if(n==0)return ;
    if(n==1){
        ans1.push_front(x);ans2.push_front(x);
        ++x;
        return;
    }
    solve((n-1)/2,x);
    ans1.push_front(x);ans2.push_front(x);
    ++x;
    if(n%2==0){
        ans1.push_front(x);ans2.push_back(x);
        ++x;
    }
}
int main(){
    ll n;
    cin>>n;
    int x = 1;
    solve(n,x);
    cout<<ans1.size()+ans2.size()<<endl;
    for(auto e : ans1)cout<<e<<" ";
    for(auto e : ans2)cout<<e<<" ";
    return 0;
}

Measured memory_bytes: 256
implicit none
integer k
integer i,j,l
character :: s*5008,ans(5)*6
read*,s,k
ans = "zzzzz"
l = len_trim(s)
do i=1,l
  do j=0,4
    if( any(ans==s(i:i+j)) .or. l<i+j )cycle
    if(s(i:i+j)<ans(1))then
      ans(5) = ans(4)
      ans(4) = ans(3)
      ans(3) = ans(2)
      ans(2) = ans(1)
      ans(1) = s(i:i+j)
    else if(s(i:i+j)<ans(2))then
      ans(5) = ans(4)
      ans(4) = ans(3)
      ans(3) = ans(2)
      ans(2) = s(i:i+j)
    else if(s(i:i+j)<ans(3))then
      ans(5) = ans(4)
      ans(4) = ans(3)
      ans(3) = s(i:i+j)
    else if(s(i:i+j)<ans(4))then
      ans(5) = ans(4)
      ans(4) = s(i:i+j)
    else if(s(i:i+j)<ans(5))then
      ans(5) = s(i:i+j)
    endif
  enddo
enddo

print'(a)',ans(k)
end

Measured memory_bytes: 256