akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>

using namespace std;

inline int ctoi(const char c)
{
	return c >= '0'&&c <= '9' ? c - '0' : -1;
}

int main()
{
	int h, w;
	cin >> h >> w;

	vector<string> s(h);

	int i, j, k;
	for (i = 0; i < h; i++) {
		cin >> s[i];
	}

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

	int next_i, next_j, num;
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				continue;
			}
			num = 0;
			for (k = 0; k < 8; k++) {
				next_i = i + dx[k];
				next_j = j + dy[k];
				if (next_i < 0 || next_i >= h || next_j < 0 || next_j >= w) {
					continue;
				}
				if (s[next_i][next_j] == '#') {
					num++;
				}
			}
			s[i][j] = num + '0';
		}
	}

	for (i = 0; i < h; i++) {
		cout << s[i] << endl;;
	}

	return 0;
}


Measured memory_bytes: 256
a, b, c, d, e, f = gets.chomp.split(' ').map(&:to_f)
max = 0
limit = e/(100+e)
a *= 100
b *= 100
result = [0, 0]
for i in 0..(f/a)
  for j in 0..(f-a*i)/b
    w = (a*i+b*j).to_f
    for k in 0..(f-w)/c
      for l in 0..(f-w-c*k)/d
        next if i+j==0 || k+l==0
        s = (c*k+d*l).to_f
        con = s/(s+w)
        next if limit < con
        if max < con
          max = con
          result[0] = s+w
          result[1] = s
        end
      end
    end
  end
end

result.map!(&:to_i)
if result[1] > 0
  puts "#{result[0]} #{result[1]}"
else
  puts "#{a.to_i} #{result[1]}"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "Yes" : "No")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

template <class T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using ordered_multiset = tree <T, null_type, less_equal <T>, rb_tree_tag, tree_order_statistics_node_update>;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "1";



int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    string s;
    cin >> s;
    int sum = 0;
    for (auto &c : s) {
        sum += (c - '0');
    }

    cout << yn(sum % 9 == 0) << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3748
import java.util.*;
import java.io.*;

public class Main {

	public static int h, w;
	public static final int mod = 1000000007;
	public static boolean[][] map;
	public static int[][] dp;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		h = Integer.parseInt(s[0]);
		w = Integer.parseInt(s[1]);
		map = new boolean[h][w];
		dp = new int[h][w];

		String st;
		for (int i = 0; i < h; i++) {
			st = br.readLine();
			for (int j = 0; j < w; j++)
				if (st.charAt(j) == '.')
					map[i][j] = true;
		}

		dp[0][0] = 1;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int k = i - j;
				if (k < 0)
					break;
				if (!map[k][j])
					continue;
				if (k - 1 >= 0 && map[k - 1][j]) {
					dp[k][j] += dp[k - 1][j];
					dp[k][j] %= mod;
				}
				if (j - 1 >= 0 && map[k][j - 1]) {
					dp[k][j] += dp[k][j - 1];
					dp[k][j] %= mod;
				}
			}
		}
		for (int j = 1; j < w; j++) {
			for (int i = h - 1; i >= 0; i--) {
				int k = j + h - i - 1;
				if (k == w)
					break;
				if (!map[i][k])
					continue;
				if (i - 1 >= 0 && map[i - 1][k]) {
					dp[i][k] += dp[i - 1][k];
					dp[i][k] %= mod;
				}
				if (k - 1 >= 0 && map[i][k - 1]) {
					dp[i][k] += dp[i][k - 1];
					dp[i][k] %= mod;
				}
			}
		}
//		for (int i = 0; i < h; i++) {
//			for (int j = 0; j < w; j++)
//				System.out.print(dp[i][j] + " ");
//			System.out.println();
//		}
		System.out.println(dp[h - 1][w - 1]);

	}

}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;
const double pi = 3.14159265358979;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問状況

int a, b; // 変数
double h, m;

int main() {
// input
    cin >> a >> b;
    cin >> h >> m;
// solve
    double longer = h * (2 * pi / 12) + m * (2 * pi / 12 / 60);
    double shorter = m * (2 * pi / 60);
    double theta = longer - shorter;
    double c = sqrt(a * a + b * b - 2 * a * b * cos(theta));
// output
    printf("%.10f\n", c);
}

Measured memory_bytes: 4116
str = input()
q = int(input())
lst = []
for i in range(q):
    cmmnd = input().split()
    lst.append(cmmnd)
