akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"

int32_t main() {
	boost;
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	int ans = 0;
	for(int i = n - 1; i > 0; i--) {
		int l = 0, r = i - 1;
		while(l < r) {
			if(a[l] + a[r] > a[i]) {
				ans += r - l;
				r--;
			}
			else
				l++;
		}
	}
	cout << ans << endl;	
}


Measured memory_bytes: 3664
#include <stdio.h>
int main(){
	int n,m,i,x,y,a;
	scanf("%d%d",&n,&m);
	a=m;
	for(i=0;i<n;i++){
		scanf("%d %d",&x,&y);
		m+=x-y;
		if(m<0)a=0;
		if(a>0&&m>a)a=m;
	}
	printf("%d\n",a);
    return 0;
}

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

using namespace std;

int main()
{
    int a,b,c,d,e;
    cin>>a>>b;
    c = a+b;
    d = a-b;
    e= a*b;
    if(c>=d && c>=e)
    {
        cout<<c<<endl;
    }
    else if(d>=c && d>=e)
    {
        cout<<d<<endl;
    }
    else if(e>=c && e>=d)
    {
        cout<<e<<endl;
    }
    return 0;
}


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

int R[4001],G[4001],B[4001];

int main()
{
	int n;
	string s;
	cin>>n>>s;
	
	int cnt1=1,cnt2=1,cnt3=1;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='R') R[cnt1++]=i;
		if(s[i]=='G') G[cnt2++]=i;
		if(s[i]=='B') B[cnt3++]=i;
	}
	
	long long sum=0;
	int temp;
	for(int i=1;i<cnt1;i++)
		for(int j=1;j<cnt2;j++)
		{
			sum+=cnt3-1;
			if(2*R[i]-G[j]>0)
				if(binary_search(B+1,B+cnt3,2*R[i]-G[j]))
					sum--;
			if(2*G[j]-R[i]>0)
				if(binary_search(B+1,B+cnt3,2*G[j]-R[i]))
					sum--;
			if((R[i]+G[j])%2==0)
				if(binary_search(B+1,B+cnt3,(R[i]+G[j])/2))
					sum--;
		}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>

void bubbleSort(int A[], int N){
    int flag = 1;
    int tmp;
    int num=0;
    while(flag){
        flag = 0;
        for(int i = 1; i < N; i++){
            if(A[i] < A[i-1]){
                tmp = A[i];
                A[i] = A[i-1];
                A[i-1] = tmp;
                flag = 1;
                num++;
            }
        }
    }
    for(int i = 0; i < N; i++){
        if(i != 0){
            printf(" "); 
        }
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", num);
}

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


    return 0;   
}


Measured memory_bytes: 2760
from heapq import heappush,heappop
K=int(input())
table=[[] for i in range(K)]
for i in range(K):
    table[i].append([1,(i+1)%K])
    t = (10*i)%K
    if t!=i:
        table[i].append([0,t])
dij=[]
visit=[False]*K
val=[10**9]*K
val[1]=0
heappush(dij,[0,1])
while dij:
    d,x=heappop(dij)
    if val[x]<d:
        continue
    for q,y in table[x]:
        if val[y]>val[x]+q:
            val[y]=val[x]+q
            heappush(dij,[val[y],y])
print(val[0]+1)

Measured memory_bytes: 47004
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
最後の0ラッシュで作れる値と同じだったらOKとか
10^18までふえうるかな
setとsort+uniqueどっちが時間かかるか
mapなら早いとかある？

くそう
mapでも超でかいメモリ。入る数字が多いということか
調整できないやつを探すとか
00001
00010
00100
01000
10000
の5個があれば、どれでも調整可能
調整できない桁を探すとか
010
111
101

010

101はいけるとか
最大2^100 2^100になるか
桁でみる？
さっぱりわからん
set,map,sort+unique全部だめ。
map有力だと思ったんだが
せいぜい2^30くらいまで

むしできるbit桁を探す
それででたのがM4かな
もっと短縮せな

項目3つって、パターン少ないの

