akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ld = long double;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  if (N % 1000 == 0) {
    cout << 0 << endl;
  } else {
    cout << 1000 - N % 1000 << endl;
  }

  return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

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

ll lcm(int a, int b)
{
    return a / gcd(a, b) * b;
}

void solve()
{
    int N; cin >> N;
    vector<pair<string, int>> v(N); REP(i, N) {cin >> v[i].first >> v[i].second; v[i].second = -v[i].second;}
    vector<pair<string, int>> t(v);
    sort(ALL(v));
    REP(i, N)
    {
        pair<string, int> p = v[i];
        REP(j, N)
        {
            if(p.first == t[j].first && p.second == t[j].second)
            {
                cout << j+1 << endl;
                break;
            }
        }
    }
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

koe=[]

for i in range(M):
  a,b=map(int,input().split())
  koe.append([a,b])

  
koe.sort(key=lambda x :x[1])


right=0
answer=0
for l,r in koe:
  if l>=right:
    right=r
    answer+=1

print(answer)

Measured memory_bytes: 21336
#include <stdio.h>
int main() {
	int n, tmax, t0 = 0, t1;
	unsigned long long ans = 0;
	scanf("%d%d", &n, &tmax);
	
	ans += tmax;

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &t1);
		if (t1 - t0 > tmax)	ans += tmax;
		else ans += t1 - t0;
		t0 = t1;
	}

	printf("%ld", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll     = long long;
using prefix = __attribute__((constructor))void;
const ll MOD = 1000000007;
const ll INF = LONG_MAX;

#define elif           else if
#define def            inline auto
#define func           inline constexpr ll
#define up(i,a,n)      for(ll i=(a),i##_1=(n);i<=i##_1;++i)
#define down(i,a,n)    for(ll i=(a),i##_1=(n);i>=i##_1;--i)
#define rep(i,n)       up(i,0,n-1)
#define append(a)      push_back(a)

func    gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
func    lcm(ll a,ll b) {return a*b/gcd(a,b);}
def     dig(ll a)      {return to_string(a).length();}
prefix  init()         {cin.tie(0),ios::sync_with_stdio(0),cout<<fixed<<setprecision(10);}

ll x[200000],a[200000],N,X,S=INF;

def C(ll n){
    if(n==0)return 5LL;
    return 3+2*n;
}

def solve(ll n){
    ll i=N-1,k=0,s=0;
    while(i-n>=0){
        if(s>=S)return INF;
        s+=(a[i]-a[i-n])*C(k);
        k++;
        i-=n;
    }
    s+=a[i]*C(k);
    return s+(n+N)*X;
}

signed main(){
    cin>>N>>X;
    rep(i,N){
        cin>>x[i];
        a[i]=x[i]+(i?a[i-1]:0);
    }
    up(i,1,N){
        S=min(solve(i),S);
    }
    cout<<S<<endl;
}


Measured memory_bytes: 3328
function pint(s) { return parseInt(s); }
function pfloat(s) { return parseFloat(s); }
Array.prototype.sortNumAsc  = function () { return this.sort((a, b) => (a - b)); }
Array.prototype.sortNumDesc = function () { return this.sort((a, b) => (b - a)); }
Array.prototype.sortStrAsc  = function () { return this.sort();                  }
Array.prototype.sortStrDesc = function () { return this.sort().reverse();        }
Array.prototype.without = function (itm) { return this.filter((elem) => elem !== itm); }
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', chunk => input += chunk);
process.stdin.on('end', () => {
  var lines = input.split('\n').map(l => l.trim());
  if (lines[lines.length-1] === '')
    lines = lines.slice(0, -1);
  main(lines);
});
function main(lines) {
  var arr = lines[0].split(' ').map(pint);
  var N = arr[0];
  var T = arr[1];
  arr = lines[1].split(' ').map(pint);
  if (N === 1) {
    console.log(T);
    return;
  }
  var t = 0;
  for (var i = 0; i < N - 1; i++) {
    var curr = arr[i];
    var next = arr[i+1];
    var s = (next - curr);
    t += Math.min(T, s);
  }
  t += T;
  console.log(t);
}

Measured memory_bytes: 33228
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    double n; cin >> n;

    if(int(ceil(n/1.08)*1.08) == int(n)){
        cout << (int(ceil(n/1.08)));
    }else cout << ":(";
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=II()
  l=LI()

  ad1=0
  f=True
  sm=0
  for x in l:
    if f:
      sm+=x
      if sm<=0:
        ad1+=abs(sm)+1
        sm=1
      f=False
    else:
      sm+=x
      if sm>=0:
        ad1+=abs(sm)+1
        sm=-1
      f=True

  ad2=0
  f=False
  sm=0
  for x in l:
    if not f:
      sm+=x
      if sm>=0:
        ad2+=abs(sm)+1
        sm=-1
      f=True
    else:
      sm+=x
      if sm<=0:
        ad2+=abs(sm)+1
        sm=1
      f=False

  return min(ad1,ad2)

print(main())


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

int Rank[1000005];
int Tmp[1000005];
int kc, len;

bool compare_sa(int i, int j) {
    return
        Rank[i] != Rank[j] ? Rank[i] < Rank[j] :
        (i + kc <= len ? Rank[i+kc] : -1) < (j + kc <= len ? Rank[j+kc] : -1);
}

void construct_sa(char* S, int *sa) {
    len = strlen(S);
    for(int i = 0; i <= len; i++) {
        sa[i] = i;
        Rank[i] = i < len ? S[i] : -1;
    }
    for(kc = 1; kc <= len; kc *= 2) {
        sort(sa, sa + len + 1, compare_sa);
        Tmp[sa[0]] = 0;
        for(int i = 1; i <= len; i++) {
            Tmp[sa[i]] = Tmp[sa[i-1]] + compare_sa(sa[i - 1], sa[i]);
        }
        for(int i = 0; i <= len; i++) Rank[i] = Tmp[i];
    }
}

int n, m;
char str[1000005];
char t[1000005];
int sa[1000005];

int main() {
    scanf("%s", str);
    n = strlen(str);
    construct_sa(str, sa);
    scanf("%d", &m);
    
    while(m--) {
        scanf("%s", t);
        int k = strlen(t);
        int l = 0, r = n + 1, m;
        while(l + 1 < r) {
            m = (l + r) / 2;
            if(strncmp(str + sa[m], t, k) <= 0) l = m;
            else r = m;
        }
        printf("%d\n", (strncmp(str + sa[l], t, k) == 0));
    }
    return 0;
}


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

int main() {
  int n;
  double ans=0;
  cin >> n;
  vector<double> x(n);
  vector<string> u(n);
  for(int i=0;i<n;i++) cin >> x[i] >> u[i];
  for(int i=0;i<n;i++) {
    if(u[i]=="JPY") ans+=x[i];
    else ans+=x[i]*380000;
  }
  cout << fixed << setprecision(8);
  cout << ans << endl;
}

Measured memory_bytes: 256
def bi(x, length):
    ret = "".join(["0" for _ in range(length)])
    return (ret + str(bin(x))[2:])[-length:]


def solve(inp):
    l = len(inp) - 1
    for i in range(2 ** l):
        binary = bi(i, l)
        tot = int(inp[0])
        for j in range(l):
            if binary[j] == "1":
                tot += int(inp[j+1])
            else:
                tot -= int(inp[j+1])
        if tot == 7:
            return ''.join([inp[j] + "+" if binary[j] == "1" else inp[j] + "-" for j in range(l)] + [inp[-1] + "=7"])

inp = input()

print(solve(str(inp)))


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, m, a, b, num = 0, ans = 0; cin >> n >> m;
	int aa[1001] = { 0 }; int test[1001] = { 0 };
	for (int h = 0; h < n; h++) {
		cin >> a;
		aa[h] = a;
	}
	for (int h = 0; h < m; h++) {
		cin >> b;
		int sum = 0;
		while (sum < n) {
			if (aa[sum] <= b) {
				test[sum]++;
				sum = n;
			}
			sum++;
		}
	}
	for (int h = 0; h < n; h++) {
		if (num < test[h]) {
			ans = max(ans, h);
			num = test[h];
		}
	}
	cout << ans + 1 << endl;
}


