akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct
{
    int x,y;
}a[10];
int main()
{
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d %d",&a[i].x,&a[i].y);
    double ans=0;
    int x=1,nn=n;
    while(nn)
    {
        x*=nn;
        nn--;
    }
    for(i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
    {
    	double c=a[i].x-a[j].x;
    	double b=a[i].y-a[j].y;
        double t=sqrt(c*c+b*b);
        ans+=t*x*2*1.0/n;
    }
    
    printf("%lf\n",ans/x);
	return 0;

}

/*





*/

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

void solve()
{
    ll n,d,x,y,res;
    int count=0;
    cin>>n>>d;
    for (int i = 0; i < n; i++)
    {
       cin>>x>>y;
       res = ceil(sqrtl(x*x+y*y));
       if(res<=d) count++; 
    }
    cout<<count;
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include<string>
using namespace std;
int main(){
	for( ; ; ){
		int a,b;
		cin>>a>>b;
		if(a==0 && b==0){
			break;
		}
		if(a>b){
			cout<<b<<" "<<a<<endl;
		}
		else{
			cout<<a<<" "<<b<<endl;
		}
		
	
	}
	return 0;
}
















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

int main(void){
    int ramen = 700;
    string order;
    cin >> order;
    for (int i=0;i<order.length();i++){

        if(order[i]=='o') {ramen = ramen+100;}
    }
    cout << ramen << endl;

    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>


int top=0;
int s[200];

void push(int x){
  top++;
  s[top]=x;
}

int pop(){
  top--;
  return s[top+1];
}
	



int main(){

  int i,j,k,s1,s2,sum;
  char a[8];

  for(i=0; i<200; i++){
    for(k=0; k<8; k++){
      scanf("%c",&a[k]);
      if(a[k]==' '||a[k]=='\n')
	break;
    }

    

    switch(a[0]){
    case '+':
      s1=pop();
      s2=pop();
      push(s1+s2);
      break;

    case '-':
      s1=pop();
      s2=pop();
      push(s2-s1);
      break;

    case '*':
      s1=pop();
      s2=pop();
      push(s1*s2);
      break;

    default:
      sum=0;
      for(j=0; j<8; j++){
	if(a[j]==' ')
	  break;
	sum=sum*10+(a[j]-48);
      }
      push(sum);
      break;
    }
    if(a[k]=='\n')
      break;

  }
  printf("%d\n",s[1])  ;    
  return 0;
}
    
    


Measured memory_bytes: 2128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);

		String s = in.next();
		String t = in.next();

		char[] s1 = s.toCharArray();
		char[] t1 = t.toCharArray();

		int count = 0;

		for(int i=0;i<s.length();i++) {
			if(s1[i]!=t1[i]) {
				count++;
			}
		}

		System.out.println(count);

	}

}


Measured memory_bytes: 42084
#D

N=int(input())
c=input()
d=list(c)
w=0
ans=0
w_list=[0]*N
w_cnt=0
r_cnt=0

if c.count("W")==0 or c.count("W")==N:
    ans=0
else:
    for i,j in enumerate(d):
        if j=="W":
            w_cnt +=1
        else:
            w_list[i]=w_cnt
            r_cnt += 1
            
    #print(w_list)
    #print("r個数",r_cnt)

    for i in range(N-1,-1,-1):
        if d[i]=="R":
            r_cnt -= 1
            
            if w_cnt>0:
                ans += 1
                w_cnt -= 1 
            else:
                break
        else:
            w_cnt -= 1
            if w_cnt<=0:
                break
        #print(N-1-i, r_cnt, w_cnt)
        
print(ans)

Measured memory_bytes: 13648
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
    
int run_test(){
	int n;
	cin >> n;
	int arr[n + 1];
	for(int i=1;i <= n; i++){
		cin >> arr[i];
	}
	int check[n + 1], ans = 0;
	fill(check, 0);
	for(int i=n; i>=1; i--){
		int sum = 0;
		for(int j=i; j<=n; j+=i){
			sum += check[j];
		}
		if(sum % 2 != arr[i] % 2){
			check[i] = 1;
			ans++;
		}
	}
	cout << ans << "\n";
	for(int i=1; i <=n ; i++){
		if(check[i]){
			cout << i << " ";
		}
	}
	return 0;
}
    
int main(){
   FAST;
    ll t;
    t = 1;
     
    while(t--){
        run_test();
    }
}

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

using namespace std;

typedef int64_t ll;
#define For(i, a, b) for(ll i = a; i <= b; i++)

