akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<list>
#include<algorithm>
using namespace std;

int main(){
    int q, x;
    char command[20];
    list<int> v;
    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> command;
        if(command[0] == 'i'){ //insert
            cin >> x;
            v.push_front(x);
        }else if(command[6] == 'L'){ // deleteLast
            v.pop_back();
        }else if(command[6] == 'F'){ // deleteFirst
            v.pop_front();
        }else if(command[0] == 'd'){ // delete
            cin >> x;
            for(list<int>::iterator it = v.begin(); it != v.end(); it++){
                if( *it == x ){
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for(list<int>::iterator it = v.begin(); it != v.end(); it++){
        if( i++ ) cout << " ";
        cout << *it;
    }
    cout << endl;
}

Measured memory_bytes: 34336
from collections import deque
import sys
input = sys.stdin.readline

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
dist = [[-1]*w for _ in range(h)]  # 黒ならdist[i][j]は0、白なら-1

black_cells = deque()

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            black_cells.append((i, j))
            dist[i][j] = 0

def bfs(black_cells, dist):
    d = 0
    while black_cells:
        h_black, w_black = black_cells.popleft()
        d=dist[h_black][w_black]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h_black+dy
            new_w = w_black+dx
            if new_h < 0 or h <= new_h or new_w < 0 or w <= new_w:
                continue
            if dist[new_h][new_w] == -1:
                dist[new_h][new_w] = d+1
                black_cells.append((new_h, new_w))
    return d

d = bfs(black_cells, dist)
print(d)


Measured memory_bytes: 120924
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
	char a[10], mozi[100];
	int n, x, y;
	scanf("%s %d", &a, &n);
	y=0;
	for(x=0; x<n; x++)
	{
		scanf("%s", mozi);
		strncat(mozi,mozi,10);
		if((strstr(mozi,a))!=NULL)
		{
			y++;
		}
	}
	printf("%d\n", y);
	
	return 0;
}


Measured memory_bytes: 2720
n,m=map(int,input().split())
a=list(map(int,input().split()))
l=[0]*(m+2)
for i,j in zip(a,a[1:]):
    if j>i+1:
        l[j+1]-=1
        l[i+2]+=1
    elif i>j:
        if i<=m-2:
            l[i+2]+=1
            l[m+1]-=1
            l[1]+=1
            l[j+1]-=1
        else:
            l[i+2-m]+=1
            l[j+1]-=1
from itertools import accumulate
l=list(accumulate(l))
ans=0
l1=0
for i,j in zip(a,a[1:]):
    if j>i:
        ans+=j-i
        l[j+1]-=(j-i-1)
    else:
        l1+=m-i
        ans+=m+j-i
        l[j+1]-=(m+j-i-1)
l[1]=l1
l=list(accumulate(l))
print(ans-max(l[1:m+1]))

Measured memory_bytes: 15076
import java.util.*;

public class Main{
    public static void main(String[] args){
    //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Long[] A = new Long[N+1];
        Long[] B = new Long[N];
        for(int i=0; i<N+1; i++){
            A[i] = sc.nextLong();
        }
        for(int i=0;i<N;i++){
            B[i] = sc.nextLong();
        }
    //処理
    Long ans = 0L;
        for(int i=0;i<N;i++){
            if(A[i]-B[i]>=0){A[i] -= B[i];ans+=B[i];}
            else{
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0L;
                
                
                if(A[i+1]-B[i]>=0L){
                    A[i+1]-=B[i];
                    ans += B[i];
                }
                else if(A[i+1]-B[i]<0L){
                    ans += A[i+1];
                    A[i+1]=0L;
                }
            }
        }
        System.out.println(ans);
        sc.close();

    }
}


Measured memory_bytes: 96860
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readInt()
  val d = n % 10
  if (d == 3) println("bon")
  else if (List(0, 1, 6, 8).contains(d)) println("pon")
  else println("hon")


  def readIntPair: (Int, Int) = {
    val Array(x, y) = StdIn.readLine().split(" ").map(_.toInt)
    (x, y)
  }

  def readIntArr = StdIn.readLine().split(" ").map(_.toInt)
}






Measured memory_bytes: 54512
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;

const int N=105;
int L[N],R[N];


int main(){	
	int n;cin>>n;
	For(j,0,n)cin>>L[j];
	For(i,0,n)cin>>R[i];
	For(i,1,n)L[i]+=L[i-1];
	roF(i,n-2,0)R[i]+=R[i+1];
	int mx=0;
	For(i,0,n)mx=max(mx,L[i]+R[i]);
	cout<<mx<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
int main() {
	int a, b;
	bool yes = true;
	char s[12];
	scanf("%d%d%s", &a, &b, s);
	if (strlen(s) != a + b + 1) yes = false;
	for (int i = 0; i < a + b + 1; i++) {
		if (i == a && s[a] != '-') yes = false;
		if (i != a && ('0' > s[i] || s[i] > '9')) yes = false;
	}
	if (yes)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  string S; cin >> S;

  vector<int> ans(S.size());
  int from = 0;
  int to = 0;
  int point = 0;
  for (int i=0;i<S.size()-1;i++) {
    if (S.at(i) == 'R' && S.at(i+1) == 'L') {
      point = i;
    }
    if (S.at(i) == 'L' && S.at(i+1) == 'R') {
      to = i;

      for (int j = from; j <= to; j++) {
        if (abs(point - j) % 2 == 0) {
          ans[point]++;
        } else {
          ans[point+1]++;
        }
      }
      
      from = i+1;
    }
    if (S.size() == i+2) {
      to = i+1;
      for (int j = from; j <= to; j++) {
        if (abs(point - j) % 2 == 0) {
          ans[point]++;
        } else {
          ans[point+1]++;
        }
      }
    }
  }

  for (auto n : ans) cout << n << " ";
}

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

int main(){
    int n;
    while(1){
        cin>>n;
        if(n==0)break;

        double score[n];
        double sum=0;
        for(int i=0;i<n;i++){
            cin>>score[i];
            sum += score[i];
        }
        double m = sum/n;
        
        double a2=0;

        for(int i=0;i<n;i++){
            a2 += pow(score[i]-m,2);
        }
        a2 /= n;

        double a= sqrt(a2);

        printf("%8lf\n",a);

    }



    return 0;
}



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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


auto solve() {
    ll n, k;
    cin >> n >> k;
    vll A(n);
    for (auto &&e:A) cin >> e;

    vi bits(64, 0);

    REP(j, n) {
        REP(i, 64) {
            if (A[j] % 2 == 1) bits[64 - i - 1]++;
            A[j] /= 2;

        }
    }

    vector<bool> kbits(64, false);
    REP(i, 64) {
        if (k % 2 == 1) kbits[64 - i - 1] = true;
        k >>= 1;
    }

    vector<bool> dp(64, false);
    bool free = false;
    REP(i, 64) {
        bool is_on = (n - bits[i]) > bits[i];
        if (is_on) {
            if (free) dp[i] = true;
            else if (kbits[i]) dp[i] = true;
        } else {
            if (kbits[i]) free = true;
        }
    }

    ll ans = 0;
    ll pow = 1;
    RREP(i, 64) {
        ll c = 0;
        if (dp[i])
            c = n - bits[i];
        else
            c = bits[i];
        ans += c * pow;
        pow *= 2;
    }

    return ans;
}


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

//    cout << (solve() ? "Yes" : "No") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 1024
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int N = 1e5 + 5; 
vii g[N];
bool vis[N];
int d[N]; 

void dfs(int node, int par = -1) {
	if(vis[node]) return ; 
	vis[node] = 1; 

	for(auto i : g[node]) {
		if(not vis[i]) {
			dfs(i,node) ;
		}
		d[node] = max(d[node], d[i] + 1) ;
	}
}

void solve(int test) {
	int n,m;cin >> n >> m ;

	rep(i,0,m) {
		int u,v; cin >> u >> v ;
		g[u].eb(v) ;
	}
	
	rep(i,1,n+1) {
		if(not vis[i]) dfs(i); 
	}

	cout << *max_element(d+1, d+n+1) ; 

}

int32_t main() {
 

    fast;
	int t=1;
	// cin>>t;
	rep(i,1,t+1) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define cinv(n,vec) VL vec(n);for(auto&v:vec)cin>>v;
#define int long long
#define itn int
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define m_t make_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (signed)(a.size())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define out(a) cout<<(a)<<endl
#define ENDL cout<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define fi first
#define se second
#define V vector
#define P pair
#define T tuple
#define PQ priority_queue
#define cont const auto
#define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a))
typedef long long ll;
typedef double D;
typedef long double LD;
typedef string str;
typedef vector<ll> VL;
typedef pair<ll,ll> PL;
typedef vector<pair<ll,ll>> VP;
typedef tuple<ll,ll,ll> T3;
typedef tuple<ll,ll,ll,ll> T4;
typedef struct{ll to;ll cost;} Graphs;
typedef V<V<Graphs>> AdjList;
const signed INF = (1LL<<30);
const long long MOD = (1e9+7);
const long long LINF = (1LL<<60);
const long long LMAX = LLONG_MAX;
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  
  int N,Ma,Mb;
  cin>>N>>Ma>>Mb;
  VL a(N),b(N),c(N);
  rep(i,N)cin>>a[i]>>b[i]>>c[i];

  V<V<V<ll>>>dp(50,V<V<ll>>(500,V<ll>(500,INF)));
  dp[0][0][0]=0;
  rep(i,N){
    rep(j,450){
      rep(k,450){
        if(dp[i][j][k]==INF)continue;
        chmin( dp[i+1][j][k],dp[i][j][k] );
        chmin( dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i] );
      }
    }
  }
  
  ll ans=INF;
  reps(a,450)reps(b,450){
    if(a*Mb==b*Ma)chmin(ans,dp[N][a][b]);
  }
  if(ans==INF)out(-1);
  else out(ans);


  return 0;
}

Measured memory_bytes: 100864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#pragma gcc optimize( Ofast )
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
#define pb push_back
#define fs first
#define sc second
#define MOD 1000000007
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;

bool perf(long x)
{
  // Find floating point value of
  // square root of x.
  long double sr = sqrt(x);

  // If square root is an integer
  return ((sr - floor(sr)) == 0);
}

int M[11][11];
int n, d;
bool calc(int a, int b){
    ll sm = 0;
    rep(i,0,d){
        ll diff = M[a][i]-M[b][i];
        sm += diff*diff;
    }
    return perf(sm);
}

int main(){
    cin.sync_with_stdio(false);
    cin >>  n >> d;
    rep(i,0,n){
        rep(x,0,d){
           cin >> M[i][x];
        }
    }
    int sm = 0;
    rep(i,0,n){
        rep(x,i+1,n){
            sm += calc(i,x);
        }
    }
    cout << sm << endl;
}


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

using namespace std;

using ll = long long;

const int MOD = 1e9 + 7;

template<typename T>
void min_self(T& a, T b)
{
    a = min(a,b);
}

template<typename T>
void max_self(T& a, T b)
{
    a = max(a,b);
}

const int Nax=3000;

double dp[Nax][Nax];  // [coins][heads]

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    memset(dp,0,sizeof(dp));
    
    dp[0][0] = 1;
    
    int N;
    scanf("%d",&N);
    
    double probHead;
    for(int coins=1; coins<=N; ++coins)
    {
        scanf("%lf",&probHead);
        
        for(int heads=0; heads<=coins; ++heads)
        {
            if(heads == 0)
            {
                dp[coins][heads] = dp[coins-1][heads]*(1-probHead);
            }
            else
            {
                dp[coins][heads] = dp[coins-1][heads]*(1-probHead) + 
                                    dp[coins-1][heads-1]*(probHead);
            }
        }
    }
    
    double answer = 0;
    
    for(int heads=(N+1)/2; heads<=N; ++heads)
    {
        answer += dp[N][heads];
    }

    std::cout << std::setprecision (9) << answer << std::endl;


}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
vector<ll> v;
vector<ll> v1;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/