Measured memory_bytes: 3120
// 2011/01/14 Tazoe

#include<iostream>
using namespace std;

bool DFS(int brd[102][102], int x, int y, int col, int xg, int yg)
{
	if(brd[y][x]!=col)
		return false;
	if(x==xg&&y==yg)
		return true;

	brd[y][x] = 9;

	return(DFS(brd, x+1, y, col, xg, yg)
	     ||DFS(brd, x, y+1, col, xg, yg)
	     ||DFS(brd, x-1, y, col, xg, yg)
	     ||DFS(brd, x, y-1, col, xg, yg));
}

int main()
{
	while(true){
		int w, h;
		cin >> w >> h;
		if(w==0&&h==0)
			break;

		int brd[102][102];
		for(int yy=0; yy<h+2; yy++)
			for(int xx=0; xx<w+2; xx++)
				brd[yy][xx] = 0;

		int xs, ys, xg, yg, n;
		cin >> xs >> ys;
		cin >> xg >> yg;
		cin >> n;

		for(int i=0; i<n; i++){
			int c, d, x, y;
			cin >> c >> d >> x >> y;
			brd[y  ][x  ] = c;
			brd[y  ][x+1] = c;
			brd[y+1][x  ] = c;
			brd[y+1][x+1] = c;
			if(d==0){
				brd[y  ][x+2] = c;
				brd[y  ][x+3] = c;
				brd[y+1][x+2] = c;
				brd[y+1][x+3] = c;
			}
			else{
				brd[y+2][x  ] = c;
				brd[y+2][x+1] = c;
				brd[y+3][x  ] = c;
				brd[y+3][x+1] = c;
			}
		}

		if(brd[ys][xs]==0||brd[yg][xg]==0||brd[ys][xs]!=brd[yg][xg]){
			cout << "NG" << endl;
			continue;
		}

		if(DFS(brd, xs, ys, brd[ys][xs], xg, yg))
			cout << "OK" << endl;
		else
			cout << "NG" << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m,q,a,b;
int dp[510][510];
int main() {
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=m;i++){
        scanf("%d%d",&a,&b);
        dp[a][b]++;
    }
    for(int j=1;j<n;j++) {
        for(int i=1;i+j<=n;i++) {
            int k=i+j;
            dp[i][k]+=dp[i+1][k]+dp[i][k-1];
            if(j!=1)dp[i][k]-=dp[i+1][k-1];
        }
    }
    while(q--){
        scanf("%d%d",&a,&b);
        printf("%d\n",dp[a][b]);
    }
    return 0;
}

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

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

  int dir = 1;
  vector<char> front;
  vector<char> back;

  rep(i, q) {
    int t;
    cin >> t;

    if (t == 1) {
      dir *= -1;
    } else {
      int f;
      cin >> f;
      char c;
      cin >> c;

      if (f == 1) {
        if (dir == 1) {
          front.push_back(c);
        } else {
          back.push_back(c);
        }
      } else {
        if (dir == 1) {
          back.push_back(c);
        } else {
          front.push_back(c);
        }
      }
    }
  }

  if (dir == 1) {
    reverse(front.begin(), front.end());
    for (char fc : front) {
      cout << fc;
    }
    cout << s;
    for (char bc : back) {
      cout << bc;
    }

  } else {
    reverse(back.begin(), back.end());
    for (char bc : back) {
      cout << bc;
    }
    reverse(s.begin(), s.end());
    cout << s;
    for (char fc : front) {
      cout << fc;
    }
  }

  return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long w = sc.nextLong();

		long[] ws = new long[n];
		int[] vs = new int[n];
		int vSum = 1;

		for (int i = 0; i < n; i++) {
			ws[i] = sc.nextLong();
			vs[i] = sc.nextInt();
			vSum += vs[i];
		}
		long[][] dp = new long[n + 1][vSum];
		Arrays.fill(dp[0], 1_000_000_005);

		dp[0][0] = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < vSum; j++) {
				if (j < vs[i]) {
					dp[i + 1][j] = dp[i][j];
				} else {
					dp[i + 1][j] = Math.min(
							dp[i][j - vs[i]] + ws[i],
							dp[i][j]);
				}
			}
		}

		long answer = 0;
		for (int i = 0; i < vSum; i++) {
			if (dp[n][i] <= w) answer = Math.max(i, answer);
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 124880
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e17;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14

signed main(){
	string s;
	cin >> s;

	int num[4];
	rep(i, 4)num[i] = s[i] - '0';

	rep(i, 1 << 3){
		int va = num[0];
		rep(j, 3){
			if(i >> j & 1)va += num[j + 1];
			else va -= num[j + 1];
		}
		if(va == 7){
			string ans = "";
			ans += s[0];
			rep(j, 3){
				if(i >> j & 1)ans += "+";
				else ans += "-";
				ans += s[j + 1];
			}
			ans += "=7";
			cout << ans << endl;
			return 0;
		}
	}



}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void MAIN() {
  int n; cin >> n;
  vector<ii> a(n);
  vector<int> res(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].fi;
    a[i].sc = i;
  }
  sort(all(a));
  int l = n / 2 - 1;
  for (int i = 0; i < n; i++) {
    if (i <= l) {
      res[a[i].sc] = a[l + 1].fi;
    }
    else {
      res[a[i].sc] = a[l].fi;
    }
  }
  for (auto &i : res) cout << i << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 7900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */


int main(void){
    int n, m;
    cin >> n >> m;
    int ans_1 = n*(n-1)/2;
    int ans_2 = m*(m-1)/2;
    cout << ans_1 + ans_2 << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a,c=[],[]
for _ in range(m):
  a.append(list(map(int,input().split()))[0])
  c.append(sum((1<<(int(i)-1)) for i in input().split()))
inf=float('inf')
dp=[inf]*(1<<n)
dp[0]=0
for i in range(2**n):
  for j in range(m):
    dp[i|c[j]]=min(dp[i|c[j]],dp[i]+a[j])
print(dp[-1] if inf!=dp[-1] else-1)



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

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

  int answer = 0;
  int idx = 0;
  while (idx < N) {
    int deadline = T[idx++] + K;
    int people = 1;
    answer++;
    while (idx < N && T[idx] <= deadline && people < C) {
      idx++;
      people++;
    }
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 640
class UnionFind(object):
    def __init__(self, n=0):
        self.par = [i for i in range(n)]
        self.rank = [-1 for _ in range(n)] 

    def find(self, x):
        if self.rank[x] < 0:
            return x
        else:
            self.rank[x] = self.find(self.rank[x])
            return self.rank[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 0

        if abs(x) < abs(y): 
            x, y = y, x 
        self.rank[x] += self.rank[y]
        self.rank[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return -self.rank[self.find(x)]

n,m,k=map(int, input().split())
uf=UnionFind(n)
friend = [0]*n
for i in range(m):
    a,b=map(int, input().split())
    friend[a-1] +=1
    friend[b-1] +=1
    uf.union(a-1,b-1)

block = [[] for _ in range(n)]
for i in range(k):
    x,y=map(int, input().split())
    block[x-1].append(y-1)
    block[y-1].append(x-1)

ans = [0]*n
for i in range(n):
    ans[i] = uf.size(i)-1-friend[i]
    for j in block[i]:
        if uf.same(i,j):
            ans[i] -= 1
    ans[i] = str(ans[i])
    
print(" ".join(ans))

Measured memory_bytes: 35052
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
#include <cstring>

#define MAX
#define INF
#define MOD 1000000007
#define MP make_pair
#define AA first
#define BB second
#define IS(X) cout << #X << " = " << X << endl;
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef queue<int> QI;
typedef priority_queue<int> PQI;
LL a[100006];

int main() {
    a[1] = 1;
    for(int i = 2;i <= 100000;i++) {
        a[i] = i * a[i-1] % MOD;
    }
    int n;
    while(~scanf("%d",&n)) {
        int cnt = 0;
        LL ans = 1;
        for(int i = 0;i < n;i++) {
            int x;scanf("%d",&x);
            cnt ++;
            if(x < 2*cnt - 1) {
                ans *= cnt;
                ans %= MOD;
                cnt--;
            }
        }
        ans *= a[cnt];
        ans %= MOD;
        cout << ans << endl;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#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(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(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=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll a,b;
  cin >> a >> b;
  pr(max(a+b,max(a-b,a*b)));
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
 
using namespace std;
 
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
 
const ll mod197 = 1000000007LL;
const ll INF = 200LL * 200 * 100000 + 10;
 
const double PI11 = 3.14159265359;
 
int arrr[10] = {};
 
ll arr[200][200];
 
 
 
int main() {
 
	int n, m, r;
	cin >> n >> m >> r;
 
	for (int i = 0; i < r; i++)
		cin >> arrr[i];
 
	for (int i = 0; i < 200; i++)
		for (int j = 0; j < 200; j++) {
			if (i == j)
				arr[i][j] = 0;
			else
				arr[i][j] = INF;
		}
 
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
 
		arr[a][b] = c;
		arr[b][a] = c;
 
	}
 
	//warshall_floyd
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				arr[j][k] = min(arr[j][k], arr[j][i] + arr[i][k]);
			}
		}
	}
/*
 
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << arr[i][j] << " ";
		}
		cout << endl;
	}*/
 
	ll answer = INF;
 
	sort(arrr,arrr+r);
 
	do {
 
		ll t = 0;
 
		for (int i = 0; i < r-1; i++) {
			t += arr[arrr[i] - 1][arrr[i + 1] - 1];
			//cout << arr[arrr[i]-1][arrr[i + 1]-1] << " ";
		}
		//cout << endl;
 
		//cout << t << endl;
 
		answer = min(answer,t);
 
	} while (next_permutation(arrr,arrr+r));
 
	cout << answer << endl;
 
	return 0;
}
 

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

int selectionSort(int n, vector<int> &a){
  int ans = 0;
  rep(i, n){
    int minj = i;
    for (int j = i; j<n; j++){
      if (a[minj] > a[j]){
        minj = j;
      }
    }
    if (i != minj){
      swap(a[i], a[minj]);
      ans++;
    }
  }
  return ans;
}

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i, n) cin>>a[i];
  int ans = selectionSort(n, a);
  rep(i, n-1) cout << a[i] << " ";
  cout << a[n-1] <<endl;
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define arrlen(arr) (sizeof(arr)/sizeof(arr[0]))
#define Sort(arr) sort(arr, arr+arrlen(arr))
#define For(i,n) for(int i=0;i<n;i++)
#define Foreach(i,arr) For(i,arrlen(arr))
#define Arrin(arr) Foreach(i,arr){cin>>arr[i];}
#define Arrin2(arr1,arr2) Foreach(i,arr1){cin>>arr1[i]>>arr2[i];}
#define Arrin3(arr1,arr2,arr3) Foreach(i,arr1){cin>>arr1[i]>>arr2[i]>>arr3[i];}
	
int main(){
	int N,ans=0,A=0,B=0,C=0;
	cin >> N;
	string s[N];
	Arrin(s);
	For(i,N){
		For(j,s[i].length()-1){
			if(s[i][j]=='A'&&s[i][j+1]=='B'){
				ans++;
				s[i][j]='X';
				s[i][j+1]='X';
			}
		}
	}
	
	For(i,N){
		if(s[i][0]=='B'&&s[i][s[i].length()-1]=='A') C++;
		else if(s[i][s[i].length()-1]=='A') A++;
		else if(s[i][0]=='B') B++;
	}
	
	if(A==0&&B==0) ans+=max(0,C-1);
	else ans+=min(A,B)+C;
	
	cout << ans;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
using namespace std;

string S, T;

int main(void) {
	cin >> S >> T;

	int ans = 0;
	for (int i = 0; i < (int)S.length(); ++i) {
		if (S[i] != T[i])
			++ans;
	}

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


Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t Ln_1 = 2;
  int64_t Ln = 1;
  int n = 0;
  int64_t tmp =0;
  
  cin >> n;
  
  if(n == 1){
    cout << 1 << endl;
  }else{
    for(int i=0;i<n-1;i++){
        tmp = Ln;
        Ln = Ln + Ln_1;
        Ln_1 = tmp;
    }
    cout << Ln << endl;
  }
  
}


Measured memory_bytes: 256
n=int(input())
s=0
xy=[tuple(map(int,input().split())) for _ in range(n)]
import itertools
l=[i for i in range(1,n+1)]
for y in itertools.permutations(l):
    for i in range(n-1):
        s+=((xy[y[i]-1][0]-xy[y[i+1]-1][0])**2+(xy[y[i]-1][1]-xy[y[i+1]-1][1])**2)**0.5
e=1
for i in range(1,n+1):
    e*=i
print(s/e)


Measured memory_bytes: 41068
public class Main{
public static void main(String[ ]args){

int k = 0;
for(int i = 1 ; i<10 ;i++){
for(int j = 1 ; j < 10 ; j++){
k = i * j;

System.out.println(i + "x" + j + "=" + k);
}
}
}
}

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

int main(){
  int N;
  cin >> N;
  int W[N];
  int sum = 0;
  for(int i=0;i<N;i++){
    cin >> W[i];
    sum += W[i];
  }
  int part_sum = 0;
  int judge = 0;
  for(int i=0;part_sum * 2 < sum;i++){
    part_sum += W[i];
    if(part_sum*2 >= sum){
      judge = i;
    }
  }
  int ans  = 0;
  int part_sum_sub = part_sum - W[judge];
  int ans_sub = sum - part_sum_sub*2;
  if(part_sum*2 == sum){
    ans = 0;
  }else{
    if(sum - part_sum*2 > 0){
      ans = sum - part_sum*2;
    }else{
      ans = part_sum*2 - sum;
    }
    ans = min(ans,ans_sub);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n;
string z;
vector<int> t;
const int inf = 1e12;
int licz(){
  debug(t);
  int w1 = 0 ,w2 = 0,w3 = 0,w4 = 0;
  R(i,SZ(t)-1){
    int w12 = w4;
    int w22 = w1 + t[i];
    if(t[i] > 1){
      maxi(w22,max(w2 + t[i] - 1, w3 + 1));
    }
    int w32 = w3 + t[i+1] - 1;
    int w42 = w3 + t[i+1];
    w1 = w12;
    w2 = max(w22,w1);
    w3 = max(w32,w1);
    if(t[i+1] > 1)maxi(w3,w2);
    w4 = max({w1,w2,w3,w42});
  }
  return w4;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> z;
  n+=2;z += "00";
  int res = 0;
  int ak = 0;
  R(i,n){
    if(z[i] == '1'){
      ak++;
    }else{
      if(ak == 0){
        res += licz();
        t.clear();
      }else{
        t.PB(ak);
        ak = 0;
      }
    }
  }
  cout << res << "\n";
}


Measured memory_bytes: 1172
import numpy as np

N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

x = np.array(X)
dist_mat = np.linalg.norm(x[:, np.newaxis] - x, axis=-1)

count = 0
for i in dist_mat:
    for j in i:
        if j.is_integer():
            count += 1

print((count-N)//2)


Measured memory_bytes: 12404
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

lint lcm(lint a, lint b) {
    return (a / gcd(a, b)) * b;
}

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int> v(n, 0);
    int a, b;
    REP(i, m){
        cin >> a >> b;
        a--;
        b--;
        v[a]++;
        v[b]++;
    }
    REP(i, n){
        cout << v[i] << endl;
    }
    return 0;
}

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

#define x first
#define y second
#define For(i, j, k) for(int i = j; i <= k; i++)

using namespace std;

typedef pair<int, int> PII;

const int N = 3e5 + 10;
const int oo = 1e9;

struct Segment_Tree{

	int Max[N << 2], addv[N << 2];

	#define lc (o << 1)
	#define rc (o << 1 | 1)
	#define M ((L + R) >> 1)

	void init(int n){
		For(i, 0, (n << 2)) Max[i] = -oo, addv[i] = 0;
	}

	void update(int o, int L, int R, int l, int r, int v){
		if(l <= L && R <= r) addv[o] += v, Max[o] += v;
		else{
			if(l <= M) update(lc, L, M, l, r, v);
			if(r > M) update(rc, M + 1, R, l, r, v);
			Max[o] = max(Max[lc], Max[rc]) + addv[o];
		}
	}

}T;

int w, h, n, ans;
PII P[N], a[N], b[N];

void work(){
	sort(P + 1, P + n + 1);

	T.init(n);

	int l = 0, r = 0;

	For(i, 1, n - 1){
		if(P[i].y <= h / 2){
			int nxt = i - 1;
			while(l && a[l].y < P[i].y){
				T.update(1, 1, n, a[l].x, nxt, a[l].y - P[i].y);
				nxt = a[l].x - 1, --l;
			}
			
			if(nxt != i - 1) a[++l] = PII(nxt + 1, P[i].y);
		}
		else{
			int nxt = i - 1;
			while(r && b[r].y > P[i].y){
				T.update(1, 1, n, b[r].x, nxt, P[i].y - b[r].y);
				nxt = b[r].x - 1, --r;
			}

			if(nxt != i - 1) b[++r] = PII(nxt + 1, P[i].y);
		}
		a[++l] = PII(i, 0);
		b[++r] = PII(i, h);
		
		T.update(1, 1, n, i, i, oo + h - P[i].x);
		ans = max(ans, T.Max[1] + P[i + 1].x);

	}
}

int main(){

	scanf("%d%d%d", &w, &h, &n);
	For(i, 1, n) scanf("%d%d", &P[i].x, &P[i].y);
	P[++n] = PII(0, 0), P[++n] = PII(w, h);
	
	work();
	For(i, 1, n) swap(P[i].x, P[i].y);
	swap(w, h);
	work();

	printf("%d\n", ans << 1);

	return 0;
}

Measured memory_bytes: 15616
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k == x:
        ans += 1
print(ans)

Measured memory_bytes: 9064
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=225;

int f[N][N][N],g[N][N][N],n,m;
char s[N][N];

int main() {
	scanf("%d%d",&n,&m);
	fo(i,1,n) scanf("%s",s[i]+1);
	fo(i,1,n) {
		f[i][i][m]=m;
		fd(j,m-1,1) {
			if (s[i][j]==s[i][j+1]) f[i][i][j]=f[i][i][j+1];
			else f[i][i][j]=j;
		}
	}
	fo(i,1,n) 
		fo(k,1,m) 
			fo(j,i+1,n) {
				if (s[j][k]!=s[j-1][k]) break;
				f[i][j][k]=min(f[i][j-1][k],f[j][j][k]);
			}
	int ans=0;
	while (f[1][n][1]<m) {
		fo(i,1,n) fo(j,i,n) fo(k,1,m) g[i][j][k]=f[i][j][k]<m?f[i][j][f[i][j][k]+1]:m;
		fo(i,1,n)
			fo(k,1,m) {
				int p=i;
				fo(j,i,n) {
					while (p<j&&min(f[i][p][k],f[p+1][j][k])<=min(f[i][p+1][k],f[p+2][j][k])) p++;
					g[i][j][k]=max(g[i][j][k],min(f[i][p][k],f[p+1][j][k]));
				}
			}
		fo(i,1,n) fo(j,i,n) fo(k,1,m) f[i][j][k]=g[i][j][k];
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 75392
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[2][20];

int dp[1<<18][18];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	
	cin>>N;
	FOR(i,N) cin>>A[0][i];
	FOR(i,N) cin>>A[1][i];
	FOR(i,1<<18) FOR(x,18) dp[i][x]=1010100;
	
	FOR(i,N) dp[1<<i][i]=i;
	int mask;
	FOR(mask,(1<<N)-1) {
		FOR(i,N) if((mask&(1<<i)) && dp[mask][i]<1000000) {
			int b=__builtin_popcount(mask);
			int cur=A[abs(i-b-1)%2][i];
			FOR(x,N) if((mask&(1<<x))==0) {
				int nex=A[abs(x-b)%2][x];
				int num=__builtin_popcount((mask^(0xfffff))&((1<<x)-1));
				if(nex>=cur) {
					dp[mask|(1<<x)][x]=min(dp[mask|(1<<x)][x],dp[mask][i]+num);
				}
			}
		}
	}
	
	
	int mi=1010100;
	FOR(i,N) mi=min(mi,dp[(1<<N)-1][i]);
	
	if(mi>=1000000) {
		cout<<-1<<endl;
	}
	else {
		cout<<mi<<endl;
	}
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 18816
import java.util.Scanner;

public class Main{

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

        // input
        int num = scan.nextInt();
        String input = scan.next();

        // answer
        if(num < 3200){
            System.out.println("red");
        } else {
            System.out.println(input);
        }

    }
}

Measured memory_bytes: 21716
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

#print(N,A,B,C)
point = 0
for i in range(N):
  point += B[A[i]-1]
#print(point)
  
for i in range(N-1):
  if (A[i+1] - A[i]) == 1:
    #print(i)
    point+=C[A[i]-1]
print(point)

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

using namespace std;

int main()
{
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		long a, b;
		cin >> a >> b;
		long s = floor(sqrt(a*b));
		cout << (a == b ? s * 2 - 2 : s * s == a * b ? s * 2 - 3 : s * (s + 1) < a*b ? s * 2 - 1 : s * 2 - 2) << '\n';
	}
	cout << flush;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
    using namespace std;
     
    int a[3], b[3];
    int c[3][3];
     
    int main() {
    	for (int i = 0; i < 3; i++) {
    		for (int j = 0; j < 3; j++) {
    			cin >> c[i][j];
    		}
    	}
     
    	for (int i = 0; i < 3; i++) {
    		b[i] = c[0][i];
    	}
    	a[1] = c[1][0] - b[0];
    	a[2] = c[2][0] - b[0];
     
    	bool ans = true;
    	for (int i = 0; i < 3; i++) {
    		for (int j = 0; j < 3; j++) {
    			ans = (c[i][j] == a[i] + b[j]);
    			if (!ans) break;
    		}
    		if (!ans) break;
    	}
     
    	if (ans) cout << "Yes" << endl;
    	else cout << "No" << endl;
    }

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;

int main(){
	string input;
	while(cin >> input){
		int j =0, i =0;
		for(int p=0; p < input.size(); p++){
			if(input[p] == 'J' && input[p+1] == 'O' && input[p+2] == 'I') j++;
			else if(input[p] == 'I' && input[p+1] == 'O' && input[p+2] == 'I') i++;
		}
		cout << j << endl << i << endl;
	}
}

Measured memory_bytes: 1196
//ABC150 A

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint N;
string S;



int main() {
  cin >> N >> S;
  
  rep(i,N-2){
    if(S.substr(i,3) == "ABC") ans++;
  }

  printf("%lld\n",ans);
}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	int a,b,c;

	cin>>a>>b>>c;

	(a+b>=c)?cout<<"Yes"<<endl:cout<<"No"<<endl;



}


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

int main(){
    int a,b,N,s[105],f[105];
    cin >> a>>b>>N;
    for (int i = 0; i < N; i++){
        cin >> s[i] >> f[i];
        if (f[i]>a&&s[i]<b){
            cout << 1 << endl;
            return 0;
        }       
    }
    cout << 0<<endl;
    return 0;
}



Measured memory_bytes: 3116
#include<iostream>
#include<cstdio>

using namespace std;
struct Card
{
	char suit;
	int value;
};

Card A[100000], B[100000];
int N;

int partition(Card A[], int p, int r)
{
	int i = p - 1;
	int x = A[r-1].value;
	for (p; p < r; p++)
	{
		if (A[p].value <= x)
		{
			swap(A[++i], A[p]);
		}
	}
	return i;
}

void quicksort(Card A[], int left, int right)
{
	if (right - left > 1)
	{
		int mid = partition(A, left, right);
		quicksort(A, left, mid);
		quicksort(A, mid + 1, right);

	}
}

int isstable(Card A[], Card B[], int N)
{
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (B[j].value == A[i].value)
			{
				if (B[j].suit != A[i].suit)
					return 1;
				else
					B[j].value = -1;
				break;
			}
		}
	}
	return 0;
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i].suit >> A[i].value;
	}
	for (int i = 0; i < N; i++)
	{
		B[i] = A[i];
	}
	quicksort(A, 0, N);

	if (isstable(A, B, N))
	{
		cout << "Not stable" << endl;
	}
	else
	{
		cout << "Stable" << endl;
	}

	for (int i = 0; i < N; i++)
	{
		cout << A[i].suit << ' ' << A[i].value << endl;
	}
	
	return 0;
}


Measured memory_bytes: 4632
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl;
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

map<ll,ll> prime;

void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
    Rep(i,2,l){
        if(n%i==0){
        prime_factorize(i);prime_factorize((ll)(n/i));return;
        }
    }
    prime[n]++;return;
}

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

  prime_factorize(p);

  ll ans = 1;

  for(auto ma : prime){
    if(ma.second/n){
      rep(i, 0, ma.second/n){
        ans *= ma.first;
      }
    }
  }

  co(ans);

  return 0;
}

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


