akhauriyash/Code-Regression huggingface dataset:
n = int(input())
h = list(map(int,input().split()))
x = 0
for i in range(1,n) :
    a = h[-i]
    b = h[-i-1]
    if a >= b :
        pass
    elif b-a == 1 :
        h[-i-1] -= 1
    else :
        print('No')
        x += 1
        break
if x == 0 :
    print('Yes')

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

using namespace std;

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

    int a, b;
    char c;

    cin >> a >> c >> b;

    cout << (c == '+' ? a + b : a - b) << "\n";
    
    return 0; 
} 

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <regex>
#include <numeric>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MOD 1000000007
#define SQ(x) ((x)*(x))

const int N = 1005;
double d[N][N];
int x[N], y[N], r[N];
double dp[N];
bool vis[N];

int main() {
	int xs, ys, xt, yt, n;
	scanf("%d%d%d%d%d", &xs, &ys, &xt, &yt, &n);
	x[0] = xs;
	y[0] = ys;
	x[n + 1] = xt;
	y[n + 1] = yt;
	REP(i, n)scanf("%d%d%d", &x[i + 1], &y[i + 1], &r[i + 1]);
	REP(i, n + 2)FOR(j, i + 1, n + 2)d[i][j] = d[j][i] = max(sqrt(SQ(x[i] * 1.0 - x[j]) + SQ(y[i] * 1.0 - y[j])) - (r[i] + r[j]), 0.0);
	priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> q;
	q.push(MP(0.0, 0));
	REP(i, n + 2)dp[i] = 1.0e18;
	dp[0] = 0.0;
	while (!q.empty()) {
		auto tmp = q.top();
		q.pop();
		int idx = tmp.second;
		double dist = tmp.first;
		if (vis[idx])continue;
		vis[idx] = true;
		dp[idx] = dist;
		REP(i, n+2) {
			if (vis[i]) continue;
			q.push(MP(dist + d[idx][i], i));
		}
	}
	printf("%.12f\n", dp[n + 1]);
	return 0;
}

Measured memory_bytes: 18284
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Anurag_Gupta ios_base::sync_with_stdio(0);
#define IIIT_ALLD cin.tie(0);cout.tie(0);
#define mod 987654319
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/