for cmmnd in lst:
    if cmmnd[0] == "print":
        print(str[int(cmmnd[1]):int(cmmnd[2])+1])
    elif cmmnd[0] == "replace":
        str = str[:int(cmmnd[1])] + cmmnd[3] + str[int(cmmnd[2])+1:]
    else:
        str = str[:int(cmmnd[1])] + str[int(cmmnd[1]):int(cmmnd[2])+1][::-1] + str[int(cmmnd[2])+1:]


Measured memory_bytes: 5620
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;


 
int main()
{
    int n;
    cin>>n;
    int h;
    cin>>h;
    int min=h;
    int p=0;
    int max=0;
    for(int i=1 ; i<n ; i++)
    {
        cin>>h;
        if(h<=min)
        {
            p++;
            min=h;
        }
        else
        {
            min=h;
            if(p>max)
            max=p;
            p=0;
        }
        
    }
    if(p>max)
    max=p;
    cout<<max;
    return 0;
}

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

int main() {
	while (1) {
		int n, m; cin >> n >> m;
		if (n==0 && m==0) return 0;
		vector<int> h(n); for (int i=0; i<n; i++) cin >> h[i];
		vector<int> w(m); for (int i=0; i<m; i++) cin >> w[i];
		map<int, int> mh; map<int, int> mw;

		for (int i = 0; i < n; ++i)
		{
			int cum = 0;
			for (int j = i; j < n; ++j)
			{
				cum += h[j];
				mh[cum] += 1;
			}
		}

		for (int i = 0; i < m; ++i)
		{
			int cum = 0;
			for (int j = i; j < m; ++j)
			{
				cum += w[j];
				mw[cum] += 1;
			}
		}
		int ans = 0;
		for (auto it = mh.begin(); it != mh.end(); ++it)
		{
			ans += it->second * mw[it->first];
		}
		cout << ans << endl;
	}
}


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

class DisjointSet {
  public:

    vector<int> rank, p;

    DisjointSet() {}
    DisjointSet(int size) {
      rank.resize(size, 0);
      p.resize(size, 0);
      for (int i = 0; i < size; i++) makeSet(i);
    }

    void makeSet(int x) {
      p[x] = x;
      rank[x] = 0;
    }

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

    void unite(int x, int y) {
      link(findSet(x), findSet(y));
    }

    void link(int x, int y) {
      if (rank[x] > rank[y]) {
        p[y] = x;
      } else {
        p[x] = y;
        if (rank[x] == rank[y]) {
          rank[y]++;
        }
      }
    }

    int findSet(int x) {
      if (x != p[x]) {
        p[x] = findSet(p[x]);
      }
      return p[x];
    }
};