const int N = 1e5 + 5, MOD = 1e9 + 7;



int n, dp[N][2];
vector < int > g[N];

void dfs(int v, int pr = -1){
    int cur1 = 1, cur2 = 1;
    for(int to : g[v]){
        if(to == pr){
            continue;
        }
        dfs(to, v);
        cur1 = 1LL * cur1 * (dp[to][0] + dp[to][1]) % MOD;
        cur2 = 1LL * cur2 * dp[to][0] % MOD;
    }
    dp[v][0] = cur1;
    dp[v][1] = cur2;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(1);
    cout << (dp[1][0] + dp[1][1]) % MOD;
}


Measured memory_bytes: 13440
#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>;


void Main()
{
  int n; cin >> n;
  vector<int> ans(4);
  vector<string> S(n);
  rep(i,n) {
    cin >> S[i];
    if (S[i] == "AC") ans[0]++;
    else if (S[i] == "WA") ans[1]++;
    else if (S[i] == "TLE") ans[2]++;
    else if (S[i] == "RE") ans[3]++;
  }
  cout << "AC x " << ans[0] << endl;
  cout << "WA x " << ans[1] << endl;
  cout << "TLE x " << ans[2] << endl;
  cout << "RE x " << ans[3] << endl;
}

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


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

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
  if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
  return *ci++;
}
inline int getint() {
  int A = 0;
  if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
  else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
  return A;
}

