akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  // 1―iの人を右を向かせた場合の人数
  vector<int> right(N, 0);
  // i-Nの人を左を向かせた場合の人数
  vector<int> left(N, 0);
  
  if(S[0] == 'W') right[0] = 1;
  for(int i = 1; i < N; i++){
    if(S[i]=='W'){
      right[i] = right[i-1] + 1;
    } else {
      right[i] = right[i-1];
    }
  }
  
  if(S[N-1] == 'E') left[N-1] = 1;

  for(int i = N-2; i >=0; i--){
    if(S[i]=='E'){
      left[i] = left[i+1] + 1;
    } else {
      left[i] = left[i+1];
    }
  }
  
  cerr << right[N-1] << endl;
  cerr << left[0] << endl;
  
  int tmpans = N;
  for(int i = 0; i < N; i++){
    int tmp;
    if(i==0){
      tmp = left[i+1];
    } else if(i==N-1){
      tmp = right[N-2];
    } else { 
      tmp = right[i-1] + left[i+1];
    }
    if(tmp < tmpans){
      tmpans = tmp;
    }
  }
  cout << tmpans << endl;
}

Measured memory_bytes: 3076
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
void func(int,int);
int j,y,a[10];
int main(void)
{
	scanf("%d %d",&j,&y);
	func(0,0);
	return 0;
}
void func(int jj,int yy)
{
	int i;
	char s[3]="AB";
	if(jj==j && yy==y)	{
		for(i=0;i<j+y;i++)	printf("%c",s[a[i]]);
		printf("\n");
	}
	else if(!((jj==5 && yy<4) || (yy==5 && jj<4) || jj+yy==10))	{
		a[jj+yy]=0;
		func(jj+1,yy);
		a[jj+yy]=1;
		func(jj,yy+1);
	}
}


Measured memory_bytes: 2628
#include <stdio.h>
#include <string.h>
#include <limits.h>
#define MIN(a,b) ((a<b)?a:b)
#define ABS(a) ((a>0)?a:(-a))

int main(void) {
  char S[11];
  scanf("%s", S);
  int len = strlen(S);
  int min = INT_MAX;
  for(int i = 0; i <= len-3; i++) {
    int x = (S[i]-'0') * 100 + (S[i+1]-'0') * 10 + (S[i+2]-'0');
    min = MIN(min, ABS((753 - x)));
  }
  printf("%d\n", min);
  return 0;
}


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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
  if (a < b) {
    swap(a, b);
  }

  /* ユークリッドの互除法 */
  ll r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

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

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
  if (p == 0) {
    return 1;
  }
  if (p % 2 == 0) {
    int64_t t = __pow_mod(n, p / 2, mod);
    return (t * t) % mod;
  }
  return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
  int64_t res = __pow_mod(n, p, mod);
  if (res == 0) {
    res = mod;
  }
  return res;
}

void solve(long long H) {
    ll ans=0;
    ll p=1;
    while(H>0){
        H/=2;
        ans+=p;
        p*=2;
    }
    cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long H;
  std::cin >> H;
  solve(H);
  return 0;
}


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

using namespace std;
typedef complex<double> C;
typedef vector<C> VC;
typedef vector<VC> VVC;

void fft(VC &f, int n, int dir) {
	if (n == 1) return;
	VC f0, f1;
	for(int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			f0.push_back(f[i]);
		} else {
			f1.push_back(f[i]);
		}
	}
	fft(f0, n / 2, dir);
	fft(f1, n / 2, dir);
	C zeta = polar(1.0, 2 * M_PI * dir / n);
	C now = C(1.0);
	for(int i = 0; i < n; i++) {
		f[i] = f0[i % (n / 2)] + now * f1[i % (n / 2)];
		now *= zeta;
	}
}

inline int getMinimumPowerOf2(int size) {
	int n = 1;
	while(n < size) n <<= 1;
	return n;
}

void fft2d(VVC &A, int dir = 1) {
	for(int i = 0; i < A.size(); i++) {
		VC f;
		for(int j = 0; j < A[i].size(); j++) {
			f.push_back(A[i][j]);
		}
		fft(f, f.size(), dir);
		for (int j = 0; j < f.size(); j++) {
			A[i][j] = f[j];
		}
	}
	for(int j = 0; j < A[0].size(); j++) {
		VC f;
		for(int i = 0; i < A.size(); i++) {
			f.push_back(A[i][j]);
		}
		fft(f, f.size(), dir);
		for (int i = 0; i < f.size(); i++) {
			A[i][j] = f[i];
		}
	}
}