うしろから見る。0になる要素なら継続、そうじゃないなら1で終了
*/
int main(){
  ll T,N; cin>>T;
  for(ll i=0; i<T; i++){
    cin>>N;
    vector<ll> A(N,0);
    for(ll j=0; j<N; j++) cin>>A[j];
    string S; cin>>S;
    vector<ll> DP(1,0);//ありえる要素の最小値を追加
    bool end=false;
    for(ll j=N-1; j>=0; j--){
      ll tmp=A[j];
      for(auto v:DP) tmp=min(tmp,tmp^v);
      if(S[j]=='0' && tmp>0) DP.emplace_back(tmp);
      else{
        if(tmp>0){//存在しなかったら0にならない
          end=true;
          break;
        }
      }
    }
    cout<<end<<endl;
  } 
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=1000000000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  vector<int> a(n);
  rep(i,n){
    int aa; cin>>aa;
    a[i]=aa-(i+1);
  }
  sort(a.begin(),a.end());

  // rep(i,n){
  //   cout<<a[i]<<" ";
  // }
  cout<<endl;
  ll ans=0;
  int b;
  if(n%2==1){
    b=a[n/2];
  }else{
    b=(a[n/2-1]+a[n/2])/2;
  }
  // cout<<b<<endl;
  rep(i,n){
    ans+=abs(a[i]-b);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

void abc_150a();

void abc_151a();

int main()
{
  //abc_150a();
  abc_151a();

}

void abc_150a()
{
  int K, X;
  cin >> K >> X;

  if (500 * K >= X) cout << "Yes\n";
  else cout << "No\n";
}

void abc_151a()
{
  char C;
  cin >> C;

  cout << (char)((int)C + 1) << "\n";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
constexpr int inf = 1e9;
constexpr int MAX_H = 1e4;


int main(){
    ll H,N,a,b,k; 
    cin >> H >> N;
    vector<ll>DP(H+1,1e18);
    DP[0] = 0;
    REP(i,N){
        cin >> a >> b;
        REP(j,H) k = min(j+a,H),DP[k] = min(DP[k],DP[j]+b);
    }
    cout << DP[H] << endl;
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    int X, A;
    cin >> X >> A;

    if(X<A){
        cout << 0 << endl;
    }
    else{
        cout << 10 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

const int mod=1e9+7;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];

    sort(ALL(a));

    vint b;
    if(N%2==0){
        for(int i=1;i<=N-1;i+=2) REP(j,2) b.push_back(i);
    }
    else{
        b.push_back(0);
        for(int i=2;i<=N-1;i+=2) REP(j,2) b.push_back(i);
    }

    if(a!=b) cout<<0<<endl;
    else{
        int ans=1; 
        REP(i,N/2) ans=ans*2%mod;
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 2168
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    vector<int> dp(n+1, 0);
    for(int i = 0; i < n; i++) cin >> v[i];
    for(int i = 0; i < n; i++) cin >> c[i];

    int ans = 0;

    for(int i = 0; i < n; i++) {
        dp[i + 1] = max(dp[i], v[i] - c[i] + dp[i]);
    }

    sort(dp.begin(), dp.end());
    reverse(dp.begin(), dp.end());

    cout << dp[0] << endl;
}

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

using namespace std;


int main(void) {
    int h,w;
    cin >> w >> h;
    vector<vector<char> > g(h, vector<char>(w));
    int E = 0, W = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> g[i][j];
            if (g[i][j]=='E') E++;
            else W++;
        }
    }

    int e = W;
    int ec = 0, wc = 0, ans = -1;
    for (int i = 0; i < w; i++) {
        for (int j = 0; j < h; j++) {
            if (g[j][i] == 'W') wc++;
            else ec++;
        }
        int error = W-wc + ec;
        if (error < e) e = error, ans = i;
    }
    cout << ans+1 << " " << ans+2 << endl;
}

Measured memory_bytes: 3940
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <set>
#include <cmath>
using namespace std;


int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i=0; i<N; i++)
        cin >> A[i];
    sort(A.begin(), A.end());

    if(N%2==0){
        long long ans = 0;
        for(int i=0; i<N/2; i++)
            ans -= 2*A[i];
        for(int i=N/2; i<N; i++)
            ans += 2*A[i];
        ans += A[N/2-1];
        ans -= A[N/2];
        cout << ans << endl;
    }else{
        long long ans0 = 0;
        for(int i=0; i<N/2; i++)
            ans0 -= 2*A[i];
        for(int i=N/2; i<N/2+2; i++)
            ans0 += A[i];
        for(int i=N/2+2; i<N; i++)
            ans0 += 2*A[i];

        long long ans1 = 0;
        for(int i=0; i<N/2-1; i++)
            ans1 -= 2*A[i];
        for(int i=N/2-1; i<N/2+1; i++)
            ans1 -= A[i];
        for(int i=N/2+1; i<N; i++)
            ans1 += 2*A[i];
        long long ans = max(ans0, ans1);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=(x); i<=(y); i++)
#define N 300010
#define M 1000010
#define ll long long
using namespace std;
int n,cnt,head[N],c[N][2],l[N],r[N],len[N],fa[N],sz[N];
ll a[M],b[M],p[N],q[N],np[N],nq[N];
inline bool dfs(int u,ll lim) {
	int x=c[u][0],y=c[u][1];
	if(!x) {//叶子节点
		sz[u]=1; l[u]=r[u]=++cnt;
		a[cnt]=b[cnt]=len[u];
		return 1;
	}
	if(dfs(x,lim)&&dfs(y,lim)) {//两个子树都符合要求
		if(sz[x]>sz[y]) swap(x,y);//启发式合并
		int tp=0;//two-pointers
		for(int i=l[x],j=l[y]; i<=r[x]; i++) {
			while(j<=r[y]&&b[i]+a[j]<=lim) j++;//找出所有的合法状态
			if(j>l[y]) p[++tp]=a[i],q[tp]=b[j-1];//只需要保存最小的那个b
		}
		if(!tp) return 0;
		rep(i,tp+1,tp<<1) {//将a,b交换后同样可行
			p[i]=q[tp-(i-tp)+1]; q[i]=p[tp-(i-tp)+1];
		}
		int k=1;
		for(int i=1,j=tp+1; k<=tp<<1; k++)//归并排序，按照a从小到大排
			if((j>tp<<1)||i<=tp&&p[i]<=p[j]) {
				np[k]=p[i]; nq[k]=q[i++];
			} else {
				np[k]=p[j]; nq[k]=q[j++];
			}
		l[u]=cnt+1;
		rep(i,1,tp<<1) if(i==1||np[i]>a[cnt]&&nq[i]<b[cnt]) {//去掉无用状态
			a[++cnt]=np[i]; b[cnt]=nq[i];
		} else if(np[i]==np[i-1]) b[cnt]=min(b[cnt],nq[i]);
		r[u]=cnt; sz[u]=r[u]-l[u]+1;
		rep(i,l[u],r[u]) a[i]+=len[u],b[i]+=len[u];
	} else return 0;
	return 1;
}
inline bool check(ll x) {
	cnt=0; return dfs(1,x);
}
int main() {
	scanf("%d",&n);
	rep(i,2,n) {
		scanf("%d%d",&fa[i],&len[i]);
		c[fa[i]][c[fa[i]][0]>0]=i;
	}
	ll l=0,r=1e15,mid;
	while(l<=r) {
		mid=l+r>>1;
		if(check(mid)) r=mid-1; else l=mid+1;
	}
	printf("%d\n",r+1);
	return 0;
}

Measured memory_bytes: 31488
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 

 
void solve()
{
	int n ;
	cin>>n ; 
	set<string>s ;
	rep(i , n){
		string temp ; 
		cin>>temp ;
		s.insert(temp) ;
	}
	cout<<s.size()<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 19300
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};
struct edge { int to, cost; };

signed main() {
	int a, b;
	cin >> a >> b;
	cout << max({ a + b,a - b,a * b })<< endl;
}

Measured memory_bytes: 256
#include<iostream>
#define PARENT(x) ((x)/2)
#define LEFT(x) ((x)*2)
#define RIGHT(x) ((x)*2+1)

using namespace std;
int H[255];
int n;

bool valid(int key){
	return (key <= n) && (key > 0);
}

void printNode(int id){
	cout<<"node "<<id<<": key = "<<H[id]<<", ";
	int parent = PARENT(id);
	int left = LEFT(id);
	int right = RIGHT(id);
	if(valid(parent)){
		cout<<"parent key = "<<H[parent]<<", ";
	}
	if(valid(left)){
		cout<<"left key = "<<H[left]<<", ";
		if(valid(right)){
			cout<<"right key = "<<H[right]<<", ";
		}
	}
	cout<<endl;
}

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>H[i];
	}
	for(int i=1;i<=n;i++){
		printNode(i);
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 3100
{-# LANGUAGE FlexibleContexts #-}

module Main where

import Debug.Trace
import Data.List
import qualified Data.Sequence as S
import qualified Data.ByteString.Char8 as B
import Data.Int
import Data.Char
import Data.Array
-- import Data.Array.IO
import Data.Maybe
import qualified Data.Map as M
-- import Control.Monad.ST
-- import Data.STRef
import Data.Ord
import Data.Functor
import Control.Applicative
import Control.Monad
import Text.Printf
    
solve :: Int -> [[Int]] -> [[Int]] -> [Bool]
solve n al ql = map (\[x, y] -> components M.! x == components M.! y) ql where  
    components = iter 1 usedVertices [0..n-1] where
        iter c tbl [] = tbl 
        iter c tbl (x:xs) 
            | M.member x tbl = iter c tbl xs
            | otherwise = iter (c+1) (dfs tbl x) xs where
                dfs tbl x
                    | M.notMember x tbl = foldl' dfs updateTbl (adjacentsList!x)
                    | otherwise = tbl where
                        updateTbl = M.insert x c tbl

    usedVertices = M.empty            
    adjacentsList = accumArray (flip (:)) [] (0, n-1) $ [(x,y) | [x,y] <- al]++[(y,x) | [x,y] <- al]

readIntLn:: IO Int
readIntLn = (fst . fromJust . B.readInt) <$> B.getLine

readIntList:: IO [Int]
readIntList = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

print' :: Bool -> IO ()
print' True  = putStrLn "yes" 
print' False = putStrLn "no" 

main :: IO() 
main = do
    [n, m] <- readIntList
    al <- replicateM m readIntList
    q  <- readIntLn
    ql <- replicateM q readIntList
    mapM_ print' $ solve n al ql



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

using namespace std;
int main(){
    long long a[4];
    scanf("%lld %lld %lld %lld", a, a+1, a+2, a+3);
    long long ans=0x8000000000000000;
    int p=0;
    for(int i=0; i<2; ++i){
        for(int j=2; j<4; j++){
            ans = max(ans, a[i]*a[j]);
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3860
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>

int n;

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


Measured memory_bytes: 256
# AGC002B - Box and Ball
def main():
    N, M, *XY = map(int, open(0).read().split())
    R = [0] * (N + 1)  # red ball may be in box i
    R[1] = 1
    C = [1] * (N + 1)  # number of balls in box i (count)
    for x, y in zip(*[iter(XY)] * 2):
        R[y] = 1 if R[x] or R[y] else 0  # red ball may move from x to y
        C[x] -= 1
        C[y] += 1
        R[x] = 0 if C[x] == 0 else R[x]  # no more ball in x
    ans = sum(R[1:])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25116
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    n = int(input())
    As = list(map(int, input().split()))

    mod = 10**9+7
    sums = [0] * (n+1)

    tmp = 0
    for i, a in enumerate(As[::-1]):
        tmp += a
        tmp %= mod
        sums[-i-1] = tmp

    total = 0
    for i, a in enumerate(As[:-1]):
        total += a * (sums[i+2])
        total %= mod

    return total


def main():
    print(solve())


if __name__ == "__main__":
    main()


Measured memory_bytes: 31716
package main

import (
	"fmt"
)

type Point struct {
	I, J int
}

func main() {
	var h, w int
	fmt.Scanf("%d %d", &h, &w)
	var maze [20][20]bool
	for i := 0; i < h; i++ {
		var line string
		fmt.Scanf("%s", &line)
		for j := 0; j < w; j++ {
			if line[j] == '.' {
				maze[i][j] = false
			} else {
				maze[i][j] = true
			}
		}
	}

	maxDistance := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if maze[i][j] == true {
				continue
			}
			distance := searchMax(Point{i, j}, maze, h, w)
			if distance > maxDistance {
				maxDistance = distance
			}
		}
	}

	fmt.Println(maxDistance)
}

func searchMax(start Point, done [20][20]bool, h, w int) int {
	maxDistance := 0
	heads := []Point{start}
	done[start.I][start.J] = true
	for {
		var newHeads []Point
		for _, head := range heads {
			for _, xy := range [4][2]int{{-1, 0}, {1, 0}, {0, -1}, {0, 1}} {
				i := head.I + xy[0]
				j := head.J + xy[1]
				if i < 0 || i >= h || j < 0 || j >= w {
					continue
				}
				if done[i][j] == true {
					continue
				}
				done[i][j] = true
				newHeads = append(newHeads, Point{i, j})
			}
		}
		if len(newHeads) != 0 {
			maxDistance++
		} else {
			break
		}
		heads = newHeads
	}
	return maxDistance
}

Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
#include <algorithm>
using namespace std;

long long N, M, S;
long long X[1 << 18], Y[1 << 18], A[1 << 18], B[1 << 18];
long long C[1 << 18], D[1 << 18];
vector<pair<int, int>> G[109];

priority_queue<tuple<long long, int, int>, vector<tuple<long long, int, int>>, greater<tuple<long long, int, int>>> Q;
long long dp[59][2509];

int main() {
	cin >> N >> M >> S;
	for (int i = 1; i <= M; i++) cin >> X[i] >> Y[i] >> A[i] >> B[i];
	for (int i = 1; i <= N; i++) cin >> C[i] >> D[i];
	for (int i = 1; i <= M; i++) {
		G[X[i]].push_back(make_pair(Y[i], i));
		G[Y[i]].push_back(make_pair(X[i], i));
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= 2500; j++) dp[i][j] = (1LL << 60);
	}
	dp[1][min(2500LL, S)] = 0;
	Q.push(make_tuple(0, 1, min(2500LL, S)));

	while (!Q.empty()) {
		int a1 = get<1>(Q.top());
		int a2 = get<2>(Q.top()); Q.pop();
		if (dp[a1][min(2500LL, a2 + C[a1])] > dp[a1][a2] + D[a1]) {
			dp[a1][min(2500LL, a2 + C[a1])] = dp[a1][a2] + D[a1];
			Q.push(make_tuple(dp[a1][min(2500LL, a2 + C[a1])], a1, min(2500LL, a2 + C[a1])));
		}
		for (pair<int, int> i : G[a1]) {
			int to = i.first, idx = i.second;
			if (a2 - A[idx] >= 0 && dp[to][a2 - A[idx]] > dp[a1][a2] + B[idx]) {
				dp[to][a2 - A[idx]] = dp[a1][a2] + B[idx];
				Q.push(make_tuple(dp[to][a2 - A[idx]], to, a2 - A[idx]));
			}
		}
	}

	for (int i = 2; i <= N; i++) {
		long long ret = (1LL << 60);
		for (int j = 0; j <= 2500; j++) ret = min(ret, dp[i][j]);
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 6304
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)

bool isPrime(int x) {
  int i;
  if(x < 2)return 0;
  else if(x == 2) return 1;
  if(x%2 == 0) return 0;
  for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
  return 1;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll cnt = 0;
  sort(All(a));
  ll t = a[0];
  vector<ll> ss;

  rep(i,n) {
    t = gcd(t,a[i]);
  }
  if (t != 1) {
    cout << "not coprime\n";
    return 0;
  }
  else {
    rep(i,n-1) {
      if (a[i] == a[i+1] && a[i] != 1) goto ww;
    }

    rep(i,n) {
      auto s = prime_factorize(a[i]);
      rep(j,s.size()) {
        ss.push_back(s[j].first);
      }
    }
    sort(All(ss));
    if (ss.size() > 1) {
      rep(i,ss.size()-1) {
        if (ss[i] == ss[i+1]) {
          cout << "setwise coprime\n";
          return 0;
        }
      }
    }

    cout << "pairwise coprime\n";
    return 0;

    ww:
    cout << "setwise coprime\n";
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}


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

glaf = [[] for i in range(N)]

for i in range(M):
    a,b = map(int,input().split())
    a=a-1
    b=b-1
    glaf[a].append(b)
    glaf[b].append(a)
    
for i in glaf:
    cnt =0
    for j in i:
        cnt+=1
    
    print(cnt)

Measured memory_bytes: 3064
s = input()
count = 0
a, c, q = 0, 0, 0
for i in range(len(s)):
    if s[i] == 'C':
        c += 1
    elif s[i] == '?':
        q += 1
    else:
        continue
c = 3 * c + q
p = pow(3, q-3)
for i in range(len(s)):
    if s[i] == 'A':
        a += 3
    elif s[i] == 'C':
        c -= 3
    elif s[i] == 'B':
        count += 3*a*c
    else:
        c -= 1
        count += a*c
        a += 1
print(int(count*p) % 1000000007)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int D = Integer.parseInt(sc.next());
        int[][] point = new int[N][D];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < D; j++) {
                point[i][j] = Integer.parseInt(sc.next());
            }
        }

        int counter = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                int tmpSum = 0;
                for (int k = 0; k < D; k++) {
                    tmpSum += Math.pow(point[i][k] - point[j][k], 2);
                }

                int tmp = (int) Math.sqrt(tmpSum);

                if (tmpSum == tmp * tmp) {
                    counter++;
                }
            }
        }

        System.out.println(counter);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <list>
