akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}
ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}

void comb(vector<vector <long long int> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (ll j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


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













Measured memory_bytes: 3600
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string line = " 3";
        for (int i = 4; i <= n; i++)
        {
            if (i % 3 == 0 || INCLUDE3(i))
            {
                line = line + " " + i.ToString();
            }
        }
        Console.WriteLine(line);
    }
    static bool INCLUDE3(int i)
    {
        while (true)
        {
            int divide = i / 10;
            if (i % 10 == 3)
            {
                return true;
            }
            else if (divide < 1)
            {
                return false;
            }
            else
            {
                i = divide;
            }
        }        
    }
}

Measured memory_bytes: 11884
#include <iostream>
#include <cstdio>
#include <algorithm>
#define int long long
#define N 100002
using namespace std;
const int mod=1000000007;
const int inf=1<<30;
int n,m,i,x[N],y[N],sum;
int read()
{
	char c=getchar();
	int w=0,f=1;
	while(c<'0'||c>'9'){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w*f;
}
signed main()
{
	n=read();m=read();
	for(i=1;i<=n;i++) x[i]=read();
	for(i=1;i<=m;i++) y[i]=read();
	sort(x+1,x+n+1);
	sort(y+1,y+m+1);
	for(i=1;i<m;i++) sum=(sum+i*(m-i)%mod*(y[i+1]-y[i])%mod)%mod;
	int ans=0;
	for(i=1;i<n;i++) ans=(ans+i*(n-i)%mod*(x[i+1]-x[i])%mod)%mod;
	printf("%lld\n",ans*sum%mod);
	return 0;
}


Measured memory_bytes: 5228
import heapq


def main():
    n, m = map(int, input().split())
    lrc = [list(map(int, input().split())) for _ in range(m)]

    adj = [[(0, i-1)] for i in range(n)]
    adj[0] = []

    for l, r, c in lrc:
        l -= 1
        r -= 1
        adj[l].append((c, r))

    WHITE = 0
    GRAY = 1
    BLACK = 2

    def dijkstra(s):
        colors = [WHITE] * n
        ds = [float("inf")] * n
        ps = [-1] * n
        pq = []

        ds[s] = 0
        ps[s] = -1
        heapq.heappush(pq, (0, s))

        while pq:
            d, u = heapq.heappop(pq)
            colors[u] = BLACK

            if ds[u] < d:
                continue

            for c, v in adj[u]:
                if colors[v] != BLACK:
                    if ds[u] + c < ds[v]:
                        ds[v] = ds[u] + c
                        ps[v] = u
                        colors[v] = GRAY
                        heapq.heappush(pq, (ds[v], v))

        return ds, ps

    ds, ps = dijkstra(0)

    ans = ds[-1]
    if ans == float("inf"):
        ans = -1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63516
#include<stdio.h>

int main(void){

   int a,b;
   char op;
   
   while(op != '?'){
   
   scanf("%d %c %d", &a, &op, &b);
   
   if ( op == '+' ){
      printf("%d\n",a+b);
} 
   else if ( op == '-' ){
      printf("%d\n",a-b);
}
   else if ( op == '*' ){
      printf("%d\n",a*b);
} 
   else if ( op == '/' ){
      printf("%d\n",a/b);
} 
}
  
   return 0;
}  

Measured memory_bytes: 600
#include<iostream>
#include<cstring>
using namespace std;
string emblem[1100];
string test[2];
int n,m,sum=0;
int check(int y,int x){
  if(y<0 || n-1<=y ||
     x<0 || m-1<=x)return 0;
  
    for(int i=0;i<2;i++){
      for(int j=0;j<2;j++){
	if(test[i][j]!=emblem[y+i][x+j])
	  return 0;
      }
    }
    return 1;
}

int main(){
  char c[3]={'J','O','I'};
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>emblem[i];
  for(int i=0;i<2;i++)cin>>test[i];

  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      sum+=check(i,j);
    }
  }
  int ans=sum;
  for(int i=0;i<3;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<m;k++){
	int plus=0;
	plus-=check(j,k);
	plus-=check(j-1,k);
	plus-=check(j,k-1);
	plus-=check(j-1,k-1);
	//cout << "j:" << j << " k:" << k << " plus:" << plus << endl;

	char tmp=emblem[j][k];
	emblem[j][k]=c[i];
	plus+=check(j,k);
	plus+=check(j-1,k);
	plus+=check(j,k-1);
	plus+=check(j-1,k-1);
	emblem[j][k]=tmp;
	//cout << "j:" << j << " k:" << k << " plus:" << plus << endl;
	ans=max(ans,sum+plus);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2252
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<long long> a(n, 0);
    long long total = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
        total += a.at(i);
    }

    bool even = false;
    long long half = 0;
    if(total % 2 == 0) {
        half = total / 2;
    }else {
        half = total / 2 + 1;
    }


    long long halflen = 0;
    long long truehalf1 = 0;
    long long truehalf2 = 0;

    for(int i = 0; i < n; ++i) {
        halflen += a.at(i);
        if(halflen >= half) {
            truehalf1 = halflen;
            truehalf2 = halflen - a.at(i);
            break;
        }
    }

    long long co1 = abs(truehalf1 - (total - truehalf1));
    long long co2 = abs(truehalf2 - (total - truehalf2));

    if(co1 < co2) {
        cout << co1 << endl;
    }else {
        cout << co2 << endl;
    }

    
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N-1);
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }

        for (int i = 0; i < N; i++){
        cin >> B[i];
    }

    
        for (int i = 0; i < N-1; i++){
        cin >> C[i];
    }

    int ans = 0;
    int a;
    for (int i = 0; i < N; i++){
        a = A[i] - 1;
        ans += B[a];
                
        if (i < N-1 && A[i] == A[i+1] - 1){
            ans += C[a];
        }
        
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int N;
long long h[100010];
long long dp[100100];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];
    
    for (int i = 0; i < 100100; ++i) dp[i] = INF;
    
    dp[0] = 0;
    
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,q;
  cin>>n>>q;
  
  long long s[n],t[n],x[n];
  REP(i,n){
    cin>>s[i]>>t[i]>>x[i];
  }
  
  long long d[q];
  REP(i,q){
    cin>>d[i];
  }
  
  vector<pair<long long,pair<int,long long> > > events;
  REP(i,n){
    events.push_back(make_pair(s[i]-x[i],make_pair(1,x[i])));
    events.push_back(make_pair(t[i]-x[i],make_pair(-1,x[i])));
  }
  int event_num=events.size();
  sort(events.begin(),events.end());
  
  //long long ans=0;
  //bool flag=true;
  int index=0;
  set<long long> xs;
  REP(i,q){
    while(events[index].first<=d[i] && index<event_num){
      if(events[index].second.first==1){
        xs.insert(events[index].second.second);
      }else{
        xs.erase(events[index].second.second);
      }
      index++;
    }
    if(xs.empty()){
      cout<<-1<<endl;
    }else{
      cout<<*xs.begin()<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 27240
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s; cin >> s;
    int abcd[4];

    for (int i =  0; i < 4; i++) abcd[i] = s[i] - '0';

    if (abcd[0] + abcd[1] + abcd[2] + abcd[3] == 7) {
        cout << abcd[0] << "+" << abcd[1] << "+" << abcd[2] << "+" << abcd[3] << "=7" << endl;

    } else if (abcd[0] + abcd[1] + abcd[2] - abcd[3] == 7) {
        cout << abcd[0] << "+" << abcd[1] << "+" << abcd[2] << "-" << abcd[3] << "=7" << endl;

    } else if (abcd[0] + abcd[1] - abcd[2] - abcd[3] == 7) {
        cout << abcd[0] << "+" << abcd[1] << "-" << abcd[2] << "-" << abcd[3] << "=7" << endl;

    } else if (abcd[0] + abcd[1] - abcd[2] + abcd[3] == 7) {
        cout << abcd[0] << "+" << abcd[1] << "-" << abcd[2] << "+" << abcd[3] << "=7" << endl;

    } else if (abcd[0] - abcd[1] + abcd[2] + abcd[3] == 7) {
        cout << abcd[0] << "-" << abcd[1] << "+" << abcd[2] << "+" << abcd[3] << "=7" << endl;

    } else if (abcd[0] - abcd[1] - abcd[2] + abcd[3] == 7) {
        cout << abcd[0] << "-" << abcd[1] << "-" << abcd[2] << "+" << abcd[3] << "=7" << endl;

    } else if (abcd[0] - abcd[1] + abcd[2] - abcd[3] == 7) {
        cout << abcd[0] << "-" << abcd[1] << "+" << abcd[2] << "-" << abcd[3] << "=7" << endl;

    } else if (abcd[0] - abcd[1] - abcd[2] - abcd[3] == 7) {
        cout << abcd[0] << "-" << abcd[1] << "-" << abcd[2] << "-" << abcd[3] << "=7" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <math.h>
#include <stdlib.h>

using namespace std;

class PointQueue{
	public:
		queue<int> x;
		queue<int> y;
		queue<int> cnt;

		void push(int px,int py,int sCnt);
		int frontX();
		int frontY();
		int frontCnt();
		void pop();
		int size();
};

void PointQueue::push(int px,int py,int sCnt){
	x.push(px);
	y.push(py);
	cnt.push(sCnt);
}

int PointQueue::frontX(){
	return x.front();
}
int PointQueue::frontY(){
	return y.front();
}
int PointQueue::frontCnt(){
	return cnt.front();
}

void PointQueue::pop(){
	x.pop();
	y.pop();
	cnt.pop();
}

int PointQueue::size(){
	return x.size();
}


int main(){
	int t,n;

	while(cin>>t>>n){
		if(t==0 && n==0)break;

		PointQueue q;

		int flag[200][200];
		int data[2][400];

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

		for(int i=0;i<200;i++){
			for(int j=0;j<200;j++){
				flag[i][j]=0;
			}
		}

		for(int i=0;i<2;i++){
			for(int j=0;j<400;j++){
				data[i][j]=0;
			}
		}

		for(int i=0;i<n;i++){
			int tmpX,tmpY;
			cin>>tmpX>>tmpY;
			data[0][i]=tmpX;
			data[1][i]=tmpY;
		}

		int sx,sy;
		cin>>sx>>sy;

		for(int i=0;i<n;i++){
			if(abs(sx-data[0][i])+abs(sy-data[1][i])>2*t+1){
				continue;
			}

			int tmpX,tmpY;
			tmpX = data[0][i];
			tmpY = data[1][i];

			tmpX += (100-sx);
			tmpY += (100-sy);
			flag[tmpY][tmpX]=-1;
			//cout<<"tmpX="<<tmpX<<"tmpY="<<tmpY<<endl;
		}
		sx=100;
		sy=100;



		q.push(sx,sy,0);
		flag[sy][sx]=1;
		int ans=0;

		while(q.size()!=0){
			int topX=q.frontX();
			int topY=q.frontY();
			int topCnt = q.frontCnt();
			q.pop();
			ans++;

			if(topCnt==t)continue;


			for(int i=0;i<6;i++){
				int nextX=topX+dx[i];
				int nextY=topY+dy[i];

				if(flag[nextY][nextX]==0){
					q.push(nextX,nextY,topCnt+1);
					flag[nextY][nextX]=1;
				}
			}

		}

		cout<<ans<<endl;


	}
	return 0;
}

Measured memory_bytes: 1376
n, k = map(int, input().split())
v = list(map(int, input().split()))
m = min(n, k)
result = 0
for i in range(m + 1):
  for j in range(i + 1):
    t = v[:j]
    t.extend(v[n - (i - j):])
    t.sort(reverse = True)
    l = k - i
    while len(t) > 0 and l > 0 and t[-1] < 0:
      t.pop()
      l -= 1
    result = max(result, sum(t))
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int fa, int fb, int fc) {
	if (fb == 0)return 1;
	if (fb % 2)return mypow(fa, fb - 1, fc)*fa%fc;
	int z = mypow(fa, fb / 2, fc);
	return z * z%fc;
}
int k(int fa) {
	int x = 0;
	while (fa) {
		x++;
		fa /= 10;
	}
	return x;
}
int gcd(int fa, int fb) {
	if (fb == 0)return fa;
	return gcd(fb, fa%fb);
}
int a[200000], dp[200000], ans[200000], n;
bool used[200000];
vector<int> v[200000];
void mutu(int e) {
	used[e] = true;
	ans[e] = lower_bound(dp, dp + n, INF - 1) - dp;
	f(i, v[e].size()) {
		if (used[v[e][i]])continue;
		int z = lower_bound(dp, dp + n, a[v[e][i]]) - dp;
		int x = dp[z];
		dp[z] = a[v[e][i]];
		mutu(v[e][i]);
		dp[z] = x;
	}
}
signed main() {
	cin >> n;
	f(i, n) {
		cin >> a[i];
		dp[i] = INF;
	}
	f(i, n - 1) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dp[0] = a[0];
	mutu(0);
	f(i, n)cout << ans[i] << endl;
}


Measured memory_bytes: 30828
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		String name = scanner.next();
		
		scanner.close();
		
		if ("ABC".equals(name)) {
			System.out.println("ARC");
		} else {
			System.out.println("ABC");
		}
	}

}


