akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define N 1000010
int n,m,totnum,a[N],b[N],c[N],id[N];
int root,tot,ch[N][2];
int top,scc,tim,dfn[N],low[N],vis[N],sta[N],belong[N];
int num,biannum,h[N],g[N];
struct node{int to,next;}mp[N];
inline void ins(int x,int y){
//	printf("%d %d\n",x,y);
	mp[++num].to=y;mp[num].next=h[x];h[x]=num;
}
inline void tarjan(int x){
	dfn[x]=low[x]=++tim;vis[x]=1;sta[++top]=x; 
	for(int i=h[x];i;i=mp[i].next){
		int y=mp[i].to;
		if(!dfn[y]){
			tarjan(y);
			low[x]=min(low[x],low[y]);
		}else if(vis[y]) low[x]=min(low[x],dfn[y]);
	}
	if(dfn[x]==low[x]){
		belong[x]=++scc;vis[x]=0;
		while(x!=sta[top]){
			belong[sta[top]]=scc;
			vis[sta[top--]]=0;
		}--top;
	}
}
inline bool cmp(int x,int y){
	return a[x]<a[y];
}
inline int rev(int x){
	return x^1;
}
inline void build(int &v,int l,int r){
	v=++tot;
	if(l==r){
		ins(v,rev(c[l]));
		return;
	}int mid=l+r>>1;
	build(ch[v][0],l,mid);build(ch[v][1],mid+1,r);
	if(ch[v][0]) ins(v,ch[v][0]);
	if(ch[v][1]) ins(v,ch[v][1]);
}
inline void ins(int v,int l,int r,int x,int y,int z){
	if(x>y) return;
	if(x<=l && r<=y){ins(z,v);return;}
	int mid=l+r>>1;
	if(x<=mid) ins(ch[v][0],l,mid,x,y,z);
	if(mid<y) ins(ch[v][1],mid+1,r,x,y,z); 
}
inline bool check(int x){
	memcpy(h,g,sizeof(h));
	num=biannum;
	for(int i=1;i<=n;++i){
		for(int j=0;j<=1;++j){
			int l=max(1,(int)(upper_bound(b+1,b+totnum+1,a[i<<1|j]-x)-b));
			int r=min(totnum,(int)(lower_bound(b+1,b+totnum+1,a[i<<1|j]+x)-b-1));
			ins(root,1,totnum,l,id[i<<1|j]-1,i<<1|j);
			ins(root,1,totnum,id[i<<1|j]+1,r,i<<1|j);
		}
	}
	scc=tim=top=0;
	for(int i=2;i<=tot;++i) belong[i]=dfn[i]=low[i]=0;
	for(int i=2;i<=(n<<1|1);++i){
		if(!dfn[i]) tarjan(i);
	}
	for(int i=1;i<=n;++i) 
		if(belong[i<<1]==belong[i<<1|1]) return false;
	return true;
}
int main(){
	scanf("%d",&n);tot=n<<1|1;
	for(int i=1;i<=n;++i){
		scanf("%d%d",&a[i<<1],&a[i<<1|1]);
		c[++totnum]=i<<1;b[totnum]=a[i<<1];
		c[++totnum]=i<<1|1;b[totnum]=a[i<<1|1];
	}
	sort(b+1,b+totnum+1);
	sort(c+1,c+totnum+1,cmp);
	for(int i=1;i<=totnum;++i) id[c[i]]=i;
//	for(int i=1;i<=totnum;++i) printf("%d ",a[i]);puts("");
//	for(int i=1;i<=totnum;++i) printf("%d ",c[i]);puts("");
//	for(int i=1;i<=totnum;++i) printf("%d ",id[i]);puts("");
	build(root,1,totnum);biannum=num;
	memcpy(g,h,sizeof(g));
	int l=0,r=b[totnum],ans=0;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 38144
//Grid Compression

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<int>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int h,w;cin>>h>>w;
    vector<string>q(h);
    rep(i,0,h)cin>>q[i];
    vector<bool>hb(h,false),wb(w,false);
    rep(i,0,h){
        rep(j,0,w){
            if(q[i][j]=='#'){
                hb[i]=true;
                wb[j]=true;
            }
        }
    }
    rep(i,0,h){
        if(hb[i]!=true)continue;
        rep(j,0,w){
            if(wb[j]!=true)continue;
            cout<<q[i][j];
        }
        cout<<nnn;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>

using namespace std;
using ll = long long;

// inf
const ll infl = 1LL << 60;
const int inf = 1 << 30;

ll gcd(ll a, ll b) {
    if (b > a) swap(a, b);
    return a % b != 0LL ? gcd(b, a % b) : b;
}

int main() {
    ll A, B, C, D; cin >> A >> B >> C >> D;
    ll lcm = C * D / gcd(C, D);

    ll nc = (B - A + 1LL) - (B / C - (A - 1LL) / C);
    ll nd = (B - A + 1LL) - (B / D - (A - 1LL) / D);
    ll ncd = (B - A + 1LL) - (B / lcm - (A - 1LL) / lcm);
    
    cout << (nc + nd - ncd) << endl;
    return 0;
}

Measured memory_bytes: 888
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.text.DecimalFormat;

class Main {
    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        DecimalFormat df = new DecimalFormat();
        df.setMaximumFractionDigits(3);
        df.setMinimumFractionDigits(3);
        StringBuilder sb = new StringBuilder("");

        for (int i = 0; i < n; i++) {
            double x1 = sc.nextDouble();
            double y1 = sc.nextDouble();
            double x2 = sc.nextDouble();
            double y2 = sc.nextDouble();
            double x3 = sc.nextDouble();
            double y3 = sc.nextDouble();

            double px = .5 * ((x1*x1 + y1*y1) * (y3-y2) + (x2*x2 + y2*y2) * (y1-y3) + (x3*x3 + y3*y3) * (y2-y1)) / (x1 * (y3-y2) + x2 * (y1-y3) + x3 * (y2-y1));

            double py = .5 * ((x1*x1 + y1*y1) * (x3-x2) + (x2*x2 + y2*y2) * (x1-x3) + (x3*x3 + y3*y3) * (x2-x1)) / (y1 * (x3-x2) + y2 * (x1-x3) + y3 * (x2-x1));

            double r = Math.sqrt((x1-px)*(x1-px) + (y1-py)*(y1-py));

            sb.append(df.format(px));
            sb.append(' ');
            sb.append(df.format(py));
            sb.append(' ');
            sb.append(df.format(r));
            sb.append('\n');

        }

        System.out.print(sb);
    }
}

Measured memory_bytes: 28416
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define sz(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
//const ll MOD = 1000000007;
//const ll MOD = 998244353;
const ll MOD = 1000003;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};



void solve(){
  while(true){
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0) return;
    vector<int> s(n), t(m);
    rep(i, n) cin >> s[i];
    rep(i, m) cin >> t[i];
    int S = 0, T = 0;
    rep(i, n) S += s[i];
    rep(i, m) T += t[i];
    pair<int, pair<int, int>> ans = {INF, {INF, INF}};
    rep(i, n)rep(j, m){
      if(S - s[i] + t[j] == T - t[j] + s[i]){
        ans = min(ans, {s[i] + t[j], {s[i], t[j]}});
      }
    }
    if(ans.f == INF) cout << -1 << endl;
    else cout << ans.s.f << " " << ans.s.s << endl;
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  solve();
}



Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <algorithm>

#define INF 1010101010

using namespace std;

int main()
{
	int n, m, o;
	cin >> n >> m >> o;
	vector<int> r(o);
	for (int i = 0; i < o; i++) {
		cin >> r[i];
		r[i]--;
	}
	sort(r.begin(), r.end());

	vector<vector<int>> a(n, vector<int>(n, INF));
	for (int i = 0; i < m; i++) {
		int s, t, u;
		cin >> s >> t >> u;
		s--;
		t--;
		a[s][t] = u;
		a[t][s] = u;
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				a[j][k] = min(a[j][k], a[j][i] + a[i][k]);
			}
		}
	}

	int mn = INF;
	do {
		int tmp = 0;
		for (int i = 0; i < o - 1; i++) {
			tmp += a[r[i]][r[i + 1]];
		}
		mn = min(mn, tmp);
	} while (next_permutation(r.begin(), r.end()));
	cout << mn << endl;

	return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>