int main()
{
	ll n, x, ans = 0;
//	freopen("test.in", "r", stdin);
//	freopen("test.ok", "w", stdout);
	cin >> n;
	while (n--)
	{
		cin >> x;
		ans += x - 1;
	}
	cout << ans << "\n";
}

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

using namespace std;

#define LIMIT 100
typedef pair<int64_t, int64_t> ii;
typedef int64_t ll;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b;
  cin >> a >> b;
  std::cout << (a+b+1)/2 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  string s;
  scan(s);
  bool a = false;
  bool b = false;
  rep (i, 3) {
    if (s[i] == 'A') {
      a = true;
    }
    if (s[i] == 'B') {
      b = true;
    }
  }
  if (a & b) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


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

using namespace std;

int main()
{
    int N, d;
    cin >> N;
    int a = N;
    vector<int> v;

    for (int i = 0; i < N; i++)
    {
        cin >> d;
        v.push_back(d);
    }

    sort(v.begin(), v.end());

    for (int i = 0; i < N - 1; i++)
    {
        if (v[i] == v[i + 1])
        {
            a--;
        }
    }

    cout << a;
}

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

typedef long long LL;

//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 DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#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)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int m,t,p,r;
    cin >> m >> t >> p >> r;
    if(!m&&!t&&!p&&!r) return 0;
    vector<vector<int> > act;
    // t,p: -20*wa
    act.resize(t);
    REP(i,t) act[i].assign(p,0);
    REP(i,r){
      int tid,pid,time,sta;
      cin >> time >> tid >> pid >> sta;
      time++;tid--;pid--;
      if(act[tid][pid]>0) continue;
      if(sta) act[tid][pid]-=20;
      else act[tid][pid]=time-act[tid][pid];
    }
    vector<pair<pair<int,int>,int> > score;
    // -AC,penalty,-team
    REP(i,t) score.PB(MP(MP(0,0),-i-1));
    REP(i,t) REP(j,p) if(act[i][j]>0){
      score[i].first.first-=1;
      score[i].first.second+=act[i][j];
    }
    SORT(score);
    REP(i,t){
      if(i){
	if(score[i-1].first==score[i].first) cout << '=';
	else cout << ',';
      }
      cout << -score[i].second;
    }
    cout << endl;
  }
}

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

int main() {
  int N;
  cin >> N ;
  
  int a,b,c,d;
  a=0;
  b=0;
  c=0;
  d=0;
  
  for (int i = 0; i < N; i++) {
  string S;
  cin >> S;

    if (S == "G") {
      a++;
    }
    else if (S == "P") {
      b++;
    }
    else if (S == "Y") {
      c++;
    }
    else if (S == "W") {
      d++;
    }
    
    
  }
  if(a>=1 && b>=1 && c>=1 && d>=1){
       cout << "Four"<< endl;
  }
 
 else{
     cout<< "Three"<<endl;
 }

}


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

