akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 2000005



typedef struct{
  int key, lk, rk, pk;
}Node;



void Insert(int);
int Extractmax();
void MaxHeapify(int);
void buildMaxHeap();

Node node[N];
int hsize;
	    
int main () {
  int i, n = 0;
  char str[8];


  while(1) {
    scanf("%s",str);
    if(strcmp(str,"end") == 0) break;

    else if(strcmp(str,"insert") == 0) {
      scanf("%d",&n);
      Insert(n);
    }

    else printf("%d\n",Extract());
  }


  return 0;
}


void Insert(int n) {
  int i;
  int tmp;

  hsize++;

  node[hsize].key =  n;

  if(hsize > 1) node[hsize].pk = hsize/2;
  
  if(hsize >= 3) {
    node[hsize/2].lk = node[hsize/2*2].key;
    node[hsize/2].rk = node[hsize/2*2+1].key;
  }

  i = hsize;

  while( i > 1 && node[node[i].pk].key < node[i].key) {
    tmp = node[node[i].pk].key;
    node[node[i].pk].key = node[i].key;
    node[i].key = tmp;
    i = node[i].pk;
  }

 

}


int Extract() {
  int max;
  
  if(hsize < 1) return 0;

  //buildMaxHeap();

  max = node[1].key;
  node[1] = node[hsize];
  hsize--;
  MaxHeapify(1);

  return max;
}


void MaxHeapify(int x) {
  int left = 2 * x, right = 2 * x + 1, large = 0, tmp = 0;


  if(left <= hsize && node[left].key > node[x].key) large = left;
  
  else large = x;
  
  if(right <= hsize && node[right].key > node[large].key) large = right;

  if(large != x) {
    tmp = node[x].key;
    node[x].key = node[large].key;
    node[large].key = tmp;
    MaxHeapify(large);
  }
 
}


void buildMaxHeap() {
  int i;
  
  for(i = hsize/2 ; i >= 1 ; i--) MaxHeapify(i);
}



Measured memory_bytes: 17328
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
//ll N,W;
 //ll dp[1000000001];
int main(){

    ll a,b;
    cin>>a>>b;
    if(abs(a-b)<=1){puts("Brown");}else{
        puts("Alice");
    }
    
return 0;
}


Measured memory_bytes: 256
import sys
x,n =map(int,input().split())
if n == 0:
    print(x)
    sys.exit()
p = list(map(int,input().split()))
p.sort()
wk = 101
an = 0
#if n ==100:
 #   print(0)
  #  sys.exit()
for i in range(102):
    #if x!=i:
    if p.count(i)==0:
        if abs(x-i)<wk:
            an =i
            wk = abs(x-i)

print(an)

