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

string S;
cin >>S;
 
string ATGC="ATGC";
int series=0;
int ans=0;
for(int i=0;i<S.size();i++){
bool flg=false;
for (char c:ATGC){
//  cout <<c<<S[i]<<endl;
if(c==S[i]){
series++;
flg=true;
}
}
if(! flg)series=0;
//  cout <<series<<endl;
ans=max(ans,series);
 
}  
cout <<ans <<endl;
 
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  
  vector<int> H(N);
  
  for(int i=0;i<N;i++)
    cin>>H.at(i);
  
  int yama=1,hi=H.at(0);
  
  for(int i=1;i<N;i++){
    if(H.at(i)>hi){
      yama++;
      hi=H.at(i);
    }
    else if(H.at(i)==hi)
      yama++;
    
  }
  
  cout<<yama<<endl;
  
  return 0;
}

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

using V = vector<int>;

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

    int A, B, M;
    int x, y, c;

    cin >> A >> B >> M;

    vector<int> kA(A);
    vector<int> kB(B);
    vector<vector<int>> dis(M, vector<int>(3));

    rep(i, A)
    {
        cin >> kA[i];
    }

    rep(i, B)
    {
        cin >> kB[i];
    }

    rep(i, M)
    {
        cin >> dis[i][0] >> dis[i][1] >> dis[i][2];
    }

    int tmp = kA[dis[0][0]-1] + kB[dis[0][1]-1] - dis[0][2];

    for (const auto entry : dis)
    {
        if (tmp > kA[entry[0]-1] + kB[entry[1]-1] - entry[2])
        {
            tmp = kA[entry[0]-1] + kB[entry[1]-1] - entry[2];
        }
    }

    cout << min(*min_element(kA.begin(), kA.end()) + *min_element(kB.begin(), kB.end()), tmp);

    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;

vector<int> point[100001];
int n,x,y,siz[100001],son[100001];
bool check[100001];

void dfs1(int u,int f){siz[u]=1;for(int v:point[u])if(v!=f)dfs1(v,u),siz[u]+=siz[v];}

void dfs2(int u,int f){
	for(int v:point[u])if(v!=f){dfs2(v,u);if(siz[v]>0)++son[u];}
	if(son[u]==1)siz[u]=0;if(son[u]>1)puts("First"),exit(0);
}

int main(){
	scanf("%d",&n);for(int i=1;i<n;++i)scanf("%d%d",&x,&y),point[x].push_back(y),point[y].push_back(x);
	dfs1(1,0);dfs2(1,0);
	puts(siz[1]?"First":"Second");
}

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

int main () {

    int N;
    cin >> N;

    double x[N]; 
    string u[N];
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> u[i];
    }

    double ans = 0.0;
    for (int i = 0; i < N; i++) {
        if (u[i] == "JPY") {
            ans += x[i];
        }
        else {
            ans += 380000.0 * x[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
x = n-m
'''確率pの事象を達成するまで試行する時の期待値eは1/pとなることを考える。本件はp=(1/2)^mであることから、期待値eは2^mとなり得る
'''
print((((1900*m)+(100*x))*2**m))

Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n,m;
    string s;
    cin>>n>>m>>s;
    int x=0,y=0;
    rep(i,n){
        if(s[i]=='1') x++;
        else x=0;
        y=max(y,x);
    }
    if(y>=m){
        cout<<-1<<"\n";
        return 0;
    }
    ll dp[200001],d[200001];
    dp[n]=0;
    d[0]=n;
    ll p=0,inf=1e18;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='1'){
            dp[i]=inf;
            continue;
        }
        if(d[p]-i>m) p++;
        dp[i]=p+1,d[p+1]=i;
    }
    int a=dp[0],b=0;
    rep(i,n+1) if(a>dp[i]) cout<<i-b<<" ",a=dp[i],b=i;
    cout<<"\n";
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	int n, d;
	cin >> n >> d;
	ll ans(0);
	rep(i, n) {
		double x, y;
		cin >> x >> y;
		double k = sqrt(x * x + y * y);
		if (k <= d) {
			ans++;
		}
	}
	cout << ans;
	return 0;
}

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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N];
char ans[N];
bool u[N];
int z[N];

bool ask (int p) {
	cout << "?";
	for (int i = 0; i < n; i ++) {
		cout << ' ' << p + i;
	}
	cout << endl;
	string res;
	cin >> res;
	return (res[0] == 'R');
}


int col (vector < int > &p) {
	assert(p.size() == n);
	cout << "?";

	for (auto pos : p)
		cout << ' ' << pos;
	cout << endl; 
	string res;
	cin >> res;
	return (res[0] == 'R');
}