VVC comb2d(VVC A, VVC B) {
	int n = getMinimumPowerOf2(A.size() + B.size()), m = getMinimumPowerOf2(A[0].size() + B[0].size());
	A.resize(n);
	B.resize(n);
	for (int i = 0; i < A.size(); i++) {
		A[i].resize(m);
	}
	for (int i = 0; i < B.size(); i++) {
		B[i].resize(m);
	}
	fft2d(A);
	fft2d(B);
	VVC ret(n, VC(m, 0));
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			ret[i][j] = A[i][j] * B[i][j];
		}
	}
	fft2d(ret, -1);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			ret[i][j] /= n * m;
		}
	}
	return ret;
}


constexpr char chars[] = {'#', '.'};
constexpr int num_chars = sizeof(chars);

int main() {
	int N, M;
	cin >> N >> M;
	vector<string> A(N), B(M);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	int n = getMinimumPowerOf2(N + M);
	VVC score(n, VC(n, C(0)));
	for (int c = 0; c < num_chars; c++) {
		VVC cA, cB;
		for (int i = 0; i < N; i++) {
			cA.push_back(VC());
			for (int j = 0; j < N; j++) {
				cA[i].push_back(C(A[i][j] == chars[c]));
			}
		}
		for (int i = 0; i < M; i++) {
			cB.push_back(VC());
			for (int j = 0; j < M; j++) {
				cB[i].push_back(C(B[i][j] == chars[c]));
			}
		}
		VVC ret = comb2d(cA, cB);
		for (int i = 0; i < score.size(); i++) {
			for (int j = 0; j < score[0].size(); j++) {
				score[i][j] += ret[i][j];
			}
		}
	}
	bool flag = false;
	for (int i = 0; i < score.size(); i++) {
		for (int j = 0; j < score[0].size(); j++) {
			if ((int)(real(score[i][j]) + 0.1) == M * M) {
				flag = true;
				break;
			}
		}
		if (flag) break;
	}

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

	return 0;
}





Measured memory_bytes: 1416
#include <stdio.h>

