akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
const int inf = 1 << 30;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}
string S;
int main(){
    cin >> S;
    cout << (S[2] == S[3] && S[4] == S[5] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){
    ll a[3][3];rep(i,0,2)rep(j,0,2)cin>>a[i][j];
    bool bol[3][3];rep(i,0,2)rep(j,0,2)bol[i][j]=false;
    ll n;cin>>n;
    ll b[n];
    rep(k,0,n-1){
        cin>>b[k];
        rep(i,0,2)rep(j,0,2){
            if(b[k]==a[i][j]){
                bol[i][j]=true;
            }
        }
    }
    ll ans=true;
    rep(i,0,2){
        ans=true;
        rep(j,0,2){
            if(!bol[i][j]){
                ans=false;
            }
        }
        if(ans){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    rep(j,0,2){
        ans=true;
        rep(i,0,2){
            if(!bol[i][j]){
                ans=false;
            }
        }
        if(ans){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    ans=true;
    rep(i,0,2){
        if(!bol[i][i]){
            ans=false;
        }
    }
    if(ans){
        cout<<"Yes"<<endl;
        return 0;
    }
    ans=true;
    rep(i,0,2){
        if(!bol[i][2-i]){
            ans=false;
        }
    }
    if(ans){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}




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


int char_to_int(char c){
  switch(c){
    case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
  }
}

ll digit(ll N){
  ll res;
  res = floor(log10(N)) + 1;
  return res;
}



int main(){
  int A, B;
  cin >> A >> B;
  
  int res = A + B;
  if(res >= 24) res -= 24;
  
  cout << res;
         
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
bool used[200000];
vector<int> va, vb;
vector<vector<int> > v;
map<pair<int, int> , int> mp;
string s;
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    memset(used, 0,sizeof(used));
    int n, m;
    cin >> n >> m >> s;
    v.resize(n);
    va.resize(n, 0);
    vb.resize(n, 0);
    ll a, b;
    for(int i=0;i<m;i++){
    	cin >> a >> b;
    	a--;b--;
    	v[a].pb(b);
    	v[b].pb(a);
    }

    queue<int> q;
    for(int i=0;i<n;i++){
    	int maki = v[i].size();
    	for(int j=0;j<maki;j++){
    		int to = v[i][j];
    		mp[{i, to}] = j;
    		if(s[to] == 'A') va[i]++;
    		else vb[i]++;
    	}
    	if(va[i] == 0 || vb[i] == 0){
    		q.push(i);
    	}
    }
    while(!q.empty()){
    	int now = q.front();
    	q.pop();
    	int maki = v[now].size();
    	for(int i=0;i<maki;i++){
    		int to = v[now][i];
    		if(to == -1) continue;
    		v[now][i] = -1;
    		v[to][mp[{to, now}]] = -1;
    		if(s[now] == 'A'){
    			va[to]--;
    			if(va[to] == 0){
    				q.push(to);
    			}
    		}else{
    			vb[to]--;
    			if(vb[to] == 0){
    			    q.push(to);
    			}
    		}
    	}
    }
    bool ans = false;
    for(int i=0;i<n;i++){
    	for(auto& j: v[i]){
    		if(j != -1) ans = true;
    	}
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No"  << endl;
    return 0;
}



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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int [] l = new int [N];
        for (int i = 0 ; i < N ; i++ ) {
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);
        int max = 0;
        for(int i = 0 ; i < K ; i ++) {
            max += l[N - 1 - i];
        }
        System.out.println(max);
    }

}

Measured memory_bytes: 20820
#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
using namespace std;
/*int main()
{
	char s[100];
	cin>>s;
	if (s[0]==s[1]) printf("%c",'H');
	else printf("%c",'D');
	//cout<<s[1];
	return 0;
}*/
/*int main()
{
	char a[19000];
	for (int i=1;i<=2;i++){
		a[i]=getchar();
	}
	if (a[2]==a[1]) printf("%c",'H');
	else printf("%c",'D');
	return 0;
}*/
int main()
{
	int a[15];
	string s;
	getline(cin,s);
	a[1]=s[0]-'A';
	a[2]=s[2]-'A';
	if (a[1]==a[2]) cout<<"H"<<endl;
	else cout<<"D"<<endl;
	return 0;
}

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

const int INF = 1 << 28;
using namespace std;
using Graph = vector<vector<int>>;

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

vector<int> seen(50,-1);
int counter_for_dfs = 0;
void dfs(Graph &G, int v) {
	seen[v] = counter_for_dfs;
	counter_for_dfs++;
	for (auto v_next : G[v]) {
		if (seen[v_next]>=0)continue;

		dfs(G, v_next);
	}
}

void bfs(Graph &G) {
	vector<int> dist(G.size(), -1);
	queue<int> que;
	
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
		}
	}
	for (auto i : dist) {
		cout << i << " ";
	}
}

int counter[200005] = {};
void bfs2(Graph &G,int p,int x) {
	vector<int> dist(G.size() , -1);
	queue<int> que;
	
	dist[p] = 0;
	que.push(p);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
			counter[g] += x;
		}
	}
}
int main()
{
	int m, d;
	int counter = 0;
	std::cin >> m >> d;
	if (d < 21) counter = -1;
	if (counter >= 0) {
		for (int i = 1; i <= m; i++) {
			for (int j = 21; j <= d; j++) {
				int d1 = j - int(j / 10) * 10;
				int d10 = int(j / 10);
				if (d1 < 2 || d10 < 2)continue;
				if (d1 * d10 == i) {
					counter++;
				}
			}
		}
	}
	counter = counter == -1 ? 0 : counter;
	std::cout << counter;
	return 0;

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {

	var n int
	fmt.Scanf("%d\n", &n)
	var a [100]int

	var i int
	for i = 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}
	for j := i - 1; j >= 0; j-- {
		if j == 0 {
			fmt.Printf("%d", a[j])
		} else {
			fmt.Printf("%d ", a[j])
		}

	}
	fmt.Println("")
}




Measured memory_bytes: 1148
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Control.Arrow
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    x <- readLn
    print $ (x`quot`500)*1000+ ((x`rem`500)`quot`5)*5



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

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define sp cout << " ";
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';              

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

int main(){

	ll r,d,x;
	cin >> r >> d >> x;

	for(ll i = 1;i <= 10;i++){
		ll y = r * x - d;
		cout << y << '\n';
		x = y;
	}

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			list.add(sc.nextInt());
		}
		int q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			int b = sc.nextInt();
			int e = sc.nextInt();
			int t = sc.nextInt();
			for (int j = b; j < e; j++) {
				Collections.swap(list, j, t - b + j);
			}
		}
		StringBuilder sb = new StringBuilder();
		for (int num : list) {
			sb.append(num + " ");
		}
		String str = sb.toString();
		str = str.substring(0, str.length() - 1);
		System.out.println(str);
	}
}