int main () {
   SpeedForce;
   srand(time(0));
	cin >> n;
	for (int i = 1; i <= 2 * n; i ++) ans[i] = '#';
	int l = 1, r = n + 1;
	bool st = ask(1);
	while (r - l > 1) {
		int md = (l + r) >> 1;
		if (ask(md) == st)
			l = md;
		else
			r = md;
	}
	ans[l] = (st ? 'R' : 'B');
	ans[l + n] = (st ? 'B' : 'R');
	//(n-1) / 2 reds and (n-1) / 2 blues

	vector < int > p;
	for (int i = l + 1; i < l + n; i ++)
		p.pb(i);

	for (int i = 1; i < l; i ++) {
		p.pb(i);
		if (col(p))
			ans[i] = 'R';
		else
			ans[i] = 'B';
		p.pop_back();
	}

	for (int i = l + n + 1; i <= 2 * n; i ++) {
		p.pb(i);
		if (col(p))
			ans[i] = 'R';
		else
			ans[i] = 'B';
		p.pop_back();
	} 
	p.clear();

	for (int i = 1, j = (n - 1) / 2; i <= 2 * n && j > 0; i ++) if (ans[i] == 'R') {
		j--;
		p.pb(i);
	}
	for (int i = 1, j = (n - 1) / 2; i <= 2 * n && j > 0; i ++) if (ans[i] == 'B') {
		j--;
		p.pb(i);
	}
	
	for (int i = l + 1; i < l + n; i ++) {
		p.pb(i);
		if (col(p))
			ans[i] = 'R';
		else
			ans[i] = 'B';
		p.pop_back();
	}

	cout << "! ";
	for (int i = 1; i <= 2 * n; i ++)
		cout << ans[i];
	cout << endl;

   return Accepted;
}

// B...a

