akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

const ll dy[4] = { +1, +0, -1, +0 };
const ll dx[4] = { +0, -1, +0, +1 };

int main(void) {
  while (1) {
    ll N, M;
    cin >> N >> M;
    if (N == 0 && M == 0) break;
    vector<string> S(N);
    REP(i, 0, N) cin >> S[i];

    vector<vector<ll>> state(N, vector<ll>(M));

    ll y = 0, x = 0, d = 0, cnt = 0;
    bool t1 = false, t2 = false, t3 = false;
    do {
      if (!t1 && y + 1 == N && x + 1 == 1) { t1 = true; cnt++; }
      if (!t2 && y + 1 == N && x + 1 == M) { t2 = true; cnt++; }
      if (!t3 && y + 1 == 1 && x + 1 == M) { t3 = true; cnt++; }

      state[y][x] |= 1 << cnt;

      ll ny = y + dy[d];
      ll nx = x + dx[d];
      if (0 <= ny && ny < N && 0 <= nx && nx < M && S[ny][nx] == '.') {
        y = ny;
        x = nx;
        d = (d + 1) % 4;
      } else {
        d = (d + 3) % 4;
      }
    } while (!(y == 0 && x == 0 && d == 0));

    bool ok = cnt == 3;
    REP(i, 0, N) REP(j, 0, M) {
      if (i == 0 && j == 0) continue;
      ok = ok && __builtin_popcount(state[i][j]) <= 1;
    }
    cout << (ok ? "YES" : "NO") << endl;
  }
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;

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

    if (r < 1200) {
        cout << "ABC" << endl;
        return 0;
    }
    if (r < 2800) {
        cout << "ARC" << endl;
        return 0;
    }
    cout << "AGC" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
        int h,w,i;
        char row[102][102];

        scanf("%d%d",&h,&w);

        for(i=0;i<h;i++){
                scanf("%s",row[i]);
        }

        for(i=0;i<w+2;i++)
                printf("#");
        printf("\n");

        for(i=0;i<h;i++)
                printf("#%s#\n",row[i]);

        for(i=0;i<w+2;i++)
                printf("#");
        printf("\n");

        return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  int ans=0;
  rep(i,n){
    if(v[i]!=v[i+1]){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long
using namespace std;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
// #ifndef ONLINE_JUDGE
//    freopen ("INPUT.txt" , "r" , stdin);
//    freopen ("OUTPUT.txt" , "w" , stdout);
// #endif

    clock_t clk;
	clk = clock();

// --------------Code s0tarts here---------------------------------------------------------------------

    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(n%i==0)
        {
            if(n/i<10 && i<10)
            {
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
// -------------------------------------Code ends here------------------------------------------------------

    clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;

int main(){
  ll a,b,c=0,d=0,e,f,g,h,m,n,ans=0;
  cin>>a>>b;
  if(a>=10) co(b);
  else co(b+100*(10-a));
  
  return 0;
}


Measured memory_bytes: 256
# original submission: https://atcoder.jp/contests/tokiomarine2020/submissions/14259812
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))

if K > 4 * math.log2(N):
    for _ in range(N):
        print(N," ", end = "")
    print()
else:
    for i in range(K):
        cum_sum = [0]*N
        for j in range(N):
            left = max(0, j - A[j])
            right = min(N-1, j+A[j])
            cum_sum[left] += 1
            if right + 1 < N:
                cum_sum[right+1] -= 1
        A[0] = cum_sum[0]
        for j in range(N-1):
            cum_sum[j+1] += cum_sum[j]
            A[j+1] = cum_sum[j+1]

            
    for i in range(N):
        print(A[i], " ", end = "")
    print()
            


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

using namespace std;
#define int long long
const int MOD = 1000000007;
  
signed main(){
    int n;
    cin >>n;
    string s;
    cin >>s;
    int k=0;
    int p[n+1];
    p[0]=0;
    for(int i=0;i<n;i++){
        if(s[i]=='#')p[i+1]=p[i]+1;
        else p[i+1]=p[i];
    }
    int ans=p[n];
    for(int i=0;i<=n;i++){
        ans=min(ans,n-i-p[n]+2*p[i]);
    }

    
    cout<<ans;
}


Measured memory_bytes: 2180
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
vector<vector<pair<int, int>>> graph;
vector<bool> seen;

int dfs(int ignore, int v) {
  seen[v] = true;
  int ret = 1;
  for (auto nv : graph[v]) {
    if (seen[nv.first])
      continue;
    if (nv.second == ignore)
      continue;
    ret += dfs(ignore, nv.first);
  }
  return ret;
}

int main(void) {
  int N, M;
  cin >> N >> M;
  graph.resize(N + 1);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    graph[a].push_back(make_pair(b, i));
    graph[b].push_back(make_pair(a, i));
  }

  int ANS = 0;
  rep(i, M) {
    seen.assign(N+1, false);
    if (dfs(i, 1) != N) {
      ANS++;
    }
  }
  cout << ANS << endl;
  return 0;
}

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

int factorial(int n){
    long int res = 1;
    for(int i=2; i<=n; i++){
        res *= i;
    }
    return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(10);

    int n, i, j;
    vector<pair<int,int>> points;
    cin >> n;
    for(i=0; i<n; i++){
        int in1, in2;
        cin >> in1 >> in2;
        points.push_back({in1,in2});
    }
    sort(points.begin(), points.end());
    int paths = factorial(n);
    double up = 0;
    for(i=0; i<paths; i++){
        for(j=0; j<n-1; j++){
            up += sqrt((points[j].first-points[j+1].first)*(points[j].first-points[j+1].first) + (points[j].second-points[j+1].second)*(points[j].second-points[j+1].second));
        }
        next_permutation(points.begin(), points.end());
    }
    cout << up/paths << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=2e5+10;
ll ans;
char s1[N];
ll sum[30],tot[30];
int main(){
	scanf("%s",s1+1);
	ll len=strlen(s1+1);
	for(ll i=1;i<=len;i++) sum[s1[i]-'a'+1]++;
	for(ll i=1;i<=len;i++){
		ll t=s1[i]-'a'+1;
		tot[t]++;
		ans+=len-i-(sum[t]-tot[t]);
	} 
	printf("%lld",ans+1);
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const int MOD=1000000007;
const double PI = 3.1415926535897932384626433;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N/i != i) res.push_back(N/i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

ll zyou(ll x,ll n){
	ll y=1;
	rep(i,0,n){
		y*=x;
	}
	return y;
}

int main() {
	int x,a,b;
	cin>>x>>a>>b;
	if(-1*a+b<=x){
		if(-1*a+b<=0)print("delicious");
		else print("safe");
	}else print("dangerous");


}


Measured memory_bytes: 256
#!/usr/bin/python

import sys

def main(argv):
    line = sys.stdin.readline()
    while line:
        N = int(line)
        a = map(lambda x: int(x), sys.stdin.readline().split(" "))

        histogram = [0 for i in xrange(100000 + 2)]
        for i in a:
            histogram[i - 1] += 1
            histogram[i] += 1
            histogram[i + 1] += 1
        print(max(histogram[1:]))
        
        line = sys.stdin.readline()

if __name__ == "__main__":
    main(sys.argv)

Measured memory_bytes: 11328
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0

for i in range(0,a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            if x == (i*500 + j*100 + k*50):
                cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <complex>

using namespace std;
typedef long long ll;


typedef complex<double> xy_t;
double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

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

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define re(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
#define lb lower_bound
#define ub upper_bound

ll i,j,k,ii,jj;
ll n,m,sum,num;
ll ans=0;
ll a,b,c,d,e,h,w;

ll x[500005],y[500005],z[500005];
char s[100005],t[100005];
bool ok=false;
bool check[100005];

int main(){
    cin>>n;
    for(i=0;i<n;i++)cin>>x[i];
    for(i=0;i<n-1;i++){
        if(x[i]==x[i+1]){
            ans++;
            i++;
        }
    }
    p(ans);
    return 0;
}


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

int main(){
    vector<vector<int>> a(3,vector<int>(3,0));
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin>>a[i][j];
        }
    }
    bool ok=true;
    if(!(a[0][0]-a[0][1] == a[1][0]-a[1][1] && a[2][0]-a[2][1] == a[1][0]-a[1][1])) ok=false;
    if(!(a[0][1]-a[0][2] == a[1][1]-a[1][2] && a[2][1]-a[2][2] == a[1][1]-a[1][2])) ok=false;

    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	lp(n + 1) {
		lop(m + 1, j) {
			if (i*m + j*n - i*j * 2 == k) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n,ba=250001,fr=249999;

	int a[600000];
	int b[600000];

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

	b[250000] = a[0];
	for (int i = 1; i < n; i++) {
		if (i % 2 == n % 2) {

			b[ba] = a[i];
			ba++;
		}
		else {
			b[fr] = a[i];
			fr--;
			}
		

		}
	







	for (int i = fr + 1; i < ba - 1; i++) {

		cout << b[i] << " ";

	}

	cout << b[ba - 1] << endl;

}

Measured memory_bytes: 6784
#include<iostream>
using namespace std;
int main(){
  int a[10],t[10],n[10],mon[10];
  for(int i=0;i<4;i++){
    cin>>t[i]>>n[i];
  }
  for(int i=0;i<4;i++){
    if(t[i]==1){
      mon[i]=6000;
    }if(t[i]==2){
      mon[i]=4000;
    }if(t[i]==3){
      mon[i]=3000;
    }if(t[i]==4){
      mon[i]=2000;
    }
    a[i]=mon[i]*n[i];
  }
  for(int i=0;i<4;i++){
    cout<<a[i]<<endl;
  }
  return 0;
}

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

int64_t mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N, X, tmp, sum = 0;
    cin >> N >> X;
    vector<int> list(N);
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        list[i] = tmp;
        sum += list[i];
    }
    sort(list.begin(), list.end());
    cout << N + (X - sum) / list[0];
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n; cin >> n;
    double t, a; cin >> t >> a;
    vector<double> h(n);
    for(int i=0; i<n; i++){
        cin >> h[i];
    }
    double diff, min=100000;
    int ans;
    
    for(int i=0; i<n; i++){
        double w = t-h[i]*0.006;
        diff = abs(a-w);
        if(min>diff){
            min = diff;
            ans = i+1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

// -------------------------------------------

const long long MOD = 998244353;

 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

void solve(long long N, long long M, long long K){
  mint ans = 0;
  mint col = M;
  combination c(200001);
  for (int x = N-1; x >= 0; --x) {
    mint now = col;
    now *= c(N-1,x);
    if(x <= K) ans += now;
    col *= M-1;
  }
  std::cout << ans << std::endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    solve(N, M, K);
    return 0;
}


Measured memory_bytes: 6428
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int ch[100111][2],tot;bool die[100111];
int n;LL l;
char s[100111];
LL dfs(int x,int d)
{
	if(x==0)return (l-d+1)&-(l-d+1);
	if(die[x])return 0;
	return dfs(ch[x][0],d+1)^dfs(ch[x][1],d+1);
}
int main()
{
	tot=1;
	get2(n,l);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		int cur=1;
		for(int j=1;s[j];j++)
		{
			if(!ch[cur][s[j]-'0'])ch[cur][s[j]-'0']=++tot;
			cur=ch[cur][s[j]-'0'];
		}
		die[cur]=1;
	}
	puts(dfs(1,0)?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 4224
//B
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll a,b,c,k;
	cin >> a >> b >> c >> k;
	if(c > b and b > a){
		cout << "Yes\n";
		return 0;
	}
	while(k){
		if(b <= a){
			b *= 2;
			k--;
		}
		else break;
	}
	while(k){
		if(c <= b){
			c *= 2;
			k--;
		}
		else break;
	}
	if(c > b and b > a){
		cout << "Yes\n";
		return 0;
	}
	cout << "No";
	return 0;
}


Measured memory_bytes: 3608
n = int(input())
arr = [[[0 for m in range(10)] for n in range(3)]for l in range(4)]
for k in range(n):
    b,f,r,v =input().split()
    b,f,r,v = int(b),int(f),int(r),int(v)
    arr[b-1][f-1][r-1] += v

for i in range(len(arr)):
    for j in range(len(arr[i])):
        for k in range(len(arr[i][j])):
            print(" %d" % arr[i][j][k],end = "")
        else:
            print("")
    if i < len(arr) -1:
        print('#' * 20)


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007,N=150001;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
vector<vector<ll> > v(N);
ll pa[N];
double dpin[N],dpout[N];
void dfs1(ll now,ll p){
	pa[now]=p;
	double ans=0.0;
	double sum=double(v[now].size());
	if(p!=-1)sum-=1.0;
	if(sum==0){
		dpin[now]=1.0;
		return;
	}

	for(auto& to:v[now]){
		if(to==p)continue;
		dfs1(to,now);
		ans+=dpin[to];
	}
	ans/=sum;
	dpin[now]=ans+1;
	return;
}
void dfs2(ll now,ll p){
	vector<double> v1,v2;
	ll niko=v[now].size();
	double s=double(niko)-1.0;
	for(auto& to:v[now]){
		if(to==p)v1.pb(dpout[now]),v2.pb(dpout[now]);
		else v1.pb(dpin[to]),v2.pb(dpin[to]);
	}
	for(int i=1;i<niko;i++){
		v1[i]+=v1[i-1];
	}
	for(int i=niko-2;i>=0;i--){
		v2[i]+=v2[i+1];
	}
	for(int i=0;i<niko;i++){
		int to=v[now][i];
		if(to==p)continue;
		double ans=0;
		if(i>0)ans+=v1[i-1];
		if(i<niko-1)ans+=v2[i+1];
		if(niko==1)s=1;
		ans/=s;

		dpout[to]=ans+1.0;
		dfs2(to,now);
	}
	return;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n;
    for(int i=1;i<n;i++){
    	cin>>a>>b;
    	a--;b--;
    	v[a].pb(b);
    	v[b].pb(a);
    }
    if(n==1){
    	cout << 0 <<endl;
    	return 0;
    }
    dfs1(0,-1);
    dpout[0]=0.0;
    dfs2(0,-1);
    for(int i=0;i<n;i++){
    	double ans=0;
    	double sum=double(v[i].size());
    	ans+=dpout[i];
    	for(auto& to:v[i]){
    		if(to==pa[i])continue;
    		ans+=dpin[to];
    	}
    	doublecout(ans/sum);
    }
    return 0;
}


Measured memory_bytes: 33792
#include <bits/stdc++.h>
 
typedef long long ll;
const int MAX_N = 100000;
 
int main() {
  int N;
  ll s[MAX_N];
  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    std::cin >> s[i];
  }
 
  ll ans = 0;
  for(int C = 1; C < N - 1; ++C) {
    ll dp = 0;
    for(int k = 1; (ll) k * C < N - 1; ++k) {
      int A = N - 1 - k * C;
      int B = A - C;
      if(B <= 0) continue;
      if(A % C == 0 and k * C >= A) continue;
      dp += s[A] + s[k * C];
      ans = std::max(ans, dp);
    }
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key = lambda x: x[0])

total = 0
i = 0

while True:
    total += AB[i][1]
    if total < M:
        i += 1
    else:
        break

ans = 0
for j in range(i):
    ans += AB[j][0]*AB[j][1]
ans += (M - sum(AB[p][1] for p in range(0,i))) * AB[i][0]
print(ans)

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

void printq(deque<pair<int, int>> q){
        while(!q.empty()){
                printf("(%d,%d) ", q.front().first, q.front().second);
                q.pop_front();
        }
        cout << endl;
}
void printv(vector<vector<int>> v){
        for(int i = 0; i < v.size(); i++){
                for(int j = 0; j < v[i].size(); j++){
                        printf("%d ", v[i][j]);
                }
                printf("\n");
        }
}
void printvb(vector<vector<bool>> v){
        for(int i = 0; i < v.size(); i++){
                for(int j = 0; j < v[i].size(); j++){
                        cout << v[i][j] << " ";
                }
                printf("\n");
        }
}

int main(void){
        int h, w, ch, cw, dh, dw;
        const int INF = 1e9;
        cin >> h >> w >> ch >> cw >> dh >> dw;
        ch--; cw--; dh--; dw--;

        vector<string> s(h);
        for(int i = 0; i < h; i++){
                cin >> s[i];
        }

        vector<vector<int>> dist(h, vector<int>(w, INF));
        dist[ch][cw] = 0;
        deque<pair<int, int>> que;
        que.emplace_back(ch, cw);
        vector<vector<bool>> v(h, vector<bool>(w, false));

        vector<int> vx{1, 0, -1, 0};
        vector<int> vy{0, 1, 0, -1};
        while(!que.empty()){
                //printq(que);
                int i = que.front().first;
                int j = que.front().second;
                int d = dist[i][j];
                v[i][j] = true;
                que.pop_front();

                // walk
                for(int k = 0; k < 4; k++){
                        int y = i+vy[k], x = j+vx[k];
                        if(!(0 <= y and y < h and 0 <= x and x < w)) continue;
                        if(s[y][x] == '.' and !v[y][x]){
                                que.emplace_front(y, x);
                                dist[y][x] = d;
                        }
                }

                // warp
                for(int y = -2; y <= 2; y++){
                        for(int x = -2; x <= 2; x++){
                                int ny = i+y, nx = j+x;
                                if(!(0 <= ny and ny < h and 0 <= nx and nx < w)) continue;
                                if(s[ny][nx] == '.' and !v[ny][nx] and dist[ny][nx] > d+1){
                                        que.emplace_back(ny, nx);
                                        dist[ny][nx] = d + 1;
                                }
                        }
                }
        }
        //printv(dist);
        cout << (dist[dh][dw] == INF ? -1 : dist[dh][dw]) << endl;
	return 0;
}


Measured memory_bytes: 9740
program easy_linear

 implicit none
 integer::a,b,c,k,ans

 read*,a,b,c,k

ans=0

aa: if(a<=k) then 
    ans=ans+a
    k=k-a
bb:   if(b<=k) then
      k=k-b
dd:     if(k>=0) then
          ans=ans-k
        end if dd
      else
       go to 200
      end if bb
    else
     ans=ans+k
     go to 200
    end if aa

200 print*,ans

end program easy_linear
  

Measured memory_bytes: 2856
#include<bits/stdc++.h>
using namespace std;
  const int INF = 1e9 + 5;
int main()
{
  int n,k;
  cin>>n>>k;

  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  vector<int> dp(n,INF);
  dp[0]=0;
  for(int i=0;i<n;i++)
  {
    for(int j=i+1;j<=i+k;j++)
    {
      if(j<n)
      {
        dp[j]= min(dp[j], dp[i]+abs(arr[j]-arr[i]));

      }
    }
  }
  cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
INF = 10**10
MOD = 10**9 + 7
sys.setrecursionlimit(100000000)
from functools import lru_cache
from copy import deepcopy 

def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = deepcopy(a)

    ans1 = 0
    if a[0] <= 0:
        ans1 += 1 - a[0]
        a[0] = 1
    
    for i in range(1,n):
        a[i] += a[i - 1]
        if a[i - 1] < 0 and a[i] <= 0:
            ans1 += 1 - a[i]
            a[i] = 1
        elif a[i - 1] > 0 and a[i] >= 0:
            ans1 += a[i] + 1
            a[i] = -1
    
    ans2 = 0
    if b[0] >= 0:
        ans2 += b[0] + 1
        b[0] = -1

    for i in range(1,n):
        b[i] += b[i - 1]
        if b[i - 1] < 0 and b[i] <= 0:
            ans2 += 1 - b[i]
            b[i] = 1
        elif b[i - 1] > 0 and b[i] >= 0:
            ans2 += b[i] + 1
            b[i] = -1
    
    ans = min(ans1,ans2)
    print(ans)

if __name__=='__main__':
    main() 

Measured memory_bytes: 14828
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,x;
    cin  >> a >> b >> x;

    if(a<=x&&(a+b)>=x){
        cout << "YES";
    }
    else{
        cout << "NO";
    }


    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int max_a = -1;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    max_a = max(max_a, a[i]);
  }
  vector<bool> ok(n * max_a + 1, false);
  for (int b = 0; b < (1 << n); ++b) {
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      if ((b >> i) & 1) {
        sum += a[i];
      }
    }
    ok[sum] = true;
  }
  int q;
  cin >> q;
  while (q--) {
    int m;
    cin >> m;
    cout << (ok[m] ? "yes" : "no") << endl;
  }
  return 0;
}


Measured memory_bytes: 3084
#include<stdio.h>

int main(void)
{
        int d;

        scanf("%d", &d);

        if((d<22)&&(d>25)) return 1;

        if(d==25) printf("Christmas\n");
        else if(d==24) printf("Christmas Eve\n");
        else if(d==23) printf("Christmas Eve Eve\n");
        else if(d==22) printf("Christmas Eve Eve Eve\n");

        return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

vector<ll> mkprimes(ll N) {
    vector<bool> isprime(N + 1);
    vector<ll> primes;
    for (ll i = 0; i <= N; i++) {
        isprime[i] = true;
    }
    isprime[0] = false;
    isprime[1] = false;

    for (ll i = 2; i <= N; i++) {
        if (isprime[i]) {
            primes.push_back(i);
            for (ll j = 2 * i; j <= N; j += i) {  // 素数iの倍数は素数ではない
                isprime[j] = false;
            }
        }
    }
    return primes;
}

void primefact(ll n, vector<ll> &primes, vector<vector<ll>> &cache) {
    if (n<=1){
      return;
    }
    if (cache[n].size() > 0) {
       return;
    }
    for (ll p = 0; p < primes.size(); p++) {
        ll pr = primes[p];
        if (n % pr == 0) { 
            cache[n].push_back(pr);
            primefact(n/pr,primes,cache);
            for (auto pp: cache[n/pr]){
              if(pp!=pr){
                cache[n].push_back(pp);
              }
            }
			return;
		}
    }
}

                

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll pmax = 1000002;
    auto primes = mkprimes(pmax);
    vector<vector<ll>> cache(pmax+1);
    for (auto ppr: primes) {
      cache[ppr].push_back(ppr);
    }
    vector<vector<ll>> factors(N);
    vector<ll> usedprimes(pmax+1, 0);
    for (ll i = 0; i < N; i++) {
        primefact(A[i], primes,  cache);
        for (ll pf : cache[A[i]]) {
           usedprimes[pf]++;
        }
    }
    ll maxused = 0;
    for (auto u : usedprimes) {
        maxused = max(u, maxused);
    }
    if (maxused == N) {
        print("not coprime");
    } else if (maxused >= 2) {
        print("setwise coprime");
    } else {
        print("pairwise coprime");
    }
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

signed main(){

	lli n;
	cin>>n;
	map<lli,lli> cnt;

	REP(i,0,n){
		lli a;
		cin>>a;
		if((a+1)%2 != n%2){
			cout<<0<<endl;
			return 0;
		}
		cnt[a]++;
	}

	lli ans=1;
	for(auto e:cnt){
		if(e.first==0){
			if(e.second!=1){
				cout<<0<<endl;
				return 0;
			}
			continue;
		}
		else{
			if(e.second!=2){
				cout<<0<<endl;
				return 0;
			}
		}
		if(e.first>=n){
			cout<<0<<endl;
			return 0;
		}
		ans*=2;
		ans%=MOD;
	}
	cout<<ans%MOD<<endl;

	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;

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

	if (A < 9 && B < 9)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;

	return 0;
}

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

string sortString(string s)
{
  // 文字列s をソートして返す

  int len = s.size();

  vector<char> v(len);
  for (int i = 0; i < len; ++i)
  {
    v[i] = s[i];
  }
  sort(v.begin(), v.end());

  string ret = "";
  for (int i = 0; i < len; ++i)
  {
    ret += v[i];
  }

  return ret;
}

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

  map<string, long long> count;
    // 答えは 32bit 整数型(int)に収まらない
    // 可能性があるので, long long を使う

  for (int i = 0; i < N; ++i)
  {
    string s; cin >> s;
    s = sortString(s);
    count[s] += 1;
  }

  long long ans = 0;

  for (auto it = count.begin(); it != count.end(); it++)
  {
    long long n = it->second;
    ans += n * (n - 1) / 2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 12800
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[500][500];

int main(){
  cin >> n;
  ll ans = 1;
  lep(i,1,n){
    ans *= i;
    ans %= INF;
  }
  print(ans);
  return 0;
}

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

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  long long ret = 0;
  int last_w = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'W') {
      ret += i - last_w;
      ++last_w;
    }
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 640
import math
def calc(x_i,x_j,y_i,y_j):
    tmp = ((x_i)-(x_j))**2
    tmp += ((y_i)-(y_j))**2
    return math.sqrt(tmp)
N = int(input())
array = []
for _ in range(N):
    array.append(list(map(int, input().split())))
sum = 0
check = []
kai = 1
for i in range(1,N+1):
    kai *= i
    if i == N - 1:
        tmp = kai
for i in range(N):
    for k in range(N):
        if k == i:
            continue
        sum += calc(array[i][0],array[k][0],array[i][1],array[k][1])
sum *= tmp
print(sum/kai)

Measured memory_bytes: 3064
#168 C
import math

p = [int(s) for s in list(input().split())]
A = p[0]
B = p[1]
H = p[2]
M = p[3]

theta = math.fabs(H + M / 60 - M * 12 / 60) * 2 * math.pi / 12
theta2 = 2 * math.pi - theta

theta = min(theta,theta2)

#print(theta * 360 / math.pi / 2)
print(math.sqrt(A * A + B * B - 2 * A * B * math.cos(theta)))

#168 B
#K = int(input())
#S = input()

#if len(S) <= K:
#	print(S)
#else:
#	print(S[:K] + '...')


#168 A
#n_last = int(list(input())[-1])

#if n_last in [3]:
#	print('bon')
#elif n_last in [0,1,6,8] :
#	print('pon')
#else:
#	print('hon')



Measured memory_bytes: 9444
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define RALL(x) (x).rbegin(), (x).rend()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define debug(x) std::cerr<<#x<<": "<<(x)<<endl;
using namespace std;
using lint = long long;
template<class T> using grid = vector<vector<T>>;
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; }
static const lint MOD = (lint)1e9+7;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep (i, N) { cin >> A[i]; A[i]--;}

    vector<int> ans(N);
    for (int i = 0; i < N; ++i)
    {
        ans[A[i]] = i+1;
    }

    for (int i = 0; i < N; ++i)
    {
        cout << ans[i] << " ";
    }


    return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
int main() {
	int N;
	int A[200020], B[200020];
	cin >> N;
	pair<int, int> ab[200020];
	for (int i = 1; i <= N; i++) {
		cin >> A[i] >> B[i];
		ab[i] = make_pair(B[i], A[i]);
	}

	sort(ab + 1, ab + N + 1);

	int jikan = 0;
	for (int i = 1; i <= N; i++) {
		jikan += ab[i].second;
		if (jikan <= ab[i].first);
		else { cout << "No"; return 0; }
	}
	cout << "Yes";
}

Measured memory_bytes: 3328
s = [x for x in input()]
t = [x for x in input()]
s_num = len(s);t_num = len(t)
ans = [x for x in 'z'*51]
chinpo = [x for x in 'z'*51]
for i in range(s_num-t_num+1):
    anco = list(s)
    for j in range(t_num):
        check = 0
        if s[i+j] == '?' or s[i+j] == t[j]:
            pass
        else:
            check = 1
            break
    if check == 0:
        for k in range(0,i):
            if anco[k] == '?':anco[k] = 'a'
        c = 0
        for k in range(i,i+t_num):
            anco[k] = t[c]
            c += 1
        for k in range(i+t_num,s_num):
            if anco[k] == '?':anco[k] = 'a'
        ans = min(ans,anco)
if ans == chinpo:print('UNRESTORABLE')
else:print(''.join(ans))

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

int main(){
    string s,t;
    cin >> s ;
    int num = s.size();
    //string t[num];
    //cout << num << endl;
    rep(i,num){
        s[i] = 'x';
    }
    cout << s << endl;
    
    

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
  int i, j, H, W;
  while( 1 ) {
    scanf("%d %d", &H, &W);
    if(H == 0 && W == 0) break;
    for(i = 1; i <= H; i++) {
      for(j = 1; j <= W; j++) {
        if((i + j) % 2 == 0) printf("#");
        else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(){
	int n, m, d, p, ans;

	while( cin >> n >> m , n || m ){
		ans = 0;
		map<int,int> f;
		for(int i=0 ; i <= 10 ; i++ ){
			f[i] += 0;
		}
		
		for(int i=0 ; i<n ; i++ ){
			cin >> d >> p;
			f[p] += d;
		}
		for(int i=10 ; i >= 0 ; i-- ){
			for( ; f[i] && m ; ){
				m--;
				f[i] -= 1;
			}
			ans += f[i] * i;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 912
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    char data[110];
    for(int i=0; i<n; i++){
        cin >> data[i];
    }
    bool flag = true;
    for(int i=0; i<n; i++){
        if(data[i]=='Y'){
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import math
N = int(input())
lst = list(map(int,input().split()))
x = lst[0]
y = sum(lst[1:])
ans = abs(y - x)
for i in range(1,N-1):
    x+=lst[i]
    y-=lst[i]
    ans = min(ans,abs(x-y))
print(ans)

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

int main()
{
    string s;
    string le, ri;
    int n = 0;
    int l = 0, r = 0;
    cin >> n >> s;
    string kari = s;
    for (int i = 0; i < n; i++) if (s[i] == ')') l++;
    for (int i = 0; i < n; i++) if (s[i] == '(') r++;

    for (int i = 0; i < n; i++) {
        if (kari[i] == '(') {
            for (int j = i + 1; j < n; j++) {
                if (kari[j] == ')') {
                    r--;                  	
                    l--;
                    kari[j] = '*';
                    break;
                }
            }
        }
    }


    for (int i = 0; i < l; i++) ri += '(';
    for (int i = 0; i < r; i++) le += ')';

    cout << ri << s << le << endl;

    return 0;
}


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

int main()
{
    int i, temp, face[6];
    for(i=0; i<6; i++) {
        scanf("%d", &face[i]);
    }
    char d;
    while(scanf("%c", &d)!=EOF) {
        switch(d) {
        case 'N':
            temp=face[0];
            face[0]=face[1];
            face[1]=face[5];
            face[5]=face[4];
            face[4]=temp;
            break;
        case 'E':
            temp=face[0];
            face[0]=face[3];
            face[3]=face[5];
            face[5]=face[2];
            face[2]=temp;
            break;
        case 'W':
            temp=face[0];
            face[0]=face[2];
            face[2]=face[5];
            face[5]=face[3];
            face[3]=temp;
            break;
        case 'S':
            temp=face[0];
            face[0]=face[4];
            face[4]=face[5];
            face[5]=face[1];
            face[1]=temp;
            break;
        }
    }
    printf("%d\n", face[0]);
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N; string S; int Q;
    cin >> N >> S >> Q;

    while(Q--) {
        int k; cin >> k;
        long long d = 0, m = 0, dm = 0, res = 0;
        for(int i=0; i<N; ++i) {
            if(i - k >= 0) {
                if(S[i - k] == 'D') d -= 1, dm -= m;
                if(S[i - k] == 'M') m -= 1;
            }
            if(S[i] == 'D') d += 1;
            if(S[i] == 'M') dm += d, m += 1;
            if(S[i] == 'C') res += dm; 
        }
        cout << res << '\n';
    }
}

Measured memory_bytes: 1948
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <climits>
#include <set>

//#define int long long
//typedef long long ll;
using ll = long long;
//using R = double;

//#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

#define MOD 1000000007

const int INF = int(1e9);

using namespace std;

typedef vector<int> V;
typedef vector<V> VV;

signed main()
{
    int N;

    cin >> N;
    cout << 800 * N - N / 15 * 200 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define fish        push_front
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Deque       std::deque
#define PQueue      std::priority_queue
#define Set         std::set
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B, class C> A power ( A x, B n, C mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A> A lcm ( A x, A y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A> inline boolean chmax ( A &a, const A &b ) { return b > a ? a = b, true : false; }
    template<class A> inline boolean chmin ( A &a, const A &b ) { return b < a ? a = b, true : false; }
    inline boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        char c;
        read c;
        if ( c == 'A' ) echo "T" fin;
        if ( c == 'T' ) echo "A" fin;
        if ( c == 'G' ) echo "C" fin;
        if ( c == 'C' ) echo "G" fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cctype>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <sstream>
#include <deque>

#define REP(i, n) for ( int i = 0; i < n; i++ )

using namespace std;

int main() {
    int n;

    while(cin >> n, n) {
        vector<int> judge(n);
        int sum = 0;

        REP(i, n) {
            cin >> judge[i];
        }
        sort(judge.begin(), judge.end());

        REP(i, n-2) {
            // cout << judge[i+1] << endl;
            sum += judge[i+1];
        }
        cout << (sum/(n-2)) << endl;

    }

    return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
 
#define N 100
 
void trace(int[], int);
 
int main() {
   
  int i, j, tmp, length;
  int A[N + 1];
  scanf("%d", &length);
 
  for(i = 0; i < length; i++) {
    scanf("%d", &A[i]);
  }
    trace(A, length);
    for(j = 1; j < length; j++) {
      tmp = A[j];
      i = j - 1;
      while((i >= 0) && (A[i] > tmp)) {
    A[i + 1] = A[i];
    i--;
      }
      A[i + 1] = tmp;
       
      trace(A, length);
    }
     
    return 0;
  }
 
  void trace(int A[], int length) {
    int i;
    for(i = 0; i < length; i++){
      if(i > 0) {
    printf(" ");
      }
      printf("%d", A[i]);
    }
    printf("\n");
  }

Measured memory_bytes: 1812
#ifndef _STD
#define _STD
#include<bits/stdc++.h>
#endif


#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define clean(used) memset(used,false,sizeof(used))

using namespace std;

static const double EPS = 1e-10;
static const int INF = (const int) (1e18 + 9);
static const int Mod = (const int) (1e9 + 7);
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<pair<int,pii>> ipii;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,a,b;
    cin >> x >> a >> b;
    a = abs(x - a);
    b = abs(x - b);
    if(a < b){
        cout << "A" << endl;
    }else{
        cout << "B" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
from itertools import combinations_with_replacement
 
N, M, Q = map(int, input().split())
A = []
for i in range(Q):
    A.append(list(map(int, input().split())))
 
retsu = combinations_with_replacement(range(M), N)
result = 0
 
for i in retsu:
    score = 0
    for a in A:
        if i[a[1] - 1] - i[a[0] - 1] == a[2]:
            score += a[3]
    if result < score:
        result = score
 
print(result)

Measured memory_bytes: 9204