akhauriyash/Code-Regression huggingface dataset:
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
{
	cout << *it << " = " << a;
	nl;
	err(++it, args...);
}
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n;
vector<pll> v(n);
long double dis[n+1][n+1];
for(int i=0;i<n;i++)
{
  cin>>v[i].fi;
  cin>>v[i].se;
}
for(int i=0;i<n;i++)
{
    for(int j=0;j<n;j++)
    {
        dis[i][j]=sqrt(pow(v[i].fi-v[j].fi,2)+pow(v[i].se-v[j].se,2));
        //deb(pow(v[i].fi-v[j].fi,2)+pow(v[i].se-v[j].se,2));
        //deb(i,j,dis[i][j]);
    }
}
ll fact[n+10];
fact[0]=1;
for(int i=1;i<=n;i++)
{
    fact[i]=i*fact[i-1];
}
long double sum=0;
for(int i=0;i<n;i++)
{
    for(int j=0;j<n;j++)
    {
      sum+=dis[i][j];  
    }
}
sum*=fact[n-2];
sum*=(n-1);
cout<<fixed<<setprecision(10)<<(float)sum/fact[n];





return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int n;
  cin>>n;
  int h[n];
  for(int i(0);i<n;i++){
    cin>>h[i];
  }
  bool b[n];
  for(int i(0);i<n;i++){
    b[i]=true;
  }
  int f(0),cnt(0);
  while(f<n){
    for(int i(0);i<n;i++){
      h[i]--;
      if(h[i]==-1 && b[i]==true){
        b[i]=false;
        f++;
      }
      if(i>0 && b[i-1]==true && b[i]==false)cnt++;
    }
    if(b[n-1]==true)cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

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

using lint = long long int;
using pii = std::pair<int, int>;

using std::vector;
char str[200200];
lint len;

lint cou[30];

int main(void) {
	scanf("%s", str);
	len = strlen(str);
	for (int i = 0; i < len; i++) {
		cou[str[i] - 'a']++;
	}
	lint ans = len * (len - 1) / 2 + 1;
	for (int i = 0; i < 26; i++) {
		if (cou[i] >= 2) {
			ans -= cou[i] * (cou[i] - 1) / 2;
		}
	}

	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(){
	int x,n[101], i=0;
	char s[100];
	
	while(scanf("%s", s)!=EOF){
		if(s[0]=='+'){
			n[i-1]+=n[i];
			i--;
		}else if(s[0]=='-'){
			n[i-1]-=n[i];
			i--;
		}else if(s[0]=='*'){
			n[i-1]*=n[i];
			i--;
		}else{
			x=atoi(s);
			i++;
			n[i]=x;
			
		}
	}
	printf("%d\n", n[i]);
	
	return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	int N, M;
	vector<P> work;
	P tmp;
	ll count = 0;
	priority_queue<int> q;

	cin >> N >> M;
	
	rep(i, N)
	{
		cin >> tmp.first >> tmp.second;
		work.push_back(tmp);
	}

	sort(work.begin(), work.end(), greater<P>());

	for (int i = 1; i <= M; i++)
	{
		if (!work.empty())
		{
			while (work.back().first == i)
			{
				q.push(work.back().second);
				work.pop_back();
				if (work.empty())
					break;
			}
		}
		if (!q.empty())
		{
			count += q.top();
			q.pop();
		}

	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1908
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    N = int(input())
    xy = [0] * N
    d = {}
    offset = 0
    mina = 10 ** 9
    minb = 2 * (10 ** 9 + 1)
    maxa = -10 ** 9 -1
    maxb = 2
    for n in range(N):
        x, y = [int(x) for x in input().strip().split()]
        if (x, y) in d:
            offset += 1
            continue
        d[(x, y)] = 1
        a, b = y - x, y + x
        xy[n-offset] = (x, y, a, b)
        mina = min(mina, a)
        minb = min(minb, b)
        maxa = max(maxa, a)
        maxb = max(maxb, b)
    # print(mina, maxa, minb, maxb)
    print(max(maxa-mina, maxb-minb))

if __name__ == '__main__':
    main()

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

int main()
{
	int A,B;
	cin >> A >> B;
	if (A <= 8 && B <= 8)
	{
		cout << "Yay!" << endl;
	}
	else
	{
		cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
H = [int(i) for i in input().split()]
count = 0
max_c = 0
tmp = 0
for i in range(N):
    if i == 0:
        tmp = H[i]
        continue
    if tmp < H[i]:
        if max_c < count:
            max_c = count
        count = 0
    else:
        count += 1
    tmp = H[i]
print(max(max_c,count))

Measured memory_bytes: 14224
n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
all_cost = 0
for i in range(n+1):
    all_cost += abs(a[i+1]-a[i])
for k in range(1, n+1):
    print(all_cost - (abs(a[k]-a[k-1])+abs(a[k+1]-a[k])) + abs(a[k+1]-a[k-1]))


Measured memory_bytes: 13920
#include <stdio.h>

int main(void)
{
		int a,b,c[7],d;
		for(d=0;d<7;d++){
		scanf("%d %d",&a,&b);
		c[d]=a-b;		
}
		for(d=0;d<7;d++){
		printf("%d\n",c[d]);
}
return 0;
}


Measured memory_bytes: 2056
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,copy
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
mx = 0
pl = None
ind = -1
res = []
for i,x in enumerate(a):
    if abs(x) > mx:
        mx = abs(x)
        ind = i
        pl = True if x > 0 else False
if mx == 0:
    print(0)
    quit()
if not pl: mx *= -1
for i in range(n):
    if i == ind: continue
    res.append([ind+1,i+1])
    a[i] += mx
if pl:
    for i in range(n-1):
        res.append([i+1,i+2])
else:
    for i in range(n-1)[::-1]:
        res.append([i+2,i+1])
print(len(res))
for x in res:
    print(*x)

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;
int n,m,k;
vector<int> G[100010];
bool used[100010];
vector<int> T[100010];
vector<set<int>> st;
int stid[100010];
int cnt = 0;
int sz[100010];

void dfs(int x) {
    used[x] = 1;
    stid[x] = cnt;
    sz[cnt]++;
    for (int i = 0; i < G[x].size(); i++) {
        int to = G[x][i];
        if (used[to]) continue;
        dfs(to);
    }
}

int main() {
    cin >> n >> m >> k;
    for (int i = 0; i < m; i++) {
        int a,b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for (int i = 0; i < k; i++) {
        int a,b;
        cin >> a >> b;
        T[a].push_back(b);
        T[b].push_back(a);
    }
    for (int i = 1; i <= n; i++) {
        if (!used[i]) {
            dfs(i);
            cnt++;
        }
    }
    for (int i = 1; i <= n; i++) {
        int id = stid[i];
        int ans = sz[id] - G[i].size() - 1;
        for (int j = 0; j < T[i].size(); j++) {
            if (stid[T[i][j]] == id) ans--;
        }
        cout << ans << " \n"[i == n];
    }
    return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair



int N, M, Q;
vi L, R;
vvi imo;

void prepare() {
    imo.assign(N+1, vi(N+1, 0));

    rep(i,M){
        int from = L[i], to = R[i];
        ++imo[from][to];
    }

    for (int r=N; r>0; --r){
        rep1(c,N) {
            imo[r][c] += imo[r][c-1];
        }
        if (r < N) {
            rep(c,N+1)
                imo[r][c] += imo[r+1][c];
        }
    }
#ifdef DEBUG
    for (int r=1;r<=N;++r) {
        for (int c=1;c<=N;++c) {
            fprintf(stderr, " %2d", imo[r][c]);
        }
        fprintf(stderr, "\n");
    }
#endif
}

// int query(int p, int q) {
//     return imo[p][q];
// }

int main() {
    // cin >> N >> M >> Q;
    scanf("%d %d %d", &N, &M, &Q);
    L.resize(M); R.resize(M);
    rep(i,M) {
        // cin >> L[i] >> R[i];
        scanf("%d %d", &L[i], &R[i]);
    }

    prepare();

    rep(i,Q) {
        int p,q; // cin >> p >> q;
        scanf("%d %d", &p, &q);
        // cout << query(p,q) << endl;
        printf("%d\n", imo[p][q]);
    }
    return 0;
}


Measured memory_bytes: 3456
#include <stdio.h>

int main(void){
   
   int N,M;
   
   scanf("%d%d",&N,&M);
   
   int A[N+1][M+1];
   int K[N+1];
   int Inv[N+1][M+1];
   
   int i,j;
   
   for(i = 1;i <= N;i++){
      K[i] = 0;
      for(j = 1;j <= M;j++){
         A[i][j] = 0;
         Inv[i][j] = -1;
      }
   }
   
   for(i = 1;i <= N;i++){
      scanf("%d",&K[i]);
      for(j = 1;j <= K[i];j++){
         scanf("%d",&A[i][j]);
         Inv[i][A[i][j]] = 1;
      }
   }
   
   int count = 0;
   int flag;
   
   for(j = 1;j <= M;j++){
      flag = 1;
      for(i = 1;i <= N;i++){
         if(Inv[i][j] != 1){
            flag = 0;
            break;
         }
      }
      if(flag == 1){
         count++;
      }
   }

   printf("%d\n",count);
   
   return 0;
   
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n;
	cin >> n;
	V<int> L(n);
	RBF(i, L) {
		cin >> i;
	}
	upsort(L);

	LL ans = 0;
	REP(i, n-1) {
		RNG(j, i + 1, n) {
			int lim = L[i] + L[j];
			int k = distance(L.begin(), lower_bound(ALL(L), lim));
			int num = k - j - 1;
			if (num > 0) ans += num;
		}
	}

	col(ans);
	return 0;
}

Measured memory_bytes: 3644
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

inf = 10**30
N,X,D = II()

if D==0:
    if X==0:
        print(1)
    else:
        print(N+1)
    exit()
if D<0:
    X,D = -X,-D

kukan = []
for i in range(N+1):
    kukan.append([i*X+(i*(i-1)//2)*D, i*X+(N*(N-1)//2-(N-i)*(N-i-1)//2)*D, (i*X)%D])
kukan.sort(key=lambda x:(x[2],x[0]))

div,d_min,d_max = inf,inf,inf
ans = 0
for k in kukan:
    if k[2]!=div:
        if d_min!=inf:
            ans += (d_max-d_min)//D + 1
        d_min,d_max,div = k[0],k[1],k[2]
    else:
        if k[0]>d_max:
            ans += (d_max-d_min)//D + 1
            d_min,d_max = k[0],k[1]
        else:
            d_max = max(d_max,k[1])
ans += (d_max-d_min)//D + 1

print(ans)

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

int main(){
  string s;//入力させます
  cin >> s;
  int len = s.length() + 1;
  int k;
  cin >> k;
  string ranking[] = {"","zzzzzz","zzzzzz","zzzzzz","zzzzzz","zzzzzz"};
  for(int i=1;i<=k;++i){
    for(int j=0;j<len-i;++j){
      string Temp = s.substr(j, i);
      for(int ii=k;ii>=0;--ii){
        if(Temp.compare(ranking[ii])==0){
          break;
        }else if(Temp.compare(ranking[ii])>0){
          if(ii==5){
            break;
          }
          for(int jj=4;jj>=ii+1;--jj){
            ranking[jj+1] = ranking[jj];
          }
          ranking[ii+1] = Temp;
          break;
        }
      }
    }
  }
  cout << ranking[k] << endl;
  return 0;
}

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

using namespace std;


typedef unsigned long long ll;

vector<vector<ll> > lines;
int n;
int field[9][9];

vector<ll> tmp;

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

bool ok=false;

ll fin;


void dfs(ll s,int idx){
	if(ok){
		return;
	}
	if(idx==lines.size()){
		if(fin==s)
			ok=true;
		return;
	}
	for(int i = 0; i < lines[idx].size(); i++){
		if((s&lines[idx][i])==0){
			dfs(s|lines[idx][i],idx+1);
		}
	}
}

void lineSearch(ll s,int curSum,int ret,int x,int y){
	if(curSum==ret){
		tmp.push_back(s);
	}
	for(int i= 0; i < 4; i++){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx>=0&&ny>=0&&nx<n&&ny<n&&field[ny][nx]>=1&&(curSum+field[ny][nx]<=ret)){
			if(!((s>>(ny*n+nx))&(1ull))){
				ll ns=s|(((1ull)<<(ny*n+nx)));
				lineSearch(ns,curSum+field[ny][nx],ret,nx,ny);
			}
		}
	}
}

int main(){


	while(cin>>n&&n!=0){
		fin=0;
		for(int i = 0; i < n*n; i++){
			fin|=(1ull<<i);
		}

		ok=false;
		lines.clear();
		vector<pair<int,pair<int,int> > > vpii;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin>>field[i][j];
				if(field[i][j]<0){
					vpii.push_back(make_pair(field[i][j],make_pair(i,j)));
				}
			}
		}
		for(int i = 0; i < vpii.size(); i++){
			tmp.clear();
			if(i==5){
				//cout<<endl;
			}

			lineSearch(((1ull)<<(vpii[i].second.first*n+vpii[i].second.second)),0,-vpii[i].first,vpii[i].second.second,vpii[i].second.first);
			lines.push_back(tmp);
		}
		dfs(0ull,0);
		if(ok)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}

	return 0;
}

Measured memory_bytes: 964
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <utility>
#include <cstring>
using namespace std;
typedef long long ll;

int N,M;
int main() {
	cin >> N >> M;
	bool err = false;
	int I,O;
	int ans = M;
	for (int i = 0; i < N; ++i) {
		cin >> I >> O;
		M += I-O;
		ans = max(ans, M);
		if (M < 0) err = true;
	}
	cout << (err ? 0 : ans) << endl;
}

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

using namespace std;

int select_pair(int n) {
    int p = n * (n-1) / 2;
    return p;
}

int main() {
    int n, m;
    cin >> n >> m;
    cout << select_pair(n) + select_pair(m) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
//#include <array>
#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//#include <stack>
//#include <queue>
#include <numeric>
using ll = long long;
using namespace std;

template<typename Tint>
Tint gcd(Tint a, Tint b) {
	// O(log max(a,b))
	return b != 0 ? gcd(b, a % b) : a;
}
int main() {
	int N,M;
	cin >> N >> M;
	string S, T;
	cin >> S >> T;
	int g = gcd(N, M);
	int a = N / g;
	int b = M / g;
	bool is_ok = true;
	for (int i = 0; i < g; i++)
	{
		if (S[a*i] != T[b*i]) {
			is_ok = false;
			break;
		}
	}
	if (is_ok) {
		cout << (ll)a * g * b << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}



Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int gcd(int k, int l) {
    while(true) {
        if(k > l) {
            int t = k;
            k = l;
            l = t;
        }
        if(l % k != 0) {
            l = l % k;
        } else {
            return k;
        }
    }
}
int main() {
    int n;
    cin >> n;
    vector<int> ary(n, 0);
    for(int i=0; i<n; i++) {
        cin >> ary[i];
    }
    for(int i=0; i<n-1; i++) {
        ary[i+1] = gcd(ary[i], ary[i+1]);
    }
    cout << ary[n-1] << endl;

    // for(int i=0; i<n; i++) {
    //     cout << ary[i] << endl;
    // }
    // sort(ary.begin(), ary.end());
    // int k = ary[0];
    // for(int i=1; i<n; i++) {
    //     if(ary[i] % k != 0) {
    //         ary[i] = ary[i] % k;
    //         k = ary[i];
    //     }
    // }
    // cout << k << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
#define pb push_back
#define fi0(i,n) for(int i=0; i<n; i++)
#define fi1(i,n) for(int i=1; i<n; i++)
#define fll0(i,n) for(long long i=0; i<n; i++)
#define fll1(i,n) for(long long i=1; i<n; i++)
#define vll vector<long long>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
int main()
{
  ll a,b;
  cin>>a>>b;
  cout<<a*b<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,result = -100000;
    int num[100005] = {0};
    int memo[100000] = {0};
    while(cin >> n >> m,n + m)
    {
        for(int i = 0; i < n; i++)cin >> num[i];
        for(int i = m-1; i < n; i++)
        {
            memo[i]=0;
            if(i == m-1)
            {
                for(int j = 0; j < m; j++)
                {
                    memo[i] += num[i-j];
                }
            }
            else if(i > m-1)
            {
                memo[i] = memo[i-1] +  num[i] - num[i-m];
            }
        }
        for(int i = m - 1; i < n; i++)
        {
            result = max(result,memo[i]);
        }
        cout << result << endl;
        result = -100005;
    }
    return 0;
}

Measured memory_bytes: 3868
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
typedef long long LL;
int main(){
	LL x,y,z=0;
	cin>>x>>y;
	if((x>y&&x%y==0)||x==y){
		printf("-1");
		return 0;
	}
	for(int i=1;;i++){
		z+=x;
		if(z>y&&z%y!=0){
			printf("%lld\n",z);
		return 0;
}
	}
}



Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}

	public static void main(String[] args){
		Map <Integer,Integer> mapL = new HashMap<Integer,Integer> ();

		Scanner sc = new Scanner(System.in);
			// 整数の入力
			int n,x,index,a,b,p;
			int result,len,sumLen;
			n = sc.nextInt();
			x = sc.nextInt();
			sumLen=0;
			result=n+1;
			for (index=0;index<n;index++) {
				len = sc.nextInt();
				sumLen=sumLen+len;
				if(sumLen>x) {
					result=index+1;
					break;
				}
			}
			sc.close();
			System.out.println(result);

			// 出力

	}
}

Measured memory_bytes: 22996
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int n, m, k, dp[100000];
void dfs(int cnt, int sum) {
	//cout << cnt << " " << sum << endl;
	if(cnt == 0) {
		dp[max(sum-k, 1)]++;
		return;
	}
	FOR(i, 1, m+1) {
		dfs(cnt-1, sum+i);
	}
}

signed main(void)
{
	while(true) {
		cin >> n >> m >> k;
		if(!n && !m && !k) break;
		REP(i, 100000) dp[i] = 0;
		dfs(n, 0);
		double sum = 0;
		REP(i, 100000) sum += i*dp[i];
		REP(i, n) sum /= m;
		cout << fixed << setprecision(15) << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 3608
# じょえチャンネルおもしろいよ～～～
# https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ

yay="Yay!"
noyay=":("
a,b,c=map(int,input().split())
k=int(input())
while a>=b:
  b*=2
  k-=1
while b>=c:
  c*=2
  k-=1
if k>=0:print("Yes")
else:print("No")

Measured memory_bytes: 9172
a = input().split(" ")
b = list(map(int, input().split(" ")))
c = input()
if (a[0] == c):
  print("{0} {1}".format(b[0]-1, b[1]))
elif (a[1] == c):
  print("{0} {1}".format(b[0], b[1]-1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int n,sum,ans;
char a;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		{
			cin >> a;
			if (a == 'I') sum++;
				else sum--;
			if (sum > ans) ans = sum;	
		}
	cout << ans << endl;	
	return 0;	
 } 

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

int main()
{
	int D;
	cin >> D;
	cout << "Christmas";
	if (D <= 24) cout << " Eve";
	if (D <= 23) cout << " Eve";
	if (D == 22) cout << " Eve";
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void){
  long i;
  long N;
  long t;
  scanf("%ld",&N);
  long A[N+1];

  for(i=1; i<=N; i++){
    scanf("%ld",&t);
    A[t]=i;
  }

  for(i=1; i<=N; i++){
    if(i!=N){
      printf("%ld ",A[i]);
    }else{
      printf("%ld\n",A[i]);
    }
  }

  return 0;
}


Measured memory_bytes: 1536
#include	<stdio.h>

int main(void)
{
	int	a,b,c;
	int	i;

	scanf("%d%d%d",&a,&b,&c);

	if(a<b){
		if(b<c)
			printf("%d %d %d\n",a,b,c);
		else{
			if(a>c)
				printf("%d %d %d\n",c,a,b);
			else
				printf("%d %d %d\n",a,c,b);
		}
	}
	else{
		if(b<c){
			if(a>c)
				printf("%d %d %d\n",b,c,a);
			else
				printf("%d %d %d\n",b,a,c);
		}
		else
			printf("%d %d %d\n",c,b,a);
	}
	
	return(0);
}
	

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define foru(a,b,c) for(int a=b;a<=c;++a)
#define int long long
using namespace std;

main()
{
    int r,d,x;
    cin>>r>>d>>x;
    foru(i,1,10)
    {
        int kq=r*x-d;
        x=kq;
        cout << kq << "\n";
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
import java.io.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            int n = sc.nextInt();
            if(h == 0 && w == 0 && n == 0) break;
            int[][] status = new int[h][w];
            for(int i = 0; i < h; i++) {
                for(int j = 0; j < w; j++) {
                    status[i][j] = sc.nextInt();
                }
            }
             
            int[][] dp1 = new int[h+1][w+1];
            dp1[0][0] = n-1;
            for(int i = 0; i < h; i++) {
                for(int j = 0; j < w; j++) {
                        if(status[i][j] == 0) {
                            dp1[i+1][j] += dp1[i][j]/2 + ((dp1[i][j] % 2 == 0)?0:1);
                        }
                        else {
                            dp1[i+1][j] += dp1[i][j]/2;
                        }
                        if(status[i][j] == 0) {
                            dp1[i][j+1] += dp1[i][j]/2;
                        }
                        else {
                            dp1[i][j+1] += dp1[i][j]/2 + ((dp1[i][j] % 2 == 0)?0:1);
                        }
                }
            }
            int[][] dp2 = new int[h+1][w+1];
            dp2[0][0] = n;
            for(int i = 0; i < h; i++) {
                for(int j = 0; j < w; j++) {
                        if(status[i][j] == 0) {
                            dp2[i+1][j] += dp2[i][j]/2 + ((dp2[i][j] % 2 == 0)?0:1);
                        }
                        else {
                            dp2[i+1][j] += dp2[i][j]/2;
                        }
                        if(status[i][j] == 0) {
                            dp2[i][j+1] += dp2[i][j]/2;
                        }
                        else {
                            dp2[i][j+1] += dp2[i][j]/2 + ((dp2[i][j] % 2 == 0)?0:1);;
                        }
                }
            }
            int nowx = 0;
            int nowy = 0;
             
            while(nowx != w && nowy != h) {
                if(dp1[nowy+1][nowx] < dp2[nowy+1][nowx]) nowy++;
                else nowx++;
            }
            System.out.println((nowy+1) + " " + (nowx+1));
        }
    }
}
             
        

Measured memory_bytes: 297268
#include<iostream>
#include<vector>
using namespace std;
int n,m,q;
vector<int> a,b,c,d;
int ans=0;
void dfs(vector<int> s){
  if(s.size()==n+1){
    int now=0;
    for(int i=0;i<q;i++) if(s[b[i]]-s[a[i]]==c[i]) now+=d[i];
    ans=max(ans,now);
    return;
  }
  s.push_back(s.back());
  while(s.back()<=m){
    dfs(s);
    s.back()++;
  }
}

int main(){
  cin>>n>>m>>q;
  a=b=c=d=vector<int>(q);
  for(int i=0;i<q;i++) cin>>a[i]>>b[i]>>c[i]>>d[i];
  dfs(vector<int>(1,1));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
vector<int> a;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    rep(i, 0, n) {
        int x; cin >> x;
        a.pb(x);
    }
    sort(a.begin(), a.end());
    cout << a[a.size()-1] - a[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 77;
constexpr int MAX_M = 575;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout <<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

int dp[MAX_N][MAX_M][MAX_M];

signed main() {
  INIT;
	VAR(int, n, ma, mb);
	vector< int > a(n), b(n), c(n);
	REP(i, n) {
		cin >> a[i] >> b[i] >> c[i];
	}
	REP(i, MAX_N) {
		REP(j, MAX_M) {
			REP(k, MAX_M) {
				dp[i][j][k] = INF;
				if (j == 0 && k == 0) dp[i][j][k] = 0;
			}
		}
	}

	REP(i, n) {
		REP(j, MAX_M) {
			REP(k, MAX_M) {
				dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]],
																						dp[i][j][k] + c[i]);
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
			}
		}
	}
	
	int ans = INF;
	FOR(i, 1, MAX_M) {
		if (max(ma * i, mb * i) >= MAX_M) break;
		ans = min(ans, dp[n][i * ma][i * mb]);
	}
	if (ans == INF) ans = -1;
	OUT(ans)BR;
  return 0;
}


Measured memory_bytes: 199168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int x=1;
		for (int i=1;i<=3;i++){
			x=x*n;
		}
		System.out.println( x );
	}

}

Measured memory_bytes: 17164
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	string s;
	cin >> s;
	int l = s.length();
	int table[s.length()];
	for(int i=1; i<s.length(); i++) {
		if(s[i-1] == 'L' && s[i] == 'L') {
			table[i] = table[i-1] - 1;
		}
		else if (s[i] == 'L') {
			table[i] = -1;
		}
	}
	for (int i = s.length() - 2; i >= 0; i--) {
		if(s[i+1] == 'R' && s[i] == 'R') {
			table[i] = table[i+1] + 1;
		}
		else if (s[i] == 'R') {
			table[i] = 1;
		}
	}
	int ans[l];
	memset(ans, 0, sizeof(ans));
	//rep(i,l) {cout << table[i] << " ";}
	//cout << endl;
	for(int i=0; i < l; i++) {
		//cout << i << " ";
		if(table[i] < 0) {
			if(table[i] % 2 == 0) {
				//cout << "p1" << endl;
				ans[i+table[i]]++;
			}
			else {
				//cout << "p2" << endl;
				ans[i+table[i]+1]++;
			}
		}
		if(table[i] > 0) {
			if(table[i] % 2 == 0) {
				//cout << "p3" << endl;
				ans[i+table[i]]++;
			}
			else {
				//cout << "p4" << endl;
				ans[i+table[i]-1]++;
			}
		}
	}
	rep(i,l) {
		cout << ans[i];
		if(i == l-1) cout << endl;
		else cout << " ";
	}

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>

enum struct Panel { none, up, down, right, left };

int main() {
    int h, w;
    while (std::cin >> h >> w && h != 0 && w != 0) {
        std::cin.ignore();

        auto room = new std::pair<Panel, bool>[h * w]();
        std::string s;
        for (int i = 0; i < h; i++) {
            std::getline(std::cin, s);
            for (int j = 0; j < w; j++) {
                switch (s[j]) {
                    case '.': room[i * w + j].first = Panel::none; break;
                    case '^': room[i * w + j].first = Panel::up; break;
                    case 'v': room[i * w + j].first = Panel::down; break;
                    case '>': room[i * w + j].first = Panel::right; break;
                    case '<': room[i * w + j].first = Panel::left; break;
                    default: return EXIT_FAILURE;
                }
            }
        }

        int x = 0, y = 0;
        [&]() {
            while (true) {
                if (room[y * w + x].second) {
                    std::cout << "LOOP";
                    break;
                }
                room[y * w + x].second = true;
                switch (room[y * w + x].first) {
                    case Panel::up: y--; break;
                    case Panel::down: y++; break;
                    case Panel::right: x++; break;
                    case Panel::left: x--; break;
                    case Panel::none: std::cout << x << ' ' << y; return;
                }
            }
        }();
        std::cout << std::endl;
    }
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    while (1)
    {

        C -= B;
        if (C <= 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if (A <= 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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 int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n,y;
    cin>>n>>y;

    rep(i,n+1){
        for(int j=0;j+i<=n;j++){
            int k=n-j-i;
            if(k<0) continue;
            if(y==10000*i+5000*j+1000*k){
                printf("%d %d %d\n",i,j,k);
                return 0;
            }
        }
    }

    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 3736
fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val n = readLine()!!.split(" ").map(String::toInt).sorted().reversed()
    var alice = 0
    var bob = 0
    for(i in 0 until a){
        if(i % 2 == 0){
            alice += n[i]
        }else{
            bob += n[i]
        }
    }
    println(alice - bob)

}



Measured memory_bytes: 37956
s = input()
ans = [0]*(len(s)+1)

for i in range(len(s)):
    if s[i] == '<':
        ans[i+1] = ans[i] + 1
for i in range(len(s)-1,-1,-1):
    if s[i] == '>':
        ans[i] = max(ans[i], ans[i+1] + 1)
print(sum(ans))


Measured memory_bytes: 46320
#define _USE_MATH_DEFINES
#define INF 100000000

#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <string,string> P;
typedef pair <int,P> PP;

static const double EPS = 1e-8;

void dfs(map<char,int>& co,map<char,int>::iterator it,map<char,bool>& pre,int visited,int sum,map<int, map<int,int> >& result){

	if(it==co.end()){
		result[sum][visited]++;
		return;
	}

	for(int i=0;i<=9;i++){		
		if(visited & (1<<i)) continue;
		if(i==0 && pre[it->first]) continue;

		sum += it->second * i;
		it++;
		visited |= (1<<i);
		dfs(co,it,pre,visited,sum,result);
		visited &= ~(1<<i);
		it--;
		sum -= it->second * i;
	}
}

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		int count = 0;
		map<char,int> coefficient;
		map<char,bool> prefix; // prefix or not
		for(int i=0;i<n;i++){
			string str;
			cin >> str;
			if(str.size() > 1) prefix[str[0]] = true;
			for(int j=str.size()-1,k=1;j>=0;j--,k*=10){
				if(i!=n-1) coefficient[str[j]] += k;
				else coefficient[str[j]] -= k;
			}
		}
	
		map<char,int> co_front;
		map<char,int> co_rear;

		int ub=0;
		map<char,int>::iterator cit;
		for(cit = coefficient.begin(); cit != coefficient.end();cit++){
			if(ub >= coefficient.size()/2) break;
			co_front[cit->first] = cit->second;
			ub++;
		}

		for(; cit != coefficient.end();cit++){
			co_rear[cit->first] = cit->second;
		}

		map<int,map<int,int> > result_front;
		map<int,map<int,int> > result_rear;

		dfs(co_front,co_front.begin(),prefix,0,0,result_front);
		dfs(co_rear,co_rear.begin(),prefix,0,0,result_rear);

		int res=0;
		for(map<int,map<int,int> >::iterator it = result_front.begin(); it != result_front.end(); it++){
			
			map<int,map<int,int> >::iterator it2;

			if((it2 = result_rear.find(-(it->first))) != result_rear.end()){
				for(map<int,int>::iterator sit = it->second.begin(); sit != it->second.end(); sit++){
					for(map<int,int>::iterator sit2 = it2->second.begin(); sit2 != it2->second.end(); sit2++){
						if(!(sit->first & sit2->first)) res+=sit->second * sit2->second;
					}
				}
			}
		}


		printf("%d\n",res);
	}
}

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

int32_t main(){
    int a, b; cin >> a >> b;
    int ans = max(ceil(a*double(12.5)), b*double(10));
    if((int)(ans * 0.08) == a && (int)(ans/10) == b) cout << ans << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FreeWorks
{
    class Program
    {
        static int Bs(int[] array, int left, int right, int target)
        {
            
            int save_left = left;
            if (array[left] >= target) return 0;
            else if (array[right] < target) return right - left + 1;
            else if (left + 1 == right) return 1;

            while (left < right - 1)
            {
                int m = (left + right) / 2;
                if (array[m] < target) left = m;
                else right = m;
            }
            if (array[right] < target) return right - save_left + 1;
            else return right - save_left;
                    
        }

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] L = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderBy(x => x).ToArray();
            int cnt = 0;
            
            for (int a = 0; a < N - 2; a++)
            {
                for (int b = a + 1; b < N - 1; b++)
                {
                    int t = L[a] + L[b];
                    int l = b + 1;
                    int r = N - 1;
                    int test = Bs(L, l, r, t);
                    cnt += test;          
                }
            }

                    Console.WriteLine(cnt);
        }   
    }
}


Measured memory_bytes: 13408
class Dice
  def initialize(line)
    @dice = line.split(" ").map(&:to_i)
  end
  def rot(command)
    if(command == "E") then
      @dice[0], @dice[3], @dice[5], @dice[2] = @dice[3], @dice[5], @dice[2], @dice[0]
    elsif(command == "N") then
      @dice[0], @dice[1], @dice[5], @dice[4] = @dice[1], @dice[5], @dice[4], @dice[0]
    elsif(command == "S") then
      @dice[0], @dice[1], @dice[5], @dice[4] = @dice[4], @dice[0], @dice[1], @dice[5]
    elsif(command == "W") then
      @dice[0], @dice[3], @dice[5], @dice[2] = @dice[2], @dice[0], @dice[3], @dice[5]
    end
  end
  def dispTop
    printf "%d\n", @dice[0]
  end
  def returnLeft(line)
    u, f = line.split(" ").map(&:to_i)
    4.times{
      rot("N")
      4.times{
        rot("E")
        if(@dice[0] == u && @dice[1] == f) then
#          printf "%s\n", @dice.join(" ")
          return @dice[2]
        end
      }
    }
    rot("E")
    4.times{
      rot("N")
      4.times{
        rot("E")
        if(@dice[0] == u && @dice[1] == f) then
#          printf "%s\n", @dice.join(" ")
          return @dice[2]
        end
      }
    }
  end
end

dice = Dice.new(gets.chomp)
n = gets.to_i
n.times {
  printf "%d\n", dice.returnLeft(gets.chomp)
}

Measured memory_bytes: 8700
#include <stdio.h>
int main(void){
    // Here your code !
    int h,w;
    int i,j;
    while(1){
        scanf("%d %d\n", &h, &w);
        if( h == 0 && w == 0){
            break;
        }
        for( i = 0; i < h; ++i){
            for( j = 0; j < w; ++j){
                if( i == 0 || j == 0 || j == w-1 || i == h-1 ){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 576
S = raw_input()
arr = []

for i in range(4):
     if S[i] not in arr:
         arr.append(S[i])

if len(arr) != 2:
    print "No"
else:
    a = 0
    b = 0
    for i in range(4):
        if S[i] == arr[0]:
            a = a + 1
        elif S[i] == arr[1]:
            b = b + 1
    if a == 2 and b == 2:
        print"Yes"
    else:
        print "No"


Measured memory_bytes: 2568
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0176
{
    public class Program

    {
        public class Color
        {
            public string Name { get; }
            public int R { get; }
            public int G { get; }
            public int B { get; }
            public Color(string name, int r, int g, int b)
            {
                Name = name;
                R = r; G = g; B = b;
            }
        }

        public static Color[] colors = new Color[]
        {
             new Color("black"  ,    0,   0,   0)
            ,new Color("blue"   ,    0,   0, 255)
            ,new Color("lime"   ,    0, 255,   0)
            ,new Color("aqua"   ,    0, 255, 255)
            ,new Color("red"    ,  255,   0,   0)
            ,new Color("fuchsia",  255,   0, 255)
            ,new Color("yellow" ,  255, 255,   0)
            ,new Color("white"  ,  255, 255, 255)
        };

        public static void Main(string[] args)
        {
            while (true)
            {
                string line = Console.ReadLine();
                if (line == "0") return;

                int colorR = Convert.ToInt32(line.Substring(1, 2), 16);
                int colorG = Convert.ToInt32(line.Substring(3, 2), 16);
                int colorB = Convert.ToInt32(line.Substring(5, 2), 16);

                double minV = double.MaxValue;
                string minN = "";

                for (int i = 0 ; i < colors.Length ; i++)
                {
                    double v = Math.Sqrt(Math.Pow(colorR - colors[i].R, 2) + Math.Pow(colorG - colors[i].G, 2) + Math.Pow(colorB - colors[i].B, 2));
                    if ( v <minV)
                    {
                        minV = v;
                        minN = colors[i].Name;
                    }
                }
                Console.WriteLine(minN);
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 13720
#include <iostream>
#include <vector>
#include <algorithm>
#define INF (int)1e9 + 7
using namespace std;

int main() {
    int n;
    while (cin >> n && n) {
        vector<int> s(n);
        for (int i = 0; i < n; i++) {
            cin >> s[i];
        }
        sort(s.begin(), s.end());
        int sum = 0;
        for (int i = 1; i < n - 1; i++) {
            sum += s[i];
        }
        cout << sum / (n - 2) << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define pb push_back
#define ld long double
#define mod 1000000007
#define mk make_pair
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
void factor(ll n,vector<pair<ll,ll>>&p)
{
    ll i=1;
    for(i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            p.pb(mk(i,n/i));
        }
    }
}
int main()
{
    fastIO;
    ll n;
    cin>>n;
    vector<pair<ll,ll>>p;
    factor(n,p);
    ll flag=0,x,y;
    for(int i=0;i<p.size();i++)
    {
        x=p[i].first;
        y=p[i].second;
        if((x>=1 && x<=9) && (y>=1 && y<=9))
        {
            flag=1;
            break;
        }
    }
    if(flag)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}

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

long long n;
long long a[30][30] = {0};
// dp[i][s]: i-man number, s-women state
long long dp[30][4194304] = {0};

long long solve();

int main() {
  cin >> n;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) cin >> a[i][j];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  for(int i = 0; i < n; ++i)
    if(a[0][i]) dp[0][(1 << n) - 1 - (1 << i)] = 1;
  for(int i = 1; i < n; ++i)
    for(int j = 0; j < n; ++j)
      if(a[i][j]) {
        for(int k = 0; k < (1 << n); ++k)
          if((k >> j) % 2 == 0) {
            dp[i][k] += dp[i - 1][k + (1 << j)];
            dp[i][k] %= N;
          }
      }
  return dp[n - 1][0];
}

Measured memory_bytes: 377088
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

int count_rank(int n) {
	if(n==0) return 0;
	return count_rank(n/10)+1;
}

signed main() {
	int n;
	std::cin >> n;
	int count = 0;
	for(int i=1;i<=n;i++) {
		if(count_rank(i)%2==1) count++;
	}
	print(count);
	return 0;
}


Measured memory_bytes: 256