//#include <bits/stdc++.h>


using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
typedef long long ll;

int main(){
    int n;
    int count=0;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(to_string(i).length() % 2 == 1){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    ve<ve<int>> a(n,ve<int>(n-1));
    rep(i,n){
        rep(j,n-1){
            cin >> a[i][j];
            a[i][j]--;
        }
        reverse(a[i].begin(), a[i].end());
    }
    ve<P> q;
    auto check = [&](int i){
        if(a[i].size() == 0) return;
        int j = a[i].back();
        if(a[j].size()==0) return;
        if(a[j].back() == i){
            if(i>j) swap(i,j);
            P p(i,j);
            q.push_back(p);
        }
    };
    rep(i,n){
        check(i);
    }
    int day = 0;
    while(q.size()>0){
        day++;
        sort(q.begin(), q.end());
        q.erase(unique(q.begin(), q.end()), q.end());
        ve<P> prevq;
        swap(q,prevq);
        for(P p: prevq){
            int i = p.first, j = p.second;
            a[i].pop_back();
            a[j].pop_back();
            check(i);
            check(j);
        }
    }
    rep(i,n){
        if(!a[i].empty()) day = -1;
    }
    cout << day << endl;
    return 0;
}

Measured memory_bytes: 4224
c = []
while s = gets
  c.push(s.split.map(&:to_i))
end

#puts c[0][0]
#puts c[0][1]
#puts c[1][0]
#puts c[1][1]
puts (c[0][0]-c[1][0])*(c[0][1]-c[1][1])

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n;
	cin>>n;
  cout<<"ABC"<<n;
  /*
	vector<pair<int,int>>ship(m);
	vector<int>s(n),g(n),sg(n);
	rep(i,m){
	    cin>>ship[i].first>>ship[i].second;
	    if(ship[i].first==1)s[ship[i].second]++;
	    else if(ship[i].second==n)g[ship[i].first]++;
	}
	rep(k,n){
	    sg[k]=s[k]*g[k];
	    ans+=sg[k];
	}
	if(ans)cout<<"POSSIBLE";
	else cout<<"IMPOSSIBLE";*/
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int n;
	cin >> n;
	string sub;
	getchar();
	for (int i = 0; i < n; ++i) {
		string s;
		getline(cin, s);
		for (int j = 0; j < s.size(); ++j) {
			if (s.size() < 7) {
				break;
			}
			sub = s.substr(j, 7);
			if (sub == "Hoshino") {
				s.replace(j, 7, "Hoshina");
			}
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 2976
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second
int main()
{
    ll n;cin >> n;
    ll arr[n];
    cin >> arr[0];
    ll x = arr[0];
    for(ll i=1;i<n;i++)
    {
        cin >> arr[i];
        x = x^arr[i];
    }
    for(ll i=0;i<n;i++)
    {
        cout << (x^arr[i]) << " ";
    }
    cout << endl;
}
    

Measured memory_bytes: 5072
#include <bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
using ar=array<ull,26>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
int main(){
	string s1,s2;
	ar ht; ht.fill(1);
	rep(i,25) ht[i+1]=ht[i]*10007;
	
	while(cin>>s1>>s2){
		if(s1.size()>s2.size()) swap(s1,s2);
		int n1=s1.size(), n2=s2.size();
		
		set<ull> list1;
		for(int l=n1;l>=1;l--){
			list1.clear();
			ull tmp=0;
			rep(i,n1) {
				tmp+=ht[s1[i]-'a'];
				if(i>=l) tmp-=ht[s1[i-l]-'a'];
				if(i>=l-1) list1.insert(tmp);
			}
			tmp=0;
			rep(i,n2){
				tmp+=ht[s2[i]-'a'];
				if(i>=l) tmp-=ht[s2[i-l]-'a'];
				if(i>=l-1) {
					if(list1.find(tmp) != list1.end()){
						cout<<l<<endl;
						goto end;
					}
				}
			}
		}
		cout<<0<<endl;
		end: ;
	}
	return 0;
}



Measured memory_bytes: 3396
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
sys.setrecursionlimit(10**6)
input = sys.stdin.readline


def main():
    s, w = map(int, input().split())
    if s > w:
        print("safe")
    else:
        print("unsafe")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9468
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let x: u64 = s.trim().parse().ok().unwrap();

    let mut ans = (x / 11) * 2;
    ans += if x % 11 == 0 {
        0
    } else if x % 11 < 7 {
        1
    } else {
        2
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#!python3.4
# -*- coding: utf-8 -*-
# abc157/abc157_a
import sys
import math

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    print(math.ceil(N / 2))
    return

main()


Measured memory_bytes: 3064
#!/usr/bin/python
# -*- coding: utf-8 -*-

def main():
    # 入力
    input = []
    while(True):
        try:
            input_list = list2int(raw_input().split())
            input.append(input_list)
        except EOFError:
            break

    for x in input:
        print(sum(x))

# リストの要素をintに変換
def list2int(list):
    return [int(x) for x in list]

if __name__=='__main__':
    main()

Measured memory_bytes: 4200
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    private static int Q;
    private static int N;
    private static int M;
    private static int[] a;
    private static int[] b;
    private static int[] c;
    private static int[] d;

    public static void main(String[] args) {
        int N = nextInt();
        int M = nextInt();
        int[] H = new int[N];
        Arrays.setAll(H, i->nextInt());
        HashMap<Integer, List<Integer>> map = new HashMap<>();
        HashMap<Integer, List<Integer>> map2 = new HashMap<>();
        for(int i=0; i<M; i++){
            int A = nextInt();
            int B = nextInt();
            if(map.containsKey((Integer)A)){
                List<Integer> list = map.get((Integer)A);
                list.add(B);
                map.put(A, list);
            }else{
                List<Integer> list = new ArrayList<>();
                list.add(B);
                map.put(A, list);
            }
        }

        boolean[] isOK = new boolean[N];
        Arrays.fill(isOK, true);
        for(int key : map.keySet()){
            for(Integer value : map.get(key)){
                //println(key + "," + value + "," + (H[key-1] <= H[value-1]));
                if(H[key-1] <= H[value-1]){
                    isOK[key-1] = false;
                }
                if(H[value-1] <= H[key-1]){
                    isOK[value-1] = false;
                }
            }
        }
        int count = 0;
        for(boolean ok : isOK){
            if(ok) count++;
        }

        println(count);

    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


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

int main(){
  int a;
  int b;
  int x;
  cin >> a >> b >> x;
  float h = 2*x / (a*b);
  double theta = 0;
  if(h <= float(a)){
    theta = atan2(a*b*b, 2*x);
    theta = theta * (180/M_PI);
  }else{
    float w = 2*b - 2.0*x/(a*a);
    theta = atan2(w, float(a));
    theta = theta * (180/M_PI);
  }
  cout << fixed;
  cout << setprecision(10) << theta << endl;
  return 0;
}


Measured memory_bytes: 256
c11,c12,c13 = map(int,input().split())
c21,c22,c23 = map(int,input().split())
c31,c32,c33 = map(int,input().split())


a1 = c11
a2 = c21
a3 = c31

if (c12-a1 == c22-a2 and c22-a2==c32-a3 and c13-a1 == c23-a2 and c23-a2 == c33-a3) is True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#create date: 2020-06-30 09:30

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    ans = 1
    if min(a) == 0:
        print(0)
        quit()
    for ai in a:
        ans *= ai
        if ans > 10**18:
            print(-1)
            quit()
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 21748
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    long long N, x;
    scanf("%lld%lld", &N, &x);
    long long ans = 0;
    vector<long long> a(N);
    REP (i, N) {
        scanf("%lld", &a[i]);
    }
    if (a[0] > x) {
        ans += a[0] - x;
        a[0] = x;
    }
    for (int i = 0; i <= N - 2; i++) {
        if (a[i] + a[i + 1] > x) {
            ans += a[i] + a[i + 1] - x;
            a[i + 1] = x - a[i];
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    ll h,w;
    cin >> h >> w;
    ll ans = 0;
    if(h==1 || w==1){
        cout << 1 << endl;
        return 0;
    }
    ans += ((h+1LL)/2LL) * ((w+1LL)/2LL) + (w/2LL)*(h/2LL);
    cout << ans << endl;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

	int a,b,c;
	cin >> a >> b >> c;

	if(a - b > c){
		cout << 0;
	} else {
		cout << c - (a-b);
	}

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long i,j,t,a,b,n,c,x,y,m,prev,sum;
    t=1;
    // cin>>t;
    while(t--)
    {
       string s;
       cin>>s;
       for(i=0;i<s.length();i+=2)
       cout<<s[i];
    }
}

Measured memory_bytes: 512
n,m,k = map(int,input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A,B = [0],[0]
 
for i in range(n):
  A.append(a[i] + A[i])
for i in range(m):
  B.append(b[i] + B[i])
 
num,x = 0,m
 
for i in range(len(A)):
  if A[i] > k:
    break
  while A[i] + B[x] > k:
    x -= 1
  num = max(num, i + x)
  
print(num)
 

Measured memory_bytes: 47448
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            String x = Console.ReadLine();
            //???????????????????????£??\
            String[] array = x.Split(' ');

            //??°???????????´????????£??\
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);

            //??????????????¨???
            if (a == b) {
                Console.WriteLine("a == b");
            }else if (a > b)
            {
                Console.WriteLine("a > b");
            }else
            {
                Console.WriteLine("a < b");
            }

        }
    }
}

Measured memory_bytes: 8836
import sys
sys.setrecursionlimit(10**9)
N,M = map(int,input().split())
note = [[0]*N for i in range(N)]
visited = [False]*N
visited[0] = True
ans = 0
for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    note[a][b] = 1
    note[b][a] = 1

def dfs(p=0, depth=0):
    if depth == N-1:
        global ans
        ans += 1
        return
    for i in range(N):
        if note[p][i] == 1 and visited[i] is False:
            visited[i] = True
            dfs(i,depth+1)
            visited[i] = False

dfs()
print(ans)

Measured memory_bytes: 3064
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
ll x[101], y[101];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++)
        cin >> x[i] >> y[i];
    for (ll i = 0; i + 2 < n; i++)
        if (x[i] == y[i] && x[i + 1] == y[i + 1] && x[i + 2] == y[i + 2])
            return cout << "Yes", 0;
    cout << "No";
}

Measured memory_bytes: 3644
#include<stdio.h>

int main()
{
	double a,b,c,d,e,f,n,m,x,y;
	while((scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f))!=EOF){
	y=(a*f-c*d)/(a*e-d*b);
	x=c/a-b*y/a;
	y=1000*y;
	x=1000*x;
	if(y>=0)
	y=y+0.5;
	else if(x>=0)
	x=x+0.5;
	else if(y<0)
	y=y-0.5;
	else if(x<0)
		x=x-0.5;
	y=(int)y;		
	x=(int)x;
	y=y/1000;
	x=x/1000;
	printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 652
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: u64 = sc.cin();
    let mut x: Vec<(u64, u64)> = (0..n).map(|_| (sc.cin(), sc.cin())).collect();
    x.sort();
    let ans = x.iter().fold((0, m),
           |(sum, rest), &(a, b)| (sum + a * min(rest, b), rest - min(rest, b)));
    // trace!(ans);
    put!(ans.0);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 6396
#include <stdio.h>

int main()
{
    int i, A, B, zeiA, zeiB, flag=0;
    
    scanf("%d %d", &A, &B);
    
    for(i=13; i<=1000; i++){
        zeiA = i*0.08;
        zeiB = i*0.1;
        if(zeiA==A&&zeiB==B){
            printf("%d", i);
            return 0;
        }else{
            flag++;
        }
    }
    
    if(flag)
        printf("-1");
        
    return 0;
}


Measured memory_bytes: 128
import collections
N, M = map(int, input().split())
sc = [tuple(map(int, input().split())) for i in range(M)]
t = collections.defaultdict(int)
flag = True
for s, c in sc:
    if s in t and t[s] != c:
        flag = False
        break
    else:
        t[s] = c

if flag:
    ans = []
    for i in range(1, N+1):
        if i in t:
            if i == 1 and t[i] == 0 and N > 1:
                print(-1)
                exit(0)
            else:
                ans.append(t[i])
        else:
            if i != 1:
                ans.append(0)
            else:
                if N == 1:
                    ans.append(0)
                else:
                    ans.append(1)

    print("".join(map(str, ans)))
else:
    print(-1)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>
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(x * a, y * a);}
  Point operator / (double a){return Point(x / a, y / a);}

  double abs(){return sqrt(norm());}
  double norm(){return x * x + y * y;}

  bool operator < (const Point &p) const{
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point &p) const{
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }

};