int main() {
  int n, a, b, q;
  int t;

  cin >> n >> q;
  DisjointSet ds = DisjointSet(n);

  for (int i = 0; i < q; i++) {
    cin >> t >> a >> b;
    if ( t == 0 ) ds.unite(a, b);
    else if ( t == 1 ) {
      if ( ds.same(a, b) ) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n;

  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  map<int,int> m1,m2;
  for(int i=0;i<n;i+=2) m1[a[i]]++,m2[a[i+1]]++;
  int fi=(*m1.begin()).f,se=(*m2.begin()).f;
  vector<pii> v1,v2;
  for(auto i:m1){
    v1.pb({i.s,i.f});
  }
  for(auto i:m2){
    v2.pb({i.s,i.f});
  }
  sort(all(v1),greater<pii>());
  sort(all(v2),greater<pii>());
  if(v1[0].s!=v2[0].s){
    cout<<(n-v1[0].f-v2[0].f)<<endl;
  }
  else{
    cout<<min((n-v1[1].f-v2[0].f),(n-v1[0].f-v2[1].f))<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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

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

  if (N % 2 != 0) {
    cout<<"No";
    return 0;
  }

  int mid = N/2;

  if (S.substr(0,mid) == S.substr(mid)) {
    cout<<"Yes";
    return 0;
  }

  cout<<"No";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long H, W, K;
  cin >> H >> W >> K;
  long a, ans = 2000, sub;
  vector<vector<char>> data(H, vector<char> (W));
  vector<long> sep(H), count(H);
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> data.at(i).at(j);
    }
  }
  long pl;
  for(int i = 0; i < pow(2, H - 1); i++){
    pl = -1;
    a = i;
    sub = 0;
    for(int j = 0; j < H; j++)count.at(j) = 0;
    for(int j = 0; j < H - 1; j++){
      if(a % 2 == 1){
        sep.at(j + 1) = sep.at(j) + 1;
        sub++;
      } else sep.at(j + 1) = sep.at(j);
      a /= 2;
    }
    for(int j = 0; j < W; j++){
      for(int k = 0; k < H; k++){
        if(data.at(k).at(j) == '1')count.at(sep.at(k))++;
      }
      for(int k = 0; k < H; k++){
        if(count.at(k) > K){
          for(int l = 0; l < H; l++)count.at(l) = 0;
          if(pl == j){
            sub = 2000;
            j = 2000;
            k = 2000;
          }
          pl = j;
          sub++;
          j--;
          break;
        }
      }
    }
    ans = min(ans, sub);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }
    let mut s = 0;
    for &x in a.iter() {
        s ^= x;
    }
    for &x in a.iter() {
        print!("{} ", s ^ x);
    }
}


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

#define rep(i,n) for(int i = 0; i < n; ++i)
#define reps(i,f,n) for(int i = f; i < n; ++i)
#define pb push_back
using namespace std;

template<typename T>
class ShortestPath{
  public:
    class Edge{
      public:
        T val;
        int to;
        Edge(T v, int t):val(v), to(t){}
    };

    int n;
    vector< vector<Edge> > g;
    vector<T> d;
    vector<T> p;
    T INF;


    ShortestPath(int _n, const T inf):n(_n),g(n),d(n),p(n), INF(inf){
    }

    bool bellman_ford(int s){
      rep(i,n){
        d[i] = INF;
        p[i] = -1;
      }
      d[s] = 0;

      reps(i,1,n-1){
        rep(j, g.size()){
          if(d[j] == INF)continue;
          rep(k, g[j].size()){
            int u = j;
            int v = g[j][k].to;
            T c = g[j][k].val;
            if( d[v] > d[u] + c){
              d[v] = d[u] + c;
              p[v] = u;
            }
          }
        }
      }
      rep(i, g.size()){
        if(d[i] == INF)continue;
        rep(j, g[i].size()){
            int u = i;
            int v = g[i][j].to;
            T c = g[i][j].val;
            if( d[v] > d[u] + c){
              return false;
            }
        }
      }
      return true;
    }
};

int main(void){
  int v, e, r;
  int s,t,d;
  cin >> v >> e >> r;
  const int inf = 1000000000;
  ShortestPath<int> sp(v, inf);
  rep(i,e){
    cin >> s >> t >> d;
    sp.g[s].pb(ShortestPath<int>::Edge(d, t));
  }
  bool res = sp.bellman_ford(r);
  if(res){
    rep(i,v){
      if(sp.d[i] == inf){
        cout << "INF" << endl;
      }else{
        cout << sp.d[i] << endl;
      }
    }
  }else{
    cout << "NEGATIVE CYCLE" << endl;
  }

  return 0;
}

Measured memory_bytes: 3160
program beginning
  implicit none
  integer :: n(4), i, j
  read(*,*) n(:)
  do i = 1, 4
     do j = i+1, 4
        if (n(i) .gt. n(j)) call swap(n(i),n(j))
     end do
  end do
  if (n(1) .eq. 1 .and. n(2) .eq. 4 .and. n(3) .eq. 7 .and. n(4) .eq. 9) then
     write(*,'(a)') 'YES'
  else
     write(*,'(a)') 'NO'
  end if
  stop
contains
  subroutine swap(a,b)
    implicit none
    integer, intent(inout) :: a, b
    integer                :: c
    c = a
    a = b
    b = c
    return
  end subroutine swap
end program beginning

Measured memory_bytes: 768
#include <stdio.h>

int main(void){
	while(1){
		int a[5], x, y, i, flag=0, max=0, p=-1;;
		
		for(i=0; i<5; i++) {
			scanf(" %d %d", &x, &y);
			if(x==0 && y==0) {
				flag=1;
				break;
			}
				
			a[i] = x+y;
			if(max < a[i]) {
				max = a[i];
				p=i;
			}
			
		}
		if(flag==1) break;
		
		printf("%c %d\n", 'A'+p, a[p]);	
	
	}

	return 0;
}

Measured memory_bytes: 600
n = int(input())
s = input()

# print(s)
max_count = 0
for i in range(len(s)):
    ss = "abcdefghijklmnopqrstuvwxyz"
    x_dict = {}
    y_dict = {}
    for c in ss:
        x_dict[c] = 0
        y_dict[c] = 0
        
    # print(i)
    
    x = s[:i]
    y = s[i:]
    # print(f"{x} {y}")
    
    for xx in x:
        x_dict[xx] += 1
        
    for yy in y:
        y_dict[yy] += 1
    
    # print(x_dict)
    # print(y_dict)
    
    count = 0
    for c in ss:
        # print(f"{x_dict[c]} {y_dict[c]}")
        if x_dict[c] > 0 and y_dict[c] > 0:
            # print(f"{x_dict[c]} {y_dict[c]}")
            count += 1
    # print(count)
    max_count = max(max_count, count)
        
print(max_count)

Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
int h[100010],nex[200010],to[200010],M,n;
void add(int a,int b){
    M++;
    to[M]=b;
    nex[M]=h[a];
    h[a]=M;
}
int d[100010],q[100010];
bool del[100010];
char s[100010];
void topsort(){
    int head,tail,x,i;
    head=1;
    tail=0;
    for(i=1;i<=n;i++){
        if(s[i]=='B'&&d[i]==1)q[++tail]=i;
    }
    while(head<=tail){
        x=q[head++];
        del[x]=1;
        for(i=h[x];i;i=nex[i]){
            if(d[to[i]])d[to[i]]--;
            if(s[to[i]]=='B'&&d[to[i]]==1&&!del[to[i]])q[++tail]=to[i];
        }
    }
}
int f[100010],sum,mn;
int tp(int x){return(d[x]&1)^(s[x]=='W');}
int val(int x){return tp(x)==1?-2:0;}
void dfs(int fa,int x){
    sum+=(tp(x)==1)+2;
    f[x]=val(x);
    for(int i=h[x];i;i=nex[i]){
        if(to[i]!=fa&&!del[to[i]]){
            dfs(x,to[i]);
            mn=min(mn,f[x]+f[to[i]]);
            f[x]=min(f[x],f[to[i]]+val(x));
        }
    }
}
int main(){
    int i,x,y;
    scanf("%d",&n);
    for(i=1;i<n;i++){
        scanf("%d%d",&x,&y);
        add(x,y);
        add(y,x);
        d[x]++;
        d[y]++;
    }
    scanf("%s",s+1);
    topsort();
    for(x=1;x<=n;x++){
        if(!del[x])break;
    }
    if(x>n)
		printf("0\n");
    else{
        dfs(0,x);
        sum-=2;
//		printf("%d\n",mn);
        printf("%d\n",sum+mn);
    }
}

Measured memory_bytes: 7296
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        LinkedList<Integer> list = new LinkedList<>();
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            int x = list.remove(i);
            boolean inserted = false;
            for (int j = 0; j < i; j++) {
                if (list.get(j) >= x) {
                    list.add(j, x);
                    inserted = true;
                    break;
                }
            }
            if (!inserted) {
                list.add(i, x);
            }
            for (int j = 0; j < n; j++) {
                if (j > 0) {
                    sb.append(" ");
                }
                sb.append(list.get(j));
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}


Measured memory_bytes: 28360
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;

int main(int argc, char ** argv) {
	int N, X, T;
	scanf("%d%d%d", &N, &X, &T);
	printf("%d\n", ((N+X-1)/X)*T);
	return 0;
}



Measured memory_bytes: 3864
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
using namespace std;
typedef pair< int , int > P;
#define fr first
#define sc second

int main(){
  int N;
  cin >> N;
  int a[3][N],pt[200] = {};
  for(int i = 0 ; i < N ; i++ ){
    for(int j = 0 ; j < 3 ; j++ ) cin >> a[j][i];
  }
  for(int i = 0 ; i < 3 ; i++ ){
    int num[101] = {};
    for(int j = 0 ; j < N ; j++ ) num[a[i][j]]++;
    for(int j = 0 ; j < N ; j++ ) if(num[a[i][j]] == 1) pt[j] += a[i][j];
  }
  for(int i = 0 ; i < N ; i++ ) cout << pt[i] << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
int lowbit(ll x){
	int res=0;
	while(x) res++,x>>=1;
	return res;
}
int main(){
	ll n=read(),m=read();
	ll p=60,x,ans=0;
	while(p>=0&&((n>>p)&1)==((m>>p)&1)) p--;
	if(p>=0){
		n&=(1ll<<p+1)-1;
		m&=(1ll<<p)-1;
		ans+=(1ll<<p)-n;
		x=lowbit(m);
		ans+=(1ll<<x);
		n=max(n,1ll<<x);
		ans+=(1ll<<p)-n;
	}else ans=1;
	cout<<ans;
}

Measured memory_bytes: 3612
n = int(input())
a = list(map(int, input().split()))[::-1]
ans = []
for i in range(n):
  for k,v in enumerate(a):
    num = n - i - k
    if num == v:
      b = a.pop(k)
      ans.append(b)
      break
  else:
    ans = 0
    break
if not ans:
  print(-1)
else:
  for i in ans[::-1]:
    print(i)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
const int sz = 100010;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, C;
    cin >> N >> C;
    vec<int> s(N),t(N),c(N);
    vvec<int> imos(30, vec<int>(sz,0));
    rep(i,N){
        cin >> s[i] >> t[i] >> c[i];
        c[i]--;
        imos[c[i]][s[i]]++;
        imos[c[i]][t[i]]--;
    }
    rep(j,30)rep(i,sz-1){
        imos[j][i+1] += imos[j][i];
    }
    rep(j,30)rep(i,sz-1){
        if(imos[j][i+1] == 1 && imos[j][i] == 0){
            imos[j][i] = 1;
        }
    }
    ll ans = 0;
    rep(i,sz){
        ll tmp = 0;
        rep(j,30){
            tmp += imos[j][i];
        }
        chmax(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define exp pow(10,-9)
#define F first
#define S second
#define PB push_back 
#define MP make_pair
#define daman ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lowercase(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define uppercase(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
main()
{
	lli n,d;
	cin>>n>>d;
	
	lli count = 0,x,y;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		
		double ans = x*x + y*y;
		ans = sqrt(ans);
		if(ans <= (double)d)
			count++;
			
	}
	cout<<count<<"\n";
	
}

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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

struct edge {
    lli to;
    lli cost;
};

vector<edge> G[100001];
bool used[100001];

lli prim() {

    //// first がその時点での最短経路のコスト、second が頂点の番号
    //priority_queue<P, vector<P>, greater<P>> vque;
    //que.push(P(0, 1));
    //used[0] = true;


    lli total = 0;
    priority_queue<P, vector<P>, greater<P> > que;

    // 事前に最初の node の辺のみ入れておく
    used[1] = true;
    lli cur_v = 1;
    REP(i, 0, (lli)G[cur_v].size()) {
        edge e = G[cur_v][i];
        if (!used[e.to])
            que.push(P(e.cost, e.to));
    }

    while (true) {
        // 次に使われる辺を選ぶ
        edge next = {LLONG_MAX, LLONG_MAX};
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            if (!used[p.second]) {
                next.cost = p.first;
                next.to = p.second;
                total += next.cost;
                used[next.to] = true;
                break;
            }
        }
        if (next.cost == LLONG_MAX)
            break;

        // next が使われた辺なので、新たに next.to から張られる辺を登録
        cur_v = next.to;
        REP(i, 0, (lli)G[cur_v].size()) {
            edge e = G[cur_v][i];
            if (!used[e.to])
                que.push(P(e.cost, e.to));
        }
    }

    return total;

    //while (!que.empty()) {
    //    P p = que.top();
    //    que.pop();

    //    lli cur_v = p.second;
    //    REP(i, 0, (lli)G[cur_v].size()) {
    //        edge e = G[cur_v][i];
    //        if (!used[e.to])
    //            que.push_back(e);
    //    }



    //    lli cur_v = p.second;
    //    // cur_v の辺を周って、更新しつつ queue に push していく
    //    edge next_edge = {LLONG_MAX, 0};
    //    REP(i, 0, (lli)G[cur_v].size()) {
    //        edge e = G[cur_v][i];
    //        if (!used[next_edge.second] && next_edge.first > e.first) {
    //            next_edge.first = e.first;
    //            next_edge.second = e.second;
    //            used[next_edge.second];
    //        }
    //    }
    //    que.push_back(next_edge);
    //}
}

int main() {
    lli n, m;
    cin >> n >> m;
    REP(i, 0, m) {
        lli a, b, c;
        cin >> a >> b >> c;
        // ここでは無向グラフとする
        edge e1 = {b, c};
        edge e2 = {a, c};
        G[a].push_back(e1);
        G[b].push_back(e2);
    }

    lli ans = prim();
    cout << ans << endl;
}

// 入力例(|V|, |E| からの、始点/終点/コスト)
// 8 15
// 1 8 1
// 7 3 14
// 8 2 13
// 3 5 4
// 5 7 5
// 6 4 1
// 6 8 17
// 7 8 5
// 1 4 2
// 4 7 1
// 6 1 3
// 3 1 10
// 2 6 5
// 2 4 12
// 5 1 30



Measured memory_bytes: 12512
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

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

    int a, b, c;

    cin >> a >> b >> c;

    a*=b;

    cout << a/2;

    return 0;
}


Measured memory_bytes: 256
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int a,b,c,x,ans;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(500*i+100*j+50*k==x)
				ans++;
			}
		}
	}
	cout<<ans;
	//system("pause");
	return 0;
}

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

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