int main()
{
  int A[100],i,j,N,a=0,n=0,flag=1;
  
  scanf("%d",&N);
  
  for(i=0; i<N; i++){
  scanf("%d",&A[i]);
  }

  while(flag)
    {
      flag = 0;
      
      for(j = N-1;j>=1; j--){
	if(A[j] < A[j-1]){
	  a = A[j];
	  A[j] = A[j-1];
	  A[j-1] = a;
	  n++;
	  flag = 1;
	}
      }
    }
  for(i=0; i<N; i++){
  printf("%d",A[i]);
  if(i!=N-1)printf(" ");
  }
  printf("\n");
   printf("%d\n",n);

   return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
typedef pair <long long,long long> ii;
priority_queue <ii,vector <ii>,greater<ii> > mq;
long long a[100005],b[100005],c[100005],p[100005],q[100005];
long long n,m;
long long dem=0;
long long tong=0;
int main(){
    cin>>n>>m;
    for(long long i=1;i<=m;i++){
        cin>>p[i];
    }
    for(long long i=1;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    for(long long i=2;i<m;i++){
        if(p[i]>p[i-1]) mq.push(make_pair(p[i]-1,2));
        else mq.push(make_pair(p[i],0));
        if(p[i]<p[i+1]) mq.push(make_pair(p[i],0));
        else mq.push(make_pair(p[i]-1,2));
    }
    if(p[1]<p[2]) mq.push(make_pair(p[1],0));
    else mq.push(make_pair(p[1]-1,2));
    if(p[m]>p[m-1]) mq.push(make_pair(p[m]-1,2));
    else mq.push(make_pair(p[m],0));
    for(long long i=1;i<n;i++){
        mq.push(make_pair(i,1));
    }
    while(mq.size()){
        ii zz=mq.top();
        mq.pop();
        if(zz.second==1) q[zz.first]=dem;
        if(zz.second==0) dem++;
        if(zz.second==2) dem--;
    }
    for(long long i=1;i<n;i++){
        if(q[i]*b[i]+c[i]>q[i]*a[i]) tong+=q[i]*a[i];
        else tong+=q[i]*b[i]+c[i];
    }
    cout<<tong<<endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

void dfs(int n, int k, string s) // 現在k種類の文字を使った
{
    if (n == 0) {
        cout << s << endl;
        return;
    }

    for (int i = 0; i < k + 1; i++) {
        if (i == k) {
            dfs(n - 1, k + 1, s + (char)('a' + i));
        } else {
            dfs(n - 1, k, s + (char)('a' + i));
        }
    }
}

int main()
{
    int n;
    cin >> n;
    string s = "";
    dfs(n, 0, s);
    return 0;
}

Measured memory_bytes: 3600
# coding: utf-8
# Your code here!


def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return A, cnt
        
def shellSort(A, n):
    cnt = 0
    m = n // 3 + 1
    G = [1]
    for i in range(m-1):
        if G[0] * 3 + 1 < n:
            G.insert(0, G[0] * 3 + 1)
    m = len(G)
    print(m)
    if m > 1:
        for i in range(m-1):
            print(str(G[i]), end = " ")
    print(str(G[m-1]))
        
    for i in range(m):
        A, cnt = insertionSort(A, n, G[i], cnt)


    print(cnt)
    for i in range(n):
        print(A[i])
    
    
#A = [1, 6, 5, 4, 3, 2]
#n = len(A)

n = int(input())
A = []
#cnt = 0
for i in range(n):
    A.append(int(input()))

shellSort(A, n)








Measured memory_bytes: 45524
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

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

bool dp[1000100];

signed main(){
	int n,m;
	while(1){
		cin>>n>>m;
		if(n+m==0) break;
		vi a(n);
		rep(i,0,n) cin>>a[i];
		//memset(dp,false,sizeof(dp));
		rep(j,0,m+1) dp[j]=false;
		dp[0]=true;
		rep(i,0,n){
			rep(j,0,m+1){
				if(dp[j] && j+a[i]<=m){
					dp[j+a[i]]=true;
				}
			}
		}
		int ans=-1;
		for(int i=m;i>=0;i--){
			//if(dp[i]) o(i);
			if(dp[i] && is_prime(i)){
				ans=i;
				break;
			}
		}
		if(ans==-1) o("NA");
		else o(ans);
	}
}

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

using namespace std;

int nowS = 0;//??????-1
int x, y, n;
int mp[1000][1000] = {};//????????¨??????
int k[4] = {1, -1, 0, 0};
int h[4] = {0, 0, 1, -1};
int cx[9] = {};
int cy[9] = {};
vector<int> bufX, bufY, bufD;

bool search(int xx, int yy, int dd) {//???????????????????????\????????????

	bufX.erase(bufX.begin());//??????????¶????
	bufY.erase(bufY.begin());
	bufD.erase(bufD.begin());
	
	if (mp[yy][xx] == nowS + 1)
		return false;

	mp[yy][xx] = nowS + 1;//?????£??????????????????????????°
	for (int i = 0; i < 4; i++) {
		if (xx + k[i] < 0 || xx + k[i] >= x || yy + h[i] < 0 || yy + h[i] >= y)//?????????
			continue;
		if (mp[yy + h[i]][xx + k[i]] == -1) {//?£?
			continue;
		}
		if (cx[nowS] == xx + k[i] && cy[nowS] == yy + h[i]) {//??????
			nowS++;
			bufX.clear();//????????????
			bufY.clear();
			bufD.clear();
			if (nowS == n) {//?????????????????????
				cout << dd + 1 << endl;
				return true;
			}
			else {//??????
				bufX.push_back(xx + k[i]);
				bufY.push_back(yy + h[i]);
				bufD.push_back(dd + 1);
			}
			return false;
		}
		if(mp[yy + h[i]][xx + k[i]] >= 0 && mp[yy + h[i]][xx + k[i]] < nowS + 1){//??????
			bufX.push_back(xx + k[i]);
			bufY.push_back(yy + h[i]);
			bufD.push_back(dd + 1);
		}
	}
	return false;
}

int main() {
	int ch = 0;
	cin >> y >> x >> n;
	for (int i = 0; i < y; i++) {//??\???
		char c[1001];
		cin >> c;
		for (int j = 0; j < x; j++) {
			if(c[j] == 'X')
				mp[i][j] = -1;
			else if(c[j] == 'S'){
				bufX.push_back(j);
				bufY.push_back(i);
				bufD.push_back(0);
				mp[i][j] = 0;
			}	
			else {
				mp[i][j] = 0;
			}
			if (c[j] >= 48 && c[j] <= 57) {
				int m;
				m = c[j] - 49;
				cx[m] = j;
				cy[m] = i;		
				ch++;
			}
		}
	}
	

	while(!search(bufX[0], bufY[0], bufD[0])){}//??????????????§?????????

	return 0;
}

Measured memory_bytes: 6984
ls = [int(i) for i in input().split()]
ls.sort()
ans = ls[2] - ls[1] + (ls[1] - ls[0] )// 2
if ((ls[2] - ls[1]) - (ls[2] - ls[0])) % 2 == 0:
  print(ans)
else:
  print(ans+2)

Measured memory_bytes: 61880
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int age = sc.nextInt();
        int fee = sc.nextInt();
        int result = 0;
        if (age <= 5) {
            result = 0;
        } else if (age <= 12) {
            result = fee / 2;
        } else {
            result = fee;
        }
        System.out.println(result);
    }
}

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

int main(){

    int h, w;
    cin >> h >> w;

    vector<vector <char>> pict(h, vector<char>(w));
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            cin >> pict.at(i).at(j);
        }
    }

    for (int i=0; i<w+2; i++) cout << "#";
    cout << endl;

    for (int i=0; i<h; i++){
        cout << "#";
        for (int j=0; j<w; j++){
            cout << pict.at(i).at(j);
        }
        cout << "#" << endl;
    }
    
    for (int i=0; i<w+2; i++) cout << "#";
    cout << endl;

    return 0;
}

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