int32_t main()
{
    Anurag_Gupta
    IIIT_ALLD
        int n,l;
        cin>>n>>l;

        int arr[n+1];
        int sum=0;

        rep(i,1,n+1)
        {
            arr[i] = l+i-1;
            sum+=arr[i];
        }

        int maxi=0;
        int mini = INT_MAX;
        rep(i,1,n+1)
        {
            int sum1 = sum-arr[i];
            if(abs(sum1-sum)<mini)
            {
                mini = abs(sum1-sum);
                maxi = sum1;
            }

        }

        cout<<maxi<<"\n";

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

        String s=gs();
        String t=gs();
        
        int i=0;
        while(i<s.length()) {
            i++;
            s=s.charAt(s.length()-1)+s.substring(0, s.length()-1);
            if(s.equals(t)) {
            	System.out.println("Yes");
            	return;
            }
        }
        

        System.out.println("No");
        

//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}
	
	public static int s(int n) {
		String S=String.valueOf(n);
		int c=0;
		for (int i=0; i<S.length();i++) {
			int k=Integer.parseInt(S.substring(i, i+1));
			c+=k;
		}
		return c;
	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

int main(){
  int N,K;cin>>N>>K;
  int h[N+10];
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
  sort(h,h+N);
  vector<int> deff;
  for(int i=K-1;i<N;i++){
    deff.push_back(h[i]-h[i-K+1]);
  }
  sort(deff.begin(),deff.end());

    cout<<deff[0]<<endl;
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;
const long long INF = 1e18;

bool in_range(int a, int b){
  return a >= 0 && a < b;
}
  
int main(){
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  vector<string> S(H);
  int sx, sy, gx, gy;
  for(int i = 0; i < H; ++i){
    cin >> S[i];
    for(int j = 0; j < W; ++j){
      if(S[i][j] == 's') sx = i, sy = j;
      if(S[i][j] == 'g') gx = i, gy = j;
    }
  }
  vector< vector<long long> > D(H,vector<long long>(W,INF));
  priority_queue< pair<long long, pair<int,int> > > Q;
  Q.push({0,{sx,sy}});
  D[sx][sy] = 0;
  int dx[] = {1,1,0,-1,-1,-1,0,1}, dy[] = {0,-1,-1,-1,0,1,1,1};
  while(not Q.empty()){
    int x = Q.top().second.first, y = Q.top().second.second;
    long long d = -Q.top().first;
    Q.pop();
    if(D[x][y] < d) continue;
    bool f = (S[x][y] != '*');
    for(int i = 0; i < 8; ++i){
      int x_ = x + dx[i], y_ = y + dy[i];
      if(in_range(x_,H) and in_range(y_,W) and S[x_][y_] == '*'){
        f = false;
        break;
      }
    }
    //cerr << x << " " << y << " " << f << endl;
    for(int i = 0; i < 8; ++i){
      int x_ = x + dx[i], y_ = y + dy[i];
      if((not in_range(x_,H)) or (not in_range(y_,W))) continue; 
      long long d_ = D[x_][y_];
      if(abs(dx[i]) + abs(dy[i]) == 1 and S[x_][y_] != '#' and d_ > d+A){
        D[x_][y_] = d+A;
        d_ = d+A;
        Q.push({-d_,{x_,y_}});
      }
      if(abs(dx[i]) + abs(dy[i]) == 1 and d_ > d+A+B and f){
        D[x_][y_] = d+A+B;
        d_ = d+A+B;
        Q.push({-d_,{x_,y_}});
      }
      if(abs(dx[i]) + abs(dy[i]) == 2 and d_ > d+2*A+B and f){
        D[x_][y_] = d+2*A+B;
        d_ = d+2*A+B;
        Q.push({-d_,{x_,y_}});
      }
    }
  }
  if(D[gx][gy] < INF) cout << D[gx][gy] << endl;
  else cout << "INF" << endl;
}



Measured memory_bytes: 11664
# ABC_086_B_1_21.py

a,b=list(map(int, input().split()))
ab=str(a)+str(b)
ab=int(ab)
flag=False
for i in range (320):
	if i**2==ab:
		flag=True
		break
if flag==True:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 61968
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
static const double pi=3.141592653589793238462643383279;

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

int main(){
    int n,d;
    cin >> n >> d;
    int X[n][d];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin >> X[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            int tmp=0;
            for(int k=0;k<d;k++){
                tmp+=pow(X[i][k]-X[j][k],2);
            }
            int num=1;
            while(tmp>=num*num){
                if(num*num==tmp) ++ans;
                ++num;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  ll h,w;
  cin >> h >> w;
  vector<vector<ll>> c(10,vector<ll>(10));
  for(ll i=0;i<10;i++) {
    for(ll j=0;j<10;j++) {
      cin >> c[i][j];
    }
  }
  for(ll k=0;k<10;k++) {
    for(ll i=0;i<10;i++) {
      for(ll j=0;j<10;j++) {
        c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
      }
    }
  }
  ll ans=0;
  for(ll i=0;i<h;i++) {
    for(ll j=0;j<w;j++) {
      ll a;
      cin >> a;
      if(a!=-1) {
        ans+=c[a][1];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
    vector<vector<ll>> c(3);
    rep(i,3){
      rep(j,3){
        ll temp;cin>>temp;
        c[i].pb(temp);
      }
    }
    int a[3][3];
    rep(i,3){
      rep(j,3){
        a[i][j]=INF;
      }
    }
    int b[3][3];
    rep(i,3){
      rep(j,3){
        b[i][j]=INF;
      }
    }
    //差分取りまくるか．
    rep(i,3){
      rep(j,3){
        rep(k,3){
          rep(l,3){
            if(i==k&&j==l){
              // pass
            }else if(j==l&&i>k){
              if(a[i][k]==INF){
                a[i][k]=c[i][j]-c[k][j];
              }else if(a[i][k]!=c[i][j]-c[k][j]){
                cout<<"No"<<endl;
                return 0;
              }
            }else if(i==k&&j>l){
              if(b[j][l]==INF){
                b[j][l]=c[i][j]-c[i][l];
              }else if(b[j][l]!=c[i][j]-c[i][l]){
                cout<<"No"<<endl;
                return 0;
              }
            }
          }
        }
      }
    }

    cout<<"Yes"<<endl;
    
    return 0;
}

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

#define int long long
#define rep(i, a) for (int i = 0; i < (a); i++)
#define repd(i, a) for (int i = (a)-1; i >= 0; i--)
#define reps(i, a, j) for (int i = (j); i < (a); i++)
#define deb(x) cout << #x << " " << x << endl;
#define debs(x) cout << #x << " " << x << " ";
#define deba(x) for (auto _i:x) cout << _i << " "; cout << endl;
#define ms(a) memset(a,0,sizeof(a));
#define mp make_pair
#define eb emplace_back
#define pii pair < int , int >
#define all(a) a.begin(),a.end()

const int inf = 1e16+7;
int presum(int i, int j, int pre[]) {
    return pre[j] - (i>0?pre[i-1]:0);
}

void solve() {
    int n; cin >> n;
    int arr[n]; rep(i,n) cin >> arr[i];
    int dp[n][n];
    rep(i,n) rep(j,n) dp[i][j] = inf;
    int pre[n]; pre[0] = arr[0]; reps(i,n,1) pre[i] = pre[i-1] + arr[i];
    repd(i,n) {
        rep(j,n) {
            if (i > j) continue;
            if (i == j) dp[i][j] = arr[i];
            else {
                reps(k,j,i) {
                    // dp[i][j] = min(dp[i][j], (k-1>=i?dp[i][k-1]:0) + arr[k] + arr[k+1] + (k+2<=j?dp[k+2][j]:0));
                    dp[i][j] = min(dp[i][j], presum(i,j,pre) + dp[i][k] + dp[k+1][j]); 
                }
            }
        }
    }
    cout << dp[0][n-1] - presum(0,n-1,pre) << endl;
}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t; t=1;
    while (t--) solve();
}

Measured memory_bytes: 4920
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

void yes(){
   cout<<"Yes"<<endl;
   //exit (0);
}
void no(){
   cout<<"No"<<endl;
   //exit (0);   
}

int n, m;
string s, t;

int32_t main(){_
   
   cin >> n;

   map<string, int> M;
   for (int i = 0; i < n; ++i)
   {
      string s;
      cin >> s;
      M[s]++;
   }
         
   vector<string> v = {"AC", "WA", "TLE", "RE"};

   for (int i = 0; i < (int)(v.size()); ++i)
   {
      cout<<v[i]<<" x "<<M[v[i]]<<endl;
   }

   return 0;
}

Measured memory_bytes: 3660
import random
import time

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum = sum + c[i]*(d-last_d[i])
        
    return int(score - sum)


def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    start = time.time()
    
    last_d = [0 for i in range(26)]
    
    ans = []
    
    score1 = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] != 0:
                max = s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])*(i-last_d[j]+1)/2) and c[j] * (i-last_d[j])*(i-last_d[j]+1)/2 > c[idx]* (i-last_d[idx])*(i-last_d[idx]+1)/2 and c[j] != 0:
                idx = j
            
        last_d[idx] = i+1
        score1 += s[i][idx]
        score1 = down_score(i+1,c,last_d,score1)
        
        ans.append(idx)

    while time.time() - start < 1.9:
        last_d = [0 for i in range(26)]
        score2 = 0  
        tmp1 = 0
        tmp2 = 1
        tmp3 = 2
        if random.randint(0,1):           
            d1 = random.randint(0,D-11) 
            d2 = random.randint(d1+1,d1+5)
            d3 = random.randint(d2+1,d2+5) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp1
                ans[d3] = tmp3
            else:
                ans[d1] = tmp1
                ans[d2] = tmp3
                ans[d3] = tmp2
                  
        else:
            d1 = random.randint(0,D-11) 
            d2 = random.randint(d1+1,d1+5)
            d3 = random.randint(d2+1,d2+5) 
            tmp1 = ans[d1]
            tmp2 = ans[d2]
            tmp3 = ans[d3]
            if random.randint(0,1):
                ans[d1] = tmp2
                ans[d2] = tmp3
                ans[d3] = tmp1
            else:
                ans[d1] = tmp3
                ans[d2] = tmp1
                ans[d3] = tmp2
            
        for i in range(D):
            score2 += s[i][ans[i]]
            last_d[ans[i]] = i+1
            score2 = down_score(i+1, c, last_d, score2)
        
        if score1 > score2:
            ans[d1] = tmp1
            ans[d2] = tmp2
            ans[d3] = tmp3
        else:
            score1 = score2
    
    for i in range(D):
        print(ans[i]+1)  

if __name__ == "__main__":
    main()


Measured memory_bytes: 9740
# coding: utf-8
# Your code here!
l = list(map(int,input().split()))
A = l[0]
B = l[1]
T = l[2]
ans = 0
for i in range(1, 30):
    if i >= T + 0.5:
        break
    elif i % A == 0:
        ans += B
        

print(ans)

Measured memory_bytes: 38512
N = int(input())

a = list(map(int, input().split()))

cnt = 1
re = a[0]
Ans = 0

for i in a[1:]:
  if i == re:
    cnt += 1
  else:
    Ans += cnt // 2
    cnt = 1
    re = i
Ans += cnt // 2

print(Ans)

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int
typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int n, h;
  cin >> n >> h;
  vector<int> a(n, 0);
  vector<int> b(n, 0);

  // int sum = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i] >> b[i];
  }
  int res = 0;
  sort(rall(a));
  sort(rall(b));

  int tmp = n;
  for (int i = 0; i < n; ++i)
  {
    if(a[0] >= b[i]) {
      tmp = i;
      break;
      // cout << "===" << endl;
    }
  }

  // for(int i : b) cout << i << endl;

  // cout << tmp << endl;
  for (int i = 0; i < tmp; i++)
  {
    res++;
    h -= b[i];
    if(h <= 0){
      cout << res << endl;
      return 0;
    }
  }
  // cout << res << endl;

  // cout << h << endl;
  // while(h > 0) {
  //   res++;
  //   h -= a[0];
  // }

  res += ceil(double(h) / double(a[0]));
  cout << res << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const ll MAX_N = 2e5 + 10;
ll in[MAX_N], now[MAX_N], pref[MAX_N];
int n, k;

bool trans() {
    for(int i = 0; i < n; i ++) {
        pref[i] = 0;
    }
    for(int i = 0; i < n; i ++) {
        pref[max(0ll, i - in[i])] ++;
        pref[min(i + in[i] + 1, MAX_N - 1)] --;
    }
    int curr = 0;
    bool change = false;
    ll sum = 0;
    for(int i = 0; i < n; i ++) {
        curr += pref[i];
        if(curr != in[i]) {
            change = true;
        }
        in[i] = curr;
        sum += curr;
    }
    return change;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k;
    bool zer = true;
    for(int i = 0; i < n; i ++) {
        cin >> in[i];
    }
    for(int i = 0; i < k; i ++) {
        bool t = trans();
        if(!t) {
            break;
        }
    }
    for(int i = 0; i < n; i ++) {
        cout << in[i] << " ";
    }
    return 0;
}




Measured memory_bytes: 6776
#include<bits/stdc++.h>
using namespace std;
typedef long long LL; 

int n;
LL k;
LL a[200005];

int find(LL v, int l)
{
	int r=n, mid, ol=l;
	if (v < a[l]) return 0;
	while (l < r)
	{
		mid=(l+r+1)>>1;
		if (a[mid] <= v) l = mid;
		else r = mid-1; 
	}
	return l-ol+1;
}

LL fl(LL a, LL b)
{
	int sgn = 1;
	if (a < 0) sgn *= -1;
	if (b < 0) sgn *= -1;
	if (sgn >= 0) return abs(a)/abs(b);
	else return -abs(a)/abs(b)-1;
}

LL cl(LL a, LL b)
{
	if (a % b == 0) return a/b;
	return fl(a, b)+1;
}

LL second(LL mid)
{
	LL ret=0;
	// a[i]*a[j] <= mid
    for(int i=1;i<n;++i)
    {
    	if (a[i]==0)
    	{
    		if (mid >= 0) ret += n-i; 
		}
		else if (a[i] > 0)
		{
			//a[j] <= mid/a[i]
			ret += find(fl(mid, a[i]), i+1);
		}
		else 
		{
			// a[j] >= mid/a[i]
			ret += n-i-find(cl(mid, a[i])-1, i+1);
		}
	}
	return ret;
}
LL first()
{
	LL l=-1e18, r=1e18, mid;
	while( l < r )
	{
		mid=l+(r-l)/2;
		LL c = second(mid);
		if (c < k) l = mid+1; 
		else r = mid;
	}
	return l;
}
int main()
{
    scanf("%d%lld", &n, &k);
    for(int i=1;i<=n;++i)
        scanf("%lld", &a[i]);
    sort(a+1,a+1+n);
    cout << first() << endl;
    //cout << second(110610286983069417) << endl;
    //cout << second(448283280358331064) << endl;
	return 0;
}

Measured memory_bytes: 5200
import sys
import math
 
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
 
def main():
  a = int(input())
  b = int(input())
  h = int(input())
  
  print(int((a+b)*h/2))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int P[10001];

void init(int n) {
	for (int i = 0; i <= n; i++)
		P[i] = i;
}

int root(int a) {
	if (P[a] == a)
		return a;
	return (P[a] = root(P[a]));
}

bool is_same_set(int a, int b) {
	return root(a) == root(b);
}

void unite(int a, int b) {
	P[root(a)] = root(b);
}

int main() {
	int n, q;
	cin >> n >> q;
	init(n);
	for (int i = 0; i < q; i++) {
		int query, x, y;
		cin >> query >> x >> y;
		if (query == 0)
			unite(x, y);
		else
			cout << (is_same_set(x, y) ? 1 : 0) << endl;
	}
}

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

using namespace std;

int main()
{
    long long n ;
    cin>>n ;
    long long arr[n] , arr2[n] , arr3[n] , arr4[n];
    long long sum = 0 ;
    for(long long i = 0 ; i < n ; ++i)
    {
        cin>>arr[i] ;
        sum += arr[i] ;
    }
    for(long long i = 0 ; i < n ; ++i)
    {
        cin>>arr2[i] ;
        arr3[i] = arr[i] - arr2[i] ;
        arr4[i] = arr[i] - arr2[i] ;
    }
    sort(arr3 , arr3 + n) ;
    sort(arr4 , arr4 + n) ;
    long long ans = 0 ;
    long long r = n ;
    for(long long i = 0 ; i < n ; ++i)
    {
        if(arr3[i] >= 0)
            break;
        if(r == n)
            r = n-1 ;
        for(long long j = r ; j > i ; --j)
        {
            r = j ;
            if(arr4[j] > 0)
            {
                long long x = min(abs(arr4[i]) , arr4[j]) ;
                arr4[i] += x ;
                arr4[j] -= x ;
            }
            if(arr4[i] >= 0)
                break;
        }
    }
    for(long long i = 0 ; i < n ; ++i)
    {
        if(arr4[i] < 0)
            ans = -1 ;
    }
    if(ans == -1)
        return cout<<-1<<"\n" , 0 ;
    for(long long i = 0 ; i < n ; ++i)
        if(arr4[i] != arr3[i])
            ans++;
    return cout<<ans<<"\n" , 0 ;
}


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

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

int main(){
  int a,b;
  cin>>a>>b;
  string t="";
  REP(i,50){
    t += '.';
  }
  REP(i,50){
    t += '#';
  }
  vector<string> s(100,t);
  int aq,ar,bq,br;
  aq = (a-1)/24;
  ar = (a-1)%24;
  bq = (b-1)/24;
  br = (b-1)%24;
  REPP(i,bq){
    REP(j,24){
      s[2*i-1][2*j+1]='#';
    }
  }
  if(br!=0){
    REP(j,br){
      s[2*(bq+1)-1][2*j+1]='#';
    }
  }
  
  REPP(i,aq){
    REP(j,24){
      s[2*i-1][2*j+1+50]='.';
    }
  }
  if(ar!=0){
    REP(j,ar){
      s[2*(aq+1)-1][2*j+1+50]='.';
    }
  }
  cout<<100<<' '<<100<<endl;
  REP(i,100){
    cout<<s[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+10,mod=1e9+7;
int n,m,k,t,mid;
vector<pair<int,int>>e[maxn];
bool cmpy(pair<long long,long long>x,pair<long long,long long>y)
{
    return x.second<y.second;
}
bool cmpx(pair<long long,long long>x,pair<long long,long long>y)
{
    return x.first<y.first;
}
vector<pair<long long,long long>>dfs(int x)
{
    if(e[x].empty())return vector<pair<long long,long long>>(1,{0,0});
    vector<pair<long long,long long>>pl=dfs(e[x][0].first);
    vector<pair<long long,long long>>pr=dfs(e[x][1].first);
    if(pl.size()>pr.size())swap(pl,pr),swap(e[x][0],e[x][1]);
    sort(pl.begin(),pl.end(),cmpy);
    sort(pr.begin(),pr.end(),cmpx);
    int pos=0;
    long long mi=1e18;
    int delta=e[x][0].second+e[x][1].second;
    vector<pair<long long,long long>>ret;
    for(int i=pl.size()-1;i>=0;i--)
    {
        auto &it=pl[i];
        while(pos<pr.size()&&pr[pos].first+it.second+delta<=mid)
        {
            mi=min(mi,pr[pos++].second);
        }
        if(mi!=1e18)
            ret.push_back({it.first+e[x][0].second,mi+e[x][1].second});
    }
    sort(pl.begin(),pl.end(),cmpx);
    sort(pr.begin(),pr.end(),cmpy);
    pos=0,mi=1e18;
    for(int i=pl.size()-1;i>=0;i--)
    {
        auto &it=pl[i];
        while(pos<pr.size()&&pr[pos].second+it.first+delta<=mid)
        {
            mi=min(mi,pr[pos++].first);
        }
        if(mi!=1e18)
            ret.push_back({mi+e[x][1].second,it.second+e[x][0].second});
    }
    return ret;
}
int main(){
    int i,j;
    scanf("%d",&n);
    for(i=2;i<=n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        e[x].push_back({i,y});
    }
    long long l=0,r=1e10,ret;
    while(l<=r)
    {
        mid=l+r>>1;
        vector<pair<long long,long long>>now=dfs(1);
        if(!now.empty())ret=mid,r=mid-1;
        else l=mid+1;
    }
    printf("%lld\n",ret);
    return 0;
}



Measured memory_bytes: 22272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<P> v(n);
    vector<int> ans(n); 
    rep(i,n){
        cin >> a[i];
        v[i]= P(a[i],i);
    }
    sort(v.begin(),v.end());
    rep(i,n){
        if(i<n/2){
            ans[v[i].second] = v[n/2].first;
        }
        else{
            ans[v[i].second] = v[n / 2-1].first;
        }
    }
    rep(i,n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <numeric>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n], b[n], c[n-1];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < n-1; i++)
    {
        cin >> c[i];
    }
    int score=0;
    score += accumulate(b, b + sizeof(b)/sizeof(b[0]), 0);

    for (int i = 0; i < n - 1; i++)
    {
        if(a[i]+1 == a[i+1]){
            score += c[a[i]-1];
        }
    }
    cout << score << endl;

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int n;
    cin >> n;
    vi p(n), p_(n);
    rep(i, n) {
        cin >> p[i];
        --p[i];
        p_[p[i]] = i;
    }

    int ans = 0;
    int now = 0;
    rep(i, n-1) {
        if(p_[i] < p_[i+1]) {
            now++;
        } else {
            ans = max(ans, now);
            now = 0;
        }
    }
    ans = max(ans, now);
    cout << n-1-ans << endl;
}

Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<climits>
#define ll long long int
using namespace std;
int main(void) {
  int n;
  int a[27]={0};
  string s;
  int ans=0;
  cin>>n;
  cin>>s;
  for(int i=1; i<n; i++) {
    for(int j=0; j<i; j++) {
      a[(int)s[j]-(int)'a']=1;
    }
    int k=0;
    for(int j=i; j<n; j++) {
      if(a[(int)s[j]-(int)'a']) {
	k++;
	a[(int)s[j]-(int)'a']=0;
      }
    }
    ans=max(ans, k);
    for(int j=0; j<27; j++) a[j]=0;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val d = readint()
    val c = readints()
    val s = Array(d){IntArray(26)}
    for(i in 0 until d){
        s[i] = readints().toIntArray()
    }
    val ans = IntArray(d)

    fun score(D : Int) : Long{
        val t = IntArray(26)
        var sum = 0L
        for(i in 0 until D){
            sum += s[i][ans[i]]
            t[ans[i]] = i + 1
            for(j in 0 until 26){
                sum -= c[j] * (i + 1 - t[j])
            }
        }
        return sum
    }

    for(i in 0 until d){
        val t = readint()
        ans[i] = t - 1
        println(score(i + 1))
    }

    /*
    for(i in 0 until d){
        var ma = 0
        var mai = 0
        for(j in 0 until 26){
            if(ma < s[i][j]){
                ma = s[i][j]
                mai = j
            }
        }
        ans[i] = mai
    }

    var ma = score()

    repeat(10){
        for(i in 0 until d){
            for(j in 0 until 26){
                val t = ans[i]
                ans[i] = j
                val m = score()
                if(m > ma){
                    ma = m
                }
                else{
                    ans[i] = t
                }
            }
        }
    }

    for(i in 0 until d){
        println(ans[i] + 1)
    }
    */
}



fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}

Measured memory_bytes: 40000
#include <iostream>
#define NMAX 100
#define AMAX 2001

using namespace std;

enum state{
  WHITE,
  BLACK
};

int main(){
  int A[NMAX][NMAX];
  int n; cin>>n;
  state s[NMAX];
  
  for(int r=0;r<n;r++){
    for(int c=0;c<n;c++){
      cin>>A[r][c];
      if(A[r][c]==-1) A[r][c]=AMAX;
    }
  }

  for(int i=0;i<n;i++) s[i]=WHITE;
  s[0]=BLACK;
  
  int sum=0;

  while(1){
    bool flag=true;
    for(int i=0;i<n;i++){
      if(s[i]!=BLACK) flag=false;
    }
    if(flag) break;

    int min=AMAX;
    int minr,minc;
    for(int r=0;r<n;r++){
      for(int c=0;c<n;c++){
        if(s[r]==BLACK && s[c]!=BLACK && A[r][c]<min){
          min=A[r][c];
          minr=r;minc=c;
        }
      }
    }
    s[minr]=BLACK;s[minc]=BLACK; 
    sum+=min;
  }
  cout<<sum<<endl;
}

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



int main() 
{
    ll x;
    cin >> x ;
    ll yen = 100;
    for (ll i = 1; true; i++)
    {
        yen = yen + yen / 100;
        if(yen>=x)
        {
            cout << i << endl;
            break;
        }
    }

        return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  int n;cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int cnt = 0;
  rep(i,n){
    if((i+1)%2==0) continue;
    if(a[i]%2!=0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3612
s = input()
count = 0
for i in range(len(s)):
    if s[i] == 'R' and i % 2 == 1:
        count +=1
    if s[i] == 'L' and i % 2 == 0:
        count +=1
if count == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
    public static void main(String[] defargs) {
        Scanner scanner = new Scanner(System.in);
        int H,W;
        while(true){
           H = scanner.nextInt();
           W = scanner.nextInt();
          if ( H == 0 && W == 0 ){
              break;
            }
        for ( int i = 0; i < H; i++ ){
             for ( int j = 0; j < W; j++ ){
               System.out.print("#");		       
            }
            System.out.println();
        }
        System.out.println();
    }
  }
}


Measured memory_bytes: 35004
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    int n,k; cin>>n>>k;
    vector<double> kitai(n);
    rep(i,n){
        int a;
        cin>>a;
        kitai[i]=(a+1)/2.0;
    }
    double ans=0;
    rep(i,k){
        ans+=kitai[i];
    }
    double temp=ans;
    for(int i=0; i+k<n; i++){
        temp=temp-kitai[i]+kitai[i+k];
        ans=max(ans,temp);
    }
    cout<<fixed<<setprecision(10);
    cout<<ans<<endl;
}

Measured memory_bytes: 1920
use std::io;
use std::cmp;


fn main() {
    let (n, k) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let mut xn = read::<isize>();
    xn.sort();
    let mut start = ::std::usize::MAX;
    for i in 0..n {
        start = cmp::min(start, xn[i].abs() as usize);
    }
    let mut ans = ::std::usize::MAX;
    for i in 0..n - k + 1 {
        ans = cmp::min(ans, xn[i].abs() as usize + (xn[i] - xn[i + k - 1]).abs() as usize);
        ans = cmp::min(ans, xn[i + k - 1].abs() as usize + (xn[i] - xn[i + k - 1]).abs() as usize);
    }

    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en 


constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

VVI attack(int r, int c, VVI av) {
    REP(i, 8) {
        av[i][c] ^= 1;
        av[r][i] ^= 1;
    }
    FOR(i, -8, 8) {
        if (0 <= r + i  && r + i <= 7 && 0 <= c + i && c + i <= 7) {
            av[r+i][c+i] ^= 1;
        }
        if (0 <= r - i  && r - i <= 7 && 0 <= c + i && c + i <= 7) {
            av[r-i][c+i] ^= 1;
        }
    }
    return av;
}
void Main(){
    int x;
    cin >> x;
    x ^= 1;
    cout << x << endl;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3632
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, a;
int main() {
	cin >> n;
	int ret = 1, mul = 1;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 0) ret *= 2;
		mul *= 3;
	}
	cout << mul - ret << endl;
	return 0;
}

Measured memory_bytes: 384
#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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int a, b; cin >> a >> b;

  cout << (a <= 5 ? 0 : a >= 6 && a <= 12 ? b/2 : b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
  string s, t;
  cin >> s >> t;
  
  int count = 0;
  
  for(int i = 0; i < s.size(); i++){
    if(s[i] != t[i])
      count++;
  }
  
  printf("%d", count);
}

int main()
{
  std::cout << std::fixed << std::setprecision(15);
  Main();
}



Measured memory_bytes: 3916
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,i,j,k;
    scanf("%d",&a);
    int x[a][6];
    for(i=0;i<a;i++){
        for(j=0;j<6;j++){
            scanf("%d",&x[i][j]);
        }
    }
    
    for(i=0;i<a-1;i++){
        for(j=i+1;j<a;j++){
            for(k=0;k<122;k++){
                if(x[i][0]==x[j][0]&&x[i][5]==x[j][5]){
                    if(x[i][1]==x[j][1]&&x[i][4]==x[j][4]){
                        if(x[i][2]==x[j][2]&&x[i][3]==x[j][3]){
                            puts("No");
                            return 0;
                        }
                    }
                    else{
                        b=x[j][1];x[j][1]=x[j][2];x[j][2]=x[j][4];
                        x[j][4]=x[j][3];x[j][3]=b;
                    }
                }
                if(k%2){
                    b=x[j][1];x[j][1]=x[j][0];x[j][0]=x[j][4];
                    x[j][4]=x[j][5];x[j][5]=b;
                }
                else{
                    b=x[j][5];x[j][5]=x[j][2];x[j][2]=x[j][0];
                    x[j][0]=x[j][3];x[j][3]=b;
                }
            }
        }
    }
    puts("Yes");

        return 0;
}

Measured memory_bytes: 580
import collections

a=int(input())
b=collections.Counter(list(map(int,input().split())))
c=int(input())
d=collections.Counter(list(map(int,input().split())))
e=set(d)

for item in e:
  if d[item]>b[item]:
    print("NO")
    exit()
    
print("YES")


Measured memory_bytes: 63448
def eratos(N):
    isprime = [1 for i in range(N+1)]
    for i in range(2, N+1):
        j = i
        while j <= N:
            isprime[j] += 1
            j = j + i
    return isprime        

N = int(input())

is_prime = eratos(N)
ans = 0
# print(is_prime)
for i in range(1, N+1):
    ans += i * is_prime[i]
print(ans)

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

#define MOD 1000000007
#define rep(i, n) for(int i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> Pair;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll P[101][11];
ll F[101][11];
int N;

/******************************************
** A main function is start from here  ****
*******************************************/
int main(){
  cin >> N;
  rep(i, N){
    rep(j, 10){
      cin >> F[i][j];
    }
  }

  rep(i, N){
    rep(j, 11){
      cin >> P[i][j];
    }
  }

  ll ans = -1e15;
  for(int i=1;i<pow(2,10); i++){
    vector<int> count(N, 0);
    rep(j, 10){
      if(i>>j&1){
        rep(k, N){
          if(F[k][j]==1){
            count[k]++;
          }
        }
      }
    }
    
    ll tmp = 0;
    rep(k, N){
      tmp = tmp + P[k][count[k]];
    }
    ans = max(ans, tmp); 
    
  }

  cout << ans;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int q1, b, c1, c2, q2;
int main() {
  while (scanf("%d", &q1)) {
	if (q1 == 0) break;
	scanf("%d%d%d%d",&b,&c1,&c2,&q2);
	int jidori = b / c1;
	jidori = (jidori < q2 ? jidori : q2);
	b -= jidori * c1;
	int normal = b / c2;
	b -= normal * c2;
	while (jidori + normal < q1) {
	  if (jidori <= 0) break;
	  jidori--; b += c1;
	  int temp = b / c2;
	  normal += temp;
	  b -= c2 * temp;
	}
	if (jidori <= 0) puts("NA");
	else printf("%d %d\n",jidori,normal);
  }
}

Measured memory_bytes: 1044
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int,int> P;
typedef unsigned int ui;
#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++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
P t[1001][2]; int tra[1001][2];
string a, b;
void init() {
	rep(i, 1001) {
		rep(j, 2) {
			t[i][j] = { -1,-1 };
			tra[i][j] = -1;
		}
	}
}
void maketree(string x,int y) {
	P root;
	int cnt = 0;
	int len = x.length();
	rep(i, len) {
		if (x[i] == '(')cnt++;
		if (x[i] == ')')cnt--;
		if (x[i]=='['&&cnt==0) {
			string u;
			i++;
			while (x[i] != ']') {
				u += x[i]; i++;
			}
			root = { i,0 }; tra[0][y] = stoi(u);
		}
	}
	queue<P> q;
	q.push(root);
	int whe = 1;
	while (!q.empty()) {
		P now = q.front(); q.pop();
		int loc = now.first; int num = now.second;
		cnt = 0;
		for (int i = loc - 1; i >= 0; i--) {
			if (i == loc - 1) {
				while (x[i] != '[')i--;
				i--;
			}
			if (x[i] == ')')cnt++;
			if (x[i] == '(')cnt--;
			if (cnt == 0)break;
			if (x[i] == '['&&cnt == 1) {
				int j = i + 1;
				string u;
				while (x[j] != ']') {
					u += x[j]; j++;
				}
				t[num][y].first = whe;
				tra[whe][y] = stoi(u);
				q.push({ j,whe });
				whe++;
			}
		}
		cnt = 0;
		for (int i = loc + 1; i < len; i++) {
			if (x[i] == '(')cnt++;
			if (x[i] == ')')cnt--;
			if (cnt == 0)break;
			if (x[i] == '['&&cnt == 1) {
				int j = i + 1;
				string u;
				while (x[j] != ']') {
					u += x[j]; j++;
				}
				t[num][y].second = whe;
				tra[whe][y] = stoi(u);
				q.push({ j,whe });
				whe++;
			}
		}
	}
}
string uniontree(int aa,int ba) {
	string res;
	if (aa==-1||ba==-1) {
		res = "";
	}
	else {
		int r = tra[aa][0] + tra[ba][1];
		res += "(";
		res += uniontree(t[aa][0].first, t[ba][1].first);
		res += ")[";
		res += to_string(r);
		res += "](";
		res += uniontree(t[aa][0].second, t[ba][1].second);
		res += ")";
	}
	return res;
}
int main() {
	init();
	cin >> a >> b;
	maketree(a, 0); maketree(b, 1);
	cout << uniontree(0,0) << endl;
	return 0;
}


Measured memory_bytes: 3320
n,m,c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

a = n.times.map {gets.split.map(&:to_i)}
sum_arr =[]
sum = 0

a.each do |v|
  m.times do |i|
    sum += v[i]*b[i]
    if i == (m-1)
      sum_arr  <<  (sum+c)
      sum = 0
    end
  end
end

p sum_arr.count{|v| v > 0}

Measured memory_bytes: 3836
n = int(input())
p = list(map(int, input().split()))

t = [i for i in range(1,n+1)]
l = [i for i in range(n) if p[i] != t[i]]

if len(l) == 0 or len(l) == 2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
from collections import deque
h, w = list(map(int, input().split()))
grid = []
for i in range(h):
    grid.append(list(input()))
#x,y渡すと、（h,w）に入ってるかどうか判定
def check(s,t):
    if (0 <=  s <= h - 1) and (0 <= t <= w - 1):
        return True
    else:
        return False
ans = [[0 for i in range(w)] for j in range(h)]
#graph => そこまでの距離を保存した二次元配列　grid=>与えられた迷路
ans[0][0] = 1
mod = 10**9+7
for i in range(h):
    for j in range(w):
        if grid[i][j] != '#':
            if i - 1 >= 0:
                ans[i][j] += ans[i-1][j]
            if j - 1 >= 0:
                ans[i][j] += ans[i][j-1]
        else:
            ans[i][j] = 0
        ans[i][j] %= mod
print(ans[-1][-1])

Measured memory_bytes: 90972