akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

ll floor_sqrt(ll x)
{
	ll lo=0,hi=INT_MAX;
	while(lo<hi){
		ll mi=(lo+hi)/2;
		if(mi*mi>x)
			hi=mi;
		else
			lo=mi+1;
	}
	return lo-1;
}

void test()
{
	for(int x=1;x<=30;x++){
		set<int> s;
		for(int a=1;a<=x;a++){
			int b=x/a;
			if(b) s.insert(b);
		}
		dump(x,s.size(),s);
		//dump(x,s.size(),floor_sqrt(4*x-1));
	}
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	//test();
	//return 0;

	for(int q;cin>>q&&q;){
		rep(_,q){
			int a,b; cin>>a>>b;
			ll x=(ll)a*b;
			ll res=floor_sqrt(4*((ll)a*b-1)+1)-1;
			if(a!=b) res--;
			cout<<res<<endl;;
		}
	}
}


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

namespace ConsoleApp30 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long A = st[0];
            long B  = st[1];
            long C = st[2];
            long D = st[3];

            long U_C = B / C - (A - 1) / C;
            long U_D = B / D - (A - 1) / D;
            long lcm = C * D / GCD(C, D);
            long U_CD = B / lcm - (A - 1) / lcm;

            Console.WriteLine((B - A + 1) - (U_C + U_D - U_CD));
        }

        static long GCD(long a, long b) {
            if (a >= b) {
                return GCDRecursive(a, b);
            } else {
                return GCDRecursive(b, a);
            }
        }

        static long GCDRecursive(long a, long b) {
            if (b == 0) {
                return a;
            }
            return GCDRecursive(b, a % b);
        }
    }
}

Measured memory_bytes: 11348
// ITP1_2_A: Small, Large, or Equal
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_A&lang=ja

fn main() {
    let v: Vec<i32> = read();

    if v[0] < v[1] {
        println!("a < b");
    } else if v[0] > v[1] {
        println!("a > b");
    } else {
        println!("a == b");
    }
}

fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let stdin = std::io::stdin();
    stdin.read_line(&mut buf).unwrap();
    return buf.split_whitespace().flat_map(str::parse).collect();
}


Measured memory_bytes: 5024
#include <stdio.h>
#define N 100

int main()
{
  int a[N], n, c=0, x = 0, i, j, minj=0;

  scanf("%d", &n);

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

  for(i=0; i<n; i++){
    minj=i;
    for(j=i; j<n; j++){
      if(a[j]<a[minj]){
	minj=j;
      }
    }
    if(i != minj){
    x = a[i];
    a[i] = a[minj];
    a[minj] = x;
    c++;
    }
  }

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

  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define int long long int
map<char,int> m;
int32_t main(){
	string s;
  	cin>>s;
  	for(int i=0;i<s.length();i++){
    	m[s[i]]++;
    }
  	int mn = min({m['a'],
                  m['b'],
                  m['c']});
  	int mx = max({m['a'],
                  m['b'],
                  m['c']});
  	if((mx-mn)>1){
    	cout<<"NO";
    }
  	else {
    	cout<<"YES";
    }
}

Measured memory_bytes: 512
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
    s=input()
    if s=='AC':
        ac+=1
    elif s=='WA':
        wa+=1
    elif s=='TLE':
        tle+=1
    elif s=='RE':
        re+=1
print('AC x ',ac)
print('WA x ',wa)
print('TLE x ',tle)
print('RE x ',re)


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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

ll mod(1000000007);
double pi(acos(-1.0));

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  int k, a, b;
  cin >> k >> a >> b;
  while (a <= b) {
    if (a % k == 0) {
      cout << "OK";
      return 0;
    }
    a++;
  }

  cout << "NG";

  return 0;
}


Measured memory_bytes: 3612
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long ans = 0;
		long buf = 0;
		while(H > 0){
			H /= 2;
			ans += Math.pow(2,buf);
			buf++;
		}
		System.out.println(ans);
	}
}

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

int main(){
    string S; cin >> S;
    int ans;
    int cnt=S.size();
    S.erase(S.size()-1,1);
    
    rep(i,cnt){
        bool check=false;
        if(S.size()%2==0){
            int j=0;
            int k=S.size()/2;
            rep(i,S.size()/2){
                if(S[j]!=S[k]){
                    check=false;
                    S.erase(S.size()-1,1);
                    break;
                }else{
                    j++;
                    k++;
                    check=true;
                }
            }
            
            if(check){
                ans=S.size();
                cout << ans;
                return 0;
            }
        }else{
            S.erase(S.size()-1,1);
        }
    }
}

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