int main(){
	ll n;
	cin>>n;
	string a;cin>>a;
	ll dp[n][n+1];
	dp[0][0]=0;
	for(ll i=1;i<=n;i++)dp[0][i]=1;
	for(ll j=0;j<n-1;j++){
		dp[j+1][0]=0;
		if(a[j]=='<'){
			ll k=1;
			for( k;k<=j+2;k++){
				dp[j+1][k]=(dp[j+1][k-1]+dp[j][k-1])%z;
			}
			for(;k <=n;k++){
				dp[j+1][k]=dp[j+1][k-1];
			}
		}
		else{
	
			ll k=1;
			for( k;k<=j+2;k++){
				dp[j+1][k]=((dp[j+1][k-1])+(dp[j][n]-dp[j][k-1])+z)%z;
			}
			for(;k <=n;k++){
				dp[j+1][k]=dp[j+1][k-1];
			}
			
		}
	}
	cout<<dp[n-1][n]<<endl;
	
}

Measured memory_bytes: 70656
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
//    vector<vector<ll>> g(n);
    vector<set<ll>> g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
//        g[a].push_back(b);
//        g[b].push_back(a);
        g[a].insert(b);
        g[b].insert(a);
    }
    vector<bool> flg(n, false);
    int ans = 0;
    rep(i, n) {
        if ( flg[i] ) continue;
        bool ok = true;
        for ( auto u : g[i] ) {
            if ( h[i] <= h[u] ) ok = false;
        }
        if ( ok )  {
            ++ans;
            for ( auto u : g[i] ) {
                flg[u] = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "ARC" << '\n';
    }else if (s == "ARC") {
        cout << "ABC" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b,c,k;
  cin>>a>>b>>c>>k;
  int cnt=0;
  if(k>a)
    cnt+=a;
  else{
   cout<<k;
    return 0;
  }
  if(k-a>b)
    cnt+=b*0;
  else{ cout<<cnt;
      return 0;
      }
  cout<<cnt+(k-a-b)*(-1);
    
  
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main() 
{
  ll n;
  ll ans = 0;
  cin >> n;
  vector<string> s(n);
  map<string, ll> m;
  rep(i,n){
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
    m[s[i]] += 1;
  }

  rep(i,n){
    if(m[s[i]] >=2){
      ans += m[s[i]] * (m[s[i]] - 1) / 2;
      m[s[i]] = 1;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 18176
// imitate chokudai scanner
type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI32()]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextI64()]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF32()]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [for _ in 0 .. n - 1 -> this.NextF64()]
end

[<EntryPoint>]
let main _ =
    let rec listsum list a : int =
        match list with
            | [x] -> a + x
            | x :: xs :: xss -> min x xs |> (+) a |> listsum (xs::xss)
            | _ -> a
    let scanner = Scanner()
    let n = scanner.NextI32()
    let b = n - 1 |> scanner.ArrayI32
    listsum b b.[0] |> printfn "%i"
    0


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

int main(){
    string s;
    cin >> s;
    int size = s.size();
    size -= size%2==0 ? 2 : 1;
    while(1){
        bool flag = true;
        for(int i=0;i<size/2;i++){
            if(s[i] != s[i+size/2]){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << size << endl;
            break;
        }
        size -= 2;
    }
    return 0;
}

Measured memory_bytes: 256
f = lambda : map(int,input().split())
n, q = f()
s = input()

cnt = 0
ln = [0]*n
for i in range(1,n):
  if s[i-1:i+1] == 'AC':
    cnt += 1
  ln[i] = cnt
for _ in range(q):
  l, r = f()
  print(ln[r-1]-ln[l-1])

Measured memory_bytes: 6164
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

const int MAXN = 1e5+10;
int n;
ll A[MAXN];

void solve() {
  ll ans = 1;
  sort(A, A+n);
  for (int i=0;i<n;i++) {
    if (ans == 0) {
      cout << 0 << endl;
      return;
    }
    if (1000000000000000000 / ans < A[i]) {
      cout << -1 << endl;
      return;
    }
    ans *= A[i];
    if (ans > 1000000000000000000) {
      cout << -1 << endl;
      return;
    }
  }
  cout << ans << endl;
}

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


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

 

int main()
{
    int i, j ,k, n;
    int b, f, r, v;
    int room[4][3][10];

    for(i=0; i<4; i++)
        for(j=0; j<3; j++)
            for(k=0; k<10; k++)
                room[i][j][k] = 0;

    cin >> n;
    for(i=0; i<n; i++)
    {
        cin >> b >> f >> r >> v;
        room[b-1][f-1][r-1] += v;
    }

    for(i=0; i<4; i++)
    {
        for(j=0; j<3; j++)
        {
            for(k=0; k<10; k++)
            {
                cout << " " << room[i][j][k];
            }
            cout << endl;
        }
        if(i<3)
            cout << "####################" << endl;
    }
}


Measured memory_bytes: 3084
#coding: UTF-8
import math

def MMS(n,a):
    min = max = int(a[0])
    sum = int(a[0])
    for i in range(1,n):
        if min > int(a[i]):
            min = int(a[i])
        if max < int(a[i]):
            max = int(a[i])
        sum += int(a[i])
    print(min,max,sum)
    
if __name__=="__main__":
    n = int(input())
    a = input().split(" ")
    MMS(n,a)    

Measured memory_bytes: 8532
#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() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    bool ok = false;
    rep(i,N) if (a[i] % 2 == 1) {
        ok = true;
        break;
    }
    if (ok) cout << "first" << endl;
    else cout << "second" << endl;
}

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

int main() {
  int n; 
  cin >> n ;
  int max = 0, sum = 0;
  
  
  for (int i = 0 ; i<n ; i++){
    int a ; 
    cin >> a ;
    sum += a;
    
    if ( a >= max) 
      max = a ;
  }
  
  if ( (sum - max*2) > 0)
    cout << "Yes" << endl ; 
  else 
    cout << "No" << endl ; 

  
}




Measured memory_bytes: 256
import java.io.*
import java.util.*

fun solve(N: Int, a: IntArray, b: IntArray, c: IntArray, d: IntArray) {
    val ab = (0 until N).map{ a[it] to b[it] }.sortedByDescending{ it.first }
    var cd = (0 until N).map{ c[it] to d[it] }.sortedBy{ it.second }
    var ans = 0
    for (i in 0 until N){
        for(j in 0 until cd.size){
            if (ab[i].first < cd[j].first && ab[i].second < cd[j].second){
                ans++
                cd -= cd[j]
                break
            }
        }
    }
    println(ans)
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val a = IntArray(N)
    val b = IntArray(N)
    for (i in 0 until N) {
        a[i] = sc.next().toInt()
        b[i] = sc.next().toInt()
    }
    val c = IntArray(N)
    val d = IntArray(N)
    for (i in 0 until N) {
        c[i] = sc.next().toInt()
        d[i] = sc.next().toInt()
    }
    solve(N, a, b, c, d)
}


Measured memory_bytes: 34044
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n;
	cin >> n;
	int max_ = -1000, min_ = 1000;
	veci a(n);
	rep(i, n)
	{
		cin >> a[i];
		min_ = min(min_, a[i]);
		max_ = max(max_, a[i]);
	}
	int ans = INT_MAX;
	for (int i = min_; i <= max_; i++)
	{
		int tmp = 0;
		rep(j, n)
		{
			tmp += pow(a[j] - i, 2);
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

#define int long long
#define trace(x) cerr << #x << ": " << x << " " << endl;


inline int add(int a, int b){a += b; if(a >= MOD)a -= MOD; return a;}
inline int sub(int a, int b){a -= b; if(a < 0)a += MOD; return a;}
inline int mul(int a, int b){return (int)((int) a * b %MOD);}


#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int dp[50][50][50][50];
int vis[50];
vector<int> G[50];
int admat[50][50];

int mult1[50][50];
int mult2[50][50];
int multr[50][50];

vector<vector<int> > mmul(int n, vector<vector<int> >& mult1, vector<vector<int> > &mult2)
{
    vector<vector<int> > multr(n , vector<int>(n,0));
    REP(i,n)
    {
        REP(j,n)
        {
            int ls = 0;
            REP(a,n)
            {
                ls = add(ls, mul(mult1[i][a], mult2[a][j]));
            }
            multr[i][j] = ls;
        }
    }
    return multr;
}

vector<vector<int> > binpow(int k, vector<vector<int> > &tb, int n)
{
    if(k==1)    return tb;
    if(k&1)
    {
        auto res = binpow(k-1, tb, n);
        return mmul(n, res, tb);
    }
    auto res = binpow(k/2, tb, n);
    return mmul(n, res, res);
}

signed main()
{
    IOS
    int n, k;
    cin >> n >> k;
    vector<vector<int> > admat(n , vector<int>(n,0));

    REP(i,n)
    REP(j,n)
    
    {
        cin >> admat[i][j];
    }
    auto res = binpow(k, admat, n);
    int lc = 0;
    REP(i, n)
        REP(j,n)
            lc = add(lc, res[i][j]);
    cout << lc;
    
}

Measured memory_bytes: 384
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

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

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

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

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

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

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

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

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let n: usize;
    input!(n);
    let s = input_line_str();
    if n >= 3200 {
        p(s);
    } else {
        p("red");
    }
}

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

char nyuryoku[100][100];
int h,w;

void fun(int y,int x,char masume){
	if((x<0)||(w<=x)||(y<0)||(h<=y))
		return;
	if(masume==nyuryoku[y][x])
		nyuryoku[y][x]='x';
	else
		return;
	fun(y+1,x,masume);
	fun(y-1,x,masume);
	fun(y,x+1,masume);
	fun(y,x-1,masume);
}

int main(){
	while(cin >> h >> w,h){
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >>nyuryoku[i][j];
			}
		}
		int count=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(nyuryoku[i][j]!='x'){
					fun(i,j,nyuryoku[i][j]);
					count++;
				}
			}
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);


signed main()
{
    cout<<fixed;
    int n;
    cin >> n;
    long double ans = INF;
    vector<pair<long double, long double>> v(n + 2);
    v[0].fi = .0;
    v[0].se = .0;
    rep(i, n) cin >> v[i + 1].fi >> v[i + 1].se;
    v[n + 1].fi = .0;
    v[n + 1].se = .0;

    sort(v.begin()+1,v.end()-1);

    do
    {
        long double cnt = abs(atan2(v[1].se, v[1].fi))* 180.0;
        //cout<<cnt<<endl;
        rep(i, n)
        {
            long double x1 = v[i].fi, y1 = v[i].se, x2 = v[i + 1].fi, y2 = v[i + 1].se, x3 = v[i + 2].fi, y3 = v[i + 2].se;
            long double a = pow(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)), 0.5);
            long double b = pow(((x3 - x2) * (x3 - x2)) + ((y3 - y2) * (y3 - y2)), 0.5);

            long double cos_sita = ((x2 - x1) * (x3 - x2) + (y2 - y1) * (y3 - y2)) / (a * b);
            long double sita = acos(cos_sita);
            //cout<<sita * 180 / M_PI<<endl;
            cnt += sita * 180.0;
            //cout << cnt/M_PI << endl;
        }
        ans = min(ans, cnt / M_PI);

    } while (next_permutation(v.begin() + 1, v.end() - 1));
    cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 3484
import java.util.Scanner;


public class Main {


//	final int MOD = 1000000007;

//	public static int min = 3000000;

	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

//		long k = sc.nextLong();
//		int n = sc.nextInt();
		long a = sc.nextLong();
		long v = sc.nextLong();
		long b = sc.nextLong();
		long w = sc.nextLong();
		long t = sc.nextLong();

		//-------------------------------------------------------------------------------------
		long tmp = Math.abs(a - b);
		for(long i = 0; i < t; i++) {
			tmp = Math.abs(tmp);

			tmp -= v;
			tmp += w;

//			tmp = Math.abs(tmp);
//			if(tmp + w != 0) {
//				tmp += w;
//			}
//			System.err.println(tmp);

			if(tmp <= 0) {
				f = true;
				break;
			}
		}

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

		if(f) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

//		System.out.println(ans);

		sc.close();
	}



}