int main()
{
	cin >> n >> k;
	v.resize(n);
	REP(i, n) cin >> v[i];
	REP(i,n-1)
	{
		if(v[i+1]-v[i]<=k) {
			ans += v[i + 1] - v[i];
		}else {
			ans += k;
		}
	}
	cout << ans + k << endl;
}

Measured memory_bytes: 1792
var a:array[0..2000000]of longint;
    i,ans,n:longint;
    sum,su,s:int64;
begin
  ans:=maxlongint;
  readln(n);
  for i:=1 to n do
  begin
    read(a[i]);
    inc(sum,a[i]);
  end;
  for i:=1 to n-1 do
  begin
    dec(sum,a[i]);
    inc(su,a[i]);
    s:=abs(sum-su);
    if s<ans then
      ans:=s;
  end;
  writeln(ans);
end.

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

using namespace std;
#define int long long
#define N 666666
int a[N],b[N];
int n;
signed main(){
	int ans=0,ans2=0;
	cin>>n;
	int sa=0,sb=0;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
	sort(a+1,a+1+n);sort(b+1,b+1+n);
	if(n%2) cout<<b[n/2+1]-a[n/2+1]+1;
	else cout<<(b[n/2]+b[n/2+1])-(a[n/2]+a[n/2+1])+1;
	//cout<<sb-sa+1;
	return 0;
}