Measured memory_bytes: 9204
// This code wrote by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
#define int long long
using namespace std;
const int MaxAi=4e9;
struct Node
{
	int x,h;
	inline bool operator < (const Node &nt) const
	{
		return x<nt.x;
	}
}b[200050];
template <class t> inline void read(t &s)
{
	s=0;
	reg int f=1;
	reg char c=getchar();
	while(!isdigit(c))
	{
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	s*=f;
	return;
}
int val[20000000],lazy[20000000],ndn=1;
int ls[20000000],rs[20000000];
int n,d,a;
#define lson ls[u]
#define rson rs[u]
inline void pushup(int u)
{
	val[u]=val[lson]+val[rson];
	return ;
}
inline void pushdown(int u,int l,int r)
{
	if(lazy[u])
	{
		reg int mid=(l+r)>>1;
		if(!lson)
			lson=++ndn;
		if(!rson)
			rson=++ndn;
		lazy[lson]+=lazy[u];
		lazy[rson]+=lazy[u];
		val[lson]+=lazy[u]*(mid-l+1);
		val[rson]+=lazy[u]*(r-mid);
		lazy[u]=0;
	}
	return;
}
inline int modify(int &u,int l,int r,int ql,int qr,int k)
{
	if(!u)
		u=++ndn;
	if(ql<=l&&r<=qr)
	{
		val[u]+=(r-l+1ll)*k;
		lazy[u]+=k;
		return u;
	}
	pushdown(u,l,r);
	reg int mid=(l+r)>>1;
	if(ql<=mid)
		lson=modify(lson,l,mid,ql,qr,k);
	if(mid<qr)
		rson=modify(rson,mid+1,r,ql,qr,k);
	pushup(u);
	return u;
}
inline int query(int u,int l,int r,int p)
{
	if(!u)
		return 0;
	if(l==r)
		return val[u];
	pushdown(u,l,r);
	reg int mid=(l+r)>>1;
	if(p<=mid)
		return query(lson,l,mid,p);
	else
		return query(rson,mid+1,r,p);
	return 0;
}
signed main(void)
{
	reg int rt=1;
	cin>>n>>d>>a;
	for(int i=1;i<=n;++i)
	{
		read(b[i].x);
		read(b[i].h);
		modify(rt,0,MaxAi,b[i].x,b[i].x,b[i].h);
	}
	sort(b+1,b+n+1);
	reg int ans=0;
	for(int i=1;i<=n;++i)
	{
		int t=query(rt,0,MaxAi,b[i].x);
		// printf("test %lld is %lld\n",i,t);
		if(t<=0)
			continue;
		reg int now=t/a+((t%a)>0?1:0);
		modify(rt,0,MaxAi,b[i].x,b[i].x+2ll*d,-now*a);
		ans+=now;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 214656
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    double a,b;
    cin >> a >> b;
    
    double x = 0;
    x = (a+b)/2 + 0.9;
    
    int x2 = 0;
    x2 = x;
    
    cout << x2 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	for(int i=0;i<200;i++)
	{
		c-=b;
		if(c<=0&&a>0)
		{
			cout<<"Yes";
			return 0;
		}
		a-=d;
		if(a<=0&&c>0)
		{
			cout<<"No";
			return 0;
		}
    }
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<string.h>
int main (void){
    char *S[1];
    char *s1 = "Sunny";
    char *s2 = "Rainy";
    char *s3 = "Cloudy";
    scanf("%s",S);

    if(strcmp(S,s1)== 0){
        printf("Cloudy\n");
    }else if(strcmp(S,s2)==0){
        printf("Sunny\n");
    }else if(strcmp(S,s3)==0){
        printf("Rainy\n");
    }
    return 0;
}

Measured memory_bytes: 128
from sys import stdin


class DisjointSet():
    def __init__(self):
        self.parent = None
        self.ancestor = self


def ancestor(elems, x):
    s = elems[x].ancestor
    while s.parent is not None:
        s = s.parent
    elems[x].ancestor = s
    return s


def unite(elems, x, y):
    ax = ancestor(elems, x)
    ay = ancestor(elems, y)
    if ax is not ay:
        ax.parent = ay
        ax.ancestor = ay.ancestor


def same(elems, x, y):
    return ancestor(elems, x) is ancestor(elems, y)


def main():
    n, q = [int(x) for x in input().split()]
    elems = [DisjointSet() for _ in range(n)]

    for _ in range(q):
        com, x, y = [int(x) for x in input().split()]
        if com == 0:
            unite(elems, x, y)
        else:
            print(1 if same(elems, x, y) else 0)


if __name__ == '__main__':
    main()



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

#define sp ' '
#define endl '\n'
#define st first
#define nd second
#define sz(x) ((long long int)x.size())
#define pb push_back
#define pob pop_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << '\n'
#define prs(XX) cout << XX << ' '
#define TEST cout << "TEST\n";

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

const long long int MOD = 1e9 + 7;
const long long int INF = 2e9 + 13;
const long long int mINF = -2e9 - 13;
const double PI = acos(-1.0);
const double EPS = 1e-9;

ll mx(ll x, ll y){ return (x>y?x:y); }
ll mn(ll x, ll y){ return (x<y?x:y); }

void max_self(ll &x, ll y){ x = mx(x, y); }
void min_self(ll &x, ll y){ x = mn(x, y); }
void add(ll &x, ll y){ x%=MOD; x += (y%MOD); x %= MOD; }
void mul(ll &x, ll y){ x%=MOD; x *= (y%MOD); x %= MOD; }

ll us(ll n, ll x, ll m){
    if(x == 0) return 1;
    ll a = us(n, x>>1, m);
    return (((a*a)%m)*(x&1?n:1))%m;
}

ll N;
vll X;

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    cin >> N;
    X.resize(N);
    for(auto& x: X) cin >> x;

    ll miny = INF;
    for(ll i = 1; i <= 100; ++i){
        ll sum = 0;
        for(ll j = 0; j < N; ++j){
            sum += abs(X[j]-i)*abs(X[j]-i);
        }
        min_self(miny, sum);
    }
    cout << miny << endl;

    return 0;
}

//cikisir



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
   
public class Main {
    boolean[] dictionary = new boolean[33554432];
    public static void main(String[] args) throws IOException {
//    	long l = System.currentTimeMillis();
        new Main().exec();
//    	long l2 = System.currentTimeMillis();
//    	System.out.println(l2 - l);
    }
      
    public void exec() throws IOException {
        InputUtil in = new InputUtil();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        for(int i=0; i<n; i++) {
        	String cmd = in.br.readLine();
        	if(cmd.charAt(0)=='i'){
        		insert(cmd.substring(7));
        	}else{
        		out.println(find(cmd.substring(5))?"yes":"no");
        	}
        }
        out.flush();
    }
    
    private void insert(String str) {
    	int key = convertKey(str);
		dictionary[key] = true;
    }

    private boolean find(String str) {
    	int key = convertKey(str);
		return dictionary[key];
    }
    
    private int convertKey(String str) {
    	int len = str.length();
    	int key = 4;
    	for(int i=0; i<len; i++) {
    		switch(str.charAt(i)){
    		case 'A':
    			key|=1;
    			break;
    		case 'G':
    			key|=2;
    			break;
    		case 'C':
    			key|=3;
    		}
    		key <<= 2;
    	}
    	return key;
    }
}

class InputUtil {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public String[] readStrArray(String delim) throws NumberFormatException, IOException{
    	return br.readLine().split(delim);
    }
    
    public int nextInt() throws NumberFormatException, IOException{
    	return Integer.parseInt(br.readLine());
    }

}

Measured memory_bytes: 94712
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
int main() {
	int x, y, z; cin >> x >> y >> z;
	int ans = 0;
	for(int i=1;i<=(x-z)/(y+z);i++){
		ans = i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
MODE = "stdio"

line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = "\
  3
  5
  11
  7
  8
  19
  0
  ".split("\n")
  tmp.each{|s|
    line << s.strip
  }
end

i=1
line.each do |n|
  if n=="0"
    break
  end
  puts "Case #{i}: #{n}"
  i += 1
end

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
void solve()
{
    ll n,x,t;
    cin>>n>>x>>t;
    ll a=(n+x-1)/x;
    cout<<(t*a);
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}



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

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

	int n;
	cin >> n;
	vector<pair<int, int> > stuff(n);
	vector<int> rem(n, n);
	vector<int> which(n * n, -1);
	for (int i = 0; i < n; i++) {
		int p;
		cin >> p;
		p--;
		stuff[i] = {p, i};
		which[p] = i;
	}
	sort(stuff.begin(), stuff.end());
	auto fail = [&]() -> void {
		cout << "No" << '\n';
		exit(0);
	};
	int cur = 0;
	vector<int> ans(n * n, -1);
	for (auto z : stuff) {
		for (int _ = 0; _ < z.second; _++) {
			while (cur < z.first && ans[cur] != -1) cur++;
			if (cur >= z.first) fail();
			ans[cur] = z.second;
			rem[z.second]--;
		}
		if (ans[z.first] != -1) fail();
		ans[z.first] = z.second;
		rem[z.second]--;
	}
	vector<bool> good(n, false);
	for (int i = 0; i < n * n; i++) {
		if (which[i] != -1) good[which[i]] = true;
		if (ans[i] == -1) {
			for (int x = 0; x < n; x++) {
				if (rem[x] && good[x]) {
					ans[i] = x;
					rem[x]--;
					break;
				}
			}
			if (ans[i] == -1) fail();
		}
	}
	for (int x = 0; x < n; x++) assert(rem[x] == 0);
	cout << "Yes" << '\n';
	for (int i = 0; i < n * n; i++) {
		cout << ans[i] + 1 << " \n"[i+1==n*n];
	}

	return 0;
}


Measured memory_bytes: 3200
n = int(input())
t_tp = 0
h_tp = 0
for i in range(n):
    t_c,h_c = map(str,input().split())

    if t_c == h_c:
        t_tp += 1
        h_tp += 1
    else:
        t_p = 0
        h_p = 0
        for j in range(len(t_c)):
            t_p += ord(t_c[j])
        for k in range(len(h_c)):
            h_p += ord(h_c[k])
        if t_c > h_c:
            t_tp += 3
        else:
            h_tp += 3
            
        
            
print(t_tp,h_tp)
        


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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	string S;
	cin >>S;
	if (S == "SUN")print(7);
	if (S == "MON")print(6);
	if (S == "TUE")print(5);
	if (S == "WED")print(4);
	if (S == "THU")print(3);
	if (S == "FRI")print(2);
	if (S == "SAT")print(1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mod 1000000007

int modInverse(ll a, ll m) 
{ 
    ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) 
      return 0; 
    while (a > 1) 
    { 
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
       x += m0; 
    return x; 
} 
 ll dp[200000];

int po(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%mod;
		y=y>>1;
		x=(x*x)%mod;
	}
	return res;
}

ll nck(ll n, ll k) {
	ll ans=1;
	for(int i=1; i<=k; ++i)
		ans=ans*(n-i+1)%mod*dp[i]%mod;
	return ans;
}
int main()
{
	ll h;
	cin>>h;
	ll ans;
	ans=log(h)/log(2);
	ans++;
	ll a=1;
	for(int i=0;i<ans;i++)
	{
		a=a*2;

	}
	cout<<a-1<<endl;
    
}


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

int main() {
  string S, T; cin >> S >> T;
  int M = S.size();
  int N = T.size();
  if (M < N) { cout << "UNRESTORABLE" << endl; return 0; }
  for (int i = M-N; i >= 0; i--) {
    bool found = true;
    int idx = 0;
    for (int j = i; j < i+N; j++) {
      if (S.at(j) != T.at(idx) && S.at(j) != '?') found = false;
      idx++;
    }
    if (found) {
      string ans = "";
      for (int j = 0; j < M; j++) {
        if (j < i) {
          if (S.at(j) == '?') ans += 'a';
          else ans += S.at(j);
        }
        else if (j == i) {
          ans += T;
          j += N-1;
        }
        else {
          if (S.at(j) == '?') ans += 'a';
          else ans += S.at(j);
        }
      }
      cout << ans << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  int K;
  int a = 0;
  long long int sum = 0;
  cin>>N;
  cin>>K;
  int arr[N];
  for(int i = 0;i < N;i++){
    cin>>arr[i];
  }
  sort(arr,arr + (N),greater<int>());
  for(int i = 0;i <= N && i < K;i++){
    arr[i] = 0;
    a += 1;
  }
  for(int i = a;i < N;i++){
    sum += arr[i];
    //cout<<"A"<<arr[i]<<'\n';   
  }
  cout<<sum<<'\n';
}

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

#define M 1046527/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1;
  int i;
  for ( i = 0; i < (int)strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1));}

int find(char str[]){
  int i,hash,key;
  key = getKey(str);
  i = 0;
  while(1){
    hash = (h1(key) + i * h2(key))%M;
    if(strcmp(H[hash],str) == 0)return 1;
    else if(strlen(H[hash]) == 0)return 0;
    i++;
  }
  return 0;
}

int insert(char str[]){
  int i,hash,key;
  key = getKey(str);
  i = 0;
  while(1){
    hash = (h1(key) + i * h2(key))%M;
    if(strcmp(H[hash],str) == 0)return 1;
    else if(strlen(H[hash]) == 0){
      strcpy(H[hash],str);
      return 0;
    }
    i++;
  }
  return 0;
  /* your task */

}

int main(){
  int i, n;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}


Measured memory_bytes: 16100
ps = gets.to_i.times.map { Complex(*gets.split.map(&:to_i)) }
p ps.size.times.all? {|i|
  u, v = ps[(i+1)%ps.size] - ps[i], ps[i-1] - ps[i]
  (v / u).arg >= 0
} ? 1 : 0

Measured memory_bytes: 8996
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

const int lim = 2e5 + 5;
const int mod = 1e9 + 7;

int n, m;
int a, b;

int fact[lim], inv[lim];

int powmod(int x, int k)
{
    if(k == 0) return 1;
    int t = powmod(x, k / 2);
    if(k % 2 == 0) return t * 1LL * t % mod;
    else return t * 1LL * t % mod * x % mod;
}

void prep()
{
    fact[0] = 1;
    for(int i = 1; i < lim; ++i)
        fact[i] = fact[i - 1] * 1LL * i % mod;
    inv[lim - 1] = powmod(fact[lim - 1], mod - 2);
    for(int i = lim - 2; i >= 0; --i)
        inv[i] = inv[i + 1] * 1LL * (i + 1) % mod;
}

void read_input()
{
    cin >> n >> m >> a >> b;
}

int C(int k, int n)
{
    return fact[n] * 1LL * inv[k] % mod * inv[n - k] % mod;
}

void add(int&tar, int val)
{
    tar += val;
    if(tar >= mod) tar -= mod;
}

void solve()
{
    int ans = 0;
    for(int i = 1; i <= n - a; ++i)
        add(ans, C(i - 1, b + i - 2) * 1LL * C(n - i, n - i + m - b - 1) % mod);
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    prep();
    read_input();
    solve();
}



Measured memory_bytes: 1792
#include<cstdio>

int M,N,K;

char map[1001][1001];
int J[1001][1001], O[1001][1001], I[1001][1001];

int main()
{
  scanf("%d%d%d",&M,&N,&K);

  for (int i = 1; i <= M; i++) {
    for (int j = 1; j <= N; j++) {
      scanf(" %c", &map[i][j]);
    }
  }

  for (int i = 1; i <= M; i++) {
    for (int j = 1; j <= N; j++) {
      J[i][j] = J[i-1][j] + J[i][j-1] - J[i-1][j-1];
      O[i][j] = O[i-1][j] + O[i][j-1] - O[i-1][j-1];	
      I[i][j] = I[i-1][j] + I[i][j-1] - I[i-1][j-1];	
      if (map[i][j] == 'J') J[i][j]++;
      if (map[i][j] == 'O') O[i][j]++;
      if (map[i][j] == 'I') I[i][j]++;
    }
  }

  int a,b,c,d;
  while (K--) {
    scanf("%d%d%d%d",&a,&b,&c,&d);
    printf("%d %d %d\n",
	   J[c][d] - J[c][b-1] - J[a-1][d] + J[a-1][b-1],
	   O[c][d] - O[c][b-1] - O[a-1][d] + O[a-1][b-1],
	   I[c][d] - I[c][b-1] - I[a-1][d] + I[a-1][b-1]
	   );
  }
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vector<int>>;

void svtr(vector<int> &a){
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
}

int main() {
  int H,W,h,w;
  cin >> H >> W >> h >> w;

  cout << (H-h)*(W-w) ;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;
 
#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
 
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
template<typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val){ //usage: int dp[10][10]; Fill(dp,INF);
    std::fill( (T*)array, (T*)(array+N), val );
}
 
typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
/*const int MAXN = 100001;
 
struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};*/
 
//-----Template---------
int n;
int a[20001];
int p[20001];
int main(){
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin>>n;
    for (int i = 1; i <= n; ++i) {
        cin>>p[i];
    }
    for (int i = 1; i <= n; ++i) {
        a[i]=20010*i;
    }
    for (int i = 1; i <=n ; ++i) {
        a[p[i]]+=i;
    }
 
    for (int i = 1; i <= n; ++i) {
        cout<<a[i];
        if(i!=n)
            cout<<" ";
    }
    cout<<endl;
    for (int i = n; i >0; --i) {
        cout<<20010*i;
        if(i!=1)
            cout<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
	double N,n;
	int i,j;
	scanf("%lf",&N);
	for(i=1;i<=N;i++)
	{
		if(N==1)
		{
			n=1;
			break;
		}
		if(i*i>N)
		{
			n=(i-1)*(i-1);
			break;
		}
	}
	printf("%.0lf",n);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()

X = 1
c = 0
for i in range(0,N):
    X = X * A[i]
    if X <= 10**18:
        c = c + 1
    else:
        break

if c == N:
    print(X)
else:
    print("-1")

Measured memory_bytes: 21476
N = int(input())
w = [input() for i in range(N)]
answer = 'Yes'

for i  in w:
    if w.count(i) > 1:
        answer = 'No'
        break

if answer == 'No':
    print(answer)
else:
    for i in range(N-1):
        if w[i][-1] != w[i+1][0]:
            answer = 'No'
            break
    print(answer)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
	int n=0,m=0;
	string key="",ancer="";
	while(cin>>n){
		key="";
		ancer="";
		if(n==0)break;
		for(int i=n;i>0;i--){
			char tmp1,tmp2;
			cin>>tmp1>>tmp2;
			key+=tmp1;
			key+=tmp2;
		}
		cin>>m;
		bool check=false;
		for(int i=m;i>0;i--){
			char tmp;
			cin>>tmp;
			for(int i=0;i<n*2;i+=2){
				if(tmp==key[i]){
					ancer+=key[i+1];
					check=true;
					break;
				}
			}
			if(!check)ancer+=tmp;
			check=false;
		}
		cout<<ancer<<endl;
	}
	return 0;
}


Measured memory_bytes: 3288
gets
as={}
s=0
gets.split.each{|e|
  e=e.to_i
  s+=e
  as[e]=(as[e]||0)+1
}
gets
$<.each{|l|
  b,c=l.split.map &:to_i
  if t=as.delete(b)
    s+=t*(c-b)
    as[c]=(as[c]||0)+t
  end
  puts s
}


Measured memory_bytes: 24788
n = int(input())

biggest = 0
biggest_arg = 0
second_biggest = 0
second_biggest_arg = 0

for i in range(n):
  num = int(input())
  if num >= biggest:
    second_biggest = biggest
    second_biggest_arg = biggest_arg
    
    biggest = num
    biggest_arg = i
  elif num >= second_biggest:
    second_biggest = num
    second_biggest_arg = i

for i in range(n):
  if i == biggest_arg:
    print(second_biggest)
  else:
    print(biggest)

Measured memory_bytes: 55640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
const ll inf =1000000007;

void solve(){
    double r;
    cin >> r;
    double ans=2*r*3.1415926535;
    printf("%.12f\n",ans);
}

int main(){
    solve();
}

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

int main()
{
  int N, L;
  int e[201];
  cin >> N >> L;
  int min = 999;
  int min_num = -1;
  for(int i=0; i<N; i++){
    e[i] = L + i;
    if (abs(e[i]) < min) {
      //cout << abs(e[i]) << ", " << e[i] << endl;
      min = abs(e[i]);
      min_num = i;
    }
  }
  int sum = 0;
  for(int i=0; i<N; i++){
    if(i != min_num){
      sum += e[i];
      }
  }
  cout << sum << endl;
  return 0;
}


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

int ps[100005];
char s[100005];

int main()
{
    int n,q;
    cin>>n>>q;
    cin>>s;

    int l=strlen(s);

    for(int i=1;i<l;i++)
	{
        if (s[i-1]=='A' && s[i]=='C') 
		  ps[i]++;
        ps[i]+=ps[i - 1];
    }

    while(q--)
	{
        int x,y;
        cin>>x>>y;
        x--;
		y--;
        cout<<ps[y] - ps[x]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>

int main(){
	int n,yen,x,y,z;
	
	scanf("%d%d",&n,&yen);
	yen=yen/1000;
	
	for(x=yen/10;x>=0;x--){
		for(z=0;z<=n-x;z++){
			y=n-x-z;
			if(10*x+5*y+z==yen){
				printf("%d %d %d\n",x,y,z);
				return 0;
			}
		}
	}
	
	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <stdio.h>

#define PI 3.14159265359

using namespace std;

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double res;
  if (x <= 0.5 * a * a * b) {
    res = atan(2.0 * x / (a * b * b));
  } else {
    res = atan(a / (2.0 * (b - x / (a * a))));
  }
  printf("%.7f\n", 90 - res * 180 / PI);
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define xrep(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define vl vector<long long>
#define vs vector<string>
#define all(A) A.begin(), A.end()

int main() {
    ll n; cin >> n;
    vl a(n), b(n), c(n);
    rep(i,n) cin >> a[i] >> b[i] >> c[i];

    vector<vl> dp(n, vl(3)); //0:a, 1:b, 2:c

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    xrep(i,1,n){
        dp[i][0] = a[i] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i] + max(dp[i-1][0], dp[i-1][1]);
    }

    ll ans = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    cout << ans << endl;
}

Measured memory_bytes: 11124
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
    cin.tie(0);
    long double a, b, k;
    cin >> a >> b >> k;
    long double temp = k - a;
    a -= k;
    if(a < 0){
        a = 0;
        b -= temp;
        if(b < 0)
            b = 0;
    }
    cout << fixed << setprecision(0) << a << ' ' << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i, N;
	int maxv, minv;
	int R[200000] = {0};
	
	scanf("%d", &N);
	
	for(i = 0; i < N; i++) {
        scanf("%d", &R[i]);
    }
	
	maxv = -2000000000;
	minv = R[0];
	
	for(i = 1; i < N; i++) {
		if(maxv < (R[i] - minv)) {
			maxv = (R[i] - minv);
		} if(minv > R[i]) {
			minv = R[i];
		}
	}
	
	printf("%d\n", maxv);
	
	return 0;
	
}




Measured memory_bytes: 2632
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
#define int long long

int32_t main(){
   boost;
   int n,x;
   cin>>x>>n;
   int ans = -1,cnt = 1e5;
   map<int,int>mp;
   for(int i=0,t;i<n;i++){
      cin>>t;
      mp[t]=1;
   }
   for(int i=0;i<105;i++){
      if(mp[i]>0)
         continue;
      if(abs(x-i) < cnt){
         cnt = abs(x-i);
         ans = i;
      }
      else if(abs(x-i) == cnt)
         ans = min(ans,i);
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3660
#include<complex>
#include<stdio.h>
#include<cmath>
#define F(a,b,c) acos((b*b+c*c-a*a)/2/b/c)
int main(){
	int n;double d,e,f,g,h,i;
	for(scanf("%d",&n);n--;){
		scanf("%lf%lf%lf%lf%lf%lf",&d,&g,&e,&h,&f,&i);
		std::complex<double> a(d,g),b(e,h),c(f,i);
		double A=abs(b-c),B=abs(c-a),C=abs(a-b),
		s=sin(2*F(A,B,C)),t=sin(2*F(B,C,A)),u=sin(2*F(C,A,B)),v=s+t+u;
		printf("%.3f %.3f %.3f\n",(d*s+e*t+f*u)/v,(g*s+h*t+i*u)/v,A/sin(F(A,B,C))/2);
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    int N = 0;
    int M = 0;
    cin >> N >> M;

    int P[1000000] = {};
    int Y[1000000] = {};
    vector<int> yd[1000001];

    for (int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
        yd[P[i]].push_back(Y[i]);
    }

    for (int i = 0; i < N; i++) {
        sort(yd[i + 1].begin(), yd[i + 1].end());
    }

    for (int i = 0; i < M; i++) {
        int x;
        x = int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin() + 1);
        printf("%012lld\n", (long long)P[i] * 1000000 + x);
    }
    return 0;
}


Measured memory_bytes: 35840
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

int main()
{
  int ans=100000000,N,A,B,C;
  cin>>N>>A>>B>>C;
  vector <int> l(N), D(N);
  for(int i=0;i<N;i++){
    cin>>l[i];
  }
  for(int mask=0; mask<pow(4,N); mask++){
    int tmp=mask;
    int al=0,bl=0,cl=0;
    int an=0,bn=0,cn=0;
    for(int pos=0; pos<N; pos++){
      if(tmp % 4==1){
        al+=l[pos];
        an++;
      }
      if(tmp % 4==2){
        bl+=l[pos];
        bn++;
      }
      if(tmp % 4==3){
        cl+=l[pos];
        cn++;
      }
      tmp /= 4;
    }
    if(an*bn*cn!=0){
      int tmp2=abs(A-al)+abs(B-bl)+abs(C-cl)+(an+bn+cn-3)*10;
      ans=min(ans,tmp2);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
using namespace std;
using ll = long long;

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

    int p[n];
    
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int ans = 0;
    for (int i=1;i<n-1;i++){
        if ((p[i-1]<p[i] && p[i] < p[i+1]) || (p[i-1]>p[i] &&p[i] > p[i+1]) ){
            ans ++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
int n,a[100005],cnt;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
int main()
{
	//freopen("Friendly Rabbits.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=1;i<=n;i++) if(a[a[i]]==i) cnt++;
	printf("%d\n",cnt/2);
	//fclose(stdin); fclose(stdout);
	return 0;
}


Measured memory_bytes: 640
import numpy as np

N = int(input())
A = np.asarray(list(map(int,input().split())))
A_sort = np.sort(A)
# print(A_sort)
k = 0
for i in range(1,N+1):
    count = 0
    for j in range(k,N-1):
        if A_sort[j] == i:
            count += 1
        else:
            break
    print(count)
    k += count


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

int main(){
  int a[5];
  REP(i, 5) cin >> a[i];
  int k;
  cin >> k;
  sort(a, a+5);
  bool ok = true;
  if (a[4]-a[0]>k) ok=false;
  cout << (ok ? "Yay!" : ":(") << endl;
  return 0;
}

Measured memory_bytes: 256
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

a, b, c = rm()
print(min(c, b//a))















Measured memory_bytes: 27036
n,c=map(int,input().split())
d=[list(map(int,input().split())) for i in range(c)]
c_=[list(map(int,input().split())) for i in range(n)]
g=[[] for i in range(3)]
for i in range(n):
    for j in range(n):
        g[(i+j+2)%3].append(c_[i][j]-1)
#print(g)
'''
for i in range(c):
    for j in range(c):
        for k in range(c):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])
print(d)
'''
f=[[] for i in range(3)]
for i in range(3):
    for j in range(c):
        x=0
        for k in g[i]:
            x+=d[k][j]
        f[i].append((j,x))
    f[i]=sorted(f[i],key=lambda x:x[1])[:3]
ans=[]
#print()
for i in f[0]:
    for j in f[1]:
        for k in f[2]:
            if i[0]!=j[0] and k[0]!=j[0] and i[0]!=k[0]:
                #print(i[0],j[0],k[0])
                #print(i[1],j[1],k[1])
                ans.append(i[1]+j[1]+k[1])
print(min(ans))


Measured memory_bytes: 7792
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;

fn main() {
    let (n, k): (usize, usize);
    input!(n, k);
    let mut h = input_vector::<usize>();
    h.sort();
    h.reverse();
    for i in 0..k {
        if i >= h.len() {
            break;
        }
        h[i] = 0;
    }
    println!("{}", h.iter().sum::<usize>());
}


Measured memory_bytes: 13560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
int cnt,n,now,table[10][10],mark[10][10];
map<int,int> vis;

int main(){
  // freopen("input.txt","r",stdin);
  for(int i = 1;i <= 3;i++){
    for(int j = 1;j <= 3;j++){
      cin>>table[i][j];
    }
  }
  cin>>n;
  for(int i = 1;i <= n;i++){
    cin>>now;
    for(int i = 1;i <= 3;i++){
      for(int j = 1;j <= 3;j++){
	if(table[i][j] == now) mark[i][j] = 1;
      }
    }
  }
  bool haveans = false;
  for(int i = 1;i <= 3;i++){
    if(mark[i][1] && mark[i][2] && mark[i][3]) haveans = true;
    if(mark[1][i] && mark[2][i] && mark[3][i]) haveans = true;
  }
  if(mark[1][1] && mark[2][2] && mark[3][3]) haveans = true;
  if(mark[1][3] && mark[2][2] && mark[3][1]) haveans = true;
  if(haveans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sp <<" "<<
bool isprime(ll n){
    if (n <= 1)return false;ll g=sqrt(n);
    for (ll i = 2; i <= g; i++)if (n % i == 0)return false;
    return true;
}
ll MOD=1e9+7;
ll power(ll base, ll exp)
{
    if(exp==1)return base;
    else{if(exp%2==0){ll base1=(pow(power(base, exp/2),2));return base1%MOD;}
        else{ll ans=(base*pow(power(base,(exp-1)/2),2));return ans%MOD;}}
}
ll temp,temp1,temp2;
int main()
{
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    ll n,sum=0,res=0;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    for(ll i=0;i<n;i++)
    {
        sum-=a[i];
        res+=((a[i]%MOD)*(sum%MOD))%MOD;
        res%=MOD;
    }
    res%=MOD;
    cout<<res;
    
    return 0;
}

Measured memory_bytes: 5172
import sys
input = sys.stdin.readline
enum = enumerate

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def vinput(rep=1, ty=int, cvt=list):
	return cvt(ty(input().rstrip()) for _ in "*"*rep)

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	N = int(input())
	vA = linput()
	#vA.sort()
	#vA.reverse()
			
	vC =[a-pp for a,pp in zip(vA[1:],vA)
		 if a!=pp]
		
	res = 0
	pp = 0

	for c in vC:
		if pp==0:
			pp = 1 if c>0 else -1
			res += 1
		if c*pp<0:
			pp = 0
	
	if pp==0:
		res += 1
	#sT = "No Yes".split()
	#print(sT[res])
	print(res)

if __name__ == "__main__":
	main()


Measured memory_bytes: 91568
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#include<random>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (int)(Y);++(X))
#define reps(X,S,Y) for (int (X) = (int)(S);(X) < (int)(Y);++(X))
#define rrep(X,Y) for (int (X) = (int)(Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (int)(Y)-1;(X) >= (int)(S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	string s;
	cin>>s;
	cout<<s.substr(0,3) NL;
  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//



     signed main(){
  int d;
  clock_t st=clock();
  cin>>d;
    clock_t ed=clock();

  int c[26];
  for(int i=0;i<26;i++)cin>>c[i];
  int t[d],s[d][26],x[26]={};
    vector<int>v[26];
    for(int i=0;i<26;i++)v[i].push_back(-1);

  for(int i=0;i<d;i++)for(int j=0;j<26;j++)cin>>s[i][j];
   // cerr<<'i';
  for(int i=0;i<d;i++){
      for(int j=0;j<26;j++)x[j]+=c[j];
      int k=0;
      for(int j=1;j<26;j++)if(x[k]+s[i][k]<x[j]+s[i][j])k=j;
      t[i]=k;
      x[k]=0;
      v[k].push_back(i);
  }
  for(int i=0;i<26;i++)v[i].push_back(d);
//for(int i=0;i<d;i++)cout<<t[i]+1<<endl;
  // cerr<<double(clock()-st)/CLOCKS_PER_SEC<<endl;

while(double(clock()-st)/CLOCKS_PER_SEC<1.95){
  if(rand()%10000000){
    int p=rand()%d;
    auto q=find(v[t[p]].begin(),v[t[p]].end(),p);
    q++;
  // int m=(p+(*q))/2;
   int m=p+rand()%((*q)-p);
//cerr<<m<<' '<<p<<endl;
   if(m==p)continue;
   auto r1=find(v[t[m]].begin(),v[t[m]].end(),m);
   auto r0=r1-1,r2=r1+1;
   if((m-p)*((*q)-m)*c[t[p]]+s[m][t[p]]>(m-(*r0))*((*r2)-m)*c[t[m]]+s[m][t[m]]){
 
    v[t[p]].insert(q,m);
    v[t[m]].erase(r1);
    t[m]=t[p];
   }
  }else{
    int p=rand()%(d-1);
    if(t[p]==t[p+1]){continue;}
    auto q1=find(v[t[p]].begin(),v[t[p]].end(),p);
    auto q0=q1-1,q2=q1+1;
      auto r1=find(v[t[p+1]].begin(),v[t[p+1]].end(),p+1);
    auto r0=q1-1,r2=q1+1;
    if((p-(*q0))*((*q2)-p)*c[t[p]]+s[p][t[p]]+(p+1-(*r0))*((*r2)-p-1)*c[t[p+1]]+s[p+1][t[p+1]]-(p+1-(*q0))*((*q2)-p-1)*c[t[p]]+s[p+1][t[p]]+(p-(*r0))*((*r2)-p)*c[t[p+1]]+s[p][t[p+1]]<0){
      (*q1)=p+1;
      (*r1)=p;
      swap(t[p],t[p+1]);
    }
   
  }




}
     for(int i=0;i<d;i++)cout<<t[i]+1<<endl;


     }


 


 






    





      

        


Measured memory_bytes: 3740
import re

s = input()
if len(s) % 2 == 1:
  s += "a"
li = re.split('(..)',s)[1::2]
check = "hi"
ans = 0
for i in li:
  if check not in i:
    ans += 1
if ans == 0:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3188
N = gets.chomp!.to_i
cells = gets.chomp!.split(" ").map! { |i| i.to_i }
count = 0
max_count = 0
(N - 1).times do |i|
  if cells[i] >= cells[i + 1]
    count += 1
  else
    count = 0
  end
  max_count = count if count > max_count
end
puts max_count


Measured memory_bytes: 19984
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

string s;

int main() {
	cin >> s;
	int ans = 0;
	for(int l = 0, r = s.size() - 1; l < r; ++l, --r)
		if(s[l] != s[r]) ++ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    string S,T;
    cin >> S >>T;
    int c=0;
    for(int i=0;i<S.length();i++){
        if(S[i] != T[i]){
            c++;
        }

    }
    cout << c;
    return 0;
}

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

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

    int res = 0;

    if (X == 1) res += 300000;
    else if (X == 2) res += 200000;
    else if (X == 3) res += 100000;

    if (Y == 1) res += 300000;
    else if (Y == 2) res += 200000;
    else if (Y == 3) res += 100000;

    if (X == 1 && Y == 1) res += 400000;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i, j, c1, c2, c3, myp;
  while(scanf("%d%d%d", &c1, &c2, &c3) == 3){
    int count = 0;
    myp = c1 + c2;
    for(i = 1;i <= 10;i++)
      if((20 - myp) >= i && i != c1 && i != c2 && i != c3) count++;
    printf((double)count / 7 >= 0.5 ? "YES\n" : "NO\n");

  }
  return 0;
}

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

vector<int> yakusu(int d){
  vector<int> res;
  for(int i=1; i*i <= d; i++){
    if(d % i == 0) {
      res.push_back(i);
      if(i*i != d) res.push_back(d / i);
    }
  }

  sort(res.begin(), res.end());

  return res;
}

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

int gcd(int* a, int n){
  if(n == 2) return gcd(a[0], a[1]);
  int b[n-1];
  for(int i=0; i<n-1; i++){
    b[i] = gcd(a[i], a[i+1]);
  }
  return gcd(b, n-1);
}


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

  int g = gcd(a, n);

  for(const auto& x : yakusu(g)){
    cout << x << endl;
  }

  return 0;
}



Measured memory_bytes: 3140