int main() {
  int N = getint();

  int ans = 0, cnt = 1;

  for (int i = 0; i < N; i++) {
    int a = getint();
    if (a == cnt) cnt++;
    else ans++;
  }

  cout << ((ans == N) ? -1 : ans) << "\n";
}

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

//*

int main()
{
    long long N;
    cin>>N;

    long long M = 1000000007;
    N++;
    //  [d][v<N][v carry]
    long long T[64][2][2] = {};

    if ((N&1)==0)
    {
        T[0][0][0] = 2;
        T[0][0][1] = 1;
    }
    else
    {
        T[0][0][0] = 1;
        T[0][1][0] = 1;
        T[0][1][1] = 1;
    }

    for (int i=1; i<64; i++)
    {
        if ((N>>i&1)==0)
        {
            T[i][0][0] = (T[i-1][0][0]*2 + T[i-1][0][1] + T[i-1][1][0] + T[i-1][1][1])%M;
            T[i][0][1] = (T[i-1][0][0] + T[i-1][0][1]*2 + T[i-1][1][1])%M;
            T[i][1][0] = (T[i-1][1][0])%M;
            T[i][1][1] = (T[i-1][1][0] + T[i-1][1][1])%M;
        }
        else
        {
            T[i][0][0] = (T[i-1][0][0] + T[i-1][0][1])%M;
            T[i][0][1] = (T[i-1][0][1])%M;
            T[i][1][0] = (T[i-1][0][0] + 2*T[i-1][1][0] + T[i-1][1][1])%M;
            T[i][1][1] = (T[i-1][0][0] + T[i-1][0][1] + T[i-1][1][0] + 2*T[i-1][1][1])%M;
        }
    }
    cout<<T[63][1][0]<<endl;
}