while True:
    n = input()
    if n == 0:
        break
    lst = []
    for i in range(n):
        lst.append(raw_input())
    S_lst = []
    for i in range(n):
        S = lst[i][0]
        for j in range(len(lst[i]) - 1):
            if lst[i][j] in ['a', 'i', 'u', 'e', 'o']:
                S += lst[i][j + 1]
        S_lst.append(S)
    if len(list(set(S_lst))) < n:
        print -1
        continue
    for i in range(1000):
        lst = []
        for j in range(n):
            lst.append(S_lst[j][:i])
        if len(list(set(lst))) == n:
            print i
            break


Measured memory_bytes: 5052
package main

import "fmt"

func main() {
	const MAX = 1000000
	prime := make([]int, MAX, MAX)
	check := make([]int, MAX, MAX)
	count := make([]int, MAX, MAX)

	prime[0] = 1
	prime[1] = 1

	// prime init
	for i := 2; i < MAX; i++ {
		if check[i] == 1 {
			continue
		}

		if prime[i] == 0 {
			for j := i * 2; j < MAX; j += i {
				check[j] = 1
				prime[j] = 1
			}
		}
	}

	for i := 2; i < MAX; i++ {
		cnt := 0

		if prime[i] == 0 {
			cnt = 1
		}

		count[i] = count[i-1] + cnt
	}

	for {
		var input int
		inputCount, _ := fmt.Scanf("%d", &input)
		if inputCount != 1 {
			break
		}

		fmt.Println(count[input])
	}
}