Measured memory_bytes: 2772
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BROTN solver = new BROTN();
        solver.solve(1, in, out);
        out.close();
    }

    static class BROTN {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;

            int n = ni();
            String st = n();
            int i = 0;
            for (i = 0; i < st.length(); i++) {
                int x = st.charAt(i) - 'A';
                x += n;
                x %= 26;
                p((char) (65 + x));
            }
        }

        String n() {
            return in.next();
        }

        int ni() {
            return in.nextInt();
        }

        void p(Object o) {
            out.print(o);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new UnknownError();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int a[10000];
int ans[100][100];

int main(void) {
    int i, j, h, w, n;
    cin >> h >> w >> n;
    REP (i,n) cin >> a[i];
    int k = 0;
    REP (i,h) {
        if (i % 2 == 0) {
            REP (j,w) {
                ans[i][j] = k + 1;
                if (--a[k] == 0) k++;
            }
        }
        else {
            RREP (j,w) {
                ans[i][j] = k + 1;
                if (--a[k] == 0) k++;
            }
        }
    }
    REP (i,h) REP (j,w) printf("%d%c",ans[i][j]," \n"[j==w-1]);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;
using ll = long long int;

int main(void){
    string S;cin>>S;
    string rS = S;
    reverse(rS.begin(),rS.end());
    if(S!=rS){
        cout << "No" << endl;
        exit(0);
    } 
    string fS = S.substr(0,(S.length()-1)/2);
    string rfS = fS;
    reverse(rfS.begin(),rfS.end());
    if(fS!=rfS){ 
        cout << "No" << endl;
        exit(0);
    }
    string eS = S.substr((S.length()+3)/2-1);
    string reS = eS;
    reverse(reS.begin(),reS.end());
    if(eS!=reS){
        cout << "No" << endl;
        exit(0);
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
using namespace std;

bool comp(pi p1, pi p2){
	return p1.second < p2.second;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	int x[n], l[n];
	vector<pi> v(n);
	for(int i = 0; i < n; i++){
		cin>>x[i]>>l[i];
		v[i] = {x[i] - l[i], x[i] + l[i]};
	}
	sort(v.begin(), v.end(), comp);
	int prev = -1000000000, ans = 0;
	for(int i = 0; i < n; i++){
		if(v[i].first >= prev){
			prev = v[i].second;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.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++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  int n;
  cin >> n;
  vi a(n);
  vi b(n);
  vi c(n);
 
  rep(i,n) {
    cin >> a[i] >> b[i] >> c[i];
    
  }
  rep(i,101)rep(j,101){
    int h = 0;
    rep(k,n){
      if(c[k]>0) h = c[k]+abs(i-a[k])+abs(j-b[k]);
    }
    bool ok = true;
    rep(k,n){
      if(c[k]!=max(h-abs(i-a[k])-abs(j-b[k]),0))ok = false;
    }
    if(ok){
      cout << i << " " << j << " " << h << endl;
      return 0;
    }
  }
  
}




Measured memory_bytes: 256
using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var aL = "bcdefghijklmnopqrstuvwxyza";
        var d = new Dictionary<char, int>();
        for (int i = 0; i < 26; i++) d[aL[i]] = 25 - i;
        var s = Console.ReadLine().Trim();
        var k = int.Parse(Console.ReadLine().Trim());
        var res = s.ToCharArray();
        for (int i = 0; i < s.Length; i++)
        {
            var w = d[s[i]];
            if (k - w >= 0) { res[i] = 'a'; k -= w; }
        }
        if (k > 0)
        {
            var w2 = d[res[res.Length - 1]] - (k % 26);
            if (w2 < 0) w2 += 26;
            var w3 = d.Where(x => x.Value == w2).First().Key;
            res[res.Length - 1] = w3;
        }
        Console.WriteLine(new string(res));
    }
}


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

int main()
{
  int n;
  cin >> n;
  int arr[n];
  int flag=0;
  for(int i=0;i<n;i++)
  {
    cin >> arr[i];
  }
  for(int i=0;i<n-1;++i)
  {
   if(arr[i+1]>arr[i])
    arr[i+1]--;
    else if(arr[i+1] < arr[i])
    flag=1;
  }

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

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

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

int main()

{

    ll n;
    cin >> n;
    vector<ll> v;
    v.pb(0);
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    v.pb(0);
    ll sum = 0;
    for(ll i = 1; i <= n+1; i++) sum+=abs(v[i]-v[i-1]);
    for(ll i = 1; i <= n; i++)
    {

        ll x = v[i-1], y = v[i], z = v[i+1];
        cout << sum-abs(x-y)-abs(y-z)+abs(x-z) << endl;
    }
}


Measured memory_bytes: 2164
import math

class P(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def width(self, p):
        return math.sqrt((self.x - p.x)**2 + (self.y - p.y)**2)

    def __repr__(self):
        return '{0:.3f} {1:.3f}'.format(self.x, self.y)

def calc_cos(a,b,c):
    return (b**2 + c**2 - a**2) / (2*b*c)

def calc_sin(c):
    return math.sqrt(1 - c**2)

def calc_2sin(s,c):
    return 2 * s * c

def run():
    n = int(input())
    for _ in range(n):
        x1, y1, x2, y2, x3, y3 = list(map(float, input().split()))
        p1, p2, p3 = P(x1, y1), P(x2, y2), P(x3, y3)
        a, b, c = p1.width(p2), p2.width(p3), p3.width(p1)
        cosA, cosB, cosC = calc_cos(a,b,c), calc_cos(b,c,a), calc_cos(c,a,b)
        sinA, sinB, sinC = calc_sin(cosA), calc_sin(cosB), calc_sin(cosC)
        sin2A, sin2B, sin2C = calc_2sin(sinA, cosA), calc_2sin(sinB, cosB), calc_2sin(sinC, cosC)

        r = a / sinA / 2

        x = (p1.x * sin2B + p2.x * sin2C + p3.x * sin2A) / (sin2A + sin2B + sin2C)
        y = (p1.y * sin2B + p2.y * sin2C + p3.y * sin2A) / (sin2A + sin2B + sin2C)

        print('{0:.3f} {1:.3f} {2:.3f}'.format(x,y,r))

if __name__ == '__main__':
    run()




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

using namespace std;

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

  int n, t, x, y;
  cin >> n;
  int px = 0, py = 0, pt = 0;
  string res = "Yes";
  for (int i = 0; i < n; ++i) {
    cin >> t >> x >> y;
    int dist = abs(x-px) + abs(y-py); 
    if (t-pt < dist || dist%2 != (t-pt)%2) { 
      res = "No";
      break;
    }
    px = x; py = y; pt = t;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
h,w = map(int,input().split())



while True:
    for i in range(h):
        for j in range(w):
            if (i + j) % 2 == 0:
                print("#",end="")
            else:
                print(".",end="")
        print("")



    print("")
    h,w = map(int,input().split())
    if  h == 0 and w ==0:
        break




Measured memory_bytes: 7012
#include<iostream>

using namespace std;

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

  int W[N];
  int S1 = 0;
  int S2 = 0;
  int min = 1000;
  int x;

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

  for (int i = 0; i < N-1; i++){
    S1 = 0;
    S2 = 0;
    for (int j = 0; j <= i; j++){
      S1 += W[j];
    }
    for (int j = i+1; j < N; j++){
      S2 += W[j];
    }
    
    x = abs(S1-S2);
    if (x < min){
      min = x;
    }
  }

  cout << min << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define All(x) (x).begin(), (x).end()
#define lowbit(x) ((x) & -(x))
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const ll mod = 1e9 + 7;
const int N = 4e6 + 10;
const db pi = acos(-1);
int a[N];
int main()
{
	int n = read();
	rep(i, 1, n)
		a[i] = read();
	int q = read();
	while(q --)
	{
		int op = read();
		int l = read();
		int r = read();
		l ++;
		int ans = a[l];
		if(op == 0) rep(i, l, r) ans = min(ans, a[i]);
		else rep(i, l, r) ans = max(ans, a[i]);
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3100
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    a, b, c = get_li()
    if a < c < b or a > c > b:
        print("Yes")
    else:
        print("No")
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5652
//45
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    bool g[21][21]={};
    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      g[y][x]=true;
    }
    g[10][10]=false;
    int m;
    cin>>m;
    int py=10,px=10;
    for(int i=0;i<m;i++){
      char d;
      int l;
      cin>>d>>l;
      while(l--){
	py+=(d=='N')-(d=='S');
	px+=(d=='E')-(d=='W');
	g[py][px]=false;
      }
    }
    cout<<((find(g[0],g[21],true)==g[21])?"Yes":"No")<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 
using namespace std;
 
#define SZ(x) ((int)(x).size())
using namespace std;
typedef pair<int,int> PII;
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FOR(i,a,b) for (int i = a; i <= b; ++i)
#define M 1000000007
#define MM 998244353
#define SZ(a) int((a).size())
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define mod 1000000007
//a and b are assumed to be taken modulo p
inline int add(int a, int b, int p = mod){ int c = a + b; if(c >= p) c -= p; return c; }
inline int sub(int a, int b, int p = mod){ int c = a - b; if(c < 0) c += p; return c; }
inline int mul(int a, int b, int p = mod){ return (a * 1ll * b) % p; }
 
using ll = long long;
using VI = vector<int>;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
using VLL = vector<ll>;
using ld = long double;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
const int MX = 2e5+10;
const int MX2 = 1e6+5;

ll INF= 4 * (ll)1e18;
int mx = 2 * (ll)1e9 + 10;

int fre[MX];
vector<int> cnt;
int ans = 1e9;
int n;
void recur(int num) {
    if (num >= n) {
        ans = min(ans,num);
        return ;
    }
    for (int i = 0; i < SZ(cnt); ++i) {
        recur(num * 10+cnt[i]);
    }
    return;
}

int main(int argc, const char * argv[]) {

    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0); // insert code here...
    int k;
    cin >> n >> k;
    REP(i,k) {
        int x;
        cin >> x;
        fre[x] = 1;
    }
    FOR(i,0,9) {
        if (!fre[i]) {
            cnt.PB(i);
        }
    }
    sort(all(cnt));
    REP(i,SZ(cnt)) {
        if (cnt[i] != 0) {
            recur(cnt[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	string S;
	int count = 0;
	cin >> S;

	for (int i = 0; i < S.length()-1; i++) {
		if (S[i] != S[i + 1]) {
			count++;
		}

	}

	cout << count << endl;

	return 0;

}

Measured memory_bytes: 512
h,w = list(map(int,input().split()))
a = [[i for i in input()] for _ in range(h)]
remove = []
for r in range(h):
  flag = True
  for c in range(w):
    if a[r][c] == "#":
      flag = False
      break
  if flag:
    remove.append(r)
for i in range(len(remove)):
  a.pop(remove[i])
  remove = [j-1 for j in remove]
remove = []
for c in range(w):
  flag = True
  for r in range(len(a)):
    if a[r][c] == "#":
      flag = False
      break
  if flag:
    remove.append(c)
for c in range(len(remove)):
  for r in range(len(a)):
    a[r].pop(remove[c])
  remove = [i-1 for i in remove]
  
for r in range(len(a)):
  print("".join(a[r]))

Measured memory_bytes: 3188
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>


using namespace std;

typedef long long LL;


int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

    int n;
    cin >> n;

    LL k;
    cin >> k;
    k++;

    vector<LL> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int p[40];
    for (int l = 0; l < 40; l += 2) {
		LL m0 = 1LL << l;
		LL m1 = m0 << 1;
        LL c = 0;
        for (int i = 0; i < n; i++) {
            c += ((a[i] & m0) > 0) + ((LL)((a[i] & m1) > 0) << 32);
        }
		*(LL *)(p + l) = c;
    }

	function<LL(LL, int, int)> f = [&](LL t, int h, int b) {
		LL s = 0, s1 = 0;
        for (int l = h - 1; l >= 0; l--) {
			LL m = 1LL << l;
            LL c = p[l];
            if (c < n - c && (t ^ m) < k) {
                if (b) s1 = max(s1, f(t, l, 0) + s + (c << l));
                t ^= m;
                s += (n - c) << l;
            } else {
                s += c << l;
            }
        }
        return max(s, s1);
    };

	cout << f(0, 40, 1) << endl;

}

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

int main() {
	int a, b;
 	 cin >> a;
 	 int count =0;

 	 for(int i=0; i<3; i++){
 		 count += !!(a & 1<<i);
 	 }

 	 cout << count << endl;
}


Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define     int 	    long long
#define 	pb 	        push_back
#define 	mp 	        make_pair
#define 	pi 	        2*acos(0.0)
#define     scan(i)     scanf("%d",&i)
#define     loop(i,n) 	for(int i = 0 ; i <n ; i++)
#define 	vect 	    vector<int>
#define 	vec_it 	    vector<int>::iterator vi
#define     sorta(v)    sort(v.begin(),v.end())
#define     sortd(v)    sort(v.begin(),v.end(),greater<>())
#define 	mapp 	    map<char,int>
#define 	pairr 	    pair<int,int>
#define 	sett	    set<int>s
#define 	set_it 	    set<int>::iterator si
#define     map_it      map<char,int> :: iterator mi
#define 	yes 	    cout<<"Yes"<<endl
#define 	no 	        cout<<"No"<<endl
#define 	ff 	        first
#define 	ss 	        second
#define     mx          iNT_MAX
#define     lmx         LLONG_MAX
#define     mn          iNT_MiN
#define     lmn         LLONG_MiN
#define     GCD         __gcd(a,b)
#define     LCM         (a/GCD)*b
template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }

void solve()
{
  // freopen ("(input).txt" , "r",  stdin) ;
   string st,stt ;
  // int low=0,high=0;
  // int l,r;
    int n,k,t,b,c,x,y,z,d=0,temp=0,cnt=0,sum=0,f=0;
    cin>>st;  ; vect v ,a  ; sett ; set_it ; mapp m,mp; pairr p; map_it;
    loop(i,st.size())
    {
        m[st[i]]++;
    }
    for(mi=m.begin();mi!=m.end();mi++)
    {
        temp=mi->ss;
        if(temp&1)
            cnt=1;
    }
    if(cnt==0)
        yes;
    else
        no;


}

main()
{
    int t;
  //  cin>>t;
  //  while(t--)
        solve();
}


Measured memory_bytes: 3596
# vim: fileencoding=utf-8


def main():
    N = int(input())
    l = list(map(int, input().split()))
    c = 0
    for i in range(N):
        li = l[i]
        for j in range(i + 1, N):
            lj = l[j]
            if li == lj:
                continue
            for k in range(j + 1, N):
                lk = l[k]
                if li == lk or lj == lk:
                    continue
                if li < lj + lk and lj < li + lk and lk < li + lj:
                    c += 1
    print(c)


if __name__ == "__main__":
    main()


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 300005;

int main(){
	fastio;
	string a,b;
	cin >> a >> b;
	int ans = mod;
	for(int i = 0; i <= sz(a)-sz(b); i++){
		int cnt = 0;
		for(int j = i, pos = 0; j < i+sz(b); j++, pos++){
			if(a[j] == b[pos])cnt++;
		}
		ans = min(ans, sz(b)-cnt);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3628
import math

def f(i, s):
    global ans
    if s.count(1) > 1:
        return
    if i == d:
        score = 0
        cnt = 0
        notcomp = -1
        for k in range(d):
            if s[k] == 1:
                notcomp = k
            if s[k] == 2:
                score += comp[k]
                cnt += x[k][0]
        if g <= score:
            ans = min(ans, cnt)
        elif not notcomp == -1:
            r = g - score
            if r <= comp[notcomp]:
                cnt += min(math.ceil(r / ((notcomp + 1) * 100)), x[notcomp][0])
                ans = min(ans, cnt)
        return
    for j in range(3):
        s[i] = j
        f(i + 1, s)

d, g = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(d)]
comp = [x[i][0] * 100 * (i + 1) + x[i][1] for i in range(d)]
s = [0] * d
ans = pow(10, 3)
f(0, s)
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
const int INFI=2147483647;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  string s; cin >>s;
  string t1 = "", t2 = "";
  int q; cin >>q;
  bool hanten = false;
  rep(qq, q){
    int tt; cin >>tt;
    if (tt == 1) hanten = hanten ? false : true;
    else{
      int f; cin >>f;
      char c; cin >>c;
      bool sentou = f == 1 ? true : false;
      if (hanten){
        if (sentou){
          t2.push_back(c);
        }else{
          t1.push_back(c);
        }
      }else{
        if (sentou){
          t1.push_back(c);
        }else{
          t2.push_back(c);
        }
      }
    }
  }
  if (hanten){
    reverse(all(s)); reverse(all(t2));
    cout <<t2 <<s <<t1 <<endl;
  }else{
    reverse(all(t1));
    cout <<t1 <<s <<t2 <<endl;
  }
}

Measured memory_bytes: 1088
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        String[] blue=new String[n];
        for(int i=0;i<n;i++)blue[i]=sc.next();
        int m=sc.nextInt();
        String[] red=new String[m];
        for(int i=0;i<m;i++)red[i]=sc.next();
        int[] tmp=new int[2];
        boolean[] visited=new boolean[n];
        int ans=0;
        for(int i=0;i<n;i++){
            tmp[0]=tmp[1]=0;
            for(int j=0;j<n;j++){
                if(blue[i].equals(blue[j])&&!visited[j]){
                    tmp[0]++;
                    visited[j]=true;
                }
            }
            for(int j=0;j<m;j++){
                if(blue[i].equals(red[j]))tmp[1]++;
            }
            ans=Math.max(ans, tmp[0]-tmp[1]);
                    
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(){
    
	int n, a[110] = {}; cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int b; cin >> b;
		if (i == 0) { a[0] = b; a[1] = b; continue; }

		if (b <= a[i]) { a[i] = b; a[i + 1] = b; }
		else { a[i + 1]= b; }
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {ans += a[i];}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
inpl = lambda: list(map(int,input().split()))
from math import sqrt
class Factorizer():
    def __init__(self):
        self.primes_ceil = 3
        self.primes = [2]

    def find_primes(self, primes_ceil):
        prev_primes_ceil, self.primes_ceil = self.primes_ceil, primes_ceil
        for i in range(prev_primes_ceil, self.primes_ceil):
            sieve = 1
            for p in self.primes:
                if p*p > i:
                    break
                elif i % p == 0:
                    sieve = 0
                    break
            if sieve == 0:
                continue
            else:
                self.primes.append(i)

    def __call__(self, n):
        if (self.primes_ceil-1)**2 < n:
            self.find_primes(int(sqrt(n))+1)
        factors = []
        powers = []
        for p in self.primes:
            if p * p > n:
                break
            elif n % p == 0:
                n //= p
                k = 1
                while n % p == 0:
                    n //= p
                    k += 1
                factors.append(p)
                powers.append(k)
        if n > 1:
            factors.append(n)
            powers.append(1)
        return factors, powers

N, P = inpl()
fct=Factorizer()
f, p = fct(P)
n = len(f)
ans = 1
for i in range(n):
    ans *= f[i]**(p[i]//N)
print(ans)

Measured memory_bytes: 6272
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, m, h[100009], a, b;
bool flag[100009];

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        if (h[a] > h[b]) swap(a, b);
        flag[a] = true;
        if (h[a] == h[b]) flag[b] = true;
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (!flag[i]) cnt++;
    }
    cout << cnt << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 4144
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<class T>
class BIT {
    vector<T> bit;
public:
    BIT(int n): bit(vector<T>(n+1, 0)){}

    T sum(int k){
        T ret = 0;
        for (++k; k > 0; k -= (k & -k)) ret += bit[k];
        return ret;
    }

    void add(int k, T x){
        for (++k; k < bit.size(); k  += (k & -k)) bit[k] += x;
    }
};

int main() {
    int q;
    cin >> q;
    set<int> s;

    vector<array<int, 3>> u(q);
    vector<int> z;
    for (int i = 0; i < q; ++i) {
        int x;
        scanf("%d", &x);
        if(x == 1){
            int a, b;
            scanf("%d %d", &a, &b);
            u[i] = {x, a, b};
            z.emplace_back(a);
        }else {
            u[i] = {x};
        }
    }
    z.emplace_back(-INF<int>);
    sort(z.begin(), z.end());
    z.erase(unique(z.begin(), z.end()), z.end());
    auto f = [&z](int i){return lower_bound(z.begin(),z.end(), i) - z.begin(); };
    int m = z.size();
    BIT<ll> S(m);
    BIT<ll> T(m);
    int cnt = 0;
    ll v = 0, vv = 0;
    for (int i = 0; i < q; ++i) {
        if(u[i][0] == 1){
            v += u[i][2];
            vv += u[i][1];
            S.add(f(u[i][1]), 1);
            T.add(f(u[i][1]), u[i][1]);
            cnt++;
        }else {
            int ng = -1, ok = m+1;
            while(ok-ng > 1){
                int mid = (ok+ng)/2;
                if(S.sum(mid) >= (cnt+1)/2) ok = mid;
                else ng = mid;
            }
            printf("%i %lli\n", z[ok], (2*S.sum(ok-1)-cnt)*z[ok] +vv-2*T.sum(ok-1)+v);
        }
    }
    return 0;
}

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

int main(){ 
    int n,m,x;
    cin>>n>>m>>x;
    int b=0;
    vector<int> a(m);
    for(int i=0;i<m;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        if(a[i]<x){
            b++;
        }
    }
    if(m-b*2>0){
        cout<<b;
    }else{
        cout<<m-b;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

ll gcd(ll a,ll b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}

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

  std::string s,t;
  std::cin>>s>>t;

  std::vector<std::string> ans;

  rep(i,0,s.size()-t.size()+1){
    std::string temp=s;
    rep(j,0,i)temp[j]=((s[j]=='?')?'a':s[j]);
    rep(j,i+t.size(),s.size())temp[j]=((s[j]=='?')?'a':s[j]);
    bool isok=true;
    rep(j,i,i+t.size()){
      if(s[j]=='?')temp[j]=t[j-i];
      else {
        if(s[j]!=t[j-i])isok=false;
      }
    }
    if(isok)ans.emplace_back(temp);
  }

  std::sort(all(ans));

  if(ans.empty())std::cout<<"UNRESTORABLE\n";
  else std::cout<<ans[0]<<"\n";

  return 0;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL Ai, Ao, At, Aj, Al, As, Az;
  cin>> Ai>> Ao>> At>> Aj>> Al>> As>> Az;

  LL max = Ai / 2 * 2 + Ao + Aj / 2 * 2 + Al / 2 * 2;
  if (Ai >= 1 && Aj >= 1 && Al >= 1)
  {
    LL x = 3 + (Ai-1) / 2 * 2 + Ao + (Aj-1) / 2 * 2 + (Al-1) / 2 * 2;
    if(x>max){
      max = x;
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int x,y,z,k;
    scanf("%lld %lld %lld %lld",&x,&y,&z,&k);
    vector<long long int> vx(x),vy(y),vz(z);
    REP(i,x){
        scanf("%lld",&vx[i]);
    }
    REP(i,y){
        scanf("%lld",&vy[i]);
    }
    REP(i,z){
        scanf("%lld",&vz[i]);
    }
    //sort(vx.begin(), vx.end(), greater<long long int>());
    //sort(vy.begin(), vy.end(), greater<long long int>());
    sort(vz.begin(), vz.end(), greater<long long int>());

    vector<long long int> vxy(x * y,0);
    REP(i,x){
        REP(j,y){
            vxy[i * y + j] = vx[i] + vy[j];
        }
    }
    sort(vxy.begin(), vxy.end(),greater<long long int>());
    vector<long long int> result(k * z,0);
    REP(i,min(x*y,k)){
        REP(j,z){
            result[i*z+j] = vxy[i] + vz[j];
        }
    }
    sort(result.begin(), result.end(), greater<long long int>());
    REP(i,k){
        cout << result[i] << endl;
    }

    
  

}


Measured memory_bytes: 31616
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>
 
static int gdbi = 0;
 
void
east(int dice[6])
{
    int t = dice[2];
    dice[2] = dice[0]; /* 3 ??? 1 */
    dice[0] = dice[3]; /* 1 ??? 4 */
    dice[3] = dice[5]; /* 4 ??? 6 */
    dice[5] = t;       /* 6 ??? 3 */
}
 
void
south(int dice[6])
{
    int t = dice[1];
    dice[1] = dice[0]; /* 2 ??? 1 */
    dice[0] = dice[4]; /* 1 ??? 5 */
    dice[4] = dice[5]; /* 5 ??? 6 */
    dice[5] = t;       /* 6 ??? 2 */
}
 
void
rotate(int dice[6])
{
    int t = dice[3];
    dice[3] = dice[1]; /* 4 ??? 2 */
    dice[1] = dice[2]; /* 2 ??? 3 */
    dice[2] = dice[4]; /* 3 ??? 5 */
    dice[4] = t;       /* 5 ??? 4 */
}
 
bool
compare(int dice1[6], int dice2[6])
{
    int u, v;
    int i;
 
    u = dice1[0];
    v = dice1[1];
    for (i = 0; i < 4; ++i)
    {
        if (dice2[1] == v)
            break;
 
        south(dice2);
    }
 
    if (dice2[1] != v) /* dice2[2]????????¢???????????????????????? */
    {
        for (i = 0; i < 4; ++i)
        {
            if (dice2[1] == v) /* dice2[2]????????¢??? */
                break;
 
            rotate(dice2);
        }
    }
 
    if (dice2[1] != v)
        return false;
 
    for (i = 0; i < 4; ++i)
    {
        if (dice2[0] == u) /* dice2[1]????????¢??? */
            break;
 
        east(dice2);
    }
 
    for (i = 0; i < 6; ++i)
    {
        if (dice1[i] != dice2[i])
            break;
    }
 
    if (i == 6)
        return true;
    else
        return false;
}
 
bool
solve(int dice[100][6], int n)
{
    int i, j;
 
    for (i = 0; i < n - 1; ++i)
    {
        for (j = i + 1; j < n; ++j)
        {
            if (i == 0 && j == 30)
                gdbi++;
 
            if (compare(dice[i], dice[j]))
                return false;
        }
    }
 
    return true;
}
 
int
main(int argc, char** argv)
{
    int dice[100][6];
    int n;
    int i, j;
 
    scanf("%d\n", &n);
    for (i = 0; i < n; ++i)
    {
        for (j = 0; j < 6; ++j)
            scanf("%d", &dice[i][j]);
    }
 
    printf("%s\n", solve(dice, n) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long> da(n*3);
    for(int i=0;i<n*3;i++){
        cin >> da[i];
    }
    sort(da.begin(),da.end());
    long long ans=0;
    for(int i=0;i<n;i++){
        ans+=da[n+i*2];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
def main():
    n,m = map(int,input().split()) 
    a=[]
    b=[]
    for _ in range(n):
        a.append( list(input()) )
    for _ in range(m):
        b.append( list(input()) )
    key=0
    for i in range(n-m+1):
        for j in range(n-m+1):
            for x in range(m):
                for y in range(m):
                    if b[x][y]==a[i+x][j+y]:
                        continue
                    else:
                        key=1
                        break
                if key==1:
                    break
            if key == 0:
                print("Yes")
                return
            key=0
    print("No")
main()

Measured memory_bytes: 38384
#include <iostream>

using namespace std;

int main() {
  int n;
  bool is = false;
  cin >> n;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (i * j == n) {
        is = true;
      }
    }
  }
  
  if (is) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K; cin>>N>>K;
    vll a(N);
    rep(i,N) cin>>a[i];
    ll ans=(ll)1e18;
    rep(S,1<<N){
        ll maxi=0;
        int cnt = __builtin_popcount(S);
        if (cnt<K) continue;
        ll sum=0;
        rep(i,N){
            if (S>>i&1){
                if (a[i]>maxi){
                    maxi=a[i];
                }else{
                    maxi++;
                    sum+=maxi-a[i];
                }
            }else{
                chmax(maxi,a[i]);
            }
        }
        chmin(ans,sum);
    }
    cout<<ans<<"\n";
    return 0;
}


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

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] X = new int[M];
        int[] Y = new int[M];
        int[] Z = new int[M];
        for (int i = 0; i < M; ++i) {
            X[i] = sc.nextInt() - 1;
            Y[i] = sc.nextInt() - 1;
            Z[i] = sc.nextInt();
        }

        System.out.println(solve(N, X, Y, Z));

        sc.close();
    }

    static int solve(int N, int[] X, int[] Y, int[] Z) {
        int[] parents = new int[N];
        Arrays.fill(parents, -1);

        for (int i = 0; i < X.length; ++i) {
            int rootX = findRoot(parents, X[i]);
            int rootY = findRoot(parents, Y[i]);
            if (rootX != rootY) {
                parents[rootY] = rootX;
            }
        }

        return (int) IntStream.range(0, N).map(i -> findRoot(parents, i)).distinct().count();
    }

    static int findRoot(int[] parents, int node) {
        int root = node;
        while (parents[root] != -1) {
            root = parents[root];
        }

        int p = node;
        while (p != root) {
            int next = parents[p];
            parents[p] = root;

            p = next;
        }

        return root;
    }
}

Measured memory_bytes: 65420