Measured memory_bytes: 36712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
  int k;
  cin >> k;
  queue<ll> q;
  rep(i,9) q.push(i+1);
  while(!q.empty()){
    ll tmp = q.front();q.pop();
    k--;
    if (k==0){
      cout << tmp << endl;
      return 0;
    }
    if (tmp%10 != 0) q.push(tmp*10+tmp%10-1);
    q.push(tmp*10+tmp%10);
    if (tmp%10 != 9) q.push(tmp*10+tmp%10+1);
  }
  return 0;
}

Measured memory_bytes: 1792
s = list(input())
pattern_a_count = 0
pattern_b_count = 0

# 1010パターン
for index, value in enumerate(s):
  if index % 2 == 0:
    if value == "0":
      pattern_a_count += 1
  if index % 2 == 1:
    if value == "1":
      pattern_a_count += 1

# 0101
for index, value in enumerate(s):
  if index % 2 == 0:
    if value == "1":
      pattern_b_count += 1
  if index % 2 == 1:
    if value == "0":
      pattern_b_count += 1
      
res = pattern_b_count
if pattern_a_count <= pattern_b_count:
  res = pattern_a_count
print(res)

Measured memory_bytes: 3956
#include<stdio.h>
#include<string.h>
int main()
{
	int i,sm=0;
	char s[2000009];
	scanf("%s",s);
	for(i=0;i<strlen(s);i++)
		sm+=s[i]-'0';
		if(sm%9==0)
		printf("Yes\n");
		else
		printf("No\n");
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=(b);i++)
#define mkp make_pair
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}