using namespace std;
int main() {
    int D;
    cin >> D;
    if(D == 25) {
        cout << "Christmas" << endl;
    } else if(D == 24) {
        cout << "Christmas Eve" << endl;
    } else if(D == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else if(D == 22) {
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

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


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

int main()
{
  ll n, x;	cin >> n >> x;
  
  ll ans=0;
  vector<int> s(n);
  
  rep(i,n)	
  {
    cin >> s[i];
    s[i] = abs(x-s[i]);
  }
  ans =s[0];
  rep(i,n)
  {
    ans =gcd(ans, s[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String S = scan.next();
		
		int answer = 0;
		
		switch (S) {
		case "SUN":
			answer = 7;
			break;
		case "MON":
			answer = 6;
		    break;
		case "TUE":
			answer = 5;
		    break;
		case "WED":
			answer = 4;
		    break;
		case "THU":
			answer = 3;
		    break;
		case "FRI":
			answer = 2;
		    break;
		case "SAT":
			answer = 1;
		    break;
		}
		
		System.out.println(answer);
		scan.close();
	}
}

Measured memory_bytes: 22740
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, B, C = MAP()
K = INT()

tmp = sorted([A, B, C])
print(tmp[0]+tmp[1]+tmp[2]*(2**K))


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

int main() {
  string S;
  cin >> S;
  bool ns = (S.find('N') != string::npos) ^ (S.find('S') != string::npos);
  bool ew = (S.find('E') != string::npos) ^ (S.find('W') != string::npos);
  cout << (ns || ew ? "No" : "Yes") << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  string str;
  cin >> str;
  int N = str.size();
  vector<int> vec;
  int c = 0;
  rep(i, N) {
    if(str.at(i) == '0') {
      vec.push_back(0);
      c++;
    }
    if(str.at(i) == '1') {
      vec.push_back(1);
      c++;
    }
    if(str.at(i) == 'B') {
      if(c > 0) {
        c--;
        vec.pop_back();
      } 
    }
  }
  rep(i, vec.size()) {
    cout << vec.at(i);
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for (long i = 0; i < n; ++i)

using namespace std;

void solve(long N, long M, vector<long> X) {
  // if there's less number of targets than the pieces, we can win without any movement
  if (M <= N) {
    cout << 0 << endl;
    return;
  }

  // sort the targets
  sort(X.begin(), X.end());

  // calc the distances between targets
  vector<long> dist(M - 1);
  REP(i, M - 1)
    dist[i] = X[i + 1] - X[i];

  // sort the distances
  sort(dist.rbegin(), dist.rend());

  // if we have no extra piece, we should move the first piece from the begin to the end
  long ans(X.back() - X.front());

  // we can skip the N-1 longest gap by putting pieces in advance
  REP(i, N - 1)
    ans -= dist[i];

  cout << ans << endl;
}

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

  long N, M;
  cin >> N >> M;
  vector<long> X(M);
  REP(i, M)
    cin >> X[i];

  solve(N, M, move(X));

  return 0;
}


Measured memory_bytes: 4640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    bool flag = true;
    string a, b, c;
    cin >> a >> b >> c;
    if (a[a.size()-1] != b[0])
        flag = false;
    if (b[b.size()-1] != c[0])
        flag = false;
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
function main(input){
    input = input.split(/\s/);
    var h = parseInt(input[0]);
    var w = parseInt(input[1]);
    var mp = [];
    for(var i = 2; i < 2 + h; i++) mp.push(input[i]);

    function check(x, y){
	var res = 0;
	for(var i = 0;i < h;i++)
	    if(mp[i][x] == '#') {
		res++;
		break;
	    }

	for(var j = 0;j < w;j++)
	    if(mp[y][j] == '#') {
		res++;
		break;
	    }
	return res == 2;
    }

    for(var i = 0; i < h;i++){
	ans = ''
	for(var j = 0; j < w;j++)
	    if( check(j, i) ) ans = ans + mp[i][j];
	if(ans != '') console.log(ans);
    }
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  string s;
  cin >> A >> B >> s;
  
  bool ret = true;
  if(s.size() == A + B + 1 && s.at(A) == '-'){
    
    int index = 0;
    while(index < A){
      int a = s.at(index) - '0';
      if(a  < 0   ||  9 < a){ret = false;}
      index ++;
    }
    index = A + 1;
    while(index < B + A + 1){
      int a = s.at(index) - '0';
      if(a  < 0   ||  9 < a){ret = false;}
      index ++;
    }
  }else ret = false;
  
  if(ret)   cout << "Yes" << endl;
  else  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
juelNum = int(input())
eachValueOrg = input().split()
eachValue = [int(i) for i in eachValueOrg]
eachCostOrg = input().split()
eachCost = [int(i) for i in eachCostOrg]

ans = 0
for i in range(juelNum):
    if eachCost[i] < eachValue[i]:
        ans += (eachValue[i] - eachCost[i])
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
 
int main(){
    int W;
    int H;
    int x;
    int y;
    int r;
    cin >> W >> H >> x >> y >> r;
    if(0<=x-r && x+r<=W && 0<=y-r && y+r<=H){
        cout << "Yes" << endl;
    }else if(x+r>W || y+r>H || x-r<0 || y-r<0){
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  int cnt=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      char a;cin >> a;
      if(a=='#'){
        cnt++;
      }
    }
  }
  if(cnt==h+w-1){
    cout << "Possible" << endl;
  }
  else{
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 256
/*
　　　 _,,..,,,,_
　　 / ,' 3　 `ヽｰっ
.　　l　　 ⊃　⌒_つ
　　 `'ｰ---‐'''''"
*/
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
  for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
  for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (int i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < v.size() - 1; ++i) {
    os << v[i] << " ";
  }
  if (v.size() > 0) {
    os << v[v.size() - 1] << endl;
  }
  return os;
}

int main() {
  int n;
  cin >> n;
  vll t(n), a(n);
  cin >> t >> a;
  if (n == 1){
    if (a[0] != t[0]){
      cout << 0 << endl;
    }else{
      cout << 1 << endl;
    }
    return 0;
  }
  if ((a[0] > a[1] && t[0] != a[0]) || (t[0] > a[0])){
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  FOR(i, 1, n-1){
    if (a[i] > a[i+1] && t[i-1] < t[i]){
      if (a[i] != t[i]){
        cout << 0 << endl;
        return 0;
      }
    }else if (a[i] > a[i+1]){
      if (a[i] > t[i]) {
        cout << 0 << endl;
        return 0;
      }
    } else if (t[i - 1] < t[i]) {
      if (a[i] < t[i]) {
        cout << 0 << endl;
        return 0;
      }
    } else {
      ans = (ans * min(a[i], t[i])) % MOD;
    }
  }
  if ( (t[n-2] < t[n-1] && t[n-1] != a[n-2]) || (t[n-1] < a[n-1]) ){
    cout << 0 << endl;
    return 0;
  }
  cout << ans << endl;
}

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

int main()
{
    int mm,dd;
    scanf("%d%d",&mm,&dd);
    int sum = 0;
    for(int m=1;m<=mm;m++)
    {
        for(int d=1;d<=dd;d++)
        {
            int d1 = d%10;
            int d10 = d/10;
            if(d1>=2&&d10>=2&&d1*d10==m)
                sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

int main() {
	int n, a;
	cin >> n;

	const int max_a = 1e6;
	vector<int> nums(max_a + 1, 0);

	for (int i = 0; i < n; i++) {
		cin >> a;
		nums[a]++;
	}

	int ans = 0;
	vector<bool> oks(max_a + 1, true);
	for (int i = 1; i < nums.size(); i++) {
		if (nums[i] > 0) {
			if (!oks[i]) {
				continue;
			}

			if (nums[i] == 1) {
				ans++;
			}
			for (int j = i; j < oks.size(); j += i) {
				oks[j] = false;
			}
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6840
#include <stdio.h>
#include <limits.h>

#ifndef KOTAISUU
#define KOTAISUU 13
#endif
#ifndef SEDAISUU
#define SEDAISUU 15000
#endif
#ifndef KAKURITU
#define KAKURITU 30 /* * 0.01 % */
#endif

#ifndef NO_ENABLE_REVERSE
#define ENABLE_REVERSE
#endif

static unsigned int x=123456789;
static unsigned int y=362436069;
static unsigned int z=521288629;
static unsigned int w=88675123;

void seed(unsigned int a,unsigned int b,unsigned int c,unsigned int d) {
	if((a|b|c|d)==0)return;
	x=a;y=b;z=c;w=d;
}

unsigned int randint(void) {
	unsigned int t;
	t=(x^(x<<11));
	x=y;y=z;z=w;
	w=(w^(w>>19))^(t^(t>>8));
	return w;
}

unsigned int randint2(unsigned int max) {
	unsigned int amari = ((UINT_MAX % max) + 1) % max;
	unsigned int ret;
	do {
		ret = randint();
	} while (ret < amari);
	return ret % max;
}

#define KIND 26
#define MAX 365

struct horieyui {
	int mamegu[MAX];
};

int D;
int c[KIND];
int s[MAX][KIND];

int mizuhasu(const struct horieyui* kitaeri) {
	int sumipe = 0;
	int i, j;
	int last[KIND] = {0};
	for (i = 0; i < D; i++) {
		sumipe += s[i][kitaeri->mamegu[i]];
		last[kitaeri->mamegu[i]] = i + 1;
		for (j = 0; j < KIND; j++) {
			sumipe -= c[j] * ((i + 1) - last[j]);
		}
	}
	return sumipe;
}

int main(void) {
	int i, j;
	struct horieyui otehon;
	struct horieyui saikyou;
	int saikyou_score = 0;
	if (scanf("%d", &D) != 1) return 1;
	for (i = 0; i < KIND; i++) {
		if (scanf("%d", &c[i]) != 1) return 1;
	}
	for (i = 0; i < D; i++) {
		for (j = 0; j < KIND; j++) {
			if (scanf("%d", &s[i][j]) != 1) return 1;
		}
	}

	for (i = 0; i < KIND; i++) {
		int score;
		for (j = 0; j < D; j++) otehon.mamegu[j] = (i + j) % KIND;
		score = mizuhasu(&otehon);
		if (i == 0 || score > saikyou_score) {
			saikyou = otehon;
			saikyou_score = score;
		}
	}
#ifdef ENABLE_REVERSE
	for (i = 0; i < KIND; i++) {
		int score;
		for (j = 0; j < D; j++) otehon.mamegu[j] = (i - (j % KIND) + KIND) % KIND;
		score = mizuhasu(&otehon);
		if (score > saikyou_score) {
			saikyou = otehon;
			saikyou_score = score;
		}
	}
#endif
	otehon = saikyou;

	for (i = 0; i < SEDAISUU; i++) {
		struct horieyui saituyo;
		int saituyo_score = 0;
		for (j = 0; j < KOTAISUU; j++) {
			struct horieyui kore = otehon;
			int k;
			int score;
			for(k = 0; k < D; k++) {
				if (randint2(10000) < KAKURITU) {
					kore.mamegu[k] = randint2(KIND - 1);
					if (kore.mamegu[k] >= otehon.mamegu[k]) kore.mamegu[k]++;
				}
			}
			score = mizuhasu(&kore);
			if (j == 0 || score > saituyo_score) {
				saituyo = kore;
				saituyo_score = score;
			}
		}
#ifdef NO_FORCE_UPDATE
		if (saituyo_score > saikyou_score)
#endif
		otehon = saituyo;
		if (saituyo_score > saikyou_score) {
#ifdef PRINT_UPDATE
			fprintf(stderr, "update at generation %d : %d -> %d\n", i + 1, saikyou_score, saituyo_score);
#endif
			saikyou = saituyo;
			saikyou_score = saituyo_score;
		}
	}
	for (i = 0; i < D; i++) {
		printf("%d\n", saikyou.mamegu[i] + 1);
	}
#ifdef PRINT_SCORE
	printf("score = %d\n", saikyou_score < -1000000 ? 0 : 1000000 + saikyou_score);
#endif
	return 0;
}


Measured memory_bytes: 1772
N = int(input())
H = list(map(int, input().split()))
height_memo = [float('inf')] * N
height_memo[0] = 0
height_memo[1] = abs(H[1] - H[0])

for i in range(N - 2):
    height_memo[i + 2] = min(height_memo[i] + abs(H[i + 2] - H[i]),
                             height_memo[i + 1] + abs(H[i + 2] - H[i + 1]))

print(height_memo[N - 1])

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

int main()
{
	long long n, x, ans = 0;
	cin >> n;
	map<long long,long long> freq;
	for(int i=0; i<n; i++)
	{
		cin >> x;
		ans += freq[i-x];
		freq[i+x]++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 26140
#include <iostream>
#include <vector>
#include <cstdint>
using namespace std;

int main() {
    uint64_t sum = 0;
    uint32_t n; cin >> n;
    vector<uint32_t> t(n);
    for (auto &e : t) {
        cin >> e;
        sum += e;
    }
    uint32_t m; cin >> m;

    uint32_t p, x;
    while (m--) {
        cin >> p >> x;
        cout << (sum - t[p - 1] + x) << endl;
    }
}



Measured memory_bytes: 3636
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let a: usize = sc.read();
    let s = sc.read::<String>();
    if a < 3200 {
        println!("red");
    } else {
        println!("{}", s);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a==b && a!=c)
        cout<<"Yes";
    else if(a==c && a!=b)
        cout<<"Yes";
    else if(b==c && b!=a)
        cout<<"Yes";
    else
        cout<<"No";
        
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        String S = sc.next();
	        char[]c = S.toCharArray();
	        int N = c.length;
	        
	        char[] ab = new char[N];
	        int[] x = new int[N+5];
	        int cntx=0;
	        int cntab=0;
	        for(int i=0;i<N;i++) {
	        	if(c[i]=='x') {
	        		x[cntx]++;
	        	} else {
	        		ab[cntab]=c[i];
	        		cntab++;
	        		cntx++;
	        	}
	        }
	        
	        for(int i=0;i<cntab/2;i++) {
	        	if(ab[i]!=ab[cntab-1-i]) {
	        		System.out.println(-1);
	        		return;
	        	}
	        }
	   	 	int ans=0;
	        for(int i=0;i<(cntx+1)/2;i++) {
	        	ans=ans+Math.abs(x[i]-x[cntx-i]);
	        }
	   	 	
	   	 System.out.println(ans);
	 }
	 

}

Measured memory_bytes: 28844
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T, class U>
inline void chmin(T &t, U f) { if (t > f)t = f; }

template<class T, class U>
inline void chmax(T &t, U f) { if (t < f)t = f; }

typedef pair<int, int> P;
typedef long long LL;
const LL INF = LLONG_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
const int MAXN = 100001;

/*struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};*/

//-----Template---------
int h, w;
char color[301][301];
LL dp[301][301];
LL cost[301][301];
LL ans[301];
LL sum = 0;
string tmpS;

int main() {
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        cin >> tmpS;
        for (int j = 0; j < w; ++j) {
            color[i][j] = tmpS[j];
        }
    }


    for (int i = 0; i < w - 1; ++i) {     //2列毎の最小コストを求める
        for (int j = 0; j <= h; ++j) {   //先にcostテーブルを作っておく．
            // 毎回計算するとdp更新にO(h)かかってTLE
            //cost[i][j]:i,j押されているときに
            //どちらかの列を押すコスト(2列の内どちらを押しても同じコスト)
            for (int k = 0; k <= h; ++k) {
                if (j == 0 || k == 0) {
                    LL tmp = 0;
                    for (int l = 0; l < h; ++l) {//0 .. h-1まで回して，変なとこを飛ばす
                        if (l - j >= 0 && l - k >= 0 && color[l - j][i] == color[l - k][i + 1])
                            tmp++;
                    }
                    cost[j][k] = tmp;
                } else {
                    cost[j][k] = cost[j - 1][k - 1] - (color[h - j][i] == color[h - k][i + 1] ? 1 : 0);
                }
            }
        }
        for (int j = 0; j <= h; ++j) {
            for (int k = 0; k <= h; ++k) {
                dp[j][k] = INF;
            }
        }
        dp[0][0] = 0;
        for (int j = 0; j <= h; ++j) {
            for (int k = 0; k <= h; ++k) {
                LL tmpA = j > 0 ? dp[j - 1][k] + cost[j - 1][k] : INF;
                LL tmpB = k > 0 ? dp[j][k - 1] + cost[j][k - 1] : INF;
                chmin(dp[j][k], min(tmpA, tmpB));
            }
        }
        sum += dp[h][h];
    }
    cout << sum << endl;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

vector<int> smalls;
vector<int> bigs;

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

    smalls.resize(N);
    bigs.resize(N);
    for (int i = 0; i < N; i++) {
        int A, B;
        cin >> A >> B;
        smalls[i] = A;
        bigs[i] = B;
    }
    sort(smalls.begin(), smalls.end());
    sort(bigs.begin(), bigs.end());

    if (N % 2 == 0) {
        int l = smalls[N / 2 - 1] + smalls[N / 2];
        int r = bigs[N / 2 - 1] + bigs[N / 2];
        cout << r - l + 1 << endl;
    } else {
        int l = smalls[N / 2];
        int r = bigs[N / 2];
        cout << r - l + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 4800
li = list(input())
li_even = ["L", "U", "D"]
li_odd = ["R", "U", "D"]
flag = True

for i in range(1, len(li)+1):
    if i%2 == 0: 
        if li[i-1] not in li_even:
            flag = False
            break
    else: 
        if li[i-1] not in li_odd:
            flag = False
            break
            
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
//void Multi_verse(ll a,ll b,ll &x_curr,ll &y_curr){
//    if(b == 0){
//        x_curr = 1;
//        y_curr = 0;
//        return;
//    }
//    ll x_next,y_next;
//    Multi_verse(b,a%b,x_next,y_next);
//    x_curr = y_next;
//    y_curr = x_next - (a/b)*y_next;
//    return;
//}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll nCk(ll n, ll k) {
    ll res = 1LL;
    if (k < 0 || n < 0) return res;
    for (ll i = n; i > n - k; --i) {
        res *= i;
        res %= MOD;
    }
    for (ll i = k; i > 0; --i) {
        res %= MOD;
        res *= modinv(i, MOD);
    }
    return res;
}


//ll Binomial_Coeff_modulo(ll n,ll r)
//{
//    if(r<0 || n<0)  return 0;
//    if(n-r<r)   r = n-r;
//    ll numerator = 1,denominator = 1,sum = 1;
//    for(ll i=0;i<r;i++){
//        numerator = (numerator*(n-i)%MOD)%MOD;
////        ll y,mod_inverse;
////        Multi_verse(i+1,MOD,mod_inverse,y);
//        denominator = (denominator*(modinv(i+1,MOD))%MOD)%MOD;
//    }
//    sum = (numerator*denominator)%MOD;
//    return sum;
//
//}
int main()
{
    //freopen("in.txt","r",stdin);
    int n,r,b;
    cin >> n >> b;
    ll sum;
    r = n-b;
    for(int i=1;i<=b;i++){
        //sum = (Binomial_Coeff_modulo(r+1,i)*Binomial_Coeff_modulo(b-1,i-1))%MOD;
        sum = (nCk(r+1,i)*nCk(b-1,i-1))%MOD;
        cout << sum << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
#define INF 1e12
#define MOD 1e9+7
typedef long long ll;
using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> a(n + 1);
	rep1(i, n)cin >> a[i];
	vector<int> c(n + 1, -1);
	for (int i = n; i >= 1; i--)
	{
		int c_sum = 0;
		for (int j = 2; i * j <= n; j++)
		{
			c_sum += c[i * j];
		}
		c[i] = (c_sum + a[i]) % 2;
	}
	vector<int> ans;
	rep1(i, n)
	{
		if (c[i] == 1)ans.push_back(i);
	}
	int m = ans.size();
	co(m);
	rep(i, m)cs(ans[i]);
	return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forN(i, n) for(int i = 0; i <n ; ++i)
#define endl "\n"
#define noob (main)
typedef long long ll;
using namespace  std;
typedef vector<ll> vi;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const int N = 1e5 + 5 ;
ll  n , A[N] , B[N];

int noob(){
    fastIO;
    cin>>n;
    for(int i = 0 ; i<n+1 ; i++){
        cin>>A[i];
    }
    for(int i = 0 ; i<n ; i++){
        cin>>B[i];
    }

    ll ans = 0 ;
    for(int i = 0 ; i<n ; i++){
        if(B[i]<=A[i]){
            ans+=B[i];
//            ll temp = A[i];
            A[i]-=B[i];
            B[i] = 0;
        }
        else{
            ans+=A[i];
            B[i]-=A[i];
            A[i]=0;
        }
        if(B[i]){
            if(B[i]<=A[i+1]){
                ans+=B[i];
                ll temp = A[i+1];
                A[i+1]-=B[i];
                B[i]-=temp;
            }
            else{
                ans+=A[i+1];
                B[i]-=A[i+1];
                A[i+1]=0;
            }
        }
    }
    cout<<ans;
//    for(int i = 0 ; i<n+1 ; i++){
//        cout<<A[i]<<" ";
//    }
//    cout<<endl;
//    for(int i = 0 ; i<n ; i++){
//        cout<<B[i]<<" ";
//    }

}

Measured memory_bytes: 5208
/*
ID: wangjun30
TASK:
LANG: C++
*/
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,k,minv=0x7FFFFFFF;
	cin>>n>>k;
	int num[n];
	for(int i=0;i<n;i++)
		cin>>num[i];
	sort(num,num+n);
	for(int i=0;i<=n-k;i++)
		minv=min(minv,num[i+k-1]-num[i]);
	cout<<minv;
	return 0;
}

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

int main() {
  string S;
  cin >> S;

  int diff = 753;
  for (int i=2; i<S.size(); i++) {
    int n = stoi(S.substr(i-2, 3));
    diff = min(diff, abs(753 - n));
  }

  cout << diff << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
	int  a, b, c;
	int  rectangle = 0, lozenges = 0;
	char comma;
	while (std::cin >> a >> comma >> b >> comma >> c) {
		if (a*a + b*b == c*c) { // もし直角三角形なら
			rectangle++;
		}
		else if (a == b) {
			lozenges++;
		}
	}
	std::cout << rectangle << '\n' << lozenges << std::endl;
}

Measured memory_bytes: 1160
n = int(input())
s = [input() for i in range(n)]
dic={}
count=0
for i in range(n):
  s[i] = sorted(s[i],key=str)
  s[i] = ''.join(s[i])
  if(s[i] in dic.keys()):
    count=count+dic[s[i]]
    dic[s[i]] = dic[s[i]] + 1
  else:
    dic[s[i]] = 1
print(count)

Measured memory_bytes: 19472
n = int(input())
aes = list(map(int, input().split()))
q = int(input())
bs = []
cs = []
for _ in range(q):
  b,c = map(int, input().split())
  bs.append(b)
  cs.append(c)


counts = [0] * 110000

for a in aes:
  counts[a] += 1

ans = 0
for i, c in enumerate(counts):
  ans += i * c

for i in range(q):
  p = counts[bs[i]]
  counts[bs[i]] = 0
  ans -= bs[i] * p
  counts[cs[i]] += p
  ans += cs[i] * p
  print(ans)



Measured memory_bytes: 22020
import sys
input = sys.stdin.buffer.readline

K, Q = map(int, input().split())
D = list(map(int, input().split()))
NXM = [list(map(int, input().split())) for _ in range(Q)]

for N, X, M in NXM:
    E = [d % M for d in D]
    cnt0 = 0
    tmp0 = 0
    for e in E:
        if e > 0:
            cnt0 += 1
            tmp0 += e
    cnt = ((N - 1) // K) * cnt0
    tmp = ((N - 1) // K) * tmp0
    for i in range((N - 1) % K):
        if E[i] > 0:
            cnt += 1
        tmp += E[i]
    tmp += X % M
    print(cnt - tmp // M)

Measured memory_bytes: 69468
{-# LANGUAGE BangPatterns #-}
module Main where
import Data.Hashable
import qualified Data.Vector as V
import Data.ByteString.Char8 as B
import Data.Monoid
import qualified Data.HashMap.Strict as HM

main = do
  n <- readLn
  let go 0 acc m = print acc
      go n acc m = do
        str <- B.sort <$> B.getLine
        let !acc' = maybe acc (acc+) $ HM.lookup str m
        go (n-1) acc' $! HM.insertWith (+) str 1 m
  go (n :: Int) 0 HM.empty


Measured memory_bytes: 428924
#include<cstdio>

int main(){
  int a,b,c,h,i,j;
  j=0;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    h=c%i;
    if(h==0)
      j++;
  }
  printf("%d\n",j);
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 210;
int N, M, R;
int g[maxn][maxn], d[maxn][maxn];
bool vis[maxn];
vector<int> r;

void dij(int s) {
    memset(vis, 0, sizeof(vis));
    while(1) {
        int v = -1;
        for(int i = 0; i < N; ++i) {
            if(!vis[i] && (v == -1 || d[s][i] < d[s][v]))
                v = i;
        }
        if(v == -1) break;
        vis[v] = true;
        for(int i = 0; i < N; ++i)
            d[s][i] = min(d[s][i], d[s][v] + g[v][i]);
    }
}

int main(void) {
    scanf("%d%d%d", &N, &M, &R);
    for(int i = 0; i < N; ++i) {
        g[i][i] = d[i][i] = 0;
        for(int j = i + 1; j < N; ++j) {
            g[i][j] = g[j][i] = inf;
            d[i][j] = d[j][i] = inf;
        }
    }
    for(int i = 0; i < R; ++i) {
        int x; scanf("%d", &x);
        r.push_back(x - 1);
    }
    for(int i = 0; i < M; ++i) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        a--; b--;
        g[a][b] = g[b][a] = min(g[a][b], c);
    }
    for(int i = 0; i < R; ++i) dij(r[i]);
    sort(r.begin(), r.end());
    int ans = inf;
    do {
        int t = 0;
        for(int i = 0; i < R - 1; ++i)
            t += d[r[i]][r[i + 1]];
        ans = min(ans, t);
    } while(next_permutation(r.begin(), r.end()));
    printf("%d\n", ans);
}

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

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

  vector< pair<int, int> > ab(n);
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    ab[i] = make_pair(a, b);
  }

  sort(ab.begin(), ab.end(), [&](pair<int, int> first, pair<int, int> second) {
      if (first.first == second.first) {
	return first.second > second.second;
      }
      return first.first < second.first;
    });

  priority_queue<int> q;
  int cur = 0;
  int ans = 0;
  for (int i = 1; i <= m; ++i) {
    while (cur < n) {
      if (ab[cur].first != i) break;
      q.push(ab[cur++].second);
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1660
class Point{
	double x,y,z;
	
	Point(double x, double y, double z)
	{
		this.x = x; this.y = y; this.z = z;
	}
	
	Point cross(Point t){
		return new Point(y*t.z-z*t.y, z*t.x-x*t.z, x*t.y-y*t.x);
	}
	
	Point to(Point t){
		return new Point(t.x-x,t.y-y,t.z-z);
	}
	
	Point from(Point t){
		return new Point(t.x+x,t.y+y,t.z+z);
	}
	
	double dot(Point t){
		return x*t.x + y*t.y + z*t.z;
	}
	
	double len(){
		return Math.sqrt(x*x+y*y+z*z);
	}
	
	Point unit(){
		double len = this.len();
		return new Point(this.x / len, this.y / len, this.z / len);
	}
	
	Point extend(double mag)
	{
		return new Point(this.x * mag, this.y * mag, this.z * mag);
	}
	
	public String toString(){
		String ret = "("+x+" "+y+" "+z+")";
		return ret;
	}
}

class Main {
	
	public static void main(String [] args)
	{
		java.util.Scanner sc = new java.util.Scanner(System.in);
		
		Point advance = new Point(sc.nextDouble(), sc.nextDouble(), sc.nextDouble());
		Point enemy = new Point(sc.nextDouble(), sc.nextDouble(), sc.nextDouble());
		Point[] tri = new Point[3];
		for(int i = 0; i < tri.length; ++i){
			tri[i] = new Point(sc.nextDouble(), sc.nextDouble(), sc.nextDouble());
		}
		
		Point a = tri[0].to(tri[1]);
		Point b = tri[0].to(tri[2]);
		Point f = a.cross(b).unit();
		
		boolean miss = true;
		double n1 = f.dot(enemy.to(tri[0]));
		double n2 = f.dot(advance.to(tri[0]));
		
		if( equals(n1, 0) && isOnBarrier(enemy, tri) ) {
			// enemy is on the barrier
			
		} else if ( equals(n1,0) || n1 * n2 > 0 ) {
			// enemy and adv same side
			
			miss = false;
		} else {
			// enemy and adv on oppsite side
			
			Point v = enemy.to(advance);
			Point cp = v.unit().extend( v.len() * (Math.abs(n1)/(Math.abs(n1)+Math.abs(n2))) ).from(enemy);
			// System.out.println( cp );
			if( !isOnBarrier(cp, tri) ) {
				miss = false;
			}
		}
		
		if ( miss ) {
			System.out.println("MISS");
		} else {
			System.out.println("HIT");
		}
	}
	
	private static boolean equals(double a, double b)
	{
		return Math.abs(b-a) < 0.00000001;
	}

	private static boolean isOnBarrier(Point cp, Point [] tri)
	{
		boolean ret = true;
		int sign = 0;
		Point a = tri[0].to(tri[1]);
		Point b = tri[0].to(tri[2]);
		Point f = a.cross(b).unit();

		for(int i = 0; i < 3; ++i){
			Point t1 = tri[i].to(tri[ (i+1) % 3 ]);
			
			double cc = t1.cross(tri[i].to(cp)).dot(f);
			if( equals( cc, 0 ) ) {
				continue;
			}else if( sign == 0 ) {
				if( cc < 0 ) {
					sign = -1;
				} else {
					sign = 1;
				}
			}else{
				if( cc * sign < 0 ) {
					// HIT
					ret = false;
				}
			}
		}
		return ret;
	}
	
}

Measured memory_bytes: 18856
#include<iostream>

using namespace std;

int main()
{
    char x, y;

    cin>>x>>y;
    if(x>y)
    {
        cout<<">"<<endl;
    }
    else if (x<y)
    {
        cout<<"<"<<endl;
    }
    else
    {
        cout<<"="<<endl;
    }


    return 0;
}


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

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,c,x,y; cin>>a>>b>>c>>x>>y;
  
  ll ans=a*x+b*y;
  
  if(x<y) swap(x,y), swap(a,b);
  chmin(ans,c*x*2);
  chmin(ans,c*y*2+(x-y)*a);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n;
const ll INF = 1e15;
ll mn = INF;
int main()
{
    cin >> n;
    for (int i = 0; i < 5; i++)
    {
        ll x;
        cin >> x;
        mn = min(mn, x);
    }
    ll ans = n / mn;
    if (n % mn)
        ans++;
    cout << ans + 4 << endl;
}


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

int main(){
    long long n, a, b, c, d, ans=0;
    cin >> n;
    long long A[100010], B[100010], C[100010];
    for(long long i=0; i<n; i++){
        cin >> A[i];
    }
    for(long long i=0; i<n; i++){
        cin >> B[i];
    }
    for(long long i=0; i<n; i++){
        cin >> C[i];
    }
    sort(A, A+n);
    sort(B, B+n);
    sort(C, C+n);
    
    for(long long j=0; j<n; j++){
        a=-1; b=n;
        while(b-a>1){
            long long mid=(a+b)/2;
            if(A[mid]>=B[j]){
                b=mid;
            }
            else{
                a=mid;
            }
        }//aが答え
        c=-1; d=n;
        while(d-c>1){
            long long mid=(c+d)/2;
            if(C[mid]>B[j]){
                d=mid;
            }
            else{
                c=mid;
            }
        }//n-d答え
        ans += (n-d)*(b-0);
       // cout << b<< " " << (n-d)<<"\n";
    }


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

Measured memory_bytes: 2560
#include <stdio.h>
 
int main(void) {
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 584
#!/usr/bin/perl

use warnings; 


 
my $AC = 0;
my $WA = 0;
my $TLE = 0;
my $RE = 0;
while ($line = <STDIN>) {
    if ($line eq "AC\n" ) {
        $AC = $AC + 1;
    } elsif ($line eq "WA\n") {
        $WA = $WA + 1;
    } elsif ($line eq "TLE\n") {
        $TLE = $TLE + 1;
    } elsif ($line eq "RE\n") {
        $RE = $RE + 1;
    }
}
print ("AC x $AC\n");
print ("WA x $WA\n");
print ("TLE x $TLE\n");
print ("RE x $RE\n");


Measured memory_bytes: 5120
def insertion_sort(array):
    for i in range(len(array)):
        v = array[i]
        j = i - 1
        while j >= 0 and array[j] > v:
            array[j+1] = array[j]
            j -= 1
        array[j+1] = v
        print(' '.join(map(str, array)))
    return array

if __name__ == '__main__':
    n = int(input())
    array = list(map(int, input().split()))[0:n]
    insertion_sort(array)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
int a,b;
int main() {
	//freopen("1.txt","r",stdin);
	read(a); read(b);
	if (a==2||b==2) printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
k,A,B = gets.split.map(&:to_i)
if A+2 >= B
  p k + 1
  exit
end

ans = 1
if A > 1
  k -= (A-1)
  ans = A
end
if k.odd?
  k -= 1
  ans += 1
end
ans += k/2 * (B-A)
p ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    string ans = "z";
    ans[0]++;
    cin >> S >> T;
    for(int i = 0; i + T.size() <= S.size(); i++) {
        bool ok = true;
        string now = S;
        for(int j = 0; j < T.size(); j++) {
            if(S[i+j] == '?') {
                now[i+j] = T[j];
                continue;
            }
            if(S[i+j] == T[j]) continue;
            ok = false;
        }
        if(!ok) continue;
        for(int j = 0; j < now.size(); j++) {
            if(now[j] == '?') now[j] = 'a';
        }
        chmin(ans, now);
    }
    if(ans[0] == ('z' + 1)) cout << "UNRESTORABLE" << endl;
    else cout << ans << endl;
    return 0;
}


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

int main() {
    int h, w;
    int i, j;
    while (true) {
        cin >> h >> w;
        if (h == 0 && w == 0) {
            break;
        }
        for (i = 0; i < h; i++) {
            for (j = 0; j < w; j++) {
                if ((i + j) % 2 == 0) {
                    cout << "#";
                } else {
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3096