Measured memory_bytes: 26992
#include <bits/stdc++.h>
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#define fst first
#define snd second
#define fore(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int) (n).size())
#define INFI ((ll)1e9)
#define MINI ((ll)-1e16)
using namespace std;
typedef long long ll;       
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }          
int a[100001];
int res[100001];
ll n;


int main(){FIN;
	cin >> n;
	fore(i,0,n){
		cin >> a[i];
	}
	fore(i,0,n){
		res[i]=INFI;
	}
	res[0]=0;
	if(n>=2)res[1]=abs(a[1]-a[0]);
	if(n>=3)res[2]=abs(a[2]-a[0]);
	fore(i,3,n){
		res[i]=min(res[i],min(res[i-1]+abs(a[i-1]-a[i]),res[i-2]+abs(a[i-2]-a[i])));
	}
	cout << res[n-1];
}
	




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long a, b, c;
    cin >> a >> b >> c;

    int ans = 0;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
    {
        long long temp = b + c, temp1 = a + b, temp3 = a + c;
        a = temp;
        b = temp3;
        c = temp1;
        ans++;
        a /= 2;
        b /= 2;
        c /= 2;
        if (ans > 1000000)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;

int q,h,s,d;
ll n,ans;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    #endif
    scanf("%d%d%d%d",&q,&h,&s,&d);
    if(q*2<h)h=q*2;
    if(h*2<s)s=h*2;
    if(s*2<d)d=s*2;
    cin>>n;
    if(n>=2)
    {
        ll dq=n/2;
        n-=dq*2;
        ans+=d*dq;
    }
    if(n>=1)
    {
        ll dq=n/1;
        n-=dq*1;
        ans+=s*dq;
    }
    if(n>=0.5)
    {
        ll dq=n/0.5;
        n-=dq*0.5;
        ans+=h*dq;
    }
    if(n>=0.25)
    {
        ll dq=n/0.25;
        n-=dq*0.25;
        ans+=q*dq;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
alfa = [chr(i) for i in range(97, 97+26)]
for i in range(len(alfa)):
    for j in range(len(s)):
        if alfa[i] == s[j]:
            alfa[i] = "-"
for i in range(len(alfa)):
    if alfa[i] != "-":
        ans = alfa[i]
        break
    else:
        ans = "None"
print(ans)

Measured memory_bytes: 40940
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

vector<pii> to[810];
int N;
int p[810], d[810], deg[810], rec[810];

void calc(int p, int par=-1) {
    for(auto x : to[p]) {
        if(x.first == par) continue;
        if(deg[x.first] == 1) continue;
        calc(x.first, p);
        chmax(rec[p], rec[x.first] + x.second);
    }
}

signed main() {
    while(cin >> N, N) {
        rep(i,0,810) to[i].clear();
        memset(deg, 0, sizeof(deg));

        int sum = 0;
        rep(i,0,N-1) cin >> p[i], p[i]--;
        rep(i,0,N-1) cin >> d[i], sum += d[i];
        rep(i,0,N-1) {
            to[p[i]].push_back(make_pair(i+1 , d[i]));
            to[i+1 ].push_back(make_pair(p[i], d[i]));
            deg[i+1]++; deg[p[i]]++;
        }

        int res = 0;
        rep(i,0,N) {
            for(auto x : to[i]) if(deg[i] != 1 && deg[x.first] != 1) res += x.second;
        }

        int ma = 0;
        rep(i,0,N) {
            memset(rec,0,sizeof(rec));
            if(deg[i] == 1) continue;
            calc(i);
            chmax(ma, rec[i]);
        }

        // printf("sum = %lld, res = %lld, ma = %lld\n", sum, res, ma);
        cout << sum + res - ma << endl;
    }
    return 0;
}

Measured memory_bytes: 3312
#include<stdio.h>


int main(){

	int i,n,ans[45];

	ans[0] = 1;
	ans[1] = 1;
	scanf("%d",&n);
	for(i = n;i > 0;i--)
		ans[n - i + 2] = ans[n - i + 1] + ans[n - i];
	printf("%d\n",ans[n]);
	return 0;
}

Measured memory_bytes: 596
#include<vector>
#include<iostream>
using namespace std;
int n,m;
bool input(){
  if(!(cin>>n>>m)){
    return false;
  }
  return true;
}

vector<int> ans;
void init(){
  ans.clear();
  ans.resize(2*n);
  for(int i=0;i<ans.size();i++){
    ans[i]=i+1;
  }
}
void kk(int k){
  vector<int> t[2];
  for(int i=0;i<k;i++){
    t[1].push_back(ans[i]);
  }
  for(int i=k;i<2*n;i++){
    t[0].push_back(ans[i]);
  }
  for(int i=0;i<t[1].size();i++){
    t[0].push_back(t[1][i]);
  }
  ans=t[0];
}
void r(){
  vector<int> t[2];
  for(int i=0;i<n;i++){
    t[0].push_back(ans[i]);
  }
  for(int i=n;i<2*n;i++){
    t[1].push_back(ans[i]);
  }
  for(int i=0;i<ans.size();i++){
    ans[i]=t[i%2][i/2];
  }
}
void s(int n){
  if(n==0){
    r();
  }else{
    kk(n);
  }
}

int main(){
  input();
  init();
  for(int i=0;i<m;i++){
    int tmp;
    cin>>tmp;
    s(tmp);
  }
  for(int i=0;i<ans.size();i++){
    cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int64_t n, k;
    cin >> n >> k;

    vector<pair<int64_t, int64_t>> items(n);
    for (auto&& item : items) {
        int64_t t, d;
        cin >> t >> d;
        item = {d, t};
    }

    sort(items.rbegin(), items.rend());

    vector<bool> used(n, false);
    vector<int64_t> r;
    int64_t score = 0, num_types = 0;
    for (auto i : irange(0L, k)) {
        const auto& item = items[i];

        if (used[item.second]) {
            r.push_back(item.first);
        } else {
            used[item.second] = true;
            ++num_types;
        }

        score += item.first;
    }

    score += num_types * num_types;

    int64_t max_score = score;
    for (auto i : irange(k, n)) {
        if (r.empty()) {
            break;
        }

        const auto& item = items[i];

        if (used[item.second]) {
            continue;
        }
        used[item.second] = true;

        score += item.first;
        score -= r.back();
        r.pop_back();
        score += 2 * num_types + 1;
        ++num_types;
        max_score = max(max_score, score);
    }

    cout << max_score << endl;
}

Measured memory_bytes: 2432
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
using namespace std;
typedef long long LL;
int a[500050],b[60],n,cnt,sum,u,v,y;
bool vis[500050];
int main(){
	vis[0]=vis[1]=0;
	cnt=0;
	for(int i=1;i<=500049;i++) vis[i]=1;
	for(int i=2;i<=5e5;i++){
		if(vis[i]==1) a[++cnt]=i;
		for(int j=1;j<=cnt&&a[j]*i<=5e5;j++){
			vis[i*a[j]]=0;
		}
	}
	scanf("%d",&n);
	y=0;
	sum=0;
	for(int i=1;i<=cnt;i++){
		if(a[i]%10==3){
			y++;
			sum+=a[i];
			if(y!=n) printf("%d ",a[i]);
			else{
				printf("%d\n",a[i]);
				break;
			}
		}
	}
}

Measured memory_bytes: 896
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var Ai = new long[N];
            for (var i = 0; i < N; ++i)
                Ai[i] = Sarray()[0];
            var ans = 0L;
            for (var i = 0; i < N; ++i)
            {
                ans += Ai[i] / 2;
                if (i < N - 1 && Ai[i + 1] != 0)
                    Ai[i + 1] += Ai[i] % 2;
            }
            WriteLine(ans);
            Out.Flush();
        }
    }
}