typedef Point Vector;

double dot(Vector a, Vector b){
  return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b){
  return a.x * b.y - a.y * b.x;
}

void solve(){
  int q; cin >> q;
  vector<int> ans(q);
  for(int i = 0; i < q; i++){
    int x0, y0, x1, y1, x2, y2, x3, y3;
    cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    Vector v0 = Vector(x1 - x0, y1 - y0);
    Vector v1 = Vector(x3 - x2, y3 - y2);
    if(equals(dot(v0, v1), 0)) ans[i] = 1;
    else if(equals(cross(v0, v1), 0)) ans[i] = 2;
  }
  for(int i = 0; i < q; i++){
    cout << ans[i] << endl;
  }
  return;
}

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



Measured memory_bytes: 3108
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	int H, W;
	char a[101][101];

	cin >> H >> W;

	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
			cin >> a[i][j];

	int height = H;
	int width = W;

	int delete_row;
	while (true){
		// ぜんぶ白の行を探す
		delete_row = -1;

		for (int i = 0; i < height; i++){
			// i行目の白の数
			int white_count = 0;
			for (int j = 0; j < width; j++){
				if (a[i][j] == '.'){
					white_count++;
				}
			}
//			cout << white_count << endl;
			if (white_count == width){
				delete_row = i;
//				cout << delete_row << endl;
				break;
			}
		}
		if (delete_row < 0) break;

		if (delete_row >= 0){
			for (int i = delete_row; i < height; i++){
				for (int j = 0; j < width; j++){
					a[i][j] = a[i + 1][j];
				}
			}
			height--;
		}
	}

	int delete_column;
	while (true){
		// ぜんぶ白の列を探す
		delete_column = -1;

		for (int j = 0; j < width; j++){
			// j列目の白の数
			int white_count = 0;
			for (int i = 0; i < height; i++){
				if (a[i][j] == '.'){
					white_count++;
				}
			}
			if (white_count == height){
				delete_column = j;
//				cout << delete_column << endl;
				break;
			}
		}
		if (delete_column < 0) break;

		if (delete_column >= 0){
			for (int j = delete_column; j < width; j++){
				for (int i = 0; i < height; i++){
					a[i][j] = a[i][j+1];
				}
			}
			width--;
		}
	}

	for (int i = 0; i < height; i++){
		for (int j = 0; j < width; j++){
			cout << a[i][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int[] num = in.nextIntArray(3);
			Arrays.sort(num);
			String ans = "";
			if (num[0] == 5 && num[1] == 5 && num[2] == 7) {
				ans = "YES";
			} else {
				ans = "NO";
			}
			out.println(ans);
		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

int main(){
  int N,M;
  cin>>N>>M;
  int H[N],P[M][2];
  for(int i=0;i<N;i++) cin>>H[i];
  for(int i=0;i<M;i++) cin>>P[i][0]>>P[i][1];
  int betters[N]={0};
  for(int m=0;m<M;m++){
    if(H[P[m][0]-1]<=H[P[m][1]-1]){
      betters[P[m][0]-1]=1;
    }
    if(H[P[m][0]-1]>=H[P[m][1]-1]){
      betters[P[m][1]-1]=1;
    }
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(betters[i]==0) count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 5192