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

int main()
{
  vector<vector<int>> data(3, vector<int>(3));
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
      cin >> data.at(i).at(j);
  }
  int num = 0;
  cin >> num;
  vector<int> indata(num);
  for (int i = 0; i < num; i++)
    cin >> indata.at(i);
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < num; k++){
        if(data.at(i).at(j) == indata.at(k))
          data.at(i).at(j) = 1000;
      }
  }
  int flag = 0;
  int cnt;
   for (int i = 0; i < 3; i++)
  {
     cnt = 0;
    for (int j = 0; j < 3; j++)
    {
      if(data.at(i).at(j) == 1000)
        cnt++;
    }
     if(cnt == 3)
       flag = 1;
  }
	
    if(data.at(0).at(0) == data.at(1).at(0) && data.at(0).at(0) == data.at(2).at(0))
    {
      flag = 1;
    }
  
  if(data.at(0).at(1) == data.at(1).at(1) && data.at(0).at(1) == data.at(2).at(1))
  {
    flag = 1;
  }
  
  if(data.at(0).at(2) == data.at(1).at(2) && data.at(0).at(2) == data.at(2).at(2))
  {
    flag = 1;
  }
 
  if (data.at(0).at(0) == data.at(1).at(1) && data.at(0).at(0) == data.at(2).at(2))
  {
    flag = 1;
  }
  
  if (data.at(0).at(2) == data.at(1).at(1) && data.at(1).at(1) == data.at(2).at(0))
  {
    flag = 1;
  }
  
  if (flag == 1)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;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++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

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

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli h,w;
    cin2(h,w);
    lli a[h][w];
    REP(i,0,h) {
        REP(j,0,w) {
            cin >> a[i][j];
        }
    }

    vector<string> ans;
    REP(i,0,h) {
        REP(j,0,w) {
            lli cur;
            if (i % 2 == 0) {
                cur = j;

                if (a[i][cur] % 2 == 1) {
                    // 右か下に移す
                    if (cur != w-1) {
                        a[i][cur+1]++;
                        ans.push_back(to_string(i+1)+" "+to_string(cur+1)+" "+to_string(i+1)+" "+to_string(cur+2));

                    }
                    else if (i != h-1) {
                        ans.push_back(to_string(i+1)+" "+to_string(cur+1)+" "+to_string(i+2)+" "+to_string(cur+1));
                        a[i+1][cur]++;
                    }
                }
            }
            else {
                cur = (w-1)-j;
                if (a[i][cur] % 2 == 1) {
                    // 左か下に移す
                    if (cur != 0) {
                        ans.push_back(to_string(i+1)+" "+to_string(cur+1)+" "+to_string(i+1)+" "+to_string(cur));
                        a[i][cur-1]++;
                    }
                    else if (i != h-1) {
                        ans.push_back(to_string(i+1)+" "+to_string(cur+1)+" "+to_string(i+2)+" "+to_string(cur+1));
                        a[i+1][cur]++;
                    }
                }
            }
        }
    }
    cout << ans.size() << endl;
    REP(i,0,ans.size()) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 12916
#include <bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define inf (int)(3e18)
#define mod (int)(1e9+7)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int n;
P p[222222];
signed main(){
	cin>>n;
	rep(i,n)cin>>p[i].second>>p[i].first;
	sort(p,p+n);
	int sum=0;
	rep(i,n){
		sum+=p[i].second;
		if(sum>p[i].first){
			cout<<"No"<<endl;return 0;
		}
	}
	cout<<"Yes"<<endl;
}


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

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

	int ans;

	if (a != b && b != c && c != a ) ans = 3;
	else if (a == b && b == c) ans = 1;
	else ans = 2;

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

Measured memory_bytes: 256
#include<stdio.h>

int main(){
   int N,count = 0;
   scanf("%d",&N);
   while(N > 2){
      N -= 2;
      count++;
   }
   if(N == 0){
      printf("%d\n",count);
   } else {
      count++;
      printf("%d\n",count);
   }
}


Measured memory_bytes: 1728
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

using CostType = int;
struct Edge {
  int src, dst; CostType cost;
  Edge(int src, int dst, CostType cost = 0) : src(src), dst(dst), cost(cost) {}
  inline bool operator<(const Edge &x) const {
    return cost != x.cost ? cost < x.cost : dst != x.dst ? dst < x.dst : src < x.src;
  }
  inline bool operator<=(const Edge &x) const { return !(x < *this); }
  inline bool operator>(const Edge &x) const { return x < *this; }
  inline bool operator>=(const Edge &x) const { return !(*this < x); }
};

struct Dijkstra {
  using Pci = pair<CostType, int>;

  Dijkstra(const vector<vector<Edge>> &graph, const CostType CINF) : graph(graph), CINF(CINF) {}