using namespace std;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(NULL);
    int n,i,j;
    cin >> n;
     double dp[n/2 +1][n+1];
     double arr[n];
    dp[0][0] = 1.0;
    for(i=0;i<n;i++){
        cin >> arr[i];
        dp[0][i+1] = dp[0][i] * arr[i];
    }
   
    for(i=1;i<=n/2;i++){
        dp[i][0]=0.0;
        for(j=1;j<=n;j++){
            if(j < i)
            dp[i][j]=0;
            else
            dp[i][j] = ((1-arr[j-1]) * dp[i-1][j-1]) + (arr[j-1] * dp[i][j-1]);
        }
        dp[i][j-1] += dp[i-1][j-1];
    }
    cout << setprecision(10) << dp[n/2][n];
    return 0;
}

Measured memory_bytes: 35456
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

bool check(string str) {
  REP(i, str.size()) {
    if (str[i] != str[str.size() - 1 - i]) {
      dump(i, str.size() - 1 - i);
      return false;
    }
  }
  return true;
}

void solve(string s) {
  string ss = "";
  REP(i, s.size()) {
    if (s[i] != 'x')
      ss += s[i];
  }
  if (check(s)) {
    cout << "0" << endl;
    return;
  }

  deque<int> que;
  REP(i, s.size()) { que.push_back(s[i]); }

  ll ans = 0;
  while (que.size() >= 2) {
    if (que.front() == que.back()) {
      que.pop_front();
      que.pop_back();
      continue;
    }
    if (que.front() == 'x') {
      ans++;
      que.pop_front();
      continue;
    }
    if (que.back() == 'x') {
      ans++;
      que.pop_back();
      continue;
    }
    cout << "-1" << endl;
    return;
  }

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  solve(s);
  return 0;
}


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

const int INF = 1001001001;

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> dp(h+1, INF);
  dp[0] = 0;
  rep(i,n) {
    int a, b;
    cin >> a >> b;
    rep(j,h) {
      int nj = min(j+a,h);
      dp[nj] = min(dp[nj], dp[j]+b);
    }
  }
  cout << dp[h] << endl;
  return 0;
}

Measured memory_bytes: 256
n, h = list(map(int, input().split()))
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
    a[i], b[i] = list(map(int, input().split()))
f = max(a)
b.sort()
for i in range(n):
    if b[i] <= f:
        b[i] = 0
    else:
        break

total = 0
count = 0
b.reverse()
for i in range(n):
    if b[i] == 0:
        break
    total += b[i]
    count += 1
    if total >= h:
        print(count)
        exit()
if (h - total) % f == 0:
    count += (h - total) // f
else:
    count += (h - total) // f
    count += 1
print(count)


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