Measured memory_bytes: 6740
n = int(input())
a = list(map(int, input().split()))

money = 1000
stock = 0
day = 0


def buy_all(m, s, price):
    stock_n = m // price
    price_all = price * stock_n
    s += stock_n
    m -= price_all

    return m, s


def sell_all(m, s, price):
    price_all = price * s
    s = 0
    m += price_all

    return m, s


while day < n - 1:
    today, tomorrow = a[day], a[day + 1]

    if today > tomorrow:
        money, stock = sell_all(money, stock, today)
    elif today < tomorrow:
        money, stock = buy_all(money, stock, today)
    else:
        pass

    day += 1

money, stock = sell_all(money, stock, a[-1])

print(money)


Measured memory_bytes: 61856
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	class Node {
		int parent;
		public Node(int x) {
			this.parent = x;
		}
	}
	
	class DisjointSet {
		Node[] p;
		int[] rank;
		
		public DisjointSet(int size) {
			p = new Node[size];
			rank = new int[size];
			for (int i = 0; i < size; i++) {
				makeSet(i);
			}
		}

		private void makeSet(int x) {
			p[x] = new Node(x);
			rank[x] = 0;
		}
		
		private int findSet(int x) {
			while (x != p[x].parent) {
				x = p[x].parent;
			}
			return x;
		}
		
		public boolean same(int x, int y) {
			return findSet(x) == findSet(y);
		}
		
		public void unite(int x, int y) {
			link(findSet(x), findSet(y));
		}

		private void link(int x, int y) {
			if (rank[x] < rank[y]) {
				p[x].parent = y;
			} else {
				p[y].parent = x;
				if (rank[x] == rank[y]) {
					rank[y]++;
				}
			}
		}
	}
	
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		DisjointSet ds = new DisjointSet(n);
		int q = Integer.parseInt(st.nextToken());
		for (int i = 0; i < q; i++) {
			st = new StringTokenizer(reader.readLine());
			int c = Integer.parseInt(st.nextToken());
			int x = Integer.parseInt(st.nextToken());
			int y = Integer.parseInt(st.nextToken());
			if (c == 0) {
				ds.unite(x, y);
			} else {
				System.out.println(ds.same(x, y)?"1":"0");
			}
		}
		reader.close();
	}
}