int main()
{
	int n;
	scanf("%d",&n);
	ll sum=0;
	int a[105];
	REP(i,n) scanf("%d",a+i);
	REP(i,n) sum+=a[i];
	int q;
	scanf("%d",&q);
	REP(i,q)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		printf("%lld\n",sum-a[x-1]+y);
	}
	return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

ll dp[50]; // dp[i]: i段目まで上り方の種類

void init() {
   dp[1] = 1, dp[2] = 2, dp[3] = 4;
   for (int i = 4; i <= 30; i++) {
      dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
      // dp[i+1] += dp[i];
      // dp[i+2] += dp[i];
      // dp[i+3] += dp[i];
   }
}

int main() {
   init();
   while (1) {
      int n;
      cin >> n;
      if (!n) break;
      ll day = max(1LL, dp[n] / 10);
      // debug(day)
      cout << day / 365 + (day%365 != 0) << endl;
      // line()
   }

   return 0;
}


Measured memory_bytes: 2988
n,m,v,p=[int(j) for j in input().split()]
a=[int(j) for j in input().split()]
a.sort(reverse=True)

def f(x):
    if x>n-1:
        return False
    if x<p:
        return True
    if a[x]+m<a[p-1]:
        return False
    tmp=m*(p+n-x-1)
    for i in range(p-1,x):
        tmp+=min(m,a[x]+m-a[i])
    if tmp>=m*v:
        return True
    return False
left=-1
right=n
while right-left>1:
    mid=(left+right)//2
    if f(mid):
        left=mid
    else:
        right=mid
print(left+1)

Measured memory_bytes: 14964
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=int(a); i<int(b); ++i)
#define FORD(i,a,b) for(int i=int(a); i<int(b); --i)
#define REP(i,N) for(int i=0; i<int(N); ++i)
#define REPD(i,N) for(int i=0; i<int(N); --i)
#define PB push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //配列の最大のrenge