Measured memory_bytes: 25992
n = int(input())
count = 0
l = [[0]*10 for i in range(10)]
for i in range(1,n+1):
    l[int(str(i)[0])][int(str(i)[-1])] += 1
for i in range(1,10):
    for j in range(1,10):
        count += l[i][j]*l[j][i]
            

print(count)
    



Measured memory_bytes: 3060
#include<stdio.h>
int main() {
	int N;
	scanf("%d", &N);
	int i;
	int C[505] = {0}, S[505] = {0}, F[505] = {0};
	for(i = 1; i < N; i++) {
		scanf("%d %d %d", &C[i], &S[i], &F[i]);
	}
	for(i = 1; i < N; i++) {
		int j;
		int time = S[i] + C[i];
		for(j = i + 1; j < N; j++) {
			if(time < S[j]) {
				time = S[j] + C[j];
			} else if (time == S[j]) {
				time += C[j];
			} else {
				if((time - S[j]) % F[j] == 0) {
					time += C[j];
				} else {
					time = ((time - S[j]) / F[j] + 1) * F[j] + S[j] + C[j];
				}
			}
		}
		printf("%d\n", time);
	}
	printf("0");
	return 0;
}

Measured memory_bytes: 128
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  ld PI = acos(-1);
  ld r;
  cin >> r;
  cout << fixed << setprecision(10) << (2.00*PI*r) << endl;