Measured memory_bytes: 35716
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    ll n,a,b; cin >>n>>a>>b;
    vector<ll> x(n); rep(i,n) cin >> x[i];

    ll ans = 0;
    for (int i = 0; i < n-1; i++) {
        if ((x[i+1] - x[i])*a < b) {
            ans += (x[i+1] - x[i])*a;
        } else {
            ans += b;
        } 
    }
    
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.14159265
#define M 998244353 
#define inf 5e6
 
 int powerm(int x, unsigned int y, int p)  
{  
    int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 
int power(int x, unsigned int y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return power(x, y / 2) * power(x, y / 2); 
    else
        return x * power(x, y / 2) * power(x, y / 2); 
} 
 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
 
 int gcdExtended(int a, int b, int *x, int *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    int x1, y1; // To store results of recursive call 
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 
 
int modInverse(int a, int m) 
{ 
    int x, y; 
    int g = gcdExtended(a, m, &x, &y); 
    if (g != 1) 
        cout << "Inverse doesn't exist"; 
    else
    { 
        // m is added to handle negative x 
        int res = (x%m + m) % m; 
        
        return res;
        //cout << "Modular multiplicative inverse is " << res; 
    } 
}

int vis[200001];

int  dps[200001];
int  dpt[200001];

int par[200001];
int tin[200001];
int tout[200001];
int t=0;
//int a[200001];

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

void dfs(int i,int p,vector<int>adj[],int &c)
{
        vis[i]=1;
        
        for(int j=0; j<adj[i].size();j++)
        {
                if(adj[i][j]==p)continue;
                int v=adj[i][j];
                
                if(vis[v]==1&&v!=p)
                {
                        c=1;
                }
                
                if(vis[v]==0)
                dfs(v,i,adj,c);
        }
}


struct setcmp {
bool operator() (int x, int  y) 
{
       
         
   return x<y;
         
 

}
};


const int maxn=5000001;

int isPrime[maxn];



void solve()
{

 string s,t;
 cin>>s>>t;
 
 int c=0;
 
 for(int i=0; i<s.size(); i++)
 if(s[i]!=t[i])
 c++;
 
 cout<<c;
 
 
 
}







int32_t  main()
{
       // ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int qq=1;
       // cin>>qq;

 
	while(qq--)
	{
	        
       
       solve();
     
       cout<<"\n";
       
   
    
	}

   
      
  
}
     



 

Measured memory_bytes: 3852
program ruined_square
  implicit none
  integer :: r(4), dx, dy
  read(*,*) r
  dx = r(3)-r(1)
  dy = r(4)-r(2)
  write(*,'(i0,3(x,i0))') r(3)-dy, r(4)+dx, r(1)-dy, r(2)+dx
end program ruined_square

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
int qp(ll a,ll b,ll mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll n, m;
    ll s[5], c[5];

    cin >> n >> m;
    rep(i,m) {
        cin >> s[i] >> c[i];
    }

    ll ans = 0;
    rep(i,n){
        bool flag = false;
        int num = 0;

        rep(j,m){
            if(i + 1 == s[j]){
                if(i == 0 && c[j] == 0 && n != 1){
                    cout << -1;
                    return;
                }

                if(flag){
                    if(num != c[j]){
                        cout << -1;
                        return;
                    }
                }

                num = c[j];
                flag = true;
            }
        }
        ans += num * pow(10,(n-i-1));
    }

    if(n==2 && ans < 10) ans += 10;
    if(n==3 && ans < 100) ans += 100;


    cout << ans << endl;


}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    solve();
    stop
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) int((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl '\n'
#define ff first
#define ss second
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T add(T x, T y, T m) { return ((x % m)  + (y % m)) % m;}
template<typename T>   T mul(T x, T y, T m) { return ((x % m) * (long long)(y % m)) % m;}
template<typename T>   T sub(T x, T y, T m) { return add(x, -y + m);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}

int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clzll(x) - 1;	}

struct pair_hash{
	template<class T1, class T2>
	size_t operator() (const pair<T1, T2> &p) const {
		auto h1 = hash<T1>{}(p.first);
		auto h2 = hash<T2>{}(p.second);
		return h1 ^ h2;
	}
};


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	ll h, n;
	cin >> h >> n;

	ll sum = 0;
	for(int i = 0 ; i < n ; ++i) {
		ll x;
		cin >> x;
		sum += x;
	}	

	if(h <= sum) {
		cout << "Yes" << endl;
	} else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
def main(a, b):
    for i in range(10000):
        if int(i * 0.08) == a and int(i * 0.1) == b:
            print(i)
            return

    print(-1)


if __name__ == "__main__":
    a, b = map(int, input().split())

    main(a, b)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define LL long long
LL N=0ll,ans=0ll;
inline LL cxsb(LL n,LL x){
	if(n%x==0) return n*2-x;
	else ans=n/x*x*2+cxsb(x,n%x); return ans;
}  
int main(){
	LL n,x;
	std::cin>>n>>x;N=n;
	std::cout<<cxsb(n-x,x)+N<<"\n";
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(a,b) (x+y-1)/y
#define min(x,y)(x<y?x:y)
 
using namespace std;
typedef pair<long, int> P;

void cycle(int l, int k, char *t, char *r) {
	rep(i,l) {
		r[i] = t[(k+i) % l];
	}
}
 
int main() {
	FAST;

	char s[100], t[100];
	cin >> s;
	cin >> t;

	bool ans = false;

	int l = strlen(s);

	char buf[100];

	rep(i,l) {
		cycle(l,i,s,buf);
		int ctr=0;
		rep(i,l) if (t[i]==buf[i]) ctr++;
		if (ctr==l) ans = true;
	}

	if (ans) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}


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

int main(void) {
    char x, y;
    std::scanf("%c %c", &x, &y);
    std::printf("%c\n", x < y ? '<' : x > y ? '>' : '=');
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    string S;
    cin >> S;
    vector<ll> e_count(N), w_count(N);
    for(ll i=1;i<N; i++)
    {
        if(S[i-1]=='W')
        {
            w_count[i]=w_count[i-1]+1;
        }
        else
        {
            w_count[i]=w_count[i-1];
        }
    }
    //cerr << "done west" << endl;
    for(ll i=N-2;i>=0; i--)
    {
        if(S[i+1]=='E')
        {
            e_count[i]=e_count[i+1]+1;
        }
        else
        {
            e_count[i]=e_count[i+1];
        }
    }
    //cerr << "done east" << endl;
    ll min_direction = INF;
    for(size_t i=0;i<N; i++)
    {
        //cerr << e_count[i] << ":" << w_count[i] << endl;
        min_direction = min(min_direction, e_count[i] + w_count[i]);
    }
    cout << min_direction << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<pair<string,ll> > svp;

#define endl       '\n'
#define F          first
#define S          second
#define pp         pop_back
#define PI         2*acos(0)
#define pb         push_back
#define mp         make_pair
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define bs         binary_search
#define For(i,j,k) for(i=j;i<k;i++)
#define FOR(i,j,k) for(i=j;i>=k;i--)
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define btpc       __builtin_popcountll
#define sp(x)      cout<<fixed<<setprecision(x)

const   long long  cs=2e5+5;
const   long long  inf=1e18;
const   long long  mod=1e9+7;
int main()
{	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);
  
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0;
    bool flag = false;
    
    cin>>n;
    if(n>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3648
n,m,x=map(int,input().split())
c=[]
a=[]
for i in range(n):
    ca=list(map(int,input().split()))
    c.append(ca[0])
    a.append(ca[1:])

ans=float('inf')

for i in range(1<<n):
    cost_sun=0
    rikaido=[0]*m
    for j in range(n):
        if(i>>j)&1:
            cost_sun+=c[j]
            for k in range(m):
                rikaido[k]+=a[j][k]
    
    isOK=True
    for j in range(m):
        if rikaido[j]<x:
            isOK=False
            break
    if isOK:
        ans=min(ans, cost_sun)

print(ans if ans !=float('inf') else -1)

Measured memory_bytes: 68508
#include <iostream>
#include <queue>
#define MAX_NUM 100001
#define INF 2147483647
using namespace std;

typedef struct node {
    int id;
    int dist;
    node* next;

    node(int inpId, long long int inpDist, node* inpNext = NULL): id(inpId), dist(inpDist), next(inpNext) {}
}* nodeptr;

class chain {
public:
    nodeptr head;
    nodeptr tail;

    chain(): head(NULL), tail(NULL) {}

    void push(int id, long long int dist) {
        nodeptr tmp = new node(id, dist);
        if (this->tail != NULL) {
            this->tail->next = tmp;
            this->tail = tmp;
        } else {
            this->head = this->tail = tmp;
        }
    }
};

typedef pair<long long int, int> pii;

int V, E, r;
int si, ti;
long long int di;
int S[MAX_NUM];
long long int d[MAX_NUM];
chain* adjacencyList[MAX_NUM];
priority_queue<pii, vector<pii>, greater<pii> > q;

void dijkstra() {
    nodeptr tmp;

    while (!q.empty()) {
        pii u = q.top(); q.pop();
        int x = u.second;
        if (S[x]) {continue;}
        S[x] = 1;

        tmp = adjacencyList[x]->head;
        while (1) {
            if (tmp != NULL) {
                if (tmp->dist + d[x] < d[tmp->id]) {
                    d[tmp->id] = tmp->dist + d[x];
                    q.push(make_pair(d[tmp->id], tmp->id));
                }
                tmp = tmp->next;
            } else {
                break;
            }
        }
    }
}

int main() {
//    freopen("in.txt", "r", stdin);

    cin >> V >> E >> r;
    for (int i = 0; i < MAX_NUM; ++i) {
        adjacencyList[i] = new chain();
        S[i] = 0;
        d[i] = i == r ? 0 : INF;
    }


    for (int i = 0; i < E; ++i) {
        cin >> si >> ti >> di;
        adjacencyList[si]->push(ti, di);
    }
    q.push(make_pair(d[r], r));

    dijkstra();

    for (int i = 0; i < V; ++i) {
        if (d[i] < INF) {
            cout << d[i] << endl;
        } else {
            cout << "INF" << endl;
        }
    }
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int dy[8]={-1,0 , 1, 1,-1, 1,-1, 0};
int dx[8]={-1,-1,-1, 0, 0, 1, 1, 1};
int main()
{
	int h , w ;
	cin >> h >> w ;
	vector<string> s(h);
	rep(i,h) cin >>s[i];
	vector<vector<int>> ans(h+10,vector<int>(w+10));
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='.')ans[i][j] = 0;
			else ans[i][j]=-1;
		}
	}
	rep(i,h){
		rep(j,w){
			if(s[i][j]=='#'){ 
				rep(k,8){
					int y = i + dy[k];
					int x = j + dx[k];
					if(x >= 0 && x < w && y >= 0 && y < h){
						if(ans[y][x]==-1)continue;
						ans[y][x] += 1 ;
					}
				}
			}
		}
	}
	rep(i,h){
		rep(j,w){
			if(ans[i][j] ==-1) cout <<'#';
			else {
				cout << ans[i][j];
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 256