Measured memory_bytes: 18016
using System;
using System.Linq;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            string[] input = Console.ReadLine().Split(new string[] {" "}, StringSplitOptions.RemoveEmptyEntries);
            int[] Dn = new int[N];
            for (int i = 0; i < N; i++)
            {
                Dn[i] = Convert.ToInt32(input[i]);
            }
            Array.Sort(Dn);
            int center = N / 2;
            int left = center - 1;
            int right = center;
            if (Dn[left] == Dn[right])
            {
                Console.WriteLine(0);
            }
            else
            {
                int result = Dn[right] - Dn[left];
                Console.WriteLine(result);
            }
        }
    }
}


Measured memory_bytes: 19424
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    o = input()
    e = input()
    ans = ''
    for i in range(len(o)):
        ans += o[i]
        if i < len(e):
            ans += e[i]
    print(ans)


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()




"""

4
1 2
2 4
1 3
3
2 2 4
4 5 6

6
1 2
2 3
3 4
4 5
4 6
3
3 5 6
2 17 31 5 11

"""





Measured memory_bytes: 65140
using System;
using System.Collections;

class main
{
    static void Main(string[] args)
    {
        ArrayList list = new ArrayList();
        ArrayList lista = new ArrayList();
        string s;
        while ((s = Console.ReadLine()) != null)
        {
            if (s == "0")
            {
                lista.Add(list[list.Count - 1]);
                list.RemoveAt(list.Count - 1);
            }
            else
            {
                list.Add(s);
            }
        }
        for (int i = 0; i < lista.Count; ++i)
        {
            Console.WriteLine(lista[i]);
        }
    }
}