Measured memory_bytes: 60128
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner InData = new Scanner(System.in);
        int a = InData.nextInt();
        int b = InData.nextInt();
        int c = InData.nextInt();
        int Shang;
        int Yu;
        int Acc = 0;
        for(int n = a; n<=b; n++){
            Shang = c/n;
            Yu = c%n;
            if(Shang != 0 && Yu == 0){
                Acc++;

            }

        }
        System.out.println(Acc);
    }
}

Measured memory_bytes: 26204
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;
struct Zalgorithm{
    vector<int> Z;
    Zalgorithm(string s){
        Z.resize(s.size());
        Z[0]=s.size();
    }

    void Zeach(string s){
        int i=1,j=0;
        while(i<Z[0]){
            while(i+j<Z[0]&&s[j]==s[i+j]) j++;
            Z[i]=j;
            if(j==0){
                i++;
                continue;
            }
            int k=1;
            while(k+Z[k]<j){
                Z[i+k]=Z[k];
                k++;
            }
            i+=k;
            j-=k;
        }
        return;
    }

    int Zmax(string s){
        Zeach(s);
        int ans=0;
        for(int i=0; i<s.size(); i++){
            int can=min(i,Z[i]);
            ans=max(ans,can);
        }
        return ans;
    }
};
int main(){
    int n;
    string s;
    cin >> n >> s;
    int fin=0;
    rp(i,n){
        Zalgorithm zal(s);
        int cand=zal.Zmax(s);
        fin=max(fin,cand);
        s=s.substr(1,s.size()-1);
    }
    cout << fin << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define db(x) cout << "#x:" << x << endl
#define dd() cout << "Out put!\n"
const int mod=1e9+7,maxn=1000010;
const double eps=1e-8,pi=acos(-1.0);
const int inf=0x7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],v[maxn];
string s;
signed main()
{
	ios::sync_with_stdio(0);
	int t=1;
//	cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		cout << n+n*n+n*n*n;
	} 
}


Measured memory_bytes: 3652
N, K = (int(x) for x in input().split(' '))
S = input()

x = [1]
for i in range(1, N):
    if S[i-1] == S[i]:
        x[-1] += 1
    else:
        x.append(1)

if len(x) > 2*K+1:
    ans = sum(x) - len(x) + 2*K
else:
    ans = N - 1
