akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int n,i,j,t;
  char d[101];
  while(1){
    scanf("%d",&n);
    if(!n)break;
    int m[12]={0};
    scanf("%s",d);
    for(i=0;i<100;i++){
      if(d[i]=='M')m[i%n]++;
      if(d[i]=='L'){
	m[i%n]+=1+m[11];
	m[11]=0;
      }
      if(d[i]=='S'){
	m[11]+=m[i%n]+1;
	m[i%n]=0;
      }
    }
    for(i=0;i<n;i++){
      for(j=n-1;i<j;j--){
	if(m[j-1]>m[j]){
	  t=m[j];
	  m[j]=m[j-1];
	  m[j-1]=t;
	}
      }
      printf("%d ",m[i]);
    }
    printf("%d\n",m[11]);
  }
  return 0;
}
		   

Measured memory_bytes: 604
k = int(input())
n = 50
if k <= n-1:
    aas = [0] * n
    aas[0] += n * k
else:
    t = k // n
    k %= n
    aas = [n-k+t-1] * n
    i = 0
    cnt = 0
    while cnt < k:
        aas[i] += 1 + k
        i += 1
        cnt += 1
print(n)
print(*aas)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = 1000000007;
ll mpow(ll a,ll b){ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
/*template*/

int main()
{
  ll k;string s;cin>>k>>s;
  string ans;
  if(s.length()<=k){
    ans=s;
  }else{
    ans="";
    for(ll i=0;i<k;i++){
      ans+=s[i];
    }
    ans+="...";
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
	int n;
	cin >> n;
	for(int i(1);i<=9;++i){
		if(n%i==0 && (n/i)<=9){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a<b){
        System.out.println("a < b");
    }else if(a>b){
        System.out.println("a > b");
    }else {
        System.out.println("a == b");
    }   
    sc.close();
    }
}


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

int main(){
int W,H,x,y,r;
cin>>W>>H>>x>>y>>r;
if((x-r)>=0&&(x+r)<=W&&(y-r)>=0&&(y+r)<=H){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}


Measured memory_bytes: 3116
use std::io;

fn main() {
    let mut buf: String = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let i: i64 = buf.trim().replace(" ", "").parse::<i64>().unwrap();
    println!("{}", if ((i as f64).sqrt().round() as i64).pow(2) == i {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>

struct Point{
  double s,t;};
void koch(int,struct Point,struct Point);

int main(){
  struct Point x,y;
  int n;
  scanf("%d",&n);
  x.s=0;
  x.t=0;
  y.s=100;
  y.t=0;

  printf("%.8f %.8f\n",x.s,x.t);
  koch(n,x,y);
  printf("%.8f %.8f\n",y.s,y.t);
  return 0;
}
void koch(int n,struct Point x,struct Point y){
  struct Point a,b,c;
  double ch;
  if(n==0)                                                                                                                  return;
  ch=M_PI*60.0/180.0;                                                                                                     a.s=(2.0*x.s+1.0*y.s)/3.0;
  a.t=(2.0*x.t+1.0*y.t)/3.0;
  b.s=(1.0*x.s+2.0*y.s)/3.0;
  b.t=(1.0*x.t+2.0*y.t)/3.0;                                                                                              c.s=(b.s-a.s)*cos(ch)-(b.t-a.t)*sin(ch)+a.s;
  c.t=(b.s-a.s)*sin(ch)+(b.t-a.t)*cos(ch)+a.t;


  koch(n-1,x,a);
  printf("%.8f %.8f\n",a.s,a.t);
  koch(n-1,a,c);
  printf("%.8f %.8f\n",c.s,c.t);
  koch(n-1,c,b);
  printf("%.8f %.8f\n",b.s,b.t);
  koch(n-1,b,y);
}


Measured memory_bytes: 2112
#include <iostream>
#include <functional>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

namespace _{struct _{_(){ // initialize
  cin.tie(0); ios::sync_with_stdio(false);
}}_;}
template <typename T, size_t size>
inline size_t len(const T (&)[size]) { return size; }
#define println(s) cout << s << '\n';
#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()


int main() {
  bool data[30] = {false};
  rep(i, 28) {
    int k;
    cin >> k;
    data[k-1] = true;
  }
  rep(i, 30) {
    if (!data[i]) println(i+1);
  }
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  ll n,k,ans=0;cin>>n>>k;
  vector<ll> v(n),sum(n+1,0);
  map<ll,ll> pac;
  rep(i,0,n){
      cin>>v[i];
      sum[i+1]+=sum[i]+v[i];
  }

  rep(i,0,n+1){
      if(0<=i-k)pac[(sum[i-k]-i+k)%k]--;
      ans+=pac[(sum[i]-i)%k];
      pac[(sum[i]-i)%k]++;
      cerr<<ans<<endl;
  }
  cout<<ans<<endl;
}
//ABC146 E

//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 15872
N, M = gets.chomp.split.map(&:to_i)

list = []

M.times do
  a, b = gets.chomp.split.map(&:to_i)
  list << [a, b]
end

list.sort_by!(&:last)

cut_point = 0
ans = 0

list.each do |a, b|
  if cut_point < a
    cut_point = b - 1
    ans += 1
  end
end

puts ans



Measured memory_bytes: 12664
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<ll> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	 printf
#define sf			 scanf
#define pb(a)        push_back(a)
#define mp			 make_pair
#define ff			 first
#define ss			 second
#define for0(i,n)    for(ll i=0;i<n;i++)
#define for1(i,n)    for(ll i=1;i<=n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define sq(a)		 (a)*(a)
#define endl		     "\n"
#define abs(x)		 fabs(x)
#define all(v) 		 v.begin(),v.end()
#define pcase(z,x)   cout<<"Case "<<z<<": "<<x<<"\n"
#define mod 1000000007
#define WakandaForever     ios_base::sync_with_stdio(0); cin.tie(0);

int main()
{
    WakandaForever
    ll n,sum=0;
    cin>>n;
    vi a(n),suf(n+1);
    for0(i,n) cin>>a[i];
    suf[n] = 0;
    for(ll i=n-1 ; i>=0 ; i--){
        suf[i] = (a[i] + suf[i+1])%mod;
    }
    for0(i,n){
        ll x = (a[i]%mod * suf[i+1]%mod)%mod;
        sum = (sum + x) % mod;
    }

    cout<<sum<<endl;


    return 0;
}


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

int main() {
	int i;
	set<int> a;
	cin >> i;
	for (int m = 2;; m++) {
		a.insert(i);
		i = (i % 2 == 0) ? (i / 2) : (3 * i + 1);
		if (a.find(i) != a.end()) {
			cout << m << endl;
			break;
		}
	}
	return 0;
}


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> digitnums(n);
    rep(i,n){
        digitnums.at(i) = -1;
    }
    rep(i,m){
        int a,b;
        cin >> a >> b;
        if((digitnums[a-1] != -1) && (digitnums[a-1] != b)){
            cout << -1 << endl;
            return 0;
        }
        if((n > 1) &&(a==1) && (b == 0)){
            cout << -1 << endl;
            return 0;
        }
        digitnums[a-1] = b;
    }

    string result = "";
    rep(i,n){
        if(digitnums[i] == -1){
            if((i==0) && (n>1)){
                result += "1";
            }
            else {
                result += "0";
            }
        } else {
            result += to_string(digitnums[i]);
        }
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;--i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,a,b) for(int i=int(b-1);i>=int(a);--i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int k;
  cin >> k;

  sort(a,a+3);

  cout << a[0] + a[1] + pow(2,k) * a[2] << endl;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


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

signed main(){

	int H, W, N;
	cin >> H >> W >> N;
	int sr, sc;
	cin >> sr >> sc;
	string S, T;
	cin >> S >> T;

	char c[4] = { 'L', 'R', 'U', 'D' };
	char reverse_c[4] = { 'R', 'L', 'D', 'U' };

	rep(cc, 4){
		int ch = c[cc];
		int r_ch = reverse_c[cc];
		
		int current;
		int width;
		int remain;
		if (ch == 'L' || ch == 'R'){
			current = sc;
			width = W;
			if (ch == 'L') remain = current;//あと何回で落ちるか
			else remain = width - current + 1;
		}
		else{
			current = sr;
			width = H;
			if (ch == 'U') remain = current;//あと何回で落ちるか
			else remain = width - current + 1;
		}

		// simulation
		rep(i, N){
			if (S[i] == ch) remain --;
			if (remain <= 0){
				cout << "NO" << endl; return 0;
			}
			// 落ちない限り逆方向に邪魔する
			if (T[i] == r_ch) {
				if (remain + 1 <= width) remain++;
			}
		}
	}
	cout << "YES" << endl;


	return 0;
}

Measured memory_bytes: 776
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

int main() {
  int N;
  cin >> N;
  vector<float> v(N);
  // 具材を入れていく
  rep(i, N){
    cin >> v[i];
  }

  sort(v.begin(), v.end()); // O(NlogN)
  float ans = 0;
  rep(i, N - 1){
    v[i+1] = (v[i] + v[i+1])/2;
  }

  
  cout << setprecision(5) << v[N-1] << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n;
    int a[4];
    scanf("%d",&n);
    a[0] = n%10;
    a[1] = n/10%10;
    a[2] = n/100%10;
    a[3] = n/1000%10;
    int c;
    c = 0;
    for(int i = 0;i<4;i++){
        if(a[i] == 2){
            c++;
        }
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 128
import math



a,b,n=map(int, input().split()) 

x = 1

num = math.floor(n/b)

if num == 0:
    x = n
    print(math.floor(a*x/b)-a*math.floor(x/b))
    exit()
if num >= 100000:
    print(b-1)
    exit()
else:
    ans = 0
    for i in range(1,num+1):
        x = b*i-1
        ans = max(ans,math.floor(a*x/b)-a*math.floor(x/b))
print(ans)


Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll arr[407], sum[407];
ll dp[407][407];
bool vis[407][407];

ll rec( int l, int r )
{
    if(l==r)
        return 0;
    if(l>r)
        return 1e18;
    if( vis[l][r] )
        return dp[l][r];

    ll ret= 1e18;

    for( int i=l;i<r;i++ )
        ret= min( ret, rec( l, i )+rec( i+1, r )+sum[r]-sum[l-1] );

    vis[l][r]= 1;

    return dp[l][r]= ret;
}

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

    for( int i=1;i<=n;i++ )
        cin>> arr[i], sum[i]= arr[i]+sum[i-1];

    cout<< rec( 1, n ) <<endl;
}


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


def main():
  S = input()
  N = len(S)
  ans = [0] * N
  count = []
  tmp = 1
  pre = 'R'
  for i in range(1, N):
    now = S[i]
    if pre == now:
      tmp += 1
      pre = now
      if i == N-1:
        count.append(tmp)
    else:
      count.append(tmp)
      tmp = 1
      pre = now
      if i == N-1:
        count.append(tmp)
  now = -1
  for i in range(len(count)):
    if i%2==0:
      L = count[i]
      now += L
      ans[now+1] += L//2
      ans[now] += L-(L//2)
    else:
      R = count[i]
      ans[now+1] += R - (R//2)
      ans[now] += R//2
      now += R
  print(' ' .join(map(str, ans)))
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 11636
#include<bits/stdc++.h>
#define ll long long
using namespace std;

string complete(int x)
{
    string s = to_string(x);
    string zero;
    for (int i=0; i<6-s.size(); i++)
        zero += "0";
    return zero+s;
}

int main() 
{
    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, int>> v;
    for (int i=1; i<=m; i++)
    {
        int p, y;
        cin >> p >> y;
        v.emplace_back(p, y, i);
    }
    sort(v.begin(), v.end());
    vector<string> res(m+1);
    int old = get<0>(*v.begin());
    int numCities = 0;
    for(auto x: v)
    {
        if (old == get<0>(x))
            numCities++;
        else
            numCities = 1;
        old = get<0>(x);
        string part2 = complete(numCities);
        int index = get<2>(x);
        string part1 = complete(get<0>(x));
        res[index] = part1 + part2;
    }
    for (int i=1; i<=m; i++)
        cout << res[i] << "\n";
    return 0;
}

Measured memory_bytes: 9716
h,w = map(int,input().split())
A = []
for i in range(h):
    A.append(list(input()))
B = []
for a in A:
    if "#" in a:
        B.append(a)
C = []
for b in zip(*B):
    if "#" in b:
        C.append(b)
for c in zip(*C):
    print("".join(c))

Measured memory_bytes: 3188
//https://atcoder.jp/contests/abc151/tasks/abc151_a
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    char c ;
    cin >> c ;
    int a = int(c);
    cout << char(c+1); 
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,a,b;
    t = 1;
    while(t--) {
     cin >> a >> b;
     if(a > b)
      cout << a - 1 << endl;
     else
      cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int[] arrow = new int[3];
        arrow[0] = int.Parse(input[0]);
        arrow[1] = int.Parse(input[1]);
        arrow[2] = int.Parse(input[2]);
        if (arrow[2] == arrow[1] &&arrow[2]== arrow[0]) { Console.WriteLine("Yes"); }
        else { Console.WriteLine("No"); }

    }
}



Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,W,X,Y,Z;
string S,T;
vector<ll> V(100007);

int main(){
  cin >> N >> M;
  cout << (N==M? "Yes" : "No") << endl;
}

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

#define pb push_back
#define ss second
#define ff first
#define N 100005
#define inf 1000000009
#define ll long long
#define all(a) a.begin(),a.end()
#define mid(a,b) (a+b)/2
#define pii pair<int,int>

using namespace std;

string s;

int main()
{
	cin >> s;
	if(s[2] == s[3] and s[4] == s[5]) return cout << "Yes",0;
	cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[3][3];
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>arr[i][j];
        }
    }
    int n,temp=0;
    cin>>n;
    while(n--)
    {
       cin>>temp;
       for(int i=0;i<3;i++)
       {
           for(int j=0;j<3;j++)
           {
               if(arr[i][j]==temp)
               arr[i][j]=0;
           }
       } 
    }
    for(int i=0;i<3;i++)
    {
        if(arr[i][0]==arr[i][1] &&arr[i][1]==arr[i][2])
        {
        cout<<"Yes";
        return 0;
        }

    }
    for(int j=0;j<3;j++)
    {
        if(arr[0][j]==arr[1][j] && arr[1][j]==arr[2][j])
        {
            cout<<"Yes";
            return 0;
        }
    }
    if(arr[0][0]==arr[1][1] && arr[1][1]==arr[2][2])
    {
        cout<<"Yes";
        return 0;
    }
    if(arr[2][0]==arr[1][1] && arr[1][1]==arr[0][2])
    {
        cout<<"Yes";
        return 0;
    }
    cout<<"No";


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a<=0){
            cout << "No" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#define ll long long
map<ll,ll>mp;
int main()
{
    ll n,sum=0,ans;
    cin>>n;
    ll a[n+5];
    for(ll i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    for(auto it=mp.begin();it!=mp.end();it++){
        sum+=(it->second*(it->second-1))/2;
    }
    for(ll i=0;i<n;i++){
        ans=sum;
        if(mp[a[i]]>1)ans-=(mp[a[i]]*(mp[a[i]]-1))/2;
        if(mp[a[i]]>1)ans+=((mp[a[i]]-1)*(mp[a[i]]-2))/2;
        cout<<ans<<endl;
    }
    //cerr<<sum<<endl;

}


Measured memory_bytes: 11008
#include <stdio.h>

int min(int a, int b) {
	return a < b ? a : b;
}

void get(int a,int n, int arr[], int *max) {
	int d = a;
	while (d <= n) {
		arr[(*max)++] = d;
		d *= a;
	}
}

int f[100100] = {};
const int inf = 10000000;

int main() {
	int n;
	int arr[100000];
	int max = 1;
	int i, j;

	scanf("%d", &n);

	arr[0] = 1;
	get(6, n, arr, &max);
	get(9, n, arr, &max);

	f[0] = 0;
	f[1] = 1;

	for (i = 2; i <= n; i++) {
		f[i] = inf;
		for (j = 0; j < max; j++) {
			if (i - arr[j] >= 0) {
				f[i] = min(f[i], f[i - arr[j]] + 1);
			}
		}
	}

	int result = f[n] == inf ? 0 : f[n];
	printf("%d", result);

	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  int ans=0;
  int k[n];
  rep(i,n){
    cin >> k[i];
  }
  int tmp=0;
  int o=1;
  while(o<n){
    if(k[o-1]>=k[o])tmp++;
    else tmp=0;
    ans=max(ans,tmp);
    o++;
  }
  cout << ans << endl;
}  


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#define N 105
using namespace std;

int n, mn = 1e9, s = 0, x[N];
int main()
{
	int i, j;
	cin >> n;
	for (i = 0; i < n; i++) scanf("%d", &x[i]);
	for (i = 1; i < N; i++) {
		s = 0;
		for (j = 0; j < n; j++) s += (i - x[j]) * (i - x[j]);
		mn = min(mn, s);
	}
    cout << mn << endl;
    return 0;
}

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

string kansuu(string num)
{
	string ret = "";
	for (auto c : num) {
		if (c == '0') {
			ret += 'a';
		} else if (c == '1') {
			ret += 'b';
		} else if (c == '2') {
			ret += 'c';
		} else if (c == '3') {
			ret += 'd';
		} else if (c == '4') {
			ret += 'e';
		} else if (c == '5') {
			ret += 'f';
		} else if (c == '6') {
			ret += 'g';
		} else if (c == '7') {
			ret += 'h';
		} else if (c == '8') {
			ret += 'i';
		} else if (c == '9') {
			ret += 'j';
		}
	}
	return ret;
}


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

	vector<vector<pair<string, int>>> ans(10);
	ans.at(0).push_back(make_pair("0", 0));
	for (int i = 1; i < 10; i++) {
		for (auto ans_ele : ans.at(i - 1)) {
			string str = ans_ele.first;
			int max = ans_ele.second;
			for (int j = 0; j <= max + 1; j++) {
				pair<string, int> p;
				string s = str + to_string(j);
				int m = max;
				if (j == max + 1) {
					m = j;
				}
				ans.at(i).push_back(make_pair(s, m));
			}
		}
	}

	for (auto ans_ele : ans.at(n - 1)) {
		cout << kansuu(ans_ele.first) << endl;
	}

}



Measured memory_bytes: 10480
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
#define mo 1000000007
#define maxn 3005
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
inline int ksm(int x,int y=mo-2)
{
    int a=1;
    while(y)
    {
        if(y&1)a=1ll*a*x%mo;
        x=1ll*x*x%mo;y>>=1;
    }return a;
}
inline void Add(int &x,int y){x+=y;x-=(x>=mo?mo:0);}
inline int add(int x,int y){x+=y;return x>=mo?x-mo:x;}
int n,q;
int a[maxn];
int dp[maxn][maxn];
int main()
{
    n=read(),q=read();
    reg int i,j;
    for(i=1;i<=n;++i)a[i]=read();
    for(i=1;i<=n;++i)
        for(j=1;j<=n;++j)
            if(a[i]>a[j])dp[i][j]=1;
    reg int x,y,inv2=ksm(2);
    for(i=1;i<=q;++i)
    {
        x=read(),y=read();
        dp[x][y]=dp[y][x]=1ll*inv2*(dp[x][y]+dp[y][x])%mo;
        for(j=1;j<=n;++j)
        {
            if(j==x||j==y)continue;
            dp[j][x]=dp[j][y]=1ll*inv2*(dp[j][x]+dp[j][y])%mo;
            dp[x][j]=dp[y][j]=1ll*inv2*(dp[x][j]+dp[y][j])%mo;
        }
    }
    reg int ans=0;
    for(i=1;i<=n;++i)
        for(j=i+1;j<=n;++j)
            Add(ans,dp[i][j]);
    ans=1ll*ans*ksm(2,q)%mo;
    printf("%d\n",ans);
	return 0;
}


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

#define INF 0x3fffffff

typedef pair<int, int> Pos;
typedef pair<int, Pos> Data;
typedef pair<string, Data> Pair;
enum Dir {TOP, BOTTOM, NORTH, SOUTH, EAST, WEST};

string first_die = "rcgmby";
int dx[] = {0, -1, 0, 1};
int dy[] = {-1, 0, 1, 0};

int w;
int d;
char field[30][30];
char vs[8];
map<string, int> mind[8][30][30];
map<char, Pos> pos;

string Rotate(string die, vector<int> dirs) {
  string newdie = die;
  for (int i=0; i<4; i++) {
    newdie[dirs[(i+1)%4]] = die[dirs[i]];
  }
  return newdie;
}

string Advance(string die) {
  return Rotate(die, vector<int>{TOP, NORTH, BOTTOM, SOUTH});
}

string RotateRight(string die) {
  return Rotate(die, vector<int>{NORTH, EAST, SOUTH, WEST});
}

string RotateLeft(string die) {
  return Rotate(die, vector<int>{NORTH, WEST, SOUTH, EAST});
}

bool WithinRange(int y, int x) {
  if (y < 0 || d <= y) return false;
  if (x < 0 || w <= x) return false;
  return true;
}

int main() {
  while (1) {
    scanf("%d%d", &w, &d);
    if ((w|d) == 0) return 0;

    for (int i=0; i<d; i++) {
      for (int j=0; j<w; j++) {
        scanf(" %c", &field[i][j]);
        pos[field[i][j]] = Pos(i, j);
        for (int k=0; k<7; k++) mind[k][i][j].clear();
      }
    }

    vs[0] = '#';
    scanf("%s", &vs[1]);

    mind[0][pos[vs[0]].first][pos[vs[0]].second][first_die] = 0;
    queue<Pair> q;
    q.push(Pair(first_die, Data(0, pos[vs[0]])));
    while (!q.empty()) {
      int y, x;
      Pair p = q.front(); q.pop();
      string die = p.first;
      Data d = p.second;
      int t = d.first;
      tie(y, x) = d.second;
      //cout << t << " " << y << " " << x << "\n";
      //cout << "TOP: " << die[TOP] << "\n";
      //cout << "BOTTOM: " << die[BOTTOM] << "\n";
      int cost = mind[t][y][x][die];
      for (int i=0; i<4; i++) {
        int newx = x+dx[i];
        int newy = y+dy[i];
        if (!WithinRange(newy, newx)) continue;
        if (field[newy][newx] == 'k') continue;

        bool found = false;
        for (int j=1; j<7; j++) {
          if (j == t+1) continue;
          if (pos[vs[j]] == Pos(newy, newx)) {
            found = true;
            break;
          }
        }
        if (found) continue;

        int newt = t;
        if (field[newy][newx] == vs[t+1]) newt++;

        string newdie = die;
        for (int j=0; j<i; j++) {
          newdie = RotateRight(newdie);
        }
        newdie = Advance(newdie);
        for (int j=0; j<i; j++) {
          newdie = RotateLeft(newdie);
        }
        if (mind[newt][newy][newx].count(newdie)) continue;

        if (field[newy][newx] == vs[t+1]) {
          if (newdie[TOP] != vs[t+1]) continue;
        }

        mind[newt][newy][newx][newdie] = cost+1;
        q.push(Pair(newdie, Data(newt, Pos(newy, newx))));
      }
    }

    int ans = INF;
    for (auto itr : mind[6][pos[vs[6]].first][pos[vs[6]].second]) {
      ans = min(ans, itr.second);
    }
    if (ans == INF) puts("unreachable");
    else printf("%d\n", ans);
  }
}

Measured memory_bytes: 11808
x = gets.to_i


def prime (n)
  return true if n == 2
  lim = Math.sqrt(n).ceil
  (2..lim).each do |i|
    return false if n % i == 0
  end
  true
end

if x == 2
  puts x
  exit 0
end

x += 1 if x % 2 == 0
while true do
  break if prime (x)
  x +=2
end

puts x

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 4e2+5;

int dp[N][N];
int n;
int arr[N];
int pre[N];

int solve(int l, int r) {
	if(l==r)
		return 0;
	if(r-l==1) {
		return arr[l]+arr[r];
	}
	if(dp[l][r]>0)
		return dp[l][r];
	int cval = 1e18;
	for(int i=l;i<r;i++) {
		int cans = solve(l,i) + solve(i+1, r)+pre[r+1]-pre[l];
		cval = min(cans, cval);
	}
	return dp[l][r]=cval;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

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

	cout<<solve(0, n-1);

	return 0;
}

Measured memory_bytes: 4916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 40;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

ll dp[22000][300];

int main() {
    ll N, M;
    while(cin >> N >> M) {
        if(N == 0 && M == 0) return 0;

        vector<ll> C(M), x(N);
        rep(i, M) cin >> C[i];
        rep(i, N) cin >> x[i];

        rep(i, 22000) rep(j, 300) dp[i][j] = INF;
        dp[0][128] = 0;

        rep(i, N) rep(j, 256) {
            rep(k, M) {
                if(j + C[k] < 0) chmin(dp[i+1][0], dp[i][j] + x[i]*x[i]);
                else if(j + C[k] > 255) chmin(dp[i+1][255], dp[i][j] + (255-x[i])*(255-x[i]));
                else chmin(dp[i+1][j+C[k]], dp[i][j] + (j+C[k]-x[i])*(j+C[k]-x[i]));
            }
        }
        ll ans = INF;
        rep(j, 256) chmin(ans, dp[N][j]);
        cout << ans << endl;
    }
}



Measured memory_bytes: 54800
N, M = map(int, input().split())
ls = [[int(x) for x in input().split()] for _ in range(N)]


q = [[0] for _ in range(M)]
for a, b in ls:
    if a <= M:
        q[M-a].append(b*-1)

# print(q)

from heapq import heappop, heappush

pool = []
answer = 0
for x in reversed(q):
    for y in x:
        heappush(pool, y)
    m = heappop(pool)*-1
    answer += m
    

print(answer)

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

int main() {
    int N;
    cin >> N;
    vector<int>digit;
    while (N > 0){
        digit.push_back(N % 10);
        N /= 10;
    }
    ll ans = 0;
    int flag = 1;
    for (int i = 0; i < digit.size() - 1; ++i) {
        if(digit[i] != 0) flag = 0;
        ans += digit[i];
    }
    if(flag && digit.back() == 1){
        ans = 10;
    } else{
        ans += digit.back();
    }
    cout << ans;
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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[])
{
	int n;
	cin >> n;
	VVL abc(3,VL(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> abc[j][i];
		}
	}
	VVL dp(3,VL(n,0));
	for (int i = 0; i < 3; i++) {
		dp[i][0] = abc[i][0];
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			dp[j][i] = max(dp[(j+1)%3][i-1], dp[(j+2)%3][i-1]) + abc[j][i];
		}
	}
	cout << max(dp[0][n-1], max(dp[1][n-1], dp[2][n-1])) << endl;
	return 0;
}


Measured memory_bytes: 5744
#include <bits/stdc++.h>
#include <atcoder/dsu>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;
using namespace atcoder;

int main(){
  int n, q;
  cin >> n >> q;
  dsu d(n);
rep(_q, q){
  int t, u, v;
  cin >> t >> u >> v;
  if(t == 0) d.merge(u, v);
  else cout << d.same(u, v) << endl;
}
  return 0;
}

Measured memory_bytes: 3864
N, K = map(int, input().split())
xy = []
for _ in range(N):
    xy.append(tuple(map(int, input().split())))

xy=sorted(xy, key=lambda x:x[0])
#print(xy)

lst=[]
for left in range(0, N-K+1):
    for right in range(left+K-1,N):
        #print(left, right)
        W = xy[right][0] - xy[left][0]
        #print(W)
        temp=sorted(xy[left:right+1], key=lambda x:x[1])
        #print(temp)
        #含まれる点の個数はright-left+1個
        for bottom in range(0, right-left+1 - K+1):
            #print('W', W, 'bottom',bottom)
            H = temp[bottom+K-1][1] - temp[bottom][1]
            #print('H', H)
            lst.append(H * W)
#print('lst',lst)
print(min(lst))


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

const ll INF = 1LL << 60;

vector< vector< pair<int,int> > > to(100005);
vector< ll > pos(100005, INF);
set<int> A;

bool DFS( int v ) {
  bool ok = true;
//  cout << v << " : " << pos[v] << endl;
  for ( auto nv : to[v] ) {
//    cout << " " << nv.first << ", " << nv.second << " : " << pos[nv.first] << endl;
    if ( pos[nv.first] == INF ) {
      pos[nv.first] = pos[v] + nv.second;
      if (pos[nv.first] > 1000000000 && pos[nv.first] != INF) return false;
      ok = DFS( nv.first );
      if (!ok ) return ok;
    } else {
      if ( pos[nv.first] != pos[v] + nv.second ) {
//        cout << " false" << endl;
        return false;
      }
    }
  }
  return ok;
}

int main() {
  int N, M;
  cin >> N >> M;
  REP(i,M) {
    int l,r,d;
    cin >> l >> r >> d;
    to[l].emplace_back( r, d );
    to[r].emplace_back( l, -d );
    A.emplace(r);
    A.emplace(l);
  }
  for ( auto v : A ) {
    if ( pos[v] != INF ) continue;
    pos[v] = 0;
    if ( DFS( v ) == false ) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}



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

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    int ans = 0, cnt = 0;
    rep(i, n)
    {
        if (i == n - 1)
            ans = max(ans, cnt);
        if (h[i] >= h[i + 1])
            cnt++;
        else
        {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int n,m,A,B,cnt[1010],ans[1010][1010];

int main()
{
	scanf("%d%d%d%d",&n,&m,&A,&B);
	for (int i=0; i<=n; i++)
		for (int j=0; j<=m; j++)
			if (i*A+(n-i)*(m-A)==j*B+(m-j)*(n-B))
			{
				for (int k=1; k<=j; k++) cnt[k]=B;
				for (int k=j+1; k<=m; k++) cnt[k]=n-B;
				for (int k=1; k<=n; k++)
				{
					int c=(k<=i?A:(m-A));
					for (int l=1; c&&l<=m; l++)
						if (cnt[l]==0) ans[k][l]=0; else ans[k][l]=1,cnt[l]--,c--;
				}
				for (int k=1; k<=n; k++,puts(""))
					for (int l=1; l<=m; l++) putchar(ans[k][l]+'0');
				return 0;
			}
	return puts("-1"),0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF 2000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

using namespace std;

int main(void){
  int N,ans=0;
  cin >> N;
  int B[N-1];
  rep(i,N-1) cin >> B[i];
  int A[N];
  A[0]=B[0];
  for(int i=1;i<N-1;i++) A[i]=min(B[i-1],B[i]);
  A[N-1]=B[N-2];
  rep(i,N) ans+=A[i];
  cout << ans << endl;
}
  

Measured memory_bytes: 256
// in the name of Allah

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

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

const ll mod = 1000000007;

inline ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

inline ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

inline ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

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

	int n;
	cin >> n;
	ll a[n];
	for(int i=0; i<n; i++) {
		cin >> a[i];
	}
	ll all = 0, sgn = 1;
	for(int i=n-2; i>=0; i--) {
		all += a[i] * sgn;
		sgn *= -1;
	}
	assert(sgn == 1);
	ll b[n];
	b[n-1] = (a[n-1] + all);
	for(int i=n-2; i>=0; i--) {
		b[i] = 2*a[i] - b[i+1];
	}
	for(int i=0; i<n; i++) cout << b[i] << " ";

	return 0;
}

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

int main(){
	long N;
  cin>>N;
  if(N==1)
    cout<<1<<endl;
  else{
  for(long i=0;i<N;i++){
  	if(pow(i+1,2)>N){
    	cout<<i*i<<endl;
      break;
    }
  }
  }
}

Measured memory_bytes: 256
type point = Pt of float * float

let sub_vector (Pt (x1, y1)) (Pt (x2, y2)) = Pt (x2 -. x1, y2 -. y1)

let cross_sign v1 v2 v3 =
  let Pt (xv, yv), Pt (xu, yu) = (sub_vector v1 v2), (sub_vector v2 v3) in
  compare 0. (xv *. yu -. yv *. xu)

let rec loop () =
  try
    let line = read_line () in
    Scanf.sscanf
      line "%f,%f,%f,%f,%f,%f,%f,%f"
      begin
        fun x1 y1 x2 y2 x3 y3 x4 y4 ->
        let p1, p2, p3, p4 = Pt (x1, y1), Pt (x2, y2), Pt (x3, y3), Pt (x4, y4) in
        let sign = cross_sign p1 p2 p3 in
        let is_convex =
          List.for_all (fun (p, q, r) -> sign = cross_sign p q r)
                       [(p2, p3, p4); (p3, p4, p1); (p4, p1, p2)] in
        print_endline @@ if is_convex then "YES" else "NO"
      end;
    loop ()
  with End_of_file -> ()

let () = loop ();

Measured memory_bytes: 2308
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

s = rr()
t = rr()
cnt = 0
for i in range(len(s)):
  if s[i] != t[i]:
    cnt += 1
else:
  print(cnt)

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

int main() {
    int num, m;
    int cnt = 0;

    cin >> num >> m;

    if(num >= m){
        cout << 0;
        return 0;
    }

    vector<int> vec(m);
    vector<int> tmp(m-1);

    for(int i = 0; i < m; i++) cin >> vec.at(i);
    sort(vec.begin(), vec.end(), greater<int>());

    for(int i =0; i < m-1; i++){
        tmp.at(i) = abs(vec.at(i) - vec.at(i+1));
    }


    sort(tmp.begin(), tmp.end());
    for(int i = 0; i < tmp.size() - num + 1; i++){
        cnt += tmp.at(i);
    }

    cout << cnt;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
   
    int n, ans = 0;
    cin >> n;
    string s;
    cin >> s;

    s += 'Z';
    n++;

    for(int i = 0; i < n; i++){
        if(s[i] != s[i+1]) ans++;
    }

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


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int x[50],y[50];

bool check(int i1, int i2, int j1, int j2) {
  if (x[i1]-x[i2] != x[j2]-x[j1]) return 0;
  if (y[i1]-y[i2] != y[j2]-y[j1]) return 0;
  return 1;
}

int main() {
  int n;
  cin >> n;
  REP(i,n) cin >> x[i] >> y[i];
  if (n&1) {
    puts("NA");
    return 0;
  }
  REP(i,n/2) {
    if (!check(i,(i+1)%n,(i+n/2)%n,(i+n/2+1)%n)) {
      puts("NA");
      return 0;
    }
  }
  double ax = double(x[0]+x[n/2])/2;
  double ay = double(y[0]+y[n/2])/2;
  printf("%.10f %.10f\n", ax,ay);
}

Measured memory_bytes: 1200
#include <stdio.h>
#include <math.h>

typedef struct point { double x, y; } point;

point sub(point p, point q)
{
     point res = {
	  .x = p.x - q.x,
	  .y = p.y - q.y
     };
     
     return res;
}

double norm(point p)
{
     return hypot(p.x, p.y);
}

double S(point p, point q, point r)
{
     double a, b, c, z;
     
     a = norm(sub(p,q)), b = norm(sub(r,q)), c = norm(sub(r,p));
     z = (a + b + c) / 2;
     
     return sqrt(z*(z-a)*(z-b)*(z-c));
}

int main(void)
{
     point root, prev, curr;
     double res = 0;
     
     scanf("%lf,%lf", &root.x, &root.y);
     scanf("%lf,%lf", &prev.x, &prev.y);
     
     while(~scanf("%lf,%lf", &curr.x, &curr.y)){
	  res += S(root,prev,curr);
	  prev = curr;
     }

     printf("%lf\n", res);
     
     return 0;
}

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

/*.....DEFINITIONS...... */
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define T() int tt; cin>>tt; while(tt--)
#define mp make_pair
#define pb push_back
#define lchild (2*node+1)
#define rchild (2*node+2)
#define f first
#define s second
#define br cout<<"\n"
#define MOD (1000000007LL)
#define all(v) (v).begin(), (v).end()
using namespace std;

/*.....TYPEDEFS ....*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

/*....USEFUL FUNCTIONS....*/
ll gcd(ll a, ll b){ if(b==0)return a; else gcd(b, a%b);}
ll pwr(ll base, ll exp, ll mod=MOD){ll res=1; while(exp>0){if(exp%2){res=(res*base)%mod;}base=(base*base)%mod;exp/=2;}return res;}


/*---------Solution below this line --------*/
const int N = 1234567;

ll tree1[4LL*N], tree2[4LL*N];
ll a[N];

void seg1tree(int node, int lo, int hi){
    if(lo==hi){
        tree1[node] = a[lo];
    }
    else {
        int mid = (lo+hi)/2;
        seg1tree(lchild, lo, mid);
        seg1tree(rchild, mid+1, hi);
        tree1[node] = max(tree1[lchild], tree1[rchild]);
    }
}

void seg2tree(int node, int lo, int hi){
    if(lo==hi){
        tree2[node] = a[lo];
    }
    else {
        int mid = (lo+hi)/2;
        seg2tree(lchild, lo, mid);
        seg2tree(rchild, mid+1, hi);
        tree2[node] = min(tree2[lchild], tree2[rchild]);
    }
}




int main(){
FIO
//cout << fixed << setprecision(9);

ll n, k;
cin >> n >> k;

ll d = 1, mx=-1;
for(int i=0; i<n; ++i){
    int foo; cin >> foo;
    if(i==0)d = foo;
    else{
        d = gcd(d, foo);
    }
    mx = max(mx, 1LL*foo);
}

if(k%d==0 and k<=mx){
    puts("POSSIBLE");
}
else{
    puts("IMPOSSIBLE");
}



return 0;
}


Measured memory_bytes: 256
// finish date: 2018/05/20

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int A, B, C;
    ll K;
    cin >> A >> B >> C;
    cin >> K;
    if (K % 2 == 0) cout << A - B << endl;
    else cout << B - A << endl;


    return 0;
}




Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var h, w int
	_, _ = fmt.Scan(&h, &w)
	maps := make([][]string, h)
	
	for i := range maps {
		var s string
		_, _ = fmt.Scan(&s)
		ss := strings.Split(s, "")
		maps[i] = ss
	}
	
	dp := make([][]int, h)
	for i, _ := range dp {
		a := make([]int, w)
		for i := range a {
			a[i] = 1000000000
		}
		dp[i] = a
	}
	
	dp[0][0] = f(maps[0][0])
	
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if i == h-1 && j == w-1 {
				fmt.Println(dp[i][j])
			} else {
				if i == h-1 {
					dp[i][j+1] = min(dp[i][j+1], dp[i][j]+g(maps[i][j], maps[i][j+1]))
				} else if j == w-1 {
					dp[i+1][j] = min(dp[i+1][j], dp[i][j]+g(maps[i][j], maps[i+1][j]))
				} else {
					dp[i][j+1] = min(dp[i][j+1], dp[i][j]+g(maps[i][j], maps[i][j+1]))
					dp[i+1][j] = min(dp[i+1][j], dp[i][j]+g(maps[i][j], maps[i+1][j]))
				}
			}
		}
	}
	//
	//for _, v := range dp {
	//	for _, n := range v {
	//		fmt.Print(n)
	//	}
	//	fmt.Println()
	//}
}

func f(s string) int {
	if s == "#" {
		return 1
	} else {
		return 0
	}
}

func min(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

func g(s, ss string) int {
	if ss == "." {
		return 0
	} else if s == "#" {
		return 0
	} else {
		return 1
	}
}


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

using namespace std;


#define MAXN 200001
typedef long long ll;
int n, a[MAXN], s[21]={};

void add(int k) {
  for (int i = 0; i < 21; ++i) {
    if ((k>>i)&1) ++s[i];
  }
}

void remove(int k) {
  for (int i = 0; i < 21; ++i) {
    if ((k>>i)&1) --s[i];
  }
}

int check() {
  int ret = 1;
  for (int i = 0; i < 21; ++i) {
    ret &= s[i]<2;
  }
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int s = 0;
  ll ans = 0;
  for (int e = 0; e < n; ++e) {
    add(a[e]);
    while(!check()) {
      remove(a[s++]);
    }
    ans += e-s+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024