return 0;
}
///....


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

int main(){
  int W,H;
  cin>>W>>H;

  int x, y ,r;
  cin>>x>>y>>r;
  
  if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H)
  
  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
 
 
  
  return 0;
}



   
  



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  string s;
  cin >> s;

  if(s == "Sunny"){
    cout << "Cloudy";
  }else if( s == "Cloudy"){
    cout << "Rainy";
  }else if(s == "Rainy"){
    cout << "Sunny";
  }

  cout << endl;

  return 0;
}

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


int main(){
    int64_t n,a,b,p;
    cin >> n;
    a = 2;
    b = 1;
    for(int i=0; i<n; i++){
        p = a + b;
        a = b;
        b = p;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

int c[4][4],a[4],b[4];
int main()
{
	ios::sync_with_stdio(false);
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			cin>>c[i][j],a[i]=-1,b[i]=-1;
	a[1]=1;
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++){
			if(a[i]!=-1&&b[j]!=-1){
				if(c[i][j]!=a[i]+b[j]){
					cout<<"No";
					return 0;
				}
			}
			else if(a[i]!=-1&&b[j]==-1) b[j]=c[i][j]-a[i];
			else a[i]=c[i][j]-b[j];
		}
	cout<<"Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x) memset(x,0,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 110000
/*------------------------------------------------------------*/

int main(){
	int n;
	cin>>n;
	if(n%10==9||n/10==9)outy;
	 else outn;
}


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;
const int INF=1001001001;
int main(){
	ll a,b;
	cin >> a >> b;
	ll tmp;
	ll x = a * b;

	if(a<b){
		tmp = a;
		a = b;
		b = tmp;
	}
	ll r = a % b;
	while(r!=0){
		a = b;
		b = r;
		r = a%b;
	}
	cout << x/b << endl;
	return 0;

}




Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%d", $k);
fscanf(STDIN, "%d", $x);
fscanf(STDIN, "%d", $y);
echo $n > $k ? $x * $k + $y * ($n - $k) : $x * $n, "\n";

Measured memory_bytes: 3576
seqe a =
  let b = 2*a
  in
    b : seqo b

seqo a =
  let b = a/3
  in
    b : seqe b

seq' :: Double -> [Double]
seq' a = (a : seqe a)

ans x = sum $ take 10 $ seq' x

main = do
  c <- getContents
  let i = map read $ lines c :: [Double]
      o = map ans i
  mapM_ print o

Measured memory_bytes: 4268
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int h1,m1,h2,m2,k;
    cin>> h1>>m1>>h2>>m2>>k;
    cout << h2*60+m2-h1*60-m1-k << '\n';

}


Measured memory_bytes: 3688
#!/usr/bin/env python3
n, c, k, *t = map(int, open(0).read().split())
t.sort()
m = l = s = 0
for t in t:
    m += 1
    if m > c or t > l:
        s += 1
        m = 1
        l = t + k
print(s)

Measured memory_bytes: 14052
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int arr[17];
int cum[17];
int main(){
	int n; cin >> n;
	for(int i = 1; i <= n ; i++){
		cin >> arr[i];
	}
	sort(arr + 1, arr + n +1);
	int max = arr[n];
	for(int i = 1; i <= n ; i++){
		cum[i] = arr[i] + cum[i - 1];
	}
	if(max < cum[n - 1])
		cout << " Yes";
	else
		cout << "No";
  return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B := sc.nextInt(), sc.nextInt()
	ma := max(A+B, A-B, A*B)

	fmt.Fprintln(wtr, ma)
	wtr.Flush()
}


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

int main(){
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int xx, yy;
  for(int i = 0; i < n; i++){
    cin >> xx;
    if(xx > x){
      x = xx;
    }
  }
  for(int i = 0; i < m; i++){
    cin >> yy;
    if(yy < y){
      y = yy;
    }
  }
  
  if(x < y){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	long X = sc.nextLong();
    	long Y = sc.nextLong();
    	int index = 0;
    	while (X <= Y) {
    		X *= 2;
    		index++;
    	}
    	System.out.println(index);
    }
}

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;


int main()
{
    int n, m;
    priority_queue<lli> pq;
    cin >> n >> m;
    for(int i=0; i<n; i++){
        lli x;
        cin >> x;
        pq.push(x);
    }
    while(m--){
        lli x = pq.top();
        pq.pop();
        x /= 2;
        pq.push(x);
    }
    lli sum = 0;
    while(!pq.empty()){
        lli x = pq.top();
        pq.pop();
        sum += x;
    }
    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 1400
/*g++ file.cpp -o file.out*/
/*./file.out*/

#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==1&&b!=1)
    {
        printf("Alice\n");
    }
    else if(b==1&&a!=1)
    {
        printf("Bob\n");
    }
    else
    {
        if(a>b)
        {
            printf("Alice\n");
        }
        else if(a<b)
        {
            printf("Bob\n");
        }
        else
        {
            printf("Draw\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib> 
#include <algorithm>
using namespace std;
 
int main() {
  int a[100100];
  string str;
  cin >> str;
  int max;
  max = 'a';
  
    
  for(int i = 0; i < str.size(); i++){
    a[i] = str.at(i);
  }
    
  sort(a, a + str.size());
  a[str.size()] = a[str.size() - 1];
  
  if(a[0] != 'a'){
    cout << 'a' << endl;
    return 0;
  }
  
  if(str.size() == 1){
    cout << 'b' << endl;
    return 0;
  }
  
  for(int i = 0; i < str.size(); i++){
    if(a[i] != a[i+1] && a[i+1] - a[i] != 1){
        cout << char(a[i]+1) << endl;
        return 0;
    }else{
      max = a[i];
    }
  }  
  
  if(max == 122){
      cout << "None" << endl;
    }
  else{
      cout << char(max+1) << endl;
     }
    
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;

int h, w;
char a[60][60];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, -1, 0, 1};

bool in(int x, int y) { return 0 <= x && x < h && 0 <= y && y < w; }
void solve(int x, int y, char c)
{
    if (a[x][y] == '.')
        a[x][y] = c;
    if (a[x][y] == 'w' || a[x][y] == 'b')
    {
        if (a[x][y] != c)
            a[x][y] = 'm';
    }
    for (int i = 0; i < 4; i++)
    {
        int nx = x + dx[i], ny = y + dy[i];
        if (!in(nx, ny) || a[nx][ny] == 'W' || a[nx][ny] == 'B' || a[nx][ny] == 'm' || a[nx][ny] == c)
            continue;
        solve(nx, ny, c);
    }
}

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

    while (1)
    {
        cin >> w >> h;
        if (w == 0)
            break;
        rep(i, h) rep(j, w) cin >> a[i][j];
        int sum1 = 0, sum2 = 0;
        rep(i, h) rep(j, w)
        {
            if (a[i][j] == 'W')
                solve(i, j, 'w');
            if (a[i][j] == 'B')
                solve(i, j, 'b');
        }
        rep(i, h)
        {
            rep(j, w)
            {
                if (a[i][j] == 'b')
                    sum1++;
                if (a[i][j] == 'w')
                    sum2++;
            }
        }
        cout << sum1 << " " << sum2 << endl;
    }
}


Measured memory_bytes: 3176
#include<iostream>
#include<string.h>
#include<string>
using namespace std;
int main()
{
	long long n;
	while (cin >> n)
	{
		long long m=0;
		n++;
		while (n > 9)
		{
			m += 9;
			n = n / 10;
		}
		cout << m + n - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

N,X = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]
L = [0] + L
L = list(accumulate(L))

ans = 0
for i in range(len(L)):
    if X < L[i]:
        ans = i
        print(ans)
        exit()

print(N+1)


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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (998244353)
#define umap unordered_map

int main()
{
    long t = 1;
    //cin >> t;

    while (t--) {
        string s;
        cin >> s;

        if (s[0] >= 'a' and s[0] <= 'z') puts("a");
        else puts("A");
    }
}


Measured memory_bytes: 3604
program main
    implicit none

    integer music_value,money,max_count

    read(*,*) music_value, money, max_count

    if (max_count < int(money/music_value)) then 
        write(*,"(I0)") max_count
    else
        write(*,"(I0)") int(money/music_value)
    end if
end program main

Measured memory_bytes: 768
from collections import Counter
N = int(input())
S = [input() for _ in range(N)]
s = S[0]
for i in range(1,N):
  s += S[i]
  s = ''.join([key*(min(val//2,s.count(key)-S[i].count(key))) for key,val in Counter(s).items() if val > 1])
s = sorted(s)
print(''.join(s))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int r,g;
    cin >> r >> g;
    cout << g - r + g << endl;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import accumulate

n,ch = li()
MAX_T = 10**5+1

program = [[0]*MAX_T for _ in range(ch)]

endset = [set() for _ in range(ch)]
stc = []

for _ in range(n):
    s,t,c = li()
    c -= 1
    
    stc.append((s,t,c))
    endset[c].add(t)
    
stc.sort(key=lambda x:x[0])
    
for s,t,c in stc:
    if s in endset[c]:
        program[c][s] += 1
        program[c][t] -= 1
    else:
        program[c][s-1] += 1
        program[c][t] -= 1
    
for ci in range(ch):
    program[ci] = list(accumulate(program[ci]))
    
print(max([sum(time_span) for time_span in zip(*program)]))


Measured memory_bytes: 46880
#B問題
import bisect

N = int(input())
S = list(str(input()))
mod = 998244353
N_factorial = 1
for i in range(N):
    N_factorial*=(i+1)
    N_factorial%=mod

r,g,b = [],[],[]
for i,s in enumerate(S):
    if s == "R":
        r.append(i)
    if s == "G":
        g.append(i)
    if s == "B":
        b.append(i)
        
A,B,C = [],[],[]
for i in range(N):
    rgb = [r[i],g[i],b[i]]
    rgb.sort()
    A.append(rgb[0])
    B.append(rgb[1])
    C.append(rgb[2])

ans = N_factorial
for i,B_ind in enumerate(B):
    x = bisect.bisect_left(A,B_ind)-i
    y = i+1-bisect.bisect_left(C,B_ind)
    ans*=(x*y)
    ans%=mod

print(ans)

Measured memory_bytes: 20636