print(ans)


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

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

  vector<string> a(H);
  for (int i = 0; i < H; i++)
  {
    cin >> a[i];  
  }
  vector<string> ans(H + 2);
  for(int i=0;i<H + 2;i++){
    for(int j=0;j<W + 2;j++){
      ans[i]+="#";
    }
  }

  for (int i = 0; i < H; i++)
  {
      for (int j = 0; j < W; j++)
      {
          ans[i + 1].at(j + 1) = a[i].at(j);
      }
      
  }
  for (int i = 0; i < H + 2; i++)
  {
    cout << ans[i] << endl;

  }
  
  
  return 0;
  
}



Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        k: usize,
        a: [u64; n],
    }
    let mut cnt = 0;
    if n <= 3 {
        cnt += 1
    } else {
        cnt += (n - 1 - 1) / (k - 1) + 1;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
import sys
h, w = map(int, sys.stdin.readline().split())
dp = [[0 for j in range(w)] for i in range(h)]
G = [[int(j) for j in sys.stdin.readline().split()] for i in range(h)]
maxWidth = 0
for i in range(0, h):
    for j in range(0, w):
        dp[i][j] = (G[i][j] + 1) % 2
        maxWidth |= dp[i][j]
for i in range(1, h):
    for j in range(1, w):
        if(G[i][j] == 0):
            dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1
            if maxWidth < dp[i][j]:
                maxWidth = dp[i][j]
print(maxWidth * maxWidth)

Measured memory_bytes: 58592
data_h = []
data_w = []
while True:
	h, w = (int(i) for i in input().split())
	if h == 0 == w:
		break
	else:
		data_h.append(h)
		data_w.append(w)

#print(data_h, data_w)
#print(len(data_h),len(data_w))

for count in range(len(data_h)):
	h = data_h[int(count)]
	w = data_w[int(count)]
	for i in range(h):
		for j in range(w):
			print('#',end='')
		print('')
	print('')

Measured memory_bytes: 6808
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
 
#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) ( (n % k) + k ) % k
#define isOn(S, j) (S & (1 << j) )
#define setBit(S, j) (S | (1 << j ) )
#define LSB(S) (S & (-S))

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    int a, b, c, d, e, f;

    cin >> a >> b >> c >> d >> e >> f;

    bitset<3005> smag;
    for (int i = 0; i <= 30; i++) 
        for (int j = 0; j <= 30; j++)
            if (a*i*100 + b*j*100 <= f)
                smag[a*i*100+b*j*100] = 1;

    bitset<3005> smaz;
    for (int i = 0; i <= 3000; i++)
        for (int j = 0; j <= 3000; j++)
            if (i*c + j*d <= f)
                smaz[i*c + j*d] = 1;

    int res = min(a*100, b*100), sug = 0;

    for (int i = 100; i <= 3000; i += 100) {
        for (int j = 1; j <= 3000; j++) {
            if (smag[i] && smaz[j] && j <= (i / 100) * e && i + j <= f) {
                int act = j * res;
                int mx = sug * (i+j);
                if (act > mx) {
                    res = j + i;
                    sug = j;
                }
            }
        }
    }

    cout << res << " " << sug << endl;

    return 0;
}  

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)