Measured memory_bytes: 5324
#include<bits/stdc++.h>
using namespace std;
int n,m,c[1000005],d,f[1000005],a[1000005],q;
int main(){
	scanf("%d%d",&n,&m); d=m;
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if (abs(d-a[i])<d) d=abs(d-a[i]);
		c[i]=d;
	}
	f[n+1]=1;
	for (int i=n;i>=1;i--){
		f[i]=f[i+1];
		if (abs(f[i]-a[i])<f[i]) f[i]=f[i]+a[i];
	}
	c[0]=m;
	scanf("%d",&q);
	for (int i=1;i<=q;i++){
		int x;
		scanf("%d",&x);
		if (c[x-1]>=f[x+1]) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <chrono>

#define endl "\n"

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

template<typename T>
void printArray(T a) {
    for(auto i : a)
        cout << i << " ";

    cout << endl;
}

template<typename T>
void print2DArray(T a) {
    for(auto i : a) {
        for(auto j : i)
            cout << j << " ";

        cout << endl;
    }
    cout << endl;
}

int main(int argc, char *argv[])
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);

    /* auto t1 = chrono::high_resolution_clock::now(); */

    int h = 1;
    int w = 1;

    cin >> h >> w;

    vector<vector<char>> s = vector<vector<char>>(h, vector<char>(w));

    for (size_t i = 0; i < h; i++) {
        for (size_t j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }

    int numV = h * w;

    vector<vector<int>> dist = vector<vector<int>>(numV,
            vector<int>(numV, 100000));

    /* print2DArray(dist); */

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {

            int u = i * w + j;
            /* cout << "at:" << u << endl; */

            if (s[i][j] == '#') {
                continue;
            }

            dist[u][u] = 0;

            if (j + 1 < w && s[i][j+1] != '#') {
                int v = i * w + (j+1);
                dist[u][v] = 1;
                dist[v][u] = 1;
            }

            if (i + 1 < h && s[i+1][j] != '#') {
                int v = (i+1) * w + j;
                dist[u][v] = 1;
                dist[v][u] = 1;
            }

            if (j - 1 >= 0 && s[i][j-1] != '#') {
                int v = i * w + (j-1);
                dist[u][v] = 1;
                dist[v][u] = 1;
            }

            if (i - 1 >= 0 && s[i-1][j] != '#') {
                int v = (i-1) * w + j;
                dist[u][v] = 1;
                dist[v][u] = 1;
            }
        }
    }

    /* print2DArray(dist); */

    for (size_t k = 0; k < numV; k++) {
        for (size_t i = 0; i < numV; i++) {
            for (size_t j = 0; j < numV; j++) {
                if (dist[i][j] > dist[i][k] + dist[k][j]) {
                    dist[i][j]  = dist[i][k] + dist[k][j];
                }
            }
        }
    }

    /* print2DArray(dist); */


    ulli max = 0;
    for (size_t i = 0; i < numV; i++) {
        for (size_t j = 0; j < numV; j++) {
            if (dist[i][j] != 100000 && dist[i][j] > max) {
                max = dist[i][j];
            }
        }
    }

    /* auto t2 = std::chrono::high_resolution_clock::now(); */

    /* auto duration = std::chrono::duration_cast<std::chrono::seconds>( t2 - t1 ).count(); */

    cout << max << endl;

    /* cout << "time " << duration << "s" << endl; */

    return 0;
}