int main() {
    int N; cin >> N;
    vector<vector<int>> G(2, vector<int>(N));
    vector<int> G2(N);
    REP(i,2)REP(j,N) cin >> G[i][j];
    
    REP(i,N) {
        int sum = 0;
        FOR(j,0,i+1) sum += G[0][j];
        FOR(j,i,N) sum += G[1][j];
        G2[i] = sum;
    }

    int max = *max_element(ALL(G2));
    cout << max;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstring>

#define roop(i,n,k) for(i=k;i<n;i++)

using namespace std;

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int i, j;
	int a, b;
	cin >> a >> b;
	int ans = 0;
	int count = 1;
	roop(i, 100, 0) {
		if (count >= b) {
			break;
		}
		count--;
		count += a;
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int q,a,b;
int ans=0;
signed main(){
	cin>>q;
	while(q--){
		ans=0;
		cin>>a>>b;
		int t=sqrt(a*b);
		if(t*t==a*b&&a!=b){
			ans+=t*2-3;
		}
		if(t*t==a*b&&a==b)
		{
			ans=(t-1)*2;
		}
		if(t*t<a*b){
			ans=(t-1)*2;
		}
		if(t*(t+1)<a*b){
			ans=t*2-1;
		}
		cout<<ans<<endl;
	}
}


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

int conv[256];
int v[3];

int calc(char *s, char *e)
{
	/*for (char *p = s; p != e; p++){
		printf("%c", *p);
	}
	puts("");*/
	
	vector<char> op;
	vector<int> val;
	for (char *p = s; p != e; p++){
		bool f = false;
		if (*p == '('){
			char *a = p + 1;
			char *b = p + 1;
			int cnt = 1;
			while (true){
				if (*b == '(') cnt++;
				if (*b == ')') cnt--;
				if (cnt == 0) break;
				b++;
			}
			val.push_back(calc(a, b));
			p = b;
			f = true;
		}
		else if (*p == '-') op.push_back('-');
		else if (*p == '+') op.push_back('+');
		else if (*p == '*') op.push_back('*');
		else if (*p >= '0' && *p <= '2'){
			val.push_back(*p - '0');
			f = true;
		}
		else {
			val.push_back(v[conv[*p]]);
			f = true;
		}
		if (f){
			while (op.size() && op.back() == '-'){
				val.back() = 2 - val.back();
				op.pop_back();
			}
		}
		
		/*for (int i = 0; i < val.size(); i++){
			printf("%d ", val[i]);
		}
		puts("");
		for (int i = 0; i < op.size(); i++){
			printf("%c ", op[i]);
		}
		puts("");*/
	}
	
	if (op.size() == 0) return val[0];
	if (op.back() == '+') return max(val[0], val[1]);
	if (op.back() == '*') return min(val[0], val[1]);
}

int main()
{
	conv['P'] = 0;
	conv['Q'] = 1;
	conv['R'] = 2;
	
	char str[256];
	while (scanf("%s", str), str[0] != '.'){
		int res = 0;
		char *e = str + strlen(str);
		for (v[0] = 0; v[0] < 3; v[0]++){
			for (v[1] = 0; v[1] < 3; v[1]++){
				for (v[2] = 0; v[2] < 3; v[2]++){
					//printf("%d\n", calc(str, e));
					res += (calc(str, e) == 2);
				}
			}
		}
		printf("%d\n", res);
	}
}

Measured memory_bytes: 1184
#include<iostream>
#include<cstdio>
#include<queue>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#include<stack>
#include<cmath>
#include<algorithm>
#include<vector>
#include<utility>
#include<deque>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define eps 1e-6
#define mem(n,a) memset(n,a,sizeof(n))
#define rep(i,be,en) for(int i=be;i<=en;++i)
#define pre(i,be,en) for(int i=en;i>=be;--i)
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lowbit(int x) { return x & -x; }


using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 300010;

int main() {
	int n;cin >> n;
	cout << !n << endl;
}

Measured memory_bytes: 3164
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from collections import deque
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    S = readline().decode('utf-8').strip()
    K = int(readline())
    L = len(S)

    continuous = deque()

    count = 0
    last = ''
    for i in range(L):
        if i == 0:
            last = S[i]
            count += 1
        else:
            if last==S[i]:
                count += 1
            else:
                continuous.append(count)
                count = 1
                last = S[i]
    continuous.append(count)

    ans = 0
    if len(continuous)==1:
        ans = L*K//2
    else:
        if S[0]==S[-1]:
            a = continuous.popleft()
            b = continuous.pop()
            ans += ((a+b)//2)*(K-1) + a//2 + b//2
        while continuous:
            a = continuous.popleft()
            ans += a//2*K
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9444
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() { 
    int n;
    cin >> n;
    vector<long long int> v(n, 0);
    long long int s = 0;
    long long int res = 0;
    const int mod = 1e9 + 7;
    
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        res += s * v[i];
        res %= mod;
        s += v[i];
        s %= mod;
    }
    cout << res << endl;

}




Measured memory_bytes: 4840
#include<cstdio>
const int mod=1000000007;
long long power(long long a,int k){
    long long ans=1,y=a;
    while(k){
        if(k%2)
            ans=ans*y%mod;
        y=y*y%mod;
        k=k/2;
    }
    return ans;
}
long long fun[1<<17],ans=1;
int main(){
    long long n,m;
    scanf("%lld%lld",&n,&m);
    fun[0]=1;
    for(int i=1;i<1<<17;i++){
        fun[i]=fun[i-1]*i%mod;
    }
    for(int i=2;i*i<=m;i++){
        if(m%i==0){
            long long s=0;
            while (m%i==0) {
                m=m/i;
                s++;
            }
            ans=ans*fun[n+s-1]%mod*power(fun[n-1], mod-2)%mod*power(fun[s], mod-2)%mod;
        }
    }
    if(m>1)
        ans=ans*n%mod;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] ab = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long len = ab[1].ToString().Length;
            long num = ab[0] * (long)Math.Pow(10, len) + ab[1];
            if ((double)num % Math.Sqrt(num) == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


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

int main() {
  int s;
  cin >> s;
  int a = s / 100;
  int a_ = s % 100;
  int b = a_ / 10;
  int c = a_ % 10;
  
  cout << a + b + c << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    int seriese = -1;
    bool everone = false;
    for(int i = 0; i < n; i++) {
        if(a[i] == 1 && !everone) {
            seriese = 2;
            everone = true;
            continue;
        }

        if(a[i] == seriese) {
            seriese++;
        }
    }
    if(seriese==-1) cout << -1 << endl;
    else cout << n - (seriese-1) << endl;
}

Measured memory_bytes: 1024
import java.util.Arrays;

public class Main {


  private static void solve() {
    int n = ni();
    int[] l = new int[n + 1];
    int[] r = new int[n + 1];
    for (int i = 0; i < n; i ++) {
      l[i] = ni();
      r[i] = ni();
    }
    Arrays.sort(l);
    Arrays.sort(r);
    long ret = 0;
    for (int i = 0; i <= n; i ++) {
      ret += Math.max(0, l[n -i] - r[i]);
    }
    System.out.println(ret * 2);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 46900
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

    string s;
    cin >> s;

    int n = s.size();
    string key = "keyence";
    int index = 0;
    REP(i, n){
        if(s[i] != key[index]) break;
        index++;
        if(index == 7) break;
    }
    int num = index;
    REP(i, 7 - num){
        if(s[n - (7 - num) + i] != key[index]) break;
        index++;
        if(index == 7) break;
    }

    if(index == 7) cout << "YES" << endl;
    else cout << "NO" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >>n;
  vector<string> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    sort(a[i].begin(),a[i].end());
  }
  map<string,int>mp;
  for(string s:a){
    if(mp.count(s)){
      mp.at(s)++;
    }else {
      mp[s]=1;
    }
  }
  long long kotae=0;
  auto begin=mp.begin(),end=mp.end();
  for(auto iter=begin;iter!=end;iter++){
    long long x=iter->second;
    if(x==1)continue;
    kotae+=x*(x-1)/2;
  }
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 18176
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String t = scan.next();
		Character[] sc = new Character[s.length()];
		Character[] tc = new Character[t.length()];
		int length=Math.min(s.length(), t.length());
		for(int i=0;i<s.length();i++) {
			sc[i]=s.charAt(i);
		}
		for(int i=0;i<t.length();i++) {
			tc[i]=t.charAt(i);
		}
		Arrays.sort(sc);
		Arrays.sort(tc, Collections.reverseOrder());
		//System.out.println(Arrays.asList(sc));
		//System.out.println(Arrays.asList(tc));

/*
		boolean hantei = true;
		int count = 0;
		for(int i=0;i<length;i++) {
			int sci=sc[i];
		//	System.out.println(sci);
			int tci=tc[i];
		//	System.out.println(tci);
			if(sci<tci) {
				hantei=true;
				break;
			}else if(tci<sci) {
				hantei =false;
				break;
			}else {
				count++;
			}
		}
//System.out.println(count);
		//if(hantei==true) {
		//	if(tc.length<sc.length) {
			//	hantei=false;
		//	}
		//}
*/


		StringBuilder sortS = new StringBuilder();
		StringBuilder sortT = new StringBuilder();
		for(int i=0;i<s.length();i++) {
			sortS.append(sc[i]);
		}
		for(int i=0;i<t.length();i++) {
			sortT.append(tc[i]);
		}
	//	System.out.println(sortS);
	//	System.out.println(sortT);

		String[] zisyo =new String[2];
		zisyo[0]=sortS.toString();
		zisyo[1]=sortT.toString();
		Arrays.sort(zisyo);
	//	System.out.println(zisyo[0]);
	//	System.out.println(zisyo[1]);
boolean hantei = true;
		if(zisyo[0].equals(sortS.toString())) {
			hantei = true;
		}else {
			hantei =false;
		}



		if(hantei==true) {
			if(s.equals(t)) {
				System.out.println("No");
			}else {
			System.out.println("Yes");}
		}else {
			System.out.println("No");
		}


	}

}


Measured memory_bytes: 21972
//============================================================================
//  Search Allocation
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define pred(x) ((x)-1)
#define succ(x) ((x)+1)
//============================================================================
//============================================================================
//============================================================================

//============================================================================
//============================================================================
//long weight(unsigned short *ary, long *i, long *max)
//============================================================================
/*
    1<= wi <=10000
    1<= n <= 100000
    1<= k <= 100000
*/
//----------------------------------------------------------------------------
// runtime error @in25.txt why???
//----------------------------------------------------------------------------
void input(FILE *file)
{
    long K,N,k,n,max,sum,res,val;
    unsigned short *ary;

    fscanf(file, "%ld", &N);
    fscanf(file, "%ld", &K);
    ary=malloc(N*sizeof(unsigned short));
    for (n=sum=max=0; n<N; n++){
        fscanf(file, "%hd", &ary[n]);
        sum+=ary[n];
        if (max<ary[n])
            max=ary[n];
    }
    if (K==1)
        max=succ(sum);
    else{
        val = sum/K;
        if (max<val)
            max=val;
        for (res=0; res!=sum; max++){
#ifdef DESKTOP
            printf("max=%ld:", max);
#endif
            for (k=n=res=0; k<K && n<N; k++){
                for (val=0; val<=max && n<N; n++){
                    val+=ary[n];
                }
                if (max<val){
                    n--;
                    val-=ary[n];
                }
                res+=val;
#ifdef DESKTOP
                printf(" %ld", val);
#endif
            }
#ifdef DESKTOP
            printf("\n");
#endif
        }
    }
    printf("%ld\n", pred(max));
    free(ary);
}
//============================================================================
#ifndef DESKTOP
int main()
{
    input(stdin);
    return 0;
}
#endif

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] l = new int[2 * n];
		for (int i = 0; i < l.length; i++) {
			l[i] = sc.nextInt();
		}
		sc.close();

		Arrays.parallelSort(l);
		int ans = 0;
		for (int i = 0; i < l.length; i+=2) {
			ans += l[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>

#define ll long long

const ll c = 1000000007;

using namespace std;

int main()
{
  ll n, m;
  cin >> n >> m;
  if (n-m > 1 || m-n > 1){
    cout << 0 << endl;
  }else{
    if (m == n){
      ll ans = 1;
      for(ll i = n; i >= 2; --i){
        ans *= i;
        if (ans > c){
          ans %= c;
        }
      }
      ans = (ans * ans)%c * 2;
      cout << (ans%c) << endl;
    }else{
      if (m > n){
        ll tmp = m;
        m = n;
        n = tmp;
      }
      ll ans = 1;
      for(ll i = m; i >= 2; --i){
        ans *= i;
        if (ans > c){
          ans %= c;
        }
      }
      ans = (ans * ans)%c * n;
      cout << (ans%c) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

cnt = S.count('E')
if S[0] == 'E':
    cnt -= 1
ans = cnt
for i in range(1, N):
    if S[i] == 'E':
        cnt -= 1
    if S[i - 1] == 'W':
        cnt += 1
    if cnt < ans:
        ans = cnt
print(ans)


Measured memory_bytes: 3668
#include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <vector>
    #include <set>
    #include <queue>
    #include <deque>
    #include <map>
    #include <string.h>
     
    using namespace std;
     
    using ll = long long;
     
    int A, B, C;
    ll K;
    int main() {
      scanf("%d %d %d %lld", &A, &B, &C, &K);
      if (K % 2) {
        printf("%d\n", B - A);
      } else {
        printf("%d\n", A - B);
      }
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
 
#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)
 
ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}
 
int main()
{
  ll x, a, b;
  cin >> x >> a >> b;
  if (abs(x-a) > abs(x-b)){
    cout << "B" << endl;
  }else{
    cout << "A" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a,b;
int32_t main(){
CODE_START;
cin>>a;
cin>>b;
if(b<a){
    cout<<a-1;
    }else {
    cout<<a;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define it register int
#define ct const int
#define il inline
#define INF 0x3f3f3f3f
#define D 2
#define M 200005
using namespace std;
typedef long long ll;
struct node{
    int x[2];
}arr[M];
double dist[4][M],mmin[4],mmax[4];

void got(int N){
    int tot=4;
    for(int s=0;s<tot;s++){
        int c[2];
        for(int i=0;i<2;i++)
        if(s&(1<<i)) c[i]=-1.0;
        else c[i]=1.0;

        for(int i=0;i<N;i++){
            dist[s][i]=0.0;
            for(int j=0;j<2;j++)
            dist[s][i]=dist[s][i]+c[j]*arr[i].x[j];
        }
    }
}

void f(int N){
    int len=4;
    int tmp,ans;
    for(int s=0;s<len;s++){
        mmin[s]=INF;
        mmax[s]=-INF;
        for(int i=0;i<N;i++){
            if (mmin[s]>dist[s][i]) mmin[s]=dist[s][i];
            if (mmax[s]<dist[s][i]) mmax[s]=dist[s][i];
        }
    }
    ans=0;
    for(int s=0;s<len;s++){
        tmp=mmax[s]-mmin[s];
        if(tmp>ans) ans=tmp;
    }
    printf("%d\n", ans);
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d %d",&arr[i].x[0],&arr[i].x[1]);
    got(n);
    f(n);
    return 0;
}

Measured memory_bytes: 11628
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//素数判定
bool isPrime(int n) {
	if (n == 2)return true;
	if (n < 2 || n % 2 == 0)return false;

	for (int i = 3; i*i <= n; i += 2) {
		if (n%i == 0)return false;
	}
	return true;
}

int main() {
	int n;
	while (cin >> n) {
		for (int i = n - 1; true; i--) {
			if (isPrime(i)) { cout << i << " "; break; }
		}

		for (int i = n + 1; true; i++) {
			if (isPrime(i)) { cout << i << endl; break; }
		}
	}
}


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

static const int N = 100;

int main() {

	int n, p[N + 1], m[N + 1][N + 1];

	scanf("%d", &n);

	for ( int i = 1; i <= n; i++ ) {
		cin >> p[i - 1] >> p[i];
	}

	for ( int i = 1; i <= n; i++ ) m[i][i] = 0;

		for ( int l = 2; l <= n; l++ ) {
			for ( int i = 1; i <= n - l + 1; i++ ) {

				int j = i + l - 1;
				m[i][j] = (1 << 21);
				
				for ( int k = i; k <= j - 1; k++ ) {
					m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
				}
			}
		}

		printf("%d\n", m[1][n]);

		return 0;
	}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	// 入力
	string S, T;
	cin >> S >> T;
	ll ans = 0;
	REP(i, 3) {
		if (S[i] == T[i]) ans++;
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

//???
class Point {
public:
    double x, y;
    
    Point (double x = 0, double y = 0):x(x), y(y){}
    Point operator + (Point p){return Point(x + p.x, y + p.y);}
    Point operator - (Point p){return Point(x - p.x, y - p.y);}
    Point operator * (double a){return Point(a * x, a * y);}
    Point operator / (double a){return Point(x / a, y / a);}
    
    double norm(){return x*x + y*y;};
    double absolute(){return sqrt(norm());};
    
    bool operator < (const Point &p) const{
        return x != p.x ? x < p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const{
        return equals(x, p.x) && equals(y, p.y);
    }
    
};
typedef Point Vector;                               //????????????
typedef struct Segment{Point p1, p2;}Segment;       //??????
//????????????a????????????
double norm(Vector a){
    return a.x * a.x + a.y * a.y;
}
//????????????a,b?????????
double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}
//????????????a,b?????????
double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

//??????p0, p1, p2???????????????????????????p0p1???????????????p2??????????????????
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;
int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a, b) < -EPS) return CLOCKWISE;
    if(dot(a, b) < -EPS) return ONLINE_BACK;
    if(norm(a) < norm(b)) return ONLINE_FRONT;
    return ON_SEGMENT;
}

//??????S1(p1p2)??¨??????s2(p2p3)????????????????????????
bool intersect(Point p1, Point p2, Point p3, Point p4){
    return  ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0
            &&
            ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0;
}
bool intersect(Segment s1, Segment s2){
    return intersect(s1.p1, s1.p2, s2.p1, s2.p1);
}


int main(){
    
    int x0, y0, x1, y1, x2, y2, x3, y3;
    
    int q;
    
    cin >> q;
    
    for (int i = 0; i < q; i++) {
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        
        Point p0 = Point(x0, y0);
        Point p1 = Point(x1, y1);
        Point p2 = Point(x2, y2);
        Point p3 = Point(x3, y3);
        
        
        if( intersect(p0, p1, p2, p3) ) cout << 1 << endl;
        else cout << 0 << endl;
    }


    return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>
#include <string>
#include<algorithm>
using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    
    int max= 0;
    
    if(a>max)
    {
        max = a;
    }
    if(b>max)
    {
        max = b;
    }
    if(c>max)
    {
        max = c;
    }
    
    if(max == a)
    {
        cout << a *10 + b + c;
    }
    else if(max == b)
    {
        cout << b*10 + c  + a;
    }
    else if(max == c)
    {
        cout << c*10 + a + b;
    }
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m;
    cin>>n>>m;
    int l,r,maxl=1,minr=100000,pd=1;
    while (m--)
    {
        cin>>l>>r;
        if (l>minr||r<maxl) pd=0;
        if (l>maxl) maxl=l;
        if (r<minr) minr=r;
    }   
    if (pd)
        if (minr-maxl+1<n) cout<<minr-maxl+1<<'\n';
        else cout<<n;
    else 
        cout<<0<<'\n';
    return 0;
}

Measured memory_bytes: 256
PROGRAM ATCODER

implicit none
integer :: n,k
character(len=50) :: s

read*, n,k,s

if ( s(k:k) == 'A' ) then
  s(k:k) = 'a'
else if ( s(k:k) == 'B' ) then
  s(k:k) = 'b'
else
  s(k:k) = 'c'
end if

print'(a)', s(1:n)

END PROGRAM ATCODER

Measured memory_bytes: 768
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, A;
    cin >> N;
    cin >> A;
    N %= 500;
    if (N > A)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N,M = gets.split.map(&:to_i)
s,c = M.times.map { gets.split.map(&:to_i) }.transpose

(0..999).each do |n|
  next if n.to_s.length != N
  isnt = false
  M.times do |i|
    if n.to_s[s[i]-1] != c[i].to_s
      isnt = true
      break
    end
  end
  unless isnt
    puts n
    exit
  end
end
puts -1

Measured memory_bytes: 3836
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
 
void init();
void solve();
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
 
#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
 
#define MOD 1000000007
 
signed main()
{
	init();
	solve();
}

string s;
int l;

void init()
{
  cin >> s;
  l = s.length();
}
 
void solve()
{
  rep(i, l-8) cout << s[i];
  cout << endl;
}

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

using namespace std;

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    printf("%s\n",(a==5 || a==7) && (b==5 || b==7) && (c==5 || c==7) && (a+b+c==17)?"YES":"NO");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.txt");ofstream coutt("out.txt");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Use __builtin_popcountll for ll;
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

signed main(){
    FASTER;
    int n,k;cin>>n>>k;
    vi v(n);cin>>v;
    sort(all(v));
    int ans=0;
    for(int i=0;i<k;i++){
        ans+=v[i];
    }
    cout<<ans;
}



Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
const int maxh = 1005, INF = 1e8, maxn = 14;
int H, W, N;
char field[maxh][maxh];
int dp[maxh][maxh], res = 0;
int sx, sy, gx, gy;
int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
typedef pair<int, int> P;
P cheese[maxn];
int bfs()
{
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            dp[i][j] = INF;
        }
    }
    queue<P> que;
    que.push(P(sx, sy));
    dp[sx][sy] = 0;
    while(que.size()){
        P p = que.front();
        que.pop();
        int x = p.first, y = p.second;
//        printf("%d %d\n", x, y);
        if(x == gx && y == gy)
            break;
        for(int i = 0; i < 4; i++){
            int nx = x + dx[i], ny = y + dy[i];
            if(nx >= 0 && nx < H && ny >= 0 && ny < W && field[nx][ny] != 'X' && dp[nx][ny] == INF){
                que.push(P(nx, ny));
                dp[nx][ny] = dp[x][y] + 1;
            }
        }

    }
    return dp[gx][gy];
}
int main()
{
    scanf("%d%d%d", &H, &W, &N);
    for(int i = 0; i < H; i++)
        scanf("%s", field[i]);
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(field[i][j] >= '1' && field[i][j] <= '9'){
                cheese[field[i][j] - '0'].first = i;
                cheese[field[i][j] - '0'].second =j;
            }
            else if(field[i][j] == 'S'){
                sx = i; sy = j;
            }
        }
    }
    for(int i = 1; i <= N; i++){
        gx = cheese[i].first, gy = cheese[i].second;
        res += bfs();
        sx = gx; sy = gy;
    }
    printf("%d\n", res);
    return 0;
}




Measured memory_bytes: 7488