int main() {
  long long n,ans = 0;
  cin >> n;
  if(n%2 == 1){
    cout << 0 << endl;
  }
  else{
    for(long long i = 5;i <= n;i *= 5){
      ans += n/(2*i);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var str string
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%s", &str)
	chars := strings.Split(str, "")

	ans := 0
	for _, c := range chars {
		if c == "+" {
			ans++
		} else {
			ans--
		}
	}
	fmt.Println(ans)
}


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

using namespace std;

int a[200005], st[200005];

int main() {
	int n;
	long long k;
	scanf("%d%lld", &n, &k);
	
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	
	vector <int> path;
	int cur = 1;
	int t = 1;
	
	while (k--) {
		path.push_back(cur);
		st[cur] = t;
		cur = a[cur];
		if (st[cur] != 0) break;
		t++;
	}
	
	if (k) {
		int cycle = t - st[cur] + 1;
		k %= cycle;
		for (int i = 0; i < k; i++) {
			cur = a[cur];
		}
	}
	
	printf("%d\n", cur);
}


Measured memory_bytes: 5840
#include<bits/stdc++.h>
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
int main(){
  int n;cin>>n;
  int sum=0;
  int t[n];rep(i,n){cin>>t[i];sum+=t[i];}
  int m;cin>>m;
  int p[m],x[m];
  rep(i,m){
    cin>>p[i]>>x[i];
    cout<<sum-(t[p[i]-1]-x[i])<<endl;
  }
}

Measured memory_bytes: 256
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
import math
f = (a1-b1)*t1
s = (a2-b2)*t2
if f == -s:
  print("infinity")
elif (f>0 and f+s>0) or (f<0 and f+s<0):
  print(0)
elif f//(-(f+s)) == math.ceil(f/(-(f+s))):
  print(f//(-(f+s))*2)
else:
  print(f//(-(f+s))*2+1)

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

const int MAXN = 1111;
const int MAXX = 400;

struct Application {
  int s, t, w;
  bool operator < (const Application &a) const {
    return s < a.s;
  }
};

int N;
Application ap[MAXN];
int dp[MAXX][MAXX];

int main() {
  while (cin >> N && N) {
    for (int i = 0; i < N; ++i) {
      cin >> ap[i].s >> ap[i].t >> ap[i].w;
    }
    sort(ap, ap+N);
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < N; ++i) {
      for (int j = MAXX-1; j >= 0; --j) {
        for (int k = MAXX-1; k >= 0; --k) {
          if (j <= ap[i].s) {
            dp[ap[i].t+1][k] = max(dp[ap[i].t+1][k], dp[j][k] + ap[i].w);
          }
          if (k <= ap[i].s) {
            dp[j][ap[i].t+1] = max(dp[j][ap[i].t+1], dp[j][k] + ap[i].w);
          }
        }
      }
    }
    cout << *max_element(dp[0], dp[MAXX]) << endl;
  }
  return 0;
}

Measured memory_bytes: 1820
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int n, ans=1, tmp;
    cin >> n;
    vi p(n);
    rep(i, n){
        cin >> p[i];
        if(i==0){
            tmp = p[i];
        }
        if(i>0&&p[i]<tmp){
            ans++;
            tmp = p[i];
        }
    }   
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

struct Point{
  int x,y;
  bool isRed;
  bool operator < (const Point &p) const {
    return x > p.x;
  }
};

priority_queue<Point> pq;
vector<Point> vp;

int main(){
  int n;
  cin>>n;
  for(int i=0;i<2*n;i++){
    Point p;
    cin>>p.x>>p.y;
    if(i<n) p.isRed = true;
    else p.isRed = false;
    pq.push(p);
  }

  int ans = 0;
  while(!pq.empty()){
    Point p = pq.top();
    pq.pop();
    //cout<<p.x<<" "<<p.y<<" "<<p.isRed<<endl;
    if(p.isRed){
      vp.push_back(p);
    } else {
      int t = -1;
      int num = -1;
      for(int i=0;i<(int)vp.size();i++){
        if((p.y > vp[i].y) && (num < vp[i].y)){
          t = i;
          num = vp[i].y;
        }
      }
      if(t > -1){
        ans ++;
        vp.erase(vp.begin()+t);
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

void main(){
    while(true) {
        auto n = readInt();
        if(n < 0) {
            return;
        }
        string s;
        while(n > 0) {
            s = (n%4).to!string ~ s;
            n /= 4;
        }
        if(s.empty()) {
            s = "0";
        }
        writeln(s);
    }
}

Measured memory_bytes: 2660
#include<bits/stdc++.h>
using namespace std;
int a[8]={1,2,4,8,16,32,64,128};
int main(){
	int n;
	cin>>n;
    for(int i=0;i<8;i++)
    	if(a[i]>n){
    		cout<<a[i-1];
    		break;
		}
    return 0;
}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
    string n;
    cin >> n;
    VI op(4,0);
    for (int i = 0; i < 4; i++) {
        op[i] = n[i] - '0';
    }
    for (int i = 0; i < (1 << 3); i++) {
        int ans = op[0];
        for (int j = 0; j < 3; j++) {
            if (i & (1 << j)) {
                ans += op[j+1];
            }
            else {
                ans -= op[j+1];
            }
        }
        if (ans == 7) {
            string ret = "";
            for (int j = 0; j < 3; j++) {
                ret += to_string(op[j]);
                if (i & (1 << j)) {
                    ret += "+";
                }
                else {
                    ret += "-";
                }
            }
            ret += to_string(op[3]);
            ret += "=7";
            cout << ret << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h> 

int main()
{

    char a[200001];
    char b[200001];

    int sum=0;

    scanf("%s", a);
    scanf("%s", b);

    for (int i = 0;a[i]!='\0'; i++)
    {
        if (strncmp(&b[i], &a[i], 1) != 0){
            sum++;
        }
    }

    printf("%d\n", sum);
}

Measured memory_bytes: 2516
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    for(int i = 1; i <= 360; ++i){
        if((i*x)%360 == 0){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3604
while(True):
    try:
        x1,y1,x2,y2,x3,y3,xp,yp = map(float, input().split())
        c1 = (x2-x1)*(yp-y1)-(y2-y1)*(xp-x1)
        c2 = (x3-x2)*(yp-y2)-(y3-y2)*(xp-x2)
        c3 = (x1-x3)*(yp-y3)-(y1-y3)*(xp-x3)
        if (c1<0 and c2<0 and c3<0) or (c1>0 and c2>0 and c3>0):
            print("YES")
            continue
        print("NO")
    except:
        break


Measured memory_bytes: 5588
import math

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

total = 0
for i in range(N):
	for j in range(N):
		if i == j or i < j:
			continue

		distance = math.sqrt(sum([(y - z)**2 for y, z in zip(X[i], X[j])]))
		if distance.is_integer():
			total += 1

print(total)


Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		if((B - A) % 2 == 0){
			Console.WriteLine((B - A) / 2);
		} else {
			long minOne = Math.Min(A - 1, N - B);
			long ans = minOne + 1 + (B - A - 1)/2;
			Console.WriteLine(ans);
		}
		
		
	}
	long N,A,B;
	public Sol(){
		var d = rla();
		N = d[0]; A = d[1]; B = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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


Measured memory_bytes: 3120
// Created by martinezdiego on 27/5/19

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  map<string, vector<pair<int,int>>> m;
  for (int i = 0; i < n; i++) {
    string s;
    int p;
    cin >> s >> p;
    m[s].push_back({ p, i + 1});
  }
  for (auto & i : m) sort(i.second.begin(), i.second.end(), greater<pair<int,int>>());
  for (auto i : m) for (auto j : i.second) cout << j.second << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define maxn 300001
const long long mod = 998244353;
long long jc[maxn],inv[maxn]; 
long long pow(long long a, long long r){
	a %= mod;
	long long ret = 1;
	while(r){
		if(r & 1) ret = ret * a % mod;
		a = a * a % mod;
		r >>= 1;
	}
	return ret;
}
long long C(int m, int n){
	return jc[m] * inv[n] % mod * inv[m - n] % mod;
}
int main(){
	long long N, A, B, K, ans = 0;
	scanf("%lld %lld %lld %lld", &N, &A, &B, &K);
	jc[0] = inv[0] = 1;
	for(int i = 1; i <= N; i += 1) inv[i] = pow(jc[i] = jc[i - 1] * i % mod, mod - 2);
	for(int i = 0; i <= N && i * A <= K; i += 1){
		if((K - i * A) % B) continue;
		if((K - i * A) / B > N) continue;
		int j = (K - i * A) / B;
		ans += C(N, i) * C(N, j) % mod;
		ans %= mod;
	}
	printf("%lld", ans);
}

Measured memory_bytes: 4864
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

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

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

// NとAが少ないから枝狩り全探索かな
// 枝狩りだからdpだな

int main() {
    int N, A;
    cin >> N >> A;
    vector<int> x(N);
    repeat(i, N) cin >> x[i];
    auto dp = vectors(0LL, N + 1, N * A + 1);
    dp[0][0] = 1;
    for (int xi : x) {
        for (int i = N - 1; i >= 0; --i) {
            repeat(j, N * A + 1) {
                if (j - xi >= 0) {
                    dp[i + 1][j] += dp[i][j - xi];
                }
            }
        }
    }

    // 1枚,2枚、...選んだ時に平均がAになる通りを足していく
    long long res = 0;
    repeat_from(i, 1, N + 1) {
        res += dp[i][i * A];
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4220
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a,b;
		char c;
		while(sc.hasNext()) {
			a = sc.nextInt();
			c = sc.next().toCharArray()[0];
			b = sc.nextInt();
			if(c == '+') System.out.println(a+b);
			else if(c == '-') System.out.println(a-b);
			else if(c == '/') System.out.println(a/b);
			else if(c == '*') System.out.println(a*b);
			else if(c == '?') break;
		}
	}
	
}



Measured memory_bytes: 26240
import std.stdio, std.conv, std.math, std.string, std.range, std.array,
       std.algorithm;

bool checkgood(char[][] a, int shift) {
    size_t n(size_t x) {
        return x % a.length;
    }

    for (size_t i = 0; i < a.length; ++i) {
        for (size_t j = i+1; j < a[0].length; ++j) {
            if(a[n(i + shift)][n(j)] != a[n(j + shift)][n(i)]) {
                return false;
            }
        }
    }
    return true;
}

void main(){
    auto buf = readln().strip().split().map!(to!int)();
    immutable N = buf[0];

    char[][] a;
    a.length = N;

    int ans;

    foreach(immutable int i; 0 .. N) {
        a[i] = readln().strip().map!(to!(char))().array;
    }

    for (int i = 0; i < N; ++i) {
        if (checkgood(a, i)) {
            ans ++;
        }
    }

    writeln(ans * N);
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define sz size()
#define pb push_back
#define mp make_pair
#define ALL(X) (X).begin(),(X).end()

using namespace std;

const int INF = 1000000000;
const double eps = 1e-8;

int main(void) {
  while(1){
    int n;
    cin>>n;
    if(n==0)break;
    vector<int> a(n);
    REP(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    int sum = 0;
    FOR(i,1,n-1)sum+=a[i];
    cout<<sum/(n-2)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N; R(N);
    string s,t;
    R(s,t);
    string an;
    REP(i,N){
        an+=s[i];
        an+=t[i];
    }
    W(an);
    return 0;
}


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

using namespace std;
typedef long long int lli;

lli power(lli a, lli b){
    if(b==0){
        return 1;
    }
    if(b&1){
        return a*power(a*a,b/2);
    }
    return power(a*a,b/2);
}


void solve(){
    int n,m;
    cin>>n>>m;
    char g[n][m];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin>>g[i][j];
        }
    }
    lli ans[n][m]={0};
    memset(ans, 0, sizeof(ans));
    for(int i=0; i<n; i++){
        if(g[i][0]=='.'){
            ans[i][0]=1;
        }
        else{
            break;
        }
    }
    for(int i=0; i<m; i++){
        if(g[0][i]=='.'){
            ans[0][i]=1;
        }
        else{
            break;
        }
    }
    for(int i=1; i<n; i++){
        for(int j=1; j<m; j++){
            if(g[i][j]=='.'){
                ans[i][j]=(ans[i][j-1]+ans[i-1][j])%MOD;
            }
            else{
                ans[i][j]=0;
            }
        }
    }
    // for(int i=0; i<n; i++){
    //     for(int j=0; j<m; j++){
    //         cout<<ans[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<ans[n-1][m-1]<<endl;
}

signed main(){
    // #ifndef ONLINE_JUDGE
    // //for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // //for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
}


Measured memory_bytes: 12324
import sys
import copy
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(input().strip())
s = input().strip()
ans = 0
cnt = 0
for i in s:
    if i == "I": cnt += 1 
    else: cnt -= 1
    ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 9116
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct {
	int solved[10];
	int penalty[10];
} team_work_data_t;

typedef struct {
	int team_id;
	int solved;
	int penalty;
} team_data_t;

int qsort_comp(const void* x,const void* y) {
	const team_data_t* a=(const team_data_t*)x;
	const team_data_t* b=(const team_data_t*)y;
	if((a->solved)<(b->solved))return 1;
	if((a->solved)>(b->solved))return -1;
	if((a->penalty)>(b->penalty))return 1;
	if((a->penalty)<(b->penalty))return -1;
	if((a->team_id)>(b->team_id))return 1;
	if((a->team_id)<(b->team_id))return -1;
	return 0;
}


team_work_data_t twd[50];
team_data_t td[50];

int main(void) {
	int team_num,q_num,log_num;
	int team,qid,zikoku;
	char message[8];
	int i;
	while(1) {
		scanf("%d%d%d",&team_num,&q_num,&log_num);
		if((team_num|q_num|log_num)==0)break;
		memset(twd,0,sizeof(twd));
		memset(td,0,sizeof(td));
		for(i=0;i<team_num;i++)td[i].team_id=i+1;
		for(i=0;i<log_num;i++) {
			scanf("%d%d%d%s",&team,&qid,&zikoku,message);
			team--;qid--;
			if(!twd[team].solved[qid]) {
				if(message[0]=='C') {
					td[team].solved++;
					twd[team].solved[qid]=1;
					twd[team].penalty[qid]+=zikoku;
					td[team].penalty+=twd[team].penalty[qid];
				} else {
					twd[team].penalty[qid]+=1200;
				}
			}
		}
		qsort(td,team_num,sizeof(team_data_t),qsort_comp);
		for(i=0;i<team_num;i++) {
			printf("%d %d %d\n",td[i].team_id,td[i].solved,td[i].penalty);
		}
	}
	return 0;
}

Measured memory_bytes: 0
# 解答通り
N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == "AC" else 0)

for i in range(Q):
    l, r = map(int, input().split())
    ans = t[r-1] - t[l-1]
    print(ans)


Measured memory_bytes: 7748
N, A, B = map(int, input().split(" "))
cnt = 0
if (B - A) % 2 == 0:
    cnt = (B - A) // 2
else:
    c = (B - A - 1) // 2 + A
    d = (B - A - 1) // 2 + N - B + 1
    cnt = min(c, d)
print(cnt)


Measured memory_bytes: 2940
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    std::string s, t;
    std::cin >> s >> t;

    std::sort(s.begin(), s.end());
    std::sort(t.rbegin(), t.rend());

    if (s < t) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No"  << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]

row = []
col = []
for i in range(h):
  if a[i].count("#") == 0: row.append(i)
    
for i in range(w):
  for j in range(h):
    if a[j][i] == "#": break
  else: col.append(i)

for i in range(h):
  if i in row: continue
  ans = ""
  for j in range(w):
    if j in col: continue
    ans += a[i][j]
  print(ans)

Measured memory_bytes: 9208
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ld eps = (ld)1 / 1e9;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
    fast_io;
    string a, b;
    cin >> a >> b;
    a += b.back();
    cout << (a == b ? "Yes" : "No");
    return 0;
}

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

using namespace std;

int a=0,s=0;

int main() {
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i) {
		int b;
		cin >> b;
		s += b;
		if(b%10 != 0 && (a==0 || b < a)) {
			a = b;
		}
	}
	if(s%10 == 0) s -= a;
	if(s%10 == 0) s = 0;
	cout << s << "\n";
}

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


long long int gcd(long long int a, long long int b) {
    long long int r;
    /*
    if(a < b) {
        swap(a, b);
    }
    */
    while(b > 0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main() {
    long long int a, b;
    cin >> a >> b;
    long long int n = gcd(a, b);
    long long int tmp = n;

    int ans = 1;
    for (int i = 2; i <= sqrt(n); i++) {
        if(tmp%i == 0) {
            while(tmp%i == 0) {
                tmp /= i;
            }
            ans++;
        }
    }
    if(tmp != 1) {
        ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<list>
class hoge{
 public:
  int num;
  int v;
  bool ov;
  hoge(int n,int v,int c){    
    num=n;
    ov=false;
    set(v,c);
  }
  void set(int va,int c);
  bool isOV(){ return ov; };
};
void hoge::set(int va,int c){
  unsigned long long int i=va;
  i*=c;
  if(ov)
    return ;
  if(i>=(1000000-v)){
    ov=true;
    return ;
  }
  v+=i;
}

int main(){
  using namespace std;
  int i,n,v,c,num,flg;
  long long int a;
  list<hoge> ls;
  list<hoge>::iterator pos;
  do{
    scanf("%d",&n);
    if(!n) break;
    for(i=0;i<n;i++){
      scanf("%d %d %d",&num,&v,&c);
      pos=ls.begin();
      while(pos!=ls.end()){
	if((*pos).num==num){
	  (*pos).set(v,c);
	  break;
	}
	pos++;
      }
      if(pos==ls.end()){
	ls.push_back(*(new hoge(num,v,c)));       
      }
    }
    pos=ls.begin();
    flg=1;
    while(pos!=ls.end()){
      if((*pos).isOV()){
	printf("%d\n",(*pos).num);
	flg=0;
      }
      pos++;
    }
    if(flg) printf("NA\n");
    ls.clear();
  }while(1);
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  set<int> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (A.count(a)) A.erase(a);
    else A.insert(a);
  }
  cout << A.size() << endl;
}

Measured memory_bytes: 4864
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <queue>
#include <set>
#include <stack>

#define R register
#define ll long long
#define db double
#define sqr(_x) (_x) * (_x)
#define Cmax(_a, _b) ((_a) < (_b) ? (_a) = (_b), 1 : 0)
#define Cmin(_a, _b) ((_a) > (_b) ? (_a) = (_b), 1 : 0)
#define Max(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define Min(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define Abs(_x) (_x < 0 ? (-(_x)) : (_x))

using namespace std;

namespace Dntcry
{
	inline int read()
	{
		R int a = 0, b = 1; R char c = getchar();
		for(; c < '0' || c > '9'; c = getchar()) (c == '-') ? b = -1 : 0;
		for(; c >= '0' && c <= '9'; c = getchar()) a = (a << 1) + (a << 3) + c - '0';
		return a * b;
	}
	inline ll lread()
	{
		R ll a = 0, b = 1; R char c = getchar();
		for(; c < '0' || c > '9'; c = getchar()) (c == '-') ? b = -1 : 0;
		for(; c >= '0' && c <= '9'; c = getchar()) a = (a << 1) + (a << 3) + c - '0';
		return a * b;
	}
	const int Maxn = 110;
	int n, m, Ex, Ey, Sum[Maxn][Maxn], f[2][Maxn][Maxn][Maxn], v, Ans;
	int Work(R int sx, R int sy, R int tx, R int ty)
	{
		if(sx > tx || sy > ty) return 0;
    	return Sum[tx][ty] - Sum[sx - 1][ty] - Sum[tx][sy - 1] + Sum[sx - 1][sy - 1];
	}
	int Main()
	{
		n = read(), m = read();
		for(R int i = 1; i <= n; getchar(), i++)
			for(R int j = 1; j <= m; j++)
			{
				R char tmp = getchar();
				if(tmp == 'o') Sum[i][j] = 1;
				else if(tmp == 'E') Ex = i, Ey = j;
				Sum[i][j] += Sum[i - 1][j] + Sum[i][j - 1] - Sum[i - 1][j - 1];
			}
		for(R int a = 0; a <= n; v ^= 1, a++) if(Ex + a <= n)
			for(R int b = 0; b <= m; b++) if(Ey + b <= m)
				for(R int c = 0; c <= n; c++) if(Ex - c > 0)
					for(R int d = 0; d <= m; d++) if(Ey - d > 0)
					{
						if(Ex + a + 1 <= n - c) f[v ^ 1][b][c][d] = Max(f[v ^ 1][b][c][d], f[v][b][c][d] + Work(Ex + a + 1, Max(b + 1, Ey - d), Ex + a + 1, Min(m - d, Ey + b)));
	                    if(Ey + b + 1 <= m - d) f[v][b + 1][c][d] = Max(f[v][b + 1][c][d], f[v][b][c][d] + Work(Max(a + 1, Ex - c), Ey + b + 1, Min(n - c, Ex + a), Ey + b + 1));
	                    if(Ex - c - 1 >= a + 1) f[v][b][c + 1][d] = Max(f[v][b][c + 1][d], f[v][b][c][d] + Work(Ex - c - 1, Max(b + 1, Ey - d), Ex - c - 1, Min(m - d,Ey + b)));
	                    if(Ey - d - 1 >= b + 1) f[v][b][c][d + 1] = Max(f[v][b][c][d + 1], f[v][b][c][d] + Work(Max(a + 1, Ex - c), Ey - d - 1, Min(n - c, Ex + a), Ey - d - 1));
	                    Ans = Max(Ans, f[v][b][c][d]);	
					}
		printf("%d\n", Ans);
		return 0;
	}
}
int main()
{
	return Dntcry :: Main();
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

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

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rw", stdin);
#endif
	string s, t;
	int num = 0;
	cin >> s >> t;
	for (int i = 0; i < s.size(); ++i) {
		if(s[i] != t[i]) ++num;
	}
	cout << num;
	return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    
    vector<ll> a(n);
    REP(i, n) {
        cin >> a[i];
    }
    ll sum = abs(a[0]);
    RREP(i, 1, n) {
        sum += abs(a[i] - a[i-1]);
    }
    sum += abs(a[n-1]);

// 0
    cout << sum - abs(a[0]) - abs(a[1] - a[0]) + abs(a[1] - 0) << endl;
// 1~n-1
    RREP(i, 1, n-1) {
        ll temp = sum;
        temp -= abs(a[i] - a[i-1]) + abs(a[i+1] - a[i]);
        temp += abs(a[i+1] - a[i-1]);
        cout << temp << endl;
    }
// n
    cout << sum - abs(a[n-1] - a[n-2]) - abs(a[n-1]) + abs(a[n-2]) << endl;
    

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

Measured memory_bytes: 2048
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD!string;
	
	long cnt;
	foreach (c; N)
	{
		cnt += c-'0';
	}

	writeln(cnt % 9 == 0 ? "Yes" : "No");
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 3028
/*
Author:
Prob:
Link:
Tag:
Comp:
*/

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

#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair<ii, int>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define cl(a) a.clear()

#define vi vector<int>
#define vii vector<ii>

#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)

const int MAX = 1e6 + 10;
const int MAXN = 1e6 + 10;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double pi = acos(-1.0);
const double eps = 1e-6;

int main(){
	// freopen("test.in", "rt", stdin);
	ios::sync_with_stdio(false);

	string s = "CODEFESTIVAL2016";
	string t;
	int cnt = 0;

	cin >> t;
	REP(i,0,16)
		cnt += s[i] != t[i];
	cout << cnt;

	return 0;
}

Measured memory_bytes: 256
//1.includes
#include<iostream>
#include<algorithm>
#include<queue>
#include<tuple>
#include<functional>
#include<vector>
using namespace std;

//2.defines
#define INF 1000000000000000000LL//10^18
#define MAX_N 1000
#define MAX_C 100
#define BLACK 2
#define GRAY 1
#define WHITE 0

//3.variables
priority_queue<tuple<long long, long long, long long>, vector<tuple<long long, long long, long long>>, greater<tuple<long long, long long, long long>>>Q;
long long dist[MAX_N][MAX_C];
long long color[MAX_N][MAX_C];
vector<pair<long long, long long>>X[MAX_N];
long long C, N, M, S, D, A, B, G;

//4.functions
void _memset() {
	for (int i = 0; i < MAX_N; i++) {
		for (int j = 0; j < MAX_C; j++) {
			dist[i][j] = 0;
			color[i][j] = WHITE;
		}
	}
	for (int i = 0; i < MAX_N; i++) {
		X[i].clear();
	}
	while (!Q.empty()) {
		Q.pop();
	}
}

long long dijkstra(long long s, long long t, long long u) {
	for (int i = 0; i < MAX_N; i++) {
		for (int j = 0; j < MAX_C; j++) {
			dist[i][j] = INF;
			color[i][j] = WHITE;
		}
	}
	Q.push(make_tuple(0, 0, s));
	dist[s][0] = 0;
	color[s][0] = GRAY;
	while (!Q.empty()) {
		tuple<long long, long long, long long> tup = Q.top();
		Q.pop();
		long long a1 = get<0>(tup);
		long long a2 = get<1>(tup);
		long long a3 = get<2>(tup);
		color[a3][a2] = BLACK;
		for (int i = 0; i < X[a3].size(); i++) {
			long long a4 = X[a3][i].first;
			long long a5 = X[a3][i].second;
			bool ok = true;
			if (color[a4][a2] == BLACK) { ok = false; }
			if (ok == true && a1 + a5 < dist[a4][a2]) {
				dist[a4][a2] = a1 + a5;
				color[a4][a2] = GRAY;
				Q.push(make_tuple(dist[a4][a2], a2, a4));
			}
			ok = true;
			if (color[a4][a2 + 1] == BLACK) { ok = false; }
			if (a2 + 1 > u) { ok = false; }
			if (ok == true && a1 + a5 / 2 < dist[a4][a2 + 1]) {
				dist[a4][a2 + 1] = a1 + a5 / 2;
				color[a4][a2 + 1] = GRAY;
				Q.push(make_tuple(dist[a4][a2 + 1], a2 + 1, a4));
			}
		}
	}
	long long minx = INF;
	for (int i = 0; i <= u; i++) {
		minx = min(minx, dist[t][i]);
	}
	return minx;
}

int main() {
	while (true) {
		_memset();
		cin >> C >> N >> M >> S >> D;
		if (C == 0 && N == 0 && M == 0 && S == 0 && D == 0) {
			break; //C=number of ticket
		}
		for (int i = 0; i < M; i++) {
			cin >> A >> B >> G;
			X[A].push_back(make_pair(B, G));
			X[B].push_back(make_pair(A, G));
		}
		cout << dijkstra(S, D, C) << endl;
	}
	return 0;
}

Measured memory_bytes: 4672