Measured memory_bytes: 888
n, k = map(int, input().split())
ans = 0
p = 10 ** 9 + 7
a = 0
b = 0
for j in range(k):
  a += j
  b += n-j
for i in range(k, n+2):
  ans = (ans+b-a+1)%p
  a += i
  b += n-i
print(ans)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    int n ,c1=0 , c2=0 , c3=0 , c4=0;
    cin >> n ;
    string s ;
    for(int i=0;i<n ;i++)
    {
        cin >> s ;
        if(s=="AC")c1++;
        else if(s=="WA")c2++;
        else if(s=="TLE")c3++;
        else c4++;
    }
    cout << "AC x " << c1 << '\n';
    cout << "WA x " << c2 << '\n';
    cout << "TLE x " << c3 << '\n';
    cout << "RE x "<< c4 << '\n';

}


Measured memory_bytes: 3608
#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        H, W = map(lambda x: int(x), line.split(" ", 2))
        N = int(sys.stdin.readline())
        a = map(lambda x: int(x), sys.stdin.readline().split(" ", N))
        
        color = []
        for n, i in enumerate(a):
            for j in xrange(i):
                color.append(str(n + 1))
        for i in xrange(H):
            if i % 2 == 0:
                print(" ".join(color[i * W:(i + 1) * W]))
            else:
                print(" ".join(reversed(color[i * W:(i + 1) * W])))

            
#        print(color)
            
        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 3204
S=list(input())

e,o=0,0
for i in range(len(S)):
	if S[i] == "0":
		if i%2 == 0:
			e+=1
		else:
			o+=1
	else:
		if i%2 == 1:
			e+=1
		else:
			o+=1

print(min(e,o))


Measured memory_bytes: 3956
#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>
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 all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n, a[100010];
signed main() {
    cin >> n;
    repq(i,1,n) cin >> a[i];
    int ans = 0, mi = 1;
    repq(i,1,n) {
        if(a[i] < mi) continue;
        else if(a[i] == mi) mi++;
        else {
            ans += (a[i] - 1) / mi;
            a[i] -= (a[i] - 1) / mi * mi;
            if(a[i] == mi) a[i] = 1;
            mi = max(mi, a[i] + 1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024