void solve(long long N){
  //cout << N << endl;
  ll ans = 0;
  for(ll x = 1; x * x < N - x; ++x){
    if((N - x) % x == 0 ){
      //cout << x << endl;
      ans += (N - x) / x;
    }
  }
  cout << ans << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
typedef vector< int > vi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef vector< ll > vll;
// #define DEBUG_MODE
#ifdef DEBUG_MODE
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(x) fprintf(stderr, "[%s = %d]\n", #x, x)
#else
	#define errp(...)
	#define dbg(x) 
#endif


int main () { 
#ifdef DEBUG_MODE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll x;
	scanf("%lld", &x);
	ll res = 2 * (x / 11);
	x = x % 11;
	if (x > 6) res += 2;
	else if (x > 0) res++;
	printf("%lld\n", res);
}


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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

int n, m;
VPII dss;

#define s first
#define d second

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	while (1) {
		dss.clear();
		cin >> n >> m;
		if (n == 0 && m == 0) break;
		dss.resize(n);
		rep (i, n) {
			cin >> dss[i].d >> dss[i].s;
		}
		sort(rall(dss));
		for (PII &p : dss) {
			if (m < 0) break;
			int dist = p.d;
			p.d = max(dist - m, 0);
			m -= dist;
		}
		int ans = 0;
		for (PII p : dss) {
			ans += p.d * p.s;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
#include<iostream>
using namespace std;
const int N_MAX = 12, M_MAX = 12;
int N, M;
int k[M_MAX], p[M_MAX], s[M_MAX][N_MAX];
int ans;
int state = 0;

void dfs(int pos) {
    if(pos == N+1) {
        // 最終判定

        bool flag = true;
        for(int i = 0; i < M; ++i) {
            int on = 0;
            for(int j = 0; j < k[i]; ++j) {
                if( (state & (1 << s[i][j])) != 0 ) { ++on; }
            }
            if((on%2) != p[i]) { flag = false; break; }
        }
        if(flag) { ++ans;}
    }
    else {
        state += (1 << pos);
        dfs(pos + 1);
        state -= (1 << pos);
        dfs(pos + 1);
    }
}

void solve(){
    ans = 0;
    dfs(1);
    cout << ans << endl;
}

int main()
{
    cin >> N >> M;
    for(int i = 0; i < M; ++i) {
        cin >> k[i];
        for(int j = 0; j < k[i]; ++j) {
            cin >> s[i][j];
        }
    }
    for(int i = 0; i < M; ++i) {
        cin >> p[i];
    }
    solve();
    return 0;
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int N, M;
int depth[55];
vector<int> G[55];
int par[55];
vector<int> Cs[22];//Cs[i]:=i番目の制約に含まれる辺番号(葉側の頂点番号)の集合

void dfs(int v, int p, int d) {
    depth[v] = d;
    par[v] = p;
    for (int to:G[v]) {
        if (to == p)continue;
        dfs(to, v, d + 1);
    }
}

signed main() {
    cin >> N;
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0, -1, 0);
    cin >> M;
    rep(i, M) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        if (depth[u] < depth[v])swap(u, v);
        while (depth[u] > depth[v]) {
            Cs[i].push_back(u);
            u = par[u];
        }
        while (u != v) {
            Cs[i].push_back(u);
            Cs[i].push_back(v);
            u = par[u];
            v = par[v];
        }
    }
    int ans = (1l << (N - 1));
    bool bs[55];
    rep(i, (1l << M)) {
        if (i == 0)continue;
        memset(bs, 0, sizeof(bs));
        int xcnt = 0;
        rep(j, M) {
            if ((i >> j) & 1) {
                for (int v:Cs[j]) {
                    if (bs[v])continue;
                    bs[v] = true;
                    xcnt++;
                }
            }
        }
        int popcnt = __builtin_popcount(i);
        if (popcnt % 2 == 1) {
            ans -= (1l << (N - 1 - xcnt));
        } else {
            ans += (1l << (N - 1 - xcnt));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    while (in.hasNext()) {
      int n = in.nextInt();
      int halfN = n / 2;
      int[] v = new int[n];
      int[] countOdd = new int [MAX_V + 1];
      int[] countEven = new int [MAX_V + 1];

      for (int i = 0; i < v.length; ++i) {
        v[i] = in.nextInt();

        if (i % 2 == 0) {
          ++countEven[v[i]];
        } else {
          ++countOdd[v[i]];
        }
      }
      
      int evenMax1 = -1;
      int evenMax1Count = 0;
      for (int i = 0; i < countEven.length; ++i) {
        if (countEven[i] > evenMax1Count) {
          evenMax1 = i;
          evenMax1Count = countEven[i];
        }
      }

      countEven[evenMax1] = 0;
      int evenMax2Count = 0;
      for (int i = 0; i < countEven.length; ++i) {
        if (countEven[i] > evenMax2Count) {
          evenMax2Count = countEven[i];
        }
      }

      int oddMax1 = -1;
      int oddMax1Count = 0;
      for (int i = 0; i < countOdd.length; ++i) {
        if (countOdd[i] > oddMax1Count) {
          oddMax1 = i;
          oddMax1Count = countOdd[i];
        }
      }

      countOdd[oddMax1] = 0;
      int oddMax2Count = 0;
      for (int i = 0; i < countOdd.length; ++i) {
        if (countOdd[i] > oddMax2Count) {
          oddMax2Count = countOdd[i];
        }
      }

      if (evenMax1 != oddMax1) {
        System.out.println(halfN - evenMax1Count + halfN - oddMax1Count);
      } else {
        int min = Math.min(halfN - evenMax1Count + halfN - oddMax2Count, halfN - evenMax2Count + halfN - oddMax1Count);
        System.out.println(min);
      }
    }
  }
}

Measured memory_bytes: 64784
def BC(A,K):
    """2分探索によって,x未満の要素の個数を調べる.

    A:リスト
    x:調べる要素
    sort:ソートをする必要があるかどうか(Trueで必要)
    equal:Trueのときはx"未満"がx"以下"になる
    """
    N=max(A)+1
    
    L,R=0,N
    while R-L>1:
        C=L+(R-L)//2

        M=0
        for a in A:
            M+=(a+C-1)//C-1

        if M<=K:
            R=C
        else:
            L=C
    return R


N,K=map(int,input().split())
A=list(map(int,input().split()))
print(BC(A,K))


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

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

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

  int ans = 0,sum = 0;
  int r = 0;
  for(int l = 0; l < n; l++){
    while(r < n && (sum^a[r]) == sum+a[r]){
      sum ^= a[r++];
    }
    //cout << l << " " << r << endl;
    ans += (r - l);

    if(l == r) r++;
    else sum ^= a[l];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
using namespace std;
int main() {
  int n;cin>>n;
  int* stones = new int[n];
  int* dp = new int[n];
  for(int i=0;i<n;i++)cin>>stones[i];
  dp[0]=0;
  dp[1]=abs(stones[1]-stones[0]);
  for(int i=2;i<n;i++) {
  	dp[i]=min(dp[i-1]+abs(stones[i]-stones[i-1]),dp[i-2]+abs(stones[i-2]-stones[i]));
  }
  if(n>=1)cout<<dp[n-1]<<endl;
  else cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#define MOD 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;

signed main(){
    int x,y,z,k;
    cin>>x>>y>>z>>k;
    int a[114514],b[114514],c[114514];
    for(int i=0;i<x;i++)cin>>a[i];
    for(int i=0;i<y;i++)cin>>b[i];
    for(int i=0;i<z;i++)cin>>c[i];
    vector<int> ab;
    for(int i=0;i<x;i++){
        for(int j=0;j<y;j++){
            ab.push_back(a[i]+b[j]);
        }
    }
    sort(ab.begin(),ab.end(),greater<int>());
    sort(c,c+z,greater<int>());
    vector<P> com;
    int cnt=1;
    while(1){
        int m=com.size();
        for(int i=m-1;i>=m-cnt+1;i--){
            com.push_back(make_pair(com[i].first, com[i].second+1));
        }
        com.push_back(make_pair(cnt,1));
        cnt++;
        if(cnt==k+1)break;
    }
    vector<int> ans;
    for(int i=0;i<com.size();i++){
        if(com[i].first-1<ab.size()&&com[i].second-1<z){
            ans.push_back(ab[com[i].first-1]+c[com[i].second-1]);
        }
    }
    sort(ans.rbegin(),ans.rend());
    for(int i=0;i<k;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 143580
#include <bits/stdc++.h>
namespace xxx{
using namespace std;
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define CaseT int T;cin >> T;for(int cas=1;cas<=T;cas++)
#define TCase int T;scanf("%d",&T);for(int cas=1;cas<=T;cas++)
#define clr(a,b) memset(a,b,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define _1s __builtin_popcountll
#define sqr(x) ((x)*(x))
#define upd(a,b) (a%b?a/b+1:a/b)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define fst first
#define sec second
#define MAIN int main
#define GG exit(0)
#define bug cout << "!!!" << endl;
#define bugc(x) cout << "! " << (x) << endl;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const double EPS = 1e-8;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;

inline ll rd(){
    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;
}
 
}using namespace xxx;
const int N = 1e5+20;

MAIN(){
	int ans = INF;
	int n, t;
	cin >> n >> t;
	int c, w;
	while(n--){
		cin >> c >> w;
		if(w<=t) ans = min(ans,c);
	}
	if(ans==INF) cout << "TLE" << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
S=input()
Clusters=S.replace("><","> <").split(" ")
ans=0
for c in Clusters:
  r=c.count('>')
  l=c.count('<')
  M=max(r,l)
  m=min(r,l)
  ans+=max(0,M*(M+1)//2)+max(0,(m)*(m-1)//2)
print(ans)





Measured memory_bytes: 12956
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int
int main(){
   ll n , i , sum = 0 , m , sum1 = 0;
   cin >> n ;
   vector<ll>v(n) ;
   for(i = 0 ; i < n ; i++){
   	cin >> v[i] ;
   }
   for(i = 0 ; i < n ; i++){
       sum += v[i] ;
   }
   m = sum / n ;
   sum = 0 ;
   for(i = 0 ; i < n ; i++){
   	  sum += (v[i] - m) * (v[i] - m ) ;
   }
    for(i = 0 ; i < n ; i++){
   	 sum1 += (v[i] - (m + 1)) * (v[i] - (m + 1)) ;
   }
   cout << min(sum , sum1) ;
}

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

int main(){
  string S;
  cin >> S;
  string A="";
  int size;
  
  for(int i=0; i<S.size(); i++){
    if(S.at(i)=='0') {A.push_back('0');}
    else if(S.at(i)=='1') {A.push_back('1');}
    else if(S.at(i)=='B') {A = A.substr(0,A.size()-1);}
    //cout << A << endl;
  }
  
  cout << A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    long long a[n];
    long long b[n];
    long long s = 0;
    REP(i, n)
    {
        cin >> a[i];
        s += a[i];
    }

    b[0] = s;
    for (int i = 1; i < n; i += 2)
    {
        b[0] -= 2 * a[i];
    }

    for (int i = 1; i < n; i++)
    {
        b[i] = 2 * a[i - 1] - b[i - 1];
    }

    REP(i, n)
    {
        if (i == 0)
        {
            cout << b[i];
        }
        else
        {
            cout << " " << b[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
#define INF 1e9

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> h(N+1);
    for(int i = 1;i <= N;i++)   cin >> h[i];
    vector<int> dp(N+1, INF);
    dp[1] = 0;
    for(int i = 1;i <= N;i++){
        for(int j = i+1;j <= min(i+K, N);j++){
            dp[j] = min(dp[j], dp[i]+abs(h[i]-h[j]));
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
X = int(input())

gojyous = []

for i in range(-200, 201):
    gojyous.append(i ** 5)

#print(gojyous)

for i in range(-200,201):
    for j in range(-200,201):
        if(X == (int(i**5) - int(j**5))):
            print(i, j)
            exit()

Measured memory_bytes: 65588
N = int(input())
result = []
tmp = ""

for i in range(N):
  tmp = str(input())
  result.append(tmp)

print("AC x", end=" ")
print(result.count("AC"))
print("WA x", end=" ")
print(result.count("WA"))
print("TLE x", end=" ")
print(result.count("TLE"))
print("RE x", end=" ")
print(result.count("RE"))

Measured memory_bytes: 16164
#include<iostream>
using namespace std;
int main() {
    int a;
    int b;
    char op;
    while (1) {
        cin >> a >> op >> b;
        if (op =='?') break;
        if (op =='+') {
            cout << a+b << endl;
        } else if (op =='-') {
            cout << a-b << endl;
        } else if (op =='*') {
            cout << a*b << endl;
        } else if (op =='/') {
            cout << a/b << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    int n, t; cin>>n>>t;
    vector<int> a(n); for(auto& e: a) cin>>e;

    int mina=a[0];
    map<int, int> x;
    for(auto& e: a) {
        int d=e-mina;
        if (d>0) x[d]++;
        mina=min(mina, e);
    }
    cout<<(*rbegin(x)).second<<endl;
}


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

typedef long long long64;

long64 inline distance(long64 s, long64 t, long64 p)
{
	long64 d = abs(s - t);
	long64 d1 = abs(p - s);
	long64 d2 = abs(p - t);

	if (d1 < d2)
		return d1 + d;
	else
		return d2 + d;
}

int main()
{
	size_t s_num, t_num, p_num;
	std::cin >> s_num >> t_num >> p_num;

	std::vector<long64> s(s_num);
	std::vector<long64> t(t_num);
	std::vector<long64> p(p_num);

	for (size_t i = 0; i < s_num; i++)
	{
		std::cin >> s[i];
	}

	for (size_t i = 0; i < t_num; i++)
	{
		std::cin >> t[i];
	}

	for (size_t i = 0; i < p_num; i++)
	{
		std::cin >> p[i];
	}

	std::sort(s.begin(), s.end());
	std::sort(t.begin(), t.end());

	for (size_t i = 0; i < p.size(); i++)
	{
		long64 min_s = abs(s[0] - p[i]);
		size_t index_s = 0;
		long64 min_s_l;
		long64 min_s_r;
		long64 min_t_l;
		long64 min_t_r;

		auto find = [](long64& l, long64& r,long64 p, std::vector<long64>& array)
		{
			auto it_s = std::lower_bound(array.begin(), array.end(), p);
			if (it_s == array.end()) {
				r = l = array.size() - 1;
			}
			else {
				r = std::distance(array.begin(), it_s);
				if (it_s != array.begin()) {
					it_s--;
					if (it_s == array.end()) {
						l = r;
					}
					else {
						l = std::distance(array.begin(), it_s);;
					}
				}
				else {
					l = r = 0;
				}
			}
		};

		find(min_s_l, min_s_r, p[i], s);
		find(min_t_l, min_t_r, p[i], t);

		long64 mins[4] = {};
		mins[0] = distance(s[min_s_l], t[min_t_l], p[i]);
		mins[1] = distance(s[min_s_l], t[min_t_r], p[i]);
		mins[2] = distance(s[min_s_r], t[min_t_l], p[i]);
		mins[3] = distance(s[min_s_r], t[min_t_r], p[i]);


		long64 min = mins[0];
		for (size_t i = 0; i < 4; i++) {
			if (min > mins[i]) {
				min = mins[i];
			}
		}

		std::cout << min << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3712
let () =
  let s, k =
    Scanf.scanf "%s %d" (fun x y -> x, y) in

  let length = String.length s in

  let rec loop str begin_ end_ result =
    if begin_ = length then
      result 
    else
      begin
        let result = (String.sub str begin_ end_) :: result in
        if begin_ + end_ = length || end_ = k then
          loop str (begin_ + 1) 1 result
        else
          loop str begin_ (end_ + 1) result
      end
  in
  let substr = loop s 0 1 [] in
  let substr' = List.sort_uniq compare substr in
  print_endline (List.nth substr' (k - 1))
      


Measured memory_bytes: 6144
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数

int main()
{
	int a,b;
	cin >> a >> b;

	cout << max(max(a+b,a-b),a*b) << endl;

}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			string s = cin.Next();
			if (s == "SUN") {
				Console.WriteLine(7);
			} else if (s == "MON") {
				Console.WriteLine(6);
			} else if (s == "TUE") {
				Console.WriteLine(5);
			} else if (s == "WED") {
				Console.WriteLine(4);
			} else if (s == "THU") {
				Console.WriteLine(3);
			} else if (s == "FRI") {
				Console.WriteLine(2);
			} else{
				Console.WriteLine(1);
			}
		}
	}


	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 11220
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(void)
{ 
  int yama[10];
  for (int i = 0; i < 10; i++){
    scanf("%d", &yama[i]);
  }
  sort(yama, yama + 10);
  
  for (int i = 9; i >= 7; i--){
    cout << yama[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
N = gets.to_i
S = Array.new(N + 1,0)
gets.split.map(&:to_i).each_with_index do |a,i|
  S[i + 1] = S[i] + a
end
puts (1 ... N).map{|i| (S[N] - 2 * S[i]).abs }.min

Measured memory_bytes: 18436
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var p = new bool[1000000];
        GeneratePrime(p);
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var count = 0;
            for (int i = 0; i <= n / 2; i++)
                if (p[i] && p[n - i]) count++;
            Console.WriteLine(count);
        }
    }
    public static void GeneratePrime(bool[] p)
    {
        int prime;
        var m = p.Length;
        var sqrtMax = Math.Sqrt(m);
        var searchList = Enumerable.Range(2, m - 1).ToList();
        do
        {
            prime = searchList.First();
            p[prime] = true;
            searchList.RemoveAll(n => n % prime == 0);
        }
        while (prime < sqrtMax);
        foreach (var x in searchList)
            p[x] = true;
    }
}

Measured memory_bytes: 18612
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) < (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;
using unit= unsigned;
using ull = unsigned long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vvi = vector<vi>;
using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T>bool chmax(T &a, const T &b){ if (a<b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if (b<a){ a = b; return 1; } return 0; }
template<class T>T gcd(T a, T b){ if (b==0){ return a; }else{ return gcd(b, a%b); }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
constexpr double eps = 1e-10;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;

void _main() {
  int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
  int H, W;
  cin >> H >> W;
  vv(char) A(H, v(char)(W));
  vvi D(H, vi(W, 0));
  queue<P> que;
  rep(i, 0, H) rep(j, 0, W) cin >> A[i][j];
  rep(i, 0, H) rep(j, 0, W) if (A[i][j] == '#') que.push({i,j});

  int ans = 0;
  while (!que.empty()) {
    P p = que.front(); que.pop();
    int x = p.fi;
    int y = p.se;
    int d = D[x][y];
    ans = d;
    rep(i, 0, 4) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (nx < 0 || ny < 0 || H <= nx || W <= ny) continue;
      if (A[nx][ny] == '#') continue;
      que.push({nx,ny});
      A[nx][ny] = '#';
      D[nx][ny] = d + 1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 13456
from collections import deque

n = int(input())
A = list(map(int, input().split()))
B = deque()
for i in range(n):
    if(i%2 == 0):
        B.append(A[i])
    if(i%2 == 1):
        B.appendleft(A[i])

if(n%2 == 1):
    B.reverse()
text = ""
for b in B:
    text += str(b) + " "
text = text[:-1]
print(text)

Measured memory_bytes: 25920
#include <iostream>
#include <algorithm>
using namespace std;
int main(){	
	int a, b, count = 0, ans = 0;
	double ans2 = 0;
	char c;
	while (cin >> a >> c >> b){
		ans += a*b;
		ans2 += b;
		count++;
	}
	ans2 /= count;
	ans2 += 0.5;
	cout << ans << endl << (int)ans2 << endl;
}

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

int main(){
  int N,M;

  cin >> N >> M;
  vector<int> H(N);
  vector<bool> f(N, true);
  rep(i, N){
    cin >> H[i];
  }
  rep(i, M){
    int a,b;
    cin >> a >> b;
    a--; b--;
    if(H[a] > H[b]){
      f[b] = false;
    }else if(H[b] > H[a]) {
      f[a] = false;
    }else{
      f[a] = false;
      f[b] = false;
    }
  }
  int ans = 0;
  rep(i, N){
    if(f[i]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3784
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
//---------------------------------------------
 
string s;
bool check(int a,int b,int c)
{
    if(s[a]==s[b]) return false;
    if(s[b]==s[c]) return false;
    if(s[a]==s[c]) return false;

    return true;
}

int main(void)
{
ll n;

cin>>n;
cin>>s;

ll r,g,b;
r=g=b=0;

rep(i,n)
{
    if(s[i]=='R') r++;
    if(s[i]=='G') g++;
    if(s[i]=='B') b++;
}
ll out =0;




for(int l=1;l<=n;l++)
{


for(int i=0;i+l+l<n;i++)
{
    if(check(i,i+l,i+2*l)) out++;

}
}
cout<<(r*g*b)-out<<endl;

}

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

int main(){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if(b-a > k || c-a > k || d-a > k || e-a > k || c-b > k || d-b > k || e-b > k || d-c > k || e-c > k || e-d > k){
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;

    return 0;
}

Measured memory_bytes: 3588
import std.stdio;
import std.string;
import std.array;
import std.range;
import std.algorithm;
import std.conv;

void main(string[] args) {
  auto input = readln().chomp.split.map!(to!int);
  max(input[0]+input[1],input[0]-input[1],input[0]*input[1]).writeln;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int A[202020];
int d[70][202020];

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

	int N;
	ll K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i]--;
	}

	for (int i = 0; i < 70; i++) {
		for (int j = 0; j < 202020; j++) {
			d[i][j] = -1;
		}
	}

	for (int i = 0; i < N; i++) {
		d[0][i] = A[i];
	}

	for (int i = 1; i < 70; i++) {
		for (int j = 0; j < N; j++) {
			d[i][j] = d[i-1][d[i-1][j]];
		}
	}

	ll cur = 0;
	for (int i = 60; i >= 0; i--) {
		if ((1LL << i)&K) {
			cur = d[i][cur];
		}
	}
	puts(cur + 1);
	return 0;
}

Measured memory_bytes: 59664
H, W = map(int, input().split())

LL = []
for i in range(H):
    L = input()
    LL.append(L)

ans_H = []
for i in range(H):
    if "#" in LL[i]:
        ans_H.append(i)

ans_W = []
for i in range(W):
    cnt = 0
    for j in range(H):
        if LL[j][i] == "#":
            cnt = 1
    if cnt == 1:
        ans_W.append(i)


for i in ans_H:
    for j in ans_W:
        print(LL[i][j], end = "")
    print()

Measured memory_bytes: 4468
import java.util.*;

public class Main {

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

            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int c = scanner.nextInt();
            
            if((a+b+c) >= 22){
                System.out.println("bust");
            }else{
                System.out.println("win");
            }
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    if (fopen("Test.INP", "r"))
        freopen("Test.INP", "r", stdin);

    int n;
    cin >> n;

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

    int dp[n];
    dp[0] = 0;

    for (int i = 1; i < n; ++i)
    {
        dp[i] = dp[i - 1] + abs(h[i] - h[i - 1]);
        if (i > 1)
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[n - 1];
    return 0;
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    int sum = 0;
    rep(0, i, M)
    {
        int a;
        cin >> a;
        sum += a;
    }
    if (N < sum)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << N - sum << endl;
    }
}

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

using namespace std;

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define sz(x) int32_t(x.size())

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// --------------------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9 + 7;
const int inf = 2e18;
const ld eps = 1e-9;
const int NN = 2e5 + 2;

vvi g(NN);


void solve() {
	int i = 0, j = 0, k = 0, n = 0, m = 0;
	cin >> k >> m;
	if(m >= k) cout << "unsafe";
	else cout << "safe\n";
	cout << endl;
}

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
	// cin >> T;
	for(int tc = 1; tc <= T; tc++) {
		solve();
	}

	return 0;
}

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

public class Main {
	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();

		Map<Integer,Integer> data=new HashMap<Integer,Integer>();

		for(int i=0;i<n;i++) {

			int buf=sc.nextInt();

			if(data.containsKey(buf)) {
				data.put(buf,data.get(buf)+1);
			}else {
				data.put(buf,1);
			}

		}

		int ans=0;

		for(int key:data.keySet()) {

			int counter=0;

			for(int i=key-1;i<=key+1;i++) {
				//-1 0 1
				//着目してるキーより一つ少ない、着目してるキー、着目してるキーより一つ多い

					if(data.containsKey(i)) counter+=data.get(i);
			}

			//比較して更新していく。

			ans=Math.max(ans,counter);

		}

		System.out.println(ans);

	}


}


Measured memory_bytes: 61960
#include<stdio.h>

int main(void){
  int i,j,H,W;

  scanf("%d%d",&H,&W);
  while(H!=0||W!=0){
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
        putchar('#');
      }
      putchar('\n');
    }
    putchar('\n');
    scanf("%d%d",&H,&W);
  }
  return 0;
}

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

int main(void)
{
char S[4];
  scanf("%s", &S);
  if (strcmp(S, "AAA") == 0 || strcmp(S, "BBB") == 0) {
    printf("No\n");
  } else {
    printf("Yes\n");
  }
  return 0;
}

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

using namespace std;

#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

const int mod = 10000;

string A, B;
int M;

// dp[index][islower][mod][zig-zag][prev]
int dp[501][2][500][3][10];

int solve(const string& s, int idx, int lt, int m, int zg, int prev)
{
  if(idx == s.size()) return m == 0;

  int& ret = dp[idx][lt][m][zg][prev];
  if(~ret) return ret;

  ret = 0;
  int lim = lt ? 9 : s[idx]-'0';
  rep(d, lim + 1) {
    int zgzg = -1;
    if(zg == 0) { // start
      if(prev == 0) zgzg = 0;
      else if(d == prev) continue;
      else if(d < prev) zgzg = 1;
      else if(d > prev) zgzg = 2;
    } else if(zg == 1) { // up
      if(d <= prev) continue;
      else zgzg = 2;
    } else if(zg == 2) { // down
      if(d >= prev) continue;
      else zgzg = 1;
    }
    assert(zgzg != -1);
    (ret += solve(s, idx+1, lt||d<lim, (m*10+d)%M, zgzg, d)) %= mod;
  }

  return ret % mod;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> A >> B >> M;

  for(int i = (int)A.size()-1; i >= 0; i--) {
    if(A[i] == '0') {
      A[i] = '9';
    } else {
      A[i]--;
      break;
    }
  }

  memset(dp, -1, sizeof(dp));
  int a = solve(A, 0, 0, 0, 0, 0);
  memset(dp, -1, sizeof(dp));
  int b = solve(B, 0, 0, 0, 0, 0);

  cout << (b - a + mod) % mod << endl;

  return 0;
}

Measured memory_bytes: 61868
import sys
sys.setrecursionlimit(10**7)
h,w,d=map(int,input().split())
pos=[0]*(h*w+1)
for i in range(h):
    a=list(map(int,input().split()))
    for j in range(w):
        pos[a[j]]=(i,j)
ans=[0]*(h*w+1)
visited=[True]*(h*w+1)
def dfs(s,nxt):
    if nxt>h*w:
        return 
    visited[s]=False
    dfs(nxt,nxt+d)
    x,y=pos[s]
    nx,ny=pos[nxt]
    ans[s]+=ans[nxt]+abs(nx-x)+abs(ny-y)
for i in range(1,h*w+1):
    if visited[i]:
        dfs(i,i+d)
q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    print(ans[l]-ans[r])

Measured memory_bytes: 95872
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    int M = 2*N;
    int a = 0;
    for(ll i = 1; i*i <= M; i++){
        if(i*(i+1) == M){
            a = i;
            break;
        }
    }
    if(a == 0) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        cout << a+1 << endl;
        vector<vector<int>> ans(a+1,vector<int>(a+1));
        rep(i,a+1) ans[i][0] = a;
        int now = 1;
        repr(j,1,a+1)repr(i,j,a+1){
            ans[i][j] = now;
            ans[j-1][i] = now;
            now++;
        }
        rep(i,a+1){
            rep(j,a+1){
                cout << ans[i][j] << " ";
            }
            cout << endl;
        }
    }
}


Measured memory_bytes: 2176
#include<stdio.h>
int main(){
  long num;

  scanf("%ld", &num);

  int max=0;
  bool eq=true;
  int i;
  if( num < 10){ printf("%ld\n",num); return 0; }
  for(;num>100; num=num/10){
    max += 9;
    if( (num%10) != 9) eq=false;
  }
  int top2 = num;
  if( ((top2%10) ==9)&& eq){
    max += top2/10;
    max += 9;
  }else{
    max += (top2/10)-1;
    max += 9;
  }

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


Measured memory_bytes: 128