Measured memory_bytes: 896
#include<stdio.h>

int main(){
 unsigned int S;
 unsigned int h;
 unsigned int m;
 unsigned int s;

 scanf("%d", &S);

 h = S/3600;
 m = (S - h*3600) / 60;
 s = S - h*3600 - m*60;

 printf("%d:%d:%d\n", h, m, s);

 return 0;
}


Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int K, X;
  	cin	>> K >> X;
  	int min_num = -1000000;
  	int max_num = 1000000;
  	min_num = max(X+1-K,min_num);
  	max_num = min(X-1+K,max_num);
  	for(int i=min_num; i<=max_num; i++){
    	cout << i;
      	if(i!=max_num)cout <<" ";
    }
    cout <<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 500005;

int n, m, i, j, k, l, d[20][20], tab[20][20], maxx;
char t[20];
queue<ii> q;
ii w;

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

bool ok(int a, int b) {
	return a >= 0 && a < n && b >= 0 && b < m && d[a][b] == -1 && !tab[a][b];
}

int main() {
scanf("%d %d", &n, &m);
for (i=0;i<n;i++) {
	scanf("%s", t);
	for (j=0;j<m;j++) tab[i][j] = (t[j] == '#');
}
for (i=0;i<n;i++) for (j=0;j<m;j++) if (!tab[i][j]) {
	for (k=0;k<n;k++) for (l=0;l<m;l++) d[k][l] = -1;
	q.push(ii(i, j));
	d[i][j] = 0;
	while (!q.empty()) {
		w = q.front();
		q.pop();
		for (k=0;k<4;k++) if (ok(w.first + dx[k], w.second + dy[k])) {
			d[w.first + dx[k]][w.second + dy[k]] = d[w.first][w.second] + 1;
			q.push(ii(w.first + dx[k], w.second + dy[k]));
		}
	}
	for (k=0;k<n;k++) for (l=0;l<m;l++) maxx = max(maxx, d[k][l]);
}
printf("%d\n", maxx);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

struct edge{
  ll a, b, cost;
  edge(){}
  edge(ll aa, ll bb, ll cc){a = aa; b = bb; cost = cc;}
};

bool comp(edge A, edge B){
  return A.cost < B.cost;
}

vector<int> par(100100);

void init(int n){
  for(int i = 0; i < n; i++){
   par.at(i) = i;
  }
}

int root(int x){
  if(par.at(x) == x) return x;
  return par.at(x) = root(par.at(x));
}

void unite(int x, int y){
  if(root(x) == root(y)) return;
  par.at(root(x)) = root(y);
}

bool same(int x, int y){
  return root(x) == root(y);
}

int main(){
  ll N;
  cin >> N;
  init(N);
  vector<P> xx(N), yy(N);
  for(int i = 0; i < N; i++){
    ll x, y;
    cin >> x >> y;
    xx.at(i) = P(x, i);
    yy.at(i) = P(y, i);
  }
  sort(ALL(xx)); sort(ALL(yy));
  vector<edge> ed(0);
  for(int i = 0; i < N-1; i++){
    ed.push_back(edge(xx.at(i).second, xx.at(i+1).second, abs(xx.at(i).first - xx.at(i+1).first)));
    ed.push_back(edge(yy.at(i).second, yy.at(i+1).second, abs(yy.at(i).first - yy.at(i+1).first)));
  }
  sort(ALL(ed), comp);
  ll ans = 0;
  for(int i = 0; i < ed.size(); i++){
    ll aa = ed.at(i).a, bb = ed.at(i).b;
    if(same(aa, bb)) continue;
    unite(aa, bb);
    ans += ed.at(i).cost;
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    int t;
    int n;
    int a,b;
    cin >> n >> a >> b;
    int ans = 0;
    for (int i = 1;i <= n;++i) {
        int m = i;
        int sum = 0;
        while (m) {
            sum += (m%10);
            m /= 10;
        }
        if (sum <= b && sum >= a)
            ans += i;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize(3)
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
typedef long long LL;
using namespace std;

#define MAXN 1000005
#define INF 999999999

signed main() {
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	int n, m;
	scanf("%d%d", &n, &m);
	if (n >= 13) {
		printf("%d", m);
	}
	else if (n >= 6) {
		printf("%d", m / 2);
	}
	else {
		printf("0");
	}
	
	return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    prev = [0] * 3
    current = [0] * 3
    for _ in range(N):
        a, b, c = map(int, input().split())
        current[0] = a + max(prev[1], prev[2])
        current[1] = b + max(prev[0], prev[2])
        current[2] = c + max(prev[0], prev[1])
        prev = list(current)
    print(max(current))


if __name__ == "__main__":
    main()


Measured memory_bytes: 48600
function Main(input) {
    var N = parseInt(input,10);
    var c = 0;
    for(var i = 1; i < N+1; i++){
        if((i % 2) != 0){
            c++
        }
    }
    console.log(c/N);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
from collections import deque
import sys
input = sys.stdin.readline

INF = 10**18

H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(lambda x: int(x) - 1, input().split())
C = [input() for _ in range(H)]

queue = deque()
queue.append((x1, y1))

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

dist = [[INF for j in range(W)] for i in range(H)]
dist[x1][y1] = 0

while queue:
    x, y = queue.popleft()
    for i in range(4):
        for k in range(K):
            nx = x + (k + 1) * dx[i]
            ny = y + (k + 1) * dy[i]
            if not (0 <= nx < H and 0 <= ny < W):
                break
            if C[nx][ny] == '@':
                break
            if dist[nx][ny] < dist[x][y] + 1:
                break
            if dist[nx][ny] != INF:
                continue
            dist[nx][ny] = dist[x][y] + 1
            queue.append((nx, ny))

print(dist[x2][y2] if dist[x2][y2] != INF else -1)

Measured memory_bytes: 149696
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 B PIC 9(15).
      	01 C PIC 9(15).
      	01 D PIC 9(15).
      	01 ans PIC ZZZZZZZZZZZZZZ.
      	01 t PIC 9(15).
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
        01 N PIC 9(15).
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT A.
      		MOVE 2000000000000 to ans.
      		COMPUTE B = FUNCTION SQRT(A) + 2.
      		PERFORM VARYING t FROM 1 BY 1 UNTIL t = B + 1
      			COMPUTE C = A / t
      			COMPUTE C = C * t
      			IF C = A THEN
      				IF ans > t + A/t - 2 THEN
      					COMPUTE ans = t + A/t - 2
      				END-IF
      			END-IF
      		END-PERFORM.
			DISPLAY ans.
		STOP RUN.

Measured memory_bytes: 512
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
int a[N],f[N],sz[N],xr[N],Log[N],st[25],cnt[25],top,n,res,lim;
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n);
	for(R int i=1,u,v,w;i<n;++i)scanf("%d%d%d",&u,&v,&w),a[u+1]^=w,a[v+1]^=w;
	fp(i,1,n)++cnt[a[i]];
	fp(i,1,15){
		res+=cnt[i]>>1;
		if(cnt[i]&1)st[top++]=i;
	}
	lim=(1<<top);
	fp(i,0,15)Log[1<<i]=i;
	fp(i,1,lim-1)sz[i]=sz[i>>1]+(i&1),xr[i]=xr[i-(i&-i)]^st[Log[i&-i]];
	f[0]=0;
	fp(i,1,lim-1){
		if(!xr[i])f[i]=sz[i]-1;
			else f[i]=top;
//		printf("%d %d\n",i,xr[i]);
		for(R int s=i;s;s=(s-1)&i)cmin(f[i],f[s]+f[s^i]);
	}
	printf("%d\n",res+f[lim-1]);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
using namespace std;

int main() {
	int N;
	string S;
	cin >> N;
	cin >> S;
	int k = N / 2;
	string tmp = "No";
	if(N%2 == 0 && S.substr(0,k) == S.substr(k)) tmp = "Yes";
	cout << tmp << endl;
}

Measured memory_bytes: 256
(let* ((N (read))
       (M (read))
       (H-array (make-array N))
       (graph (make-hash-table))
       (result 0))
  (loop for i below N
        do (progn
             (setf (aref H-array i) (read))
             (setf (gethash i graph) nil)))
  (dotimes (x M)
    (let ((l (- (read) 1))
          (r (- (read) 1)))
      (push l (gethash r graph))
      (push r (gethash l graph))))
  (maphash (lambda (key value)
             (if value
                 (let ((tmp 0))
                   (dolist (x value)
                     (when (< (aref H-array x) (aref H-array key))
                       (incf tmp)))
                   (when (= tmp (length value))
                     (incf result)))
                 (incf result)))
           graph)
  (princ result))


Measured memory_bytes: 87252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String day = scanner.next();
		switch(day) {
			case "MON":
				System.out.println(6);
				break;
			case "TUE":
				System.out.println(5);
				break;
			case "WED":
				System.out.println(4);
				break;
			case "THU":
				System.out.println(3);
				break;
			case "FRI":
				System.out.println(2);
				break;
			case "SAT":
				System.out.println(1);
				break;
			case "SUN":
				System.out.println(7);
				break;
			default:
				break;
		}
		scanner.close();
	}
}

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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int l=a+b;
    int r=c+d;
    if(l>r){cout<<"Left"<<endl;}
    if(l==r){cout<<"Balanced"<<endl;}
    if(l<r){cout<<"Right"<<endl;}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{

    long long int x,y,n,z,m,f;
    
    cin>>x;
    
    y=x/500;
    
    n=y*1000;
    
    f=x%500;
    
    z=f/5;
    
    m=z*5;
    
    
    cout<<n+m;
    
    
    
    
    
}


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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------

int main(void){
  int n, m, q;
  cin >> n >> m >> q;
  v2(train, n+1, n+1, 0);
  rep(i,m){
    int a, b;
    cin >> a >> b;
    train[a][b]++;
  }
  vec x(q), y(q);
  rep(i,q){
    cin >> x[i] >> y[i];
  }

  v2(sum, n+1, n+1, 0);
  rep(i,n){
    rep(j,n){
      sum[i+1][j+1]=sum[i][j+1]+sum[i+1][j]-sum[i][j]+train[i+1][j+1];
    }
  }

  rep(i,q){
    prt(sum[y[i]][y[i]]-sum[x[i]-1][y[i]]-sum[y[i]][x[i]-1]+sum[x[i]-1][x[i]-1]);
  }
}


Measured memory_bytes: 6156
import numpy as np
N, M = map(int, input().split())
X = list(map(int, input().split()))

if M <= N:
    print(0)
else:
    X.sort()
    # print("X =", X)
    dX = np.diff(X)
    # print("dX =", dX)
    dX.sort()
    print(sum(dX[:M-N]))


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;

int main() {
	int a, b;
	cin >> a >> b;

	if(b % a == 0){
		cout << a + b << endl;
	}else{
		cout << b - a << endl;
	}



    return 0;
}



Measured memory_bytes: 256
S = input()
S = S.replace("C","A")
S = S.replace("G","A")
S = S.replace("T","A")
ren = 0
ans = 0
for i in range(len(S)):
    if S[i] == "A":
        ren += 1
        if ans <= ren:
            ans = ren
    else:
        ren = 0
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I=ll(A);I<ll(B);++I)

int main(){
	int n;
	while(cin>>n,n){
		double m=0.0,ans=0.0;
		vector<double> s(n);
		FOR(i,0,n){
			cin >> s[i];
			m += s[i]/n;
		}
		FOR(i,0,n){
			ans += (s[i]-m)*(s[i]-m)/n;
		}
		cout<<fixed<<setprecision(10)<<sqrt(ans)<<endl;
	}
}


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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int num=0,max=0;

  for(int i=0;i<n;i++){
    if(s[i]=='I'){
      num++;
    }
    else{
      num--;
    }
    if(num>max){
      max=num;
    }
  }

  cout<<max<<endl;
  
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >>n;
    vint a(n); rep(i,n) cin >> a[i];

    int res=INF;
    for(int j=-200; j<=200; j++){
        int tmp=0;
        rep(i,n){
            tmp+=(a[i]-j)*(a[i]-j);
        }
        chmin(res,tmp);
    }   
    cout<<res<<endl;
}

Measured memory_bytes: 3660
package main

import "fmt"

func check(s string) bool {
	ln := len(s)
	if ln%2 != 0 {
		return false
	}
	return s[:ln/2] == s[ln/2:]
}

func main() {
	var s string
	fmt.Scan(&s)

	for i := 1; i < len(s)-1; i++ {
		if t := s[:len(s)-i]; check(t) {
			fmt.Println(len(t))
			return
		}
	}
}


Measured memory_bytes: 512
s = input()
n = int(input())
for i in range(n):
    t = input().split()
    cmd, a, b = t[0], int(t[1]), int(t[2])
    if cmd == "print":
        print(s[a:b+1])
    elif cmd == "reverse":
        s = s[:a] + s[a:b+1][::-1] + s[b+1:]
    else:
        s = s[:a] + t[3] + s[b+1:]


Measured memory_bytes: 5616