  vector<CostType> build(int s) {
    int n = graph.size();
    vector<CostType> dist(n, CINF);
    dist[s] = 0;
    prev.assign(n, -1);
    priority_queue<Pci, vector<Pci>, greater<Pci>> que;
    que.emplace(0, s);
    while (!que.empty()) {
      CostType cost; int ver; tie(cost, ver) = que.top(); que.pop();
      if (dist[ver] < cost) continue;
      for (const Edge &e : graph[ver]) {
        if (dist[e.dst] > dist[ver] + e.cost) {
          dist[e.dst] = dist[ver] + e.cost;
          prev[e.dst] = ver;
          que.emplace(dist[e.dst], e.dst);
        }
      }
    }
    return dist;
  }

  vector<int> build_path(int t) {
    vector<int> res;
    for (; t != -1; t = prev[t]) res.emplace_back(t);
    reverse(ALL(res));
    return res;
  }

private:
  vector<vector<Edge>> graph;
  const CostType CINF;
  vector<int> prev;
};

int main() {
  int n, x, y; cin >> n >> x >> y; --x; --y;
  vector<vector<Edge> > graph(n);
  REP(i, n - 1) {
    graph[i].emplace_back(i, i + 1, 1);
    graph[i + 1].emplace_back(i + 1, i, 1);
  }
  graph[x].emplace_back(x, y, 1);
  graph[y].emplace_back(y, x, 1);
  Dijkstra dij(graph, INF);
  vector<int> ans(n, 0);
  REP(i, n) {
    vector<int> dist = dij.build(i);
    FOR(j, i + 1, n) ++ans[dist[j]];
  }
  FOR(i, 1, n) cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main()
{
	int s[100000],t[100000],n,q,l,r,mid,count=0;
	
	scanf("%d",&n);
	
	for(int i = 0; i<n;i++)
	{
		scanf("%d",&s[i]);
	}
	
	scanf("%d",&q);
	
	for(int i = 0;i<q;i++)
	{
		scanf("%d",&t[i]);
	}
	
	for(int i = 0; i<q;i++)
	{
		l=0;
		r=n;
		while(l<r)
		{
			mid = (l+r)/2;
			if(s[mid]==t[i])
			{
				count++;
				break;
			}
			if(t[i]>s[mid])
			{
				l = mid+1;
			}
			else if (t[i] < s[mid])
			{
				r = mid;
			}
		}
	}
	printf("%d\n",count);
	return 0;
}
			


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

typedef vector <int> VI;
typedef vector <VI> VVI;

void lotate_VVI( VVI& target )
{
	VVI next( target.size(), VI( target.size() ) );
	for ( int i = 0; i < target.size(); i++ )
	{
		for ( int j = 0; j < target.size(); j++ )
		{
			next[j][target.size()-i-1] = target[i][j];
		}
	}
	target = next;
}

class Point
{
public:
	int x;
	int y;
	Point(): x(-1), y(-1) {};
	Point( int _x, int _y ): x(_x), y(_y) {};
};

Point partly_match( const VVI& window, VVI& picture, int x, int y )
{
	bool found = true;
	Point p = Point( -1, -1 );
	for ( int i = 0; found && i < picture.size(); i++ )
	{
		for ( int j = 0; found && j < picture.size(); j++ )
		{
			int nx = x + j;
			int ny = y + i;
			if ( picture[i][j] == -1 ) continue;
			if ( picture[i][j] != window[ny][nx] ) found = false;
			if ( picture[i][j] == window[ny][nx] && p.x == -1 && p.y == -1 ) p = Point( nx, ny );
		}
	}
	if ( found ) return p;
	return Point( -1, -1 );
}

Point match( const VVI& window, VVI& picture )
{
	Point good( -1, -1 );
	for ( int k = 0; k < 4; k++ )
	{
		for ( int i = 0; i <= window.size() - picture.size(); i++ )
		{
			for ( int j = 0; j <= window.size() - picture.size(); j++ )
			{
				Point result = partly_match( window, picture, j, i );
				if ( result.x != -1 && result.y != -1 )
				{
					if ( good.x == -1 && good.y == -1 )
					{
						good.x = result.x;
						good.y = result.y;
					}
					else if ( result.y < good.y )
					{
						good.x = result.x;
						good.y = result.y;
					}
					else if ( result.y == good.y )
					{
						if ( result.x < good.x )
						{
							good.x = result.x;
							good.y = result.y;
						}
					}
				}
			}
		}
		lotate_VVI( picture );
	}
	return good;
}

int main( void )
{
	int n, m;
	while ( cin >> n >> m && n && m )
	{
		// ツ堕仰づ個景ツ色
		VVI window( n, VI( n ) );
		for ( int i = 0; i < n; i++ )
		{
			for ( int j = 0; j < n; j++ )
			{
				cin >> window[i][j];
			}
		}

		// ツ偲環真ツづ個静伉づェツ端
		VVI picture( m, VI( m ) );
		for ( int i = 0; i < m; i++ )
		{
			for ( int j = 0; j < m; j++ )
			{
				cin >> picture[i][j];
			}
		}

		Point result = match( window, picture );
		if ( result.x == -1 && result.y == -1 )
			cout << "NA" << endl;
		else
			cout << result.x + 1 << " " << result.y + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 968
n = gets.to_i
for i in 1..n do
  x = i
  if x % 3 == 0
    print(" ",i)
  else
    while x>0 do
      if x % 10 == 3
        print(" ",i)
        break
      end
      x /= 10
    end
  end
end
puts

Measured memory_bytes: 8772
#include<bits/stdc++.h>
#define ALL(c) c.begin(),c.end()
using namespace std;
using ll = long long;
using pii = pair<int,int>;
static const int MOD = 1000000007;

struct edge {int v; int c;};
struct stcon {int v; ll sum;};

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

    vector<vector<edge>> G(N);
    for(int i=0; i<N-1; i++){
        int a,b,c; cin >> a >> b >> c;
        G[a-1].push_back(edge{b-1,c});
        G[b-1].push_back(edge{a-1,c});
    }
    int Q,K; cin >> Q >> K;

    vector<ll> costs(N,-1);
    stack<stcon> st;
    st.push(stcon{K-1,0});
    while(!st.empty()){
        stcon x = st.top(); st.pop();
        costs[x.v] = x.sum;
        for(edge e : G[x.v]){
            if(costs[e.v]!=-1)continue;
            ll cos = x.sum + e.c;
            st.push(stcon{e.v,cos});
        }
    }

    for(int i=0; i<Q; i++){
        int x,y; cin>>x>>y;
        ll ans = costs[x-1]+costs[y-1];
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 9972
def min_dist(i, j, x, y)
  [(i-j).abs, (i-x).abs + 1 + (y-j).abs, (i-y).abs + 1 + (x-j).abs].min
end

n, x, y = gets.split("\s").map(&:to_i)

dists = Array.new(n, 0)

1.upto(n) do |i|
  (i+1).upto(n) do |j|
    dists[min_dist(i, j, x, y)] += 1
  end
end
    
1.upto(n-1) do |k|
  puts dists[k] || 0
end


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s,t;
	cin >> s >> t;
	unordered_map<char, vector<int>> s_mp;
	REP(i,s.size()) s_mp[s[i]].push_back(i+1);
	ll cnt = 0;
	int pos = 0;
	REP(i,t.size()){
		if(s_mp[t[i]].size()==0){
			cout << -1 << '\n';
			return 0;
		}
		bool flag = true;
		auto itr = upper_bound(ALL(s_mp[t[i]]), pos);
		if(itr!=s_mp[t[i]].end()){
			pos = *itr;
		}else{
			cnt += (ll)s.size();
			pos = s_mp[t[i]][0];
		}
		//cout << cnt << " " << pos << '\n';
	}
	cout << cnt + (ll)pos << '\n';
	return 0;
}



Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 6001001001001001001;
long double EPS = 1e-6;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

// MOD確認

ll dp1[300010][2];
ll dp2[300010][2];

int main(){
    ll N,K,C;
    string S;
    cin >> N >> K >> C >> S;
    rep(i,N){
        if(S[i] == 'x'){
            dp1[i+1][1] += dp1[i][1];
            dp1[i+1][0] += max(dp1[i][0],dp1[i][1]);
        }else{
            dp1[i+1][0] += max(dp1[i][0],dp1[i][1]);
            if(i >= C){
                dp1[i+1][1] += max(dp1[i-C][1]+1,dp1[i-C][0]+1);
            }else{
                dp1[i+1][1] += 1;
            }
        }
    }
    S += 'x';
    rrep(i,N+1){
        if(S[i] == 'x'){
            dp2[i-1][1] += dp2[i][1];
            dp2[i-1][0] += max(dp2[i][0],dp2[i][1]);
        }else{
            dp2[i-1][0] += max(dp2[i][0],dp2[i][1]);
            if(N - i - 1 > C){
                dp2[i-1][1] += max(dp2[i+C][1]+1,dp2[i+C][0]+1);
            }else{
                dp2[i-1][1] += 1;
            }
        }
    }
    /*cout << ' ' << S << endl;
    FOR(i,0,N+1) cout << dp1[i][1];
    cout << 0;
    cout << endl;
    FOR(i,0,N+1) cout << dp1[i][0];
    cout << 0;
    cout << endl;
    cout << 0;
    rep(i,N+1) cout << dp2[i-1][1];
    cout << endl;
    cout << 0;
    rep(i,N+1) cout << dp2[i-1][0];
    cout << endl;*/
    FOR(i,1,N+1){
        //cout << dp1[i-1][1] << ' ' << dp2[i-1][1] << endl;
        if(dp1[i-1][1] + dp2[i-1][1] < K) cout << i << endl;
    }
}


Measured memory_bytes: 9988
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

vll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

/*
max 448,000,000
map<string,ll> count_map;
count_map['0']=0;
for(auto x : count_map) {
    string key = x.first;
    ll value = x.second;
}
*/

int main(){

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

    map<ll,ll> count_map;

    cin >> N;
    rep(ni,N){
        cin >> ltmp;
        A.push_back(ltmp);
    }

    rep(ni,N){
        count_map[A[ni]] = ni+1;
    }

    for( ll ni = 1 ; ni <=N ; ni++ ){
        cout << count_map[ni] << " ";
    }

    

}

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

int main() {
    int a,b;
    char op;
    while (1) {
        cin >> a >> op >> b;
        switch (op) {
        case '+':
            cout << a + b << endl;
            break;
        case '-':
            cout << a - b << endl;
            break;
        case '*':
            cout << a * b << endl;
            break;
        case '/':
            cout << a / b << endl;
            break;
        case '?':
            return 0;
        }
    }
}

Measured memory_bytes: 3088
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(S: str):
    N = len(S)
    count = 1
    pre = 0
    curr = 1
    while True:
        for i in range(1, 100):
            if S[pre:curr] != S[curr:curr+i]:
                break
            if curr+i >= N:
                break
        if curr+i >= N:
            break
        pre = curr
        curr = curr+i
        count += 1
    if S[pre:curr] != S[curr:curr+i]:
        pre = curr
        curr = curr+i
        count += 1

    print(count)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3508
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const db EPS = (db) 1e-9;
const int inf = 1e9;
const ll INF = 1e18;
const int mod = 1e6 + 3;
const int MAXN = 2e5 + 5;

string s;


int main() {
	//freopen(NAME".in", "r", stdin);
	//freopen(NAME".out", "w", stdout);


	ios_base::sync_with_stdio(0);
	cin.tie(0);            	
	cout.tie(0);
	cout << setprecision(6) << fixed;

	cin >> s;
	int x = 0;
	if (s == "SUN") x = 1;
	if (s == "MON") x = 2;
	if (s == "TUE") x = 3;
	if (s == "WED") x = 4;
	if (s == "THU") x = 5;
	if (s == "FRI") x = 6;
	if (s == "SAT") x = 7;
	cout << 7 - x + 1;
	return 0;	
}    


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    for (ll i = 0; i < s.size() - 1; i++)
    {
        if (s[i] == 'A' && s[i + 1] == 'C')
        {
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
}

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

int main(){
  char p[8][9];
  char p90[8][9],p180[8][9],p270[8][9];
  int i,j;

  for(i=0;i<8;i++)scanf("%s",p[i]);

  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      p90[i][j] = p[7-j][i];
      p180[i][j] = p[7-i][7-j];
      p270[i][j] = p[j][7-i];
    }
  }
  for(i=0;i<8;i++){
    p90[i][8] = '\0';
    p180[i][8] = '\0';
    p270[i][8] = '\0';
  }
  cout << "90" << endl;
  for(i=0;i<8;i++)printf("%s\n",p90[i]);
  cout << "180" << endl;
  for(i=0;i<8;i++)printf("%s\n",p180[i]);
  cout << "270" << endl;
  for(i=0;i<8;i++)printf("%s\n",p270[i]);

  return 0;
}

Measured memory_bytes: 0
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func Max(x ...int) int {
	max := x[0]
	for _, v := range x {
		if v > max {
			max = v
		}
	}
	return max
}

func Min(x ...int) int {
	min := x[0]
	for _, v := range x {
		if v < min {
			min = v
		}
	}
	return min
}

// GCD calculate GCD (Greatest Common Divisor) by Euclidean Algorithm
func GCD(a, b int) int {
	x := Min(a, b)
	y := Max(a, b)
	for {
		t := y % x
		if t == 0 {
			return x
		}
		y = x
		x = t
	}
}

func main() {
	a := nextInt()
	b := nextInt()

	gcd := GCD(a, b)

	fmt.Printf("%d", a*b/gcd)
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,h=mii()
arrb=[]
bsum=0
amax=0
for i in range(n):
    x,y=mii()
    arrb.append(y)
    amax=max(x,amax)
    bsum+=y

arr1=sorted([i for i in arrb if (i>amax)],reverse=True)
sumarr1=sum(arr1)
z=0
if h>sumarr1:
    z=ceil((h-sumarr1)/amax)
    h-=z*amax

if h<=0:
    print(z)
    exit()

for i in range(len(arr1)):
    h-=arr1[i]
    z+=1
    if h<=0:
        print(z)
        exit()












Measured memory_bytes: 77912
import copy


def main():
    height, width, leave_black = [int(x) for x in input().split()]
    table = [list(input()) for _ in range(height)]
    ans = 0
    for num_h in range(2 ** height):
        for num_w in range(2 ** width):
            tmp = copy.deepcopy(table)
            for bit_h in range(height):
                if num_h >> bit_h & 1:
                    tmp[bit_h] = ['r'] * width
            for bit_w in range(width):
                if num_w >> bit_w & 1:
                    for row in tmp:
                        row[bit_w] = 'r'
            # print(num_h, num_w, tmp)
            if sum(c == '#' for row in tmp for c in row) == leave_black:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74440
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int a,b;
int main(){
	scanf("%d%*d%d",&a,&b);
	printf("%d",a!=b);
}

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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int k;
    cin >> k;
    for(int i = 0; i < n; i++){
        if(s[i] == 'a') continue;
        if(('{' - s[i]) <= k){
            k -= ('{' - s[i]);
            s[i] = 'a';
        }
    }
    s[n - 1] = char('a' + ((s[n - 1] - 'a') + k) % 26);
    cout << s << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
string s;
int a[1005],frontr;
int main()
{
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='B')
        {
            if(frontr!=0)
                frontr--;
        }
        else
            a[frontr++]=s[i]-'0';
    }
    for(int i=0;i<frontr;i++)
        printf("%d",a[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007
#define int long long

typedef pair<int, int> pint;
typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    int data[n];
    rep(i, n)
    {
        int tmp;
        cin >> tmp;
        data[i] = tmp;
    }

    auto max_ite = max_element(data, data + n);
    auto min_ite = min_element(data, data + n);
    int max_data = *max_ite;
    int min_data = *min_ite;

    vector<pint> ans;
    if (!(min_data > 0 || max_data < 0))
    {
        if (abs(min_data) > abs(max_data))
        {
            rep(i, n)
            {
                ans.push_back(pint(distance(data, min_ite) + 1, i + 1));
                data[i] += min_data;
            }
        }
        else
        {
            rep(i, n)
            {
                ans.push_back(pint(distance(data, max_ite) + 1, i + 1));
                data[i] += max_data;
            }
        }
    }

    if (*min_element(data, data + n) >= 0)
    {
        rep(i, n - 1)
        {
            ans.push_back(pint(i + 1, i + 2));
            data[i + 1] += data[i];
        }
    }
    else
    {
        for (int i = n - 1; i >= 1; i--)
        {
            ans.push_back(pint(i + 1, i));
            data[i - 1] += data[i];
        }
    }

    cout << ans.size() << endl;
    rep(i, ans.size())
    {
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    char a,b,c,d,e,f;
    cin >> a >> b >> c;
    cin >> d >> e >> f;
    if(b == e && a == f && c == d){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int GCD(int a, int b) {
  if (a < b)
    std::swap(a, b);
  int r;
  while (1) {
    r = a % b;
    if (r == 0) {
      return b;
    } else {
      a = b;
      b = r;
    }
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  lint k;
  cin>>k;
  lint result=0;
  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      lint gcd_ab=GCD(a,b);
      for(int c=1;c<=k;c++){
        result+=GCD(gcd_ab,c);
      }
    }
  }
  cout<<result<<endl;

  return 0;
}




Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ll long long
#define M (int)1e9+7
#define I (int)10e5

int32_t main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
    string s;
    cin>>s;
    int count = 0, max_count = INT_MIN;
    for(int i=0;i<3;i++)
    {

        if(s[i]=='R')
        {
            count++;
            max_count = max(count, max_count);
        }
        else
        {
            max_count = max(count, max_count);
            count = 0;
        }
    }
    cout<<max_count;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h> 
using namespace std;
int f[20][70010],sum[70010];
int mp[20][20];
int main()
{
	int n,m,all=0;scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++)
	{
		int u,v,w;scanf("%d%d%d",&u,&v,&w);
		mp[u][v]=mp[v][u]=w;all+=w;
	}
	memset(f,255,sizeof(f));
	for (int i=1;i<(1<<n);i++)
	for (int j=1;j<=n;j++) if((1<<(j-1))&i)
	for (int k=j+1;k<=n;k++) if((1<<(k-1))&i) sum[i]+=mp[j][k];
	for (int i=1;i<(1<<n);i++) if(i&1) f[1][i]=sum[i];
	for (int j=1;j<(1<<n);j++) 
	{
		for (int i=1;i<=n;i++) if(f[i][j]>=0)
		{
			int k=((1<<n)-1)^j;
			for(int p=k;p;p=(p-1)&k)
				for (int d=1;d<=n;d++)
					if(((1<<(d-1))&p)&&(mp[i][d])) f[d][j|p]=max(f[d][j|p],f[i][j]+mp[i][d]+sum[p]);
		}
	}
	int ans=0;
	for (int i=1;i<(1<<n);i++) ans=max(ans,f[n][i]);
	printf("%d\n",all-ans);
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var calculator = new Calculator(N);

            for (int i = 0; i < N; i++)
            {
                var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                for (int j = 0; j < 3; j++)
                {
                    calculator.Values[i, j] = input[j];
                }
            }

            Console.WriteLine(calculator.Ans());
        }
    }

    class Calculator
    {
        private int maxDay;
        private int[,] dp;
        public int[,] Values { get; set; }

        public Calculator(int N)
        {
            maxDay = N - 1;
            dp = new int[N, 3];
            Values = new int[N, 3];
        }

        private int Calc(int day, int type)
        {
            if (day > maxDay) return 0;
            if (dp[day, type] != 0) return dp[day, type];

            if (type == 0) dp[day, type] = Math.Max(Calc(day + 1, 1), Calc(day + 1, 2)) + Values[day, type];
            if (type == 1) dp[day, type] = Math.Max(Calc(day + 1, 0), Calc(day + 1, 2)) + Values[day, type];
            if (type == 2) dp[day, type] = Math.Max(Calc(day + 1, 0), Calc(day + 1, 1)) + Values[day, type];

            return dp[day, type];
        }

        public int Ans()
        {
            return Math.Max(Calc(0, 0), Math.Max(Calc(0, 1), Calc(0, 2)));
        }
    }
}


Measured memory_bytes: 24248
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
void solve(){
}
int main(){
    int n, m;
    cin >> n >> m;
    int ans = 0;
    ans += n * (n - 1) / 2;
    ans += m * (m - 1) / 2;
    cout << ans << endl;
    solve();
    return 0;
}



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

typedef long long int ll;
typedef unsigned long long int ull;

#define REP(i, n) for (ll i = 0; i < n; i++)

using namespace std;

int gcd(ll x, ll y)
{
  return y == 0 ? x : gcd(y, x % y);
}

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

  int g = gcd(a, b);

  // cout << g << endl;

  for (int i = g; i > 0; i--)
  {
    if (g % i == 0)
      k--;
    if (k == 0)
    {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val n = in.readInt
  val a = in.readLine.split(" ").map(_.toInt)
  def rec(cnt:Int, num:Int):Int = {
    if(num % 2 != 0) cnt
    else rec(cnt+1, num/2)
  }
  val ans = a.map(rec(0,_)).sum
  println(ans)
}

Measured memory_bytes: 29416
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
  string S;
  cin >> S;
  string Sb, Se;
  rep(i,7){
    Sb=S.substr(0,i);
    Se=S.substr(S.size()-7+i,S.size());
    if(Sb+Se=="keyence"){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
HW = list(map(int,input().split()))
H=HW[0]
W=HW[1]
a = [input() for i in range(H)]
a.insert(0,'#'*(W+2))
a.append('#'*(W+2))

for i in range(1,H+1):
    a[i]=list(a[i])
    a[i].insert(0,'#')
    a[i].append('#')
    a[i]=''.join(a[i])

a='\n'.join(a)

print(a)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    REP(i,n) cin >> x[i];

    int ans = 1 << 30;
    REP(i,n-k+1) {
        int e = i+k-1;
        ans = min(ans,abs(x[e]-x[i] + min(abs(x[e]),abs(x[i]))));
    }

    cout << ans << '\n';

    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

int A[305][305];
bool used[305];
int has[305];

int main(){
	ios::sync_with_stdio(0);
	int N, M;
	cin >> N >> M;
	rep(i,0,N){
		rep(j,0,M){
			cin >> A[i][j];
		}
	}
	rep(i,1,305){
		used[i] = 1;
	}
	int ans = 305;
	rep(i,0,M){
		rep(j,1,M+1){
			has[j] = 0;
		}
		rep(j,0,N){
			rep(k,0,M){
				if(!used[A[j][k]])
					continue;
				++has[A[j][k]];
				break;
			}
		}
		int best = 0;
		int bestInd = 0;
		rep(j,1,M+1){
			if(has[j] > best){
				best = has[j];
				bestInd = j;
			}
		}
		ans = min(ans, best);
		used[bestInd] = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

int monthTable[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int monthTable2[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};

bool isLeapYear(int year){
	if(year % 4 == 0){
		if(year % 100 == 0){
			if(year % 400 == 0){
				return true;
			}else{
				return false;
			}
		}else{
			return true;
		}
	}else{
		return false;
	}
}

int main(){

	long long int sum,tmp,year,month,day,b,ka,t,w,ki,NUMBER = 735224;
	int count,status;
	char buf[100];

	while(true){
		scanf("%s",buf);
		if(buf[0] == '#')break;

		count = 0;

		for(int i = 0;buf[i] != '\0';i++){
			if(buf[i] == '.')count++;
		}

		sum = 0;
		if(count == 2){ //?\?????????\??????????????´???
			status = 0;
			tmp = 0;
			//???????????´???????????\?????????
			for(int i = 0; buf[i] != '\0';i++){
				if(buf[i] >= '0' && buf[i] <= '9'){
					tmp = 10*tmp+(buf[i]-'0');

					if(buf[i+1] == '\0'){
						day = tmp;
					}
				}else{
					if(status == 0){
						year = tmp;
					}else{
						month = tmp;
					}
					status++;
					tmp = 0;
				}
			}

			if(year == 2012){
				sum = day - 21;
			}else{

				sum += 10;

				//2013???year-1??´?????§?????\??°???????¨?
				for(int i = 2013; i <= year-1; i++){
					if(isLeapYear(i))sum += 366;
					else{
						sum += 365;
					}
				}

				for(int i = 1; i <= month-1; i++){
					if(i == 2 && isLeapYear(year) == true){
						sum += 29;
					}else{
						sum += monthTable[i];
					}
				}
				sum += day;
			}

			printf("%lld.",(sum/144000)%13);
			sum %= 144000;
			printf("%lld.",sum/7200);
			sum %= 7200;
			printf("%lld.",sum/360);
			sum %= 360;
			printf("%lld.",sum/20);
			sum %= 20;
			printf("%lld\n",sum);

		}else{ //????????´?????\??????????????´???
			status = 0;
			tmp = 0;

			for(int i = 0; buf[i] != '\0';i++){
				if(buf[i] >= '0' && buf[i] <= '9'){
					tmp = 10*tmp + (buf[i] - '0');

					if(buf[i+1] == '\0'){
						ki = tmp;
					}
				}else{
					if(status == 0){
						b = tmp;
					}else if(status == 1){
						ka = tmp;
					}else if(status == 2){
						t = tmp;
					}else if(status == 3){
						w = tmp;
					}
					status++;
					tmp = 0;
				}
			}

			sum = 144000*b + 7200*ka + 360*t + 20*w + ki + NUMBER;

			year = 0,month = 1;

			for(int i = 0;sum > 366; i++){
				if(isLeapYear(i)){
					sum -= 366;
				}else{
					sum -= 365;
				}
				year++;
			}

			if((sum <= 365) || (sum == 366 && isLeapYear(year))){

				if(isLeapYear(year)){
					for(int i = 1; i <= 12 && sum > monthTable2[i];i++){
						sum -= monthTable2[i];
						month++;
					}
				}else{
					for(int i = 1; i <= 12 && sum > monthTable[i];i++){
						sum -= monthTable[i];
						month++;
					}
				}
			}else{ //?????¨366??\??§??????year??????????????´??§??????
				year++;
				month = 1;
				sum = 1;
			}
			printf("%lld.%lld.%lld\n",(year)%10000001,month,sum);
		}
	}
	return 0;
}

Measured memory_bytes: 2712
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define rep(i,n) REP(i,1,n)
#define rep0(i,n) REP(i,0,n-1)
#define repG(i,x) for(ll i=pos[x];~i;i=e[i].next)
#define ll long long
const ll N=2e5+7;
const ll INF=1e15+7;
ll pos[N],k[N],b[N],xx[N],yy[N],cc[N];
bool vis[N];
struct edge{ll v,next,c;}e[N*2];
ll n,m,num=0;
void add(ll x,ll y,ll c){e[num]=(edge){y,pos[x],c}; pos[x]=num++;}
void dfs(ll x,ll f){
	vis[x]=1;
	repG(i,x){
		if(e[i].v==f)continue;
		if(vis[e[i].v])continue;
		k[e[i].v]=-k[x];
		b[e[i].v]=e[i].c-b[x];
		dfs(e[i].v,x);
	}
}
int main(){
	memset(pos,-1,sizeof(pos));
	scanf("%lld%lld",&n,&m);
	rep(i,m){
		ll x,y,c; scanf("%lld%lld%lld",&x,&y,&c);
		add(x,y,c);
		add(y,x,c);
		xx[i]=x;
		yy[i]=y;
		cc[i]=c;
	}
	k[1]=1;
	b[1]=0;
	dfs(1,0);
	ll jx=-INF;
	rep(i,m){
		ll a=xx[i],e=yy[i];
		ll ks=k[a]+k[e],bs=b[a]+b[e];
		if(!ks){
			if(bs!=cc[i]){
				printf("0\n");
				return 0;
			}
		}
		else{
			ll j=cc[i]-bs;
			if(j%ks!=0){
				printf("0\n");
				return 0;
			}
			j/=ks;
			if(j<=0){
				printf("0\n");
				return 0;
			}
			if(jx!=-INF&&j!=jx){
				printf("0\n");
				return 0;
			}
			jx=j;
		}
	}
	if(jx!=-INF){
		rep(i,n){
			if(k[i]*jx+b[i]<=0){
				printf("0\n");
				return 0;
			}
		}
		printf("1\n");
	}
	else{
		ll xj=0,sj=INF;
		rep(j,n){
			if(k[j]==1)xj=max(xj,-b[j]);
			else sj=min(sj,b[j]);
		}
		printf("%lld\n",max(0ll,sj-xj-1));
	}
	return 0;
}


Measured memory_bytes: 20224
use std::io;
fn main() {
    let (h, _): (i32, usize) = {
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        let mut it = input.split_whitespace();
        (
            it.next().unwrap().parse().unwrap(),
            it.next().unwrap().parse().unwrap(),
        )
    };
    let a: Vec<i32> = {
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        input
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    let sum = a.iter().sum::<i32>();
    if sum < h {
        println!("No");
    } else {
        println!("Yes");
    }
}


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int k = n/2;
  bool ans = false;
  if(n%2 == 0 & s.substr(0,k) == s.substr(k,k)){
    ans = true;
  }
  if(ans) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  string s;
  string t;
  cin >> s >> t;
  int n = s.size();
  map<char,char> mps;
  map<char,char> mpt;
  char nc = 'a';
  REP(i,n){
    if(mps.count(s[i])) s[i] = mps[s[i]];
    else{
      mps[s[i]] = nc;
      s[i] = nc;
      nc += 1;
    }
  }

  nc = 'a';
  REP(i,n){
    if(mpt.count(t[i])) t[i] = mpt[t[i]];
    else{
      mpt[t[i]] = nc;
      t[i] = nc;
      nc += 1;
    }
  }
  //cout << s << " " << t << endl;

  if(s == t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3892
#include<iostream>
#include<queue>
#include<bitset>
#include<algorithm>
#include<climits>
#include<vector>
#include<deque>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define fill(x,y) memset(x,y,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define dump(a) rep(i,a.size()){ cout<<a[i]<<" "; } cout<<endl;
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define INF INT_MAX/3
#define EPS 1e-7

/* ゲーム
 * ゲーム木を書いて、どこがまとめられるか？を考える
 *
 */

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

  bool deleted;
  int depth = 0;
  while(true){
    /* dbg(s); */
    int n = s.length();
    deleted = false;
    repl(i,1,n-1){
      /* dbg(s[i]); */
      if(s[i-1]!=s[i+1]) { 
        /* dbg("hoge"); */
        s.erase(s.begin()+i);
        deleted = true;
        break;
      }
    }
    if(!deleted){
      break;
    }else{
      depth+=1;
    }
  }
  if(depth%2==0) cout<<"Second"<<endl;
  else cout<<"First"<<endl;
  return 0;
}


Measured memory_bytes: 512
from collections import deque
n,m = map(int, input().split())
h = tuple(map(int, input().split()))
G = [[] for _ in range(n+1)]
seen = [-1]*(n+1)
for i in range(m):
    a,b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
ans = 0
for j in range(1,n+1):
    tmp = h[j-1]
    flag = True
    for nq in G[j]:
        if h[nq-1]>= tmp:
            flag = False
            break
    if flag:
        ans +=1
print(ans)


Measured memory_bytes: 94440
import bisect
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
A.sort()
B.sort()
if len(set(A)) != N or len(set(B)) != M:
    print(0)
    quit()
if A[-1] != N * M or B[-1] != N * M:
    print(0)
    quit()
ans = 1
mod = 10 ** 9 + 7
for i in reversed(range(1, N * M + 1)):
    ai = bisect.bisect_left(A, i)
    bi = bisect.bisect_left(B, i)
    a_flag = A[ai] == i
    b_flag = B[bi] == i
    if a_flag and b_flag:
        pass
    elif a_flag:
        cand = M - bi
        ans = (ans * cand) % mod
    elif b_flag:
        cand = N - ai
        ans = (ans * cand) % mod
    else:
        cand = (N - ai) * (M - bi) - (N * M - i)
        if cand <= 0:
            print(0)
            quit()
        ans = (ans * cand) % mod
print(ans)


Measured memory_bytes: 3188
import java.io.*;
import java.util.StringTokenizer;
 
class Main{
 
static final PrintWriter out=new PrintWriter(System.out);
static boolean[] hasParent;
 
static class Node{
int id;
int p;
int rank;
int height;
int s;
int deg;
int l;
int r;
String type;
Node(int id){
this.id=id; this.p=-1; this.rank=-1; this.height=-1; this.s=-1; this.l=-1; this.r=-1; this.deg=0; this.type="internal node";
}
}
 
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int num=Integer.parseInt(br.readLine());
Node[] ns=new Node[num];
hasParent=new boolean[num];
StringTokenizer st;
StringBuilder sb;
for(int i=0;i<num;i++){
ns[i]=new Node(i);
}
for(int i=0;i<num;i++){
st=new StringTokenizer(br.readLine());
int id=Integer.parseInt(st.nextToken());
Node n=ns[id];
int l=Integer.parseInt(st.nextToken());
n.l=l;
int r=Integer.parseInt(st.nextToken());
n.r=r;
if(l==-1&&r==-1){
n.type="leaf";
n.height=0;
}
else if(l==-1){
ns[r].p=id;
n.deg=1;
hasParent[r]=true;
}
else if(r==-1){
ns[l].p=id;
n.deg=1;
hasParent[l]=true;
}
else{
ns[l].p=id;
ns[l].s=r;
hasParent[l]=true;
ns[r].p=id;
ns[r].s=l;
n.deg=2;
hasParent[r]=true;
}
}
for(int i=0;i<num;i++){
Node an=ns[i];
if(an.rank<0) an.rank=setRank(i,ns);
if(an.height<0) an.height=setHeight(i,ns);
sb=new StringBuilder();
sb.append("node ");
sb.append(i);
sb.append(": parent = ");
sb.append(an.p);
sb.append(", sibling = ");
sb.append(an.s);
sb.append(", degree = ");
sb.append(an.deg);
sb.append(", depth = ");
sb.append(an.rank);
sb.append(", height = ");
sb.append(an.height);
sb.append(", ");
sb.append(an.type);
sb.append(System.getProperty("line.separator"));
out.print(sb);
}
out.flush();
}
 
private static int setRank(int now,Node[] ns){
if(ns[now].rank>=0) return ns[now].rank;
if(!hasParent[now]){
ns[now].type="root";
return ns[now].rank=0;
}
return ns[now].rank=setRank(ns[now].p,ns)+1;
}

private static int setHeight(int now,Node[] ns){
if(now<0) return Integer.MIN_VALUE/2;
if(ns[now].height>=0) return ns[now].height;
return ns[now].height=Math.max(setHeight(ns[now].l,ns),setHeight(ns[now].r,ns))+1;
}
}

Measured memory_bytes: 17032
k = int(input())
import math
ans = 0
for i in range(1,k+1):
         for j in range(i,k+1):
                  for l in range(j,k+1):
                           tmp = math.gcd(i,j)
                           tmp = math.gcd(tmp,l)
                           if i == j == l:
                                    ans += tmp
                           elif i == j or j == l or l == i:
                                    ans += 3 * tmp
                           else:
                                    ans += 6 * tmp
print(ans)


Measured memory_bytes: 9180