int main() {
	int n,m;
	cin >> n >> m;
	vector<int> a(n);
	rep(i, n)	cin >> a[i];
	double all = 0;
	rep(i, n)	all += a[i];

	int counter = 0;

	rep(i, n) {
		if (a[i] >= all / (double)(4 * m))
			counter++;
	}

	if (counter >= m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
 
lli MOD  = 1000000007;
lli inf = 1e18;
 
void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
 
#define N 1000005
 
lli pref[N],suff[N],arr[N];
 
int main(void)
{
  lli n;
  cin>>n;
 
  for(int i=1;i<=n;i++)
  {
  	cin>>arr[i];
  }
 
  for(lli i=1,gc=arr[1];i<=n;i++){
  	gc = __gcd(arr[i] , gc);
  	pref[i] = gc;
  }
 
  for(lli i=n,gc=arr[n];i>=1;i--){
  	gc = __gcd(arr[i] , gc);
  	suff[i] = gc;
  }
 
  lli res = 0;
 
  for(lli i=1;i<=n;i++) {
  	res = max(res , __gcd(pref[i-1],suff[i+1]));
  }
 
  cout<<res;
  return 0;
}
 
 
void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

Measured memory_bytes: 9216
#include <stdio.h>
int main(){
	long int a=0;
	long int b=0;
	long int c=0;
	scanf("%ld",&a);
	c=a;
	while(1)
	{
		
		if(a==0) break;
		b+=a%10;
		a=a/10;
		
	}
	if(c%b==0)
	printf("Yes");
	else printf("No");
	return 0;
}

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

int main() {
  int a, b; cin >> a >> b;
  int ans = 0;
  for (int i = a; i <= b; i++) {
    if (i / 10000 == i % 10 && i / 1000 % 10 == i % 100 / 10) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n, d, x, y, c = 0;
	cin >> n >> d;
	d *= d;
	for (ll i = 0; i < n; i++){
		cin >> x >> y;
		if (x * x + y * y <= d) c++;
	}
	cout << c << endl;
}

Measured memory_bytes: 3632
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS
int c(char c) {
    return (int)(c-48);
}
int binpow(int a,int b,int mod) {
    if(b == 0) return 1;
    if(b&1) return (a*binpow(a,b-1,mod))%mod;
    return (binpow(a,b/2,mod)*binpow(a,b/2,mod))%mod;
}
vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
string s;
cin>>s;
int n=s.size();
reverse(all(s));
vector<int> rem(n);
rem[0] = c(s[0])%2019;
map<int,int> mp;
mp[rem[0]]++;
mp[0]++; 
FOR(i,1,n) rem[i] = ((c(s[i])*binpow(10,i,2019))%2019 + rem[i-1])%2019,mp[rem[i]]++;
int ans=0;
// FOR(i,0,n) cout<<rem[i]<<" ";
for(auto [k,v] : mp) ans+=v*(v-1)/2;
cout<<ans; 
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 5096
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007
#define iP pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define inf 1e15
#define mod1 998244353
#define pi 3.141592653589793238
void solve(int tc){
    int n;
    cin>>n;
    set<string> s;
    for(int i=0;i<n;i++){
        string str;
        cin>>str;
        s.insert(str);
    }
    cout<<s.size();
}
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;cerr.tie(NULL);cout.precision(20);
    int t=1,ctr=0;
    // cin>>t;
    while(t--){
        solve(ctr+1);
        ctr++;
    }
}

Measured memory_bytes: 19236
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back

int abs(int a){
    return ( a>0 ? a : -a );
}
int main(){
    int a,b;
    cin >> a >> b;
    if(a%b==0){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int mod=1e9+7;
struct P{
	int l,r,x;
}a[305];
int n,m,f[305][305][305];
bool cmp(P a,P b){
	return a.r<b.r;
}
int add(int a,int b){return a+b>=mod?a+b-mod:a+b;}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d%d%d",&a[i].l,&a[i].r,&a[i].x);
	sort(a+1,a+m+1,cmp);
	f[0][0][0]=1;
	for(int i=0,pos=0,pre=0;i<=n;i++){
		while(pos<m&&a[pos+1].r==i) pos++;
		for(int p=0;p<i;p++){
			for(int j=0;j<=p;j++)if(!j||j<p){
				for(int k=pre+1;k<=pos;k++){
					if(a[k].x==1&&a[k].l<=p){
						f[i][p][j]=0;break;
					}
					if(a[k].x==2&&(a[k].l>p||a[k].l<=j)){
						f[i][p][j]=0;break;
					}
					if(a[k].x==3&&!(a[k].l<=j)){
						f[i][p][j]=0;break;
					}
				}
			}
		}
		if(i==n) continue;
		for(int p=0;p<=i;p++)if(!p||p<i){
			for(int j=0;j<=p;j++)if(!j||j<p){
				f[i+1][p][j]=add(f[i+1][p][j],f[i][p][j]);
				f[i+1][i][j]=add(f[i+1][i][j],f[i][p][j]);
				f[i+1][i][p]=add(f[i+1][i][p],f[i][p][j]);
			}
		}
		pre=pos;
	}
	int ans=0;
	for(int i=0;i<=n;i++){
		for(int p=0;p<=n;p++) ans=add(ans,f[n][i][p]);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 108800
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m;
	int s[11]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
	cin>>n>>m;
	for(int w,h,i=0;i<m;i++){
		cin>>w>>h;
		if(s[w]!=-1 && s[w]!=h){
			cout<<-1<<endl;
	        return 0;
	    }
	    else
	        s[w]=h;
	}
	if(n==1){
		if(s[1]==-1)
		    cout<<0<<endl;
		else
		    cout<<s[1]<<endl;
	}
	else{
		if(!s[1])
			cout<<-1<<endl;
		else{
			if(s[1]==-1)
			    cout<<1;
			else
			    cout<<s[1];
			for(int i=2;i<=n;i++){
				if(s[i]==-1)
				    cout<<0;
				else
				    cout<<s[i];
			}
			cout<<endl;
		}
	}
	
	return 0;
}

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

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;

            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            c = (x - a) % b;

            Console.WriteLine(c);

            Console.ReadKey();



        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>

using namespace std;

int main(int argc, const char * argv[]) {
    int n, m, l;
    scanf("%d %d %d", &n, &m, &l);
    int A[n][m], B[m][l];
    long long int C[n][l];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            C[i][j] = 0;
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            scanf("%d", &A[i][j]);
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            scanf("%d", &B[i][j]);
        }
    }

    for(int i = 0; i < n; i++){
        for(int k = 0; k < l; k++){
            for(int j = 0; j < m; j++){
                C[i][k] += A[i][j]*B[j][k];
            }
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < l-1; j++){
            printf("%lld ", C[i][j]);
        }
        printf("%lld\n", C[i][l-1]);
    }
    return 0;
}



Measured memory_bytes: 2804
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
AB = [[int(x) for x in input().split()] for _ in range(N-1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
 
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
 
value = [0] * (N+1)
for p,x in PX:
    value[p] += x

def dfs(parent,i,add):
    for k in graph[i]:
        if k != parent:
            value[k] += add
            dfs(i,k,value[k])
    

dfs(0,1,value[1])

ans = value[1:]

print(*ans)

Measured memory_bytes: 286076
#include<bits/stdc++.h>
#define i64 long long 

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    int l=0;
    int r=1000;
    int ans=1000;
    while(l<=r)
    {
        int mid=(l+r)>>1;
        if(mid*a-mid+1>=b)
        {
            ans=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    cout<<ans;
}
/*
 
Code written by a random fan of Tokyo_Square 
gb_DH_VNU

 */


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int a, b, c;

int main() {
  cin >> a >> b >> c;
  int ma = max(a, max(b, c));
  int sum = a + b + c;
  if (ma == sum - ma) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Measured memory_bytes: 3600
#include <string>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
using namespace std;

int main() {
    char s[4];
    scanf("%s", s);
    int n = strlen(s);
    if (n == 2) {
        printf("%s\n", s);
    }
    else if (n == 3) {
        for (int i = n - 1; i >= 0; --i) {
            printf("%c", s[i]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x, y;
	while (1) {
		scanf("%d %d", &x, &y);
		
		if (x == 0 && y == 0) {
			break;
		}
		
		if (x < y) {
			printf("%d %d\n", x, y);
		} else {
			printf("%d %d\n", y, x);
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>

typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

ll MOD = 1000000007;
ll mod_add(ll a, ll b) {
    return (a + b) % MOD;
}
ll mod_sub(ll a, ll b) {
    return (a + MOD - b) % MOD;
}
ll mod_mul(ll a, ll b) {
    return ((a % MOD) * (b % MOD)) % MOD;
}
ll mod_inv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll mod_div(ll a, ll b) {
    return (a % MOD) * mod_inv(b, MOD) % MOD;
}

int main(void) {
    ll l, ans = 1;
    cin >> l;
    FOR(i, 1, l+1) {
        ans = mod_mul(ans, i);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define SORT(i) sort((i).begin(), (i).end())
#define INF 2000000000
constexpr ll mod = 1e9 + 7;
 
int main(){
    int N;
    cin >> N;
    cout << N * N * N << "\n";

    return 0;
}

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

using namespace std;
typedef long long ll;
const int N = 1005;
const ll mod = 1e9+7;
const int INF = 1 << 30;

ll dp[N][N];
char grid[N][N];
int n, m;
bool valid(int i, int j) {
    return (i >= 0 && i < n && j >= 0 && j < m && grid[i][j] == '.');
}
ll solve(int i, int j) {
    if (!valid(i, j)) {
        return 0;
    }
    if (i == n - 1 && j == m - 1) {
        return 1;
    }
    if (dp[i][j] != -1) {
        return dp[i][j];
    }
    return dp[i][j] = (solve(i, j + 1) % mod + solve(i + 1, j) % mod) % mod;
}

int main()
{

    ios::sync_with_stdio(false);cin.tie(0);ios_base::sync_with_stdio(0);
    memset(dp, -1, sizeof(dp));
    cin >> n >> m;
    for (int i = 0; i < n;i ++) {
        for (int j = 0; j < m; j++) {
            cin >> grid[i][j];
        }
    }

    cout << solve(0,0) % mod << endl;


    return 0;
}

Measured memory_bytes: 12564
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int ans;

int main(){
	int n,d[100002];
	cin >> n;
	rep(i,n){ cin >> d[i]; }

	
	sort(d, d + n);
	if (n % 2 == 0){
		ans = d[n / 2] - d[n / 2 - 1];
	}
	else{ ans = 0; }


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <cstdio>

int main(void)
{
    int A,B,N;
    scanf("%d%d%d",&N,&A,&B);
    if(N==1)
    {
        if(A==B)
            printf("1\n");
        else
            printf("0\n");
    }
    else 
    {
        if(A>B)
            printf("0\n");
        else
            printf("%lld\n",(long long )(B-A)*(N-2)+1);
    }
    return 0;
}



Measured memory_bytes: 128
#include <iostream>

void solve() {
    int d, t, s;
    std::cin >> d >> t >> s;
    std::cout << (t * s >= d ? "Yes" : "No") << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> ii;

int main() {
  ios_base::sync_with_stdio(0);
  map<ii, ll> cc;
  ll h, w, n;
  cin >> h >> w >> n;
  ll count[10]; memset(count, 0, sizeof count);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    ll a, b; cin >> a >> b; a--; b--;
    for (int j = -2; j <= 0; j++) {
      for (int k = -2; k <= 0; k++) {
        if (a+j >= 0 && b+k >= 0 && a+j+2 < h && b+k+2 < w) {
          int d = ++cc[ii(a+j, b+k)];
          if (d-1 == 0) {
            sum++;
          } else {
            --count[d-1];
          }
          ++count[d];
        }
      }
    }
  }
  count[0] = (h-3+1)*(w-3+1)-sum;
  for (int i = 0; i < 10; i++) {
    cout << count[i] << endl;
  }
}


Measured memory_bytes: 56448
fn dfs(v: usize, adjl: &Vec<Vec<usize>>, used: &mut Vec<bool>, res: &mut usize) {
    for &u in &adjl[v] {
        if !used[u] {
            used[u] = true;
            dfs(u, adjl, used, res);
            used[u] = false;
        }
    }
    // まだ全部じゃない
    for i in 0..adjl.len() {
        if !used[i] {
            return;
        }
    }
    *res += 1;
}

fn solve() {
    let (n, m): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut adjl = vec![vec![]; n];
    for _ in 0..m {
        let (a, b): (usize, usize) = (read::<usize>() - 1, read::<usize>() - 1);
        adjl[a].push(b);
        adjl[b].push(a);
    }
    let mut res = 0;
    let mut used = vec![false; n];
    used[0] = true;
    dfs(0, &adjl, &mut used, &mut res);
    println!("{}", res);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2260
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#define MAX 200200
#define MOD 1000000007
using namespace std;
#define ll long long
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,X,Y,ans;
struct Ball{int c,w;}B[MAX];
bool operator<(Ball a,Ball b){if(a.c!=b.c)return a.c<b.c;return a.w<b.w;}
int jc[MAX],jv[MAX],inv[MAX];
int pmn[MAX],smn[MAX],sz[MAX],W[MAX],p[MAX];
bool cmp(int i,int j){return W[i]<W[j];}
int main()
{
	n=read();X=read();Y=read();
	for(int i=1;i<=n;++i)B[i].c=read(),B[i].w=read();
	jc[0]=jv[0]=inv[0]=inv[1]=1;
	for(int i=2;i<=n;++i)inv[i]=1ll*inv[MOD%i]*(MOD-MOD/i)%MOD;
	for(int i=1;i<=n;++i)jc[i]=1ll*jc[i-1]*i%MOD,jv[i]=1ll*jv[i-1]*inv[i]%MOD;
	sort(&B[1],&B[n+1]);
	memset(pmn,63,sizeof(pmn));
	memset(smn,63,sizeof(smn));
	memset(W,63,sizeof(W));
	for(int i=1,j;i<=n;i=j+1)
	{
		j=i;while(j<n&&B[i].c==B[j+1].c)++j;
		pmn[B[i].c]=smn[B[i].c]=B[i].w;
	}
	for(int i=1;i<=n;++i)pmn[i]=min(pmn[i],pmn[i-1]);
	for(int i=n;i>=1;--i)smn[i]=min(smn[i],smn[i+1]);
	for(int i=1,j;i<=n;i=j+1)
	{
		j=i;while(j<n&&B[i].c==B[j+1].c)++j;
		int d=min(pmn[B[i].c-1],smn[B[i].c+1]);
		int cnt=1;
		for(int k=i+1;k<=j;++k)
			if(B[i].w+B[k].w<=X||B[k].w+d<=Y)++cnt;
			else break;
		sz[B[i].c]=cnt;W[B[i].c]=B[i].w;
	}
	for(int i=1;i<=n;++i)p[i]=i;
	sort(&p[1],&p[n+1],cmp);
	for(int i=1;i<=n;++i)
		if(i==1||W[p[i]]+W[p[1]]<=Y)
			ans+=sz[p[i]];
	ans=jc[ans];
	for(int i=1;i<=n;++i)
		if(i==1||W[p[i]]+W[p[1]]<=Y)
			ans=1ll*ans*jv[sz[p[i]]]%MOD;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 8192