akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
    	Scanner sn = new Scanner(System.in);
    	int a = sn.nextInt();
      	int b = sn.nextInt();
        int c = sn.nextInt();
        int k = sn.nextInt();
      	while(true) {
        	if( (a < b) && (b < c) && (k == 0)) {
            	System.out.println("Yes");
                break;
            } else if(k == 0 ){
            	System.out.println("No");
                break;
            } else {
            	if( a >= b) {
                	b = b * 2;
                } else if( b >= c) {
                	c = c * 2;
                }
              	k--;
            }
        }
    
    }
}

Measured memory_bytes: 35640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            string b = RSt();

            switch (b)
            {
                case "A":
                    Console.WriteLine("T");
                    break;
                case "C":
                    Console.WriteLine("G");
                    break;
                case "G":
                    Console.WriteLine("C");
                    break;
                case "T":
                    Console.WriteLine("A");
                    break;
                default:
                    break;
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}


Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main{
     public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         PrintWriter out = new PrintWriter(System.out);
         int n = Integer.parseInt(sc.next());
         int t = Integer.parseInt(sc.next());
         int ans = 0;
         int[] ta = new int[n];
         int ct = 0;
         for(int i = 0; i < n; i++)
         {
             ta[i] = Integer.parseInt(sc.next());
             if(ta[i] < ct)
             {
                 ans += (t-ct+ta[i]);
             }
             else{
                 ans += t;
             }
             ct = ta[i] + t;
         }
         out.println(ans);
         out.flush();
         sc.close();
     }
}

Measured memory_bytes: 47848
#include <iostream>

int main() {
    int H[301], W[301];
    using namespace std;

    int r = 0;
    while(1){
        cin >> H[r] >> W[r];

        if (H[r] == 0 && W[r] == 0){
        break;
        }
        ++r;
    }

    for (int i = 0; H[i] != 0 && W[i] != 0; ++i){
        for (int y = 0; y < H[i]; ++y){
            for (int x = 0; x < W[i]; ++x){
                if (x == 0 || y == 0 ||
                    x == (W[i] - 1) || y == (H[i] - 1)){
                cout << "#";
                }else{
                cout << ".";
                }

            }
                cout << endl;
        }
        cout << endl;
    }

    return 0;
}




Measured memory_bytes: 3084
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;
//using ll = long long;


const int MOD = 1000000007;
const int INF = 1e18;

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

const double pi = acos(-1);



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


using Graph = vector<vector<int>>;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//*max_element(ALL(vector))
//count(ALL(vector),num) -> n




void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int G[110][110];
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        int u; cin >> u; u--;
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int v; cin >> v; v--;
            G[u][v] = 1;
            //G[v][i] = 1;
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << G[i][j];
            if(j<n-1) cout << " ";
        }cout << endl;
    }
}



signed main() {
    solve();
    return 0;
}




Measured memory_bytes: 3180
# import sys
# sys.setrecursionlimit(200000)

N = list(map(int, input().split(" ")))[0]
s = list(input())

s = [1 if x == "B" else 0 for x in s]
B = sum(s)
R = N - B

if R > B:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
// ※※※ 解答不能 ※※※
// semiexp氏.
// https://atcoder.jp/contests/dwacon6th-prelims/submissions/9421703
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repx(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
const LL MOD = 1e9 + 7;
#define ADD(X,Y) ((X) = ((X) + (Y) % MOD) % MOD)

int A[1010];
LL C[1010][1010], dp[2][1010];

int main(){
    C[0][0] = 1;
    repx(i, 1, 1001){
        C[i][0] = 1;
        repx(j, 1, 1001) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
    }
    int N, K;
    scanf("%d%d", &N, &K);
    rep(i, K) scanf("%d", A + i);
    int t = 0;
    rep(i, N + 1) dp[t][i] = 0;
    dp[t][0] = 1;
    rep(i, K){
        rep(i, N + 1) dp[1 - t][i] = 0;
        rep(j, N + 1){
            if(dp[t][j] == 0) continue;
            int mx = min(N - j, A[i]);
            int rem = N - j;
            rep(k, mx + 1){
                ADD(dp[1 - t][j + k], dp[t][j] * C[rem][k] % MOD * C[N - k][A[i] - k]);
            }
        }
        t = 1 - t;
    }
    printf("%lld\n", dp[t][N]);
    return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include <bits/stdc++.h>
#include<algorithm>
#include <cstring>
#define endl "\n"
#define SRK ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define EPS 1e-6
typedef long long ll;
using namespace std;



int main()
{
    SRK;
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        cout << "x";
    }
    cout << "\n";



}


Measured memory_bytes: 3644
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int n, x, y; cin >> n >> x >> y;
    int ans[n] = {0};
    Rep(i, 1, n) {
        Rep(j, i+1, n+1) {
            int k = min(j - i, abs(i - x) + 1 + abs(j - y));
            ans[k]++;
        }
    }
    Rep(i, 1, n) cout << ans[i] << endl;
}

Measured memory_bytes: 256
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = [IL() for _ in range(N)]

dp = [0]*(1 << N)
for i in range(N):
  dp[1 << i] = a[0][i]
#print(dp)

for i in range(2, N+1): # 1が立っている数
  n = (1 << i) - 1
  while n < (1 << N):
    x = n
    
    for j in range(N):
      if (x >> j) & 1:
        if a[i - 1][j] == 1:
          dp[x] += dp[x ^ (1 << j)] %mod

    """
    while x != 0:
      if x & 1 == 1:
        if a[i - 1][cnt] == 1:
          DP[n] = (DP[n] + DP[n & ~(1 << (cnt))]) % MOD
      x >>= 1
      cnt += 1
    """
    
    x = n & -n
    y = n + x
    n = ((n & ~y) // x >> 1) | y

print(dp[-1] %mod)

Measured memory_bytes: 58972
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    vector<int> x, y;
    for(int i = 0;i < n;i++) {
        int z;
        cin >> z;
        x.push_back(z);
    }
    for(int i = 0;i < m;i++) {
        int h;
        cin >> h;
        y.push_back(h);
    }

    for(int i = X+1;i <= Y;i++) {
        int flag = true;
        for(int j = 0;j < n;j++) {
            if(x[j]>=i) {
                flag = false;
            }
        }
        for(int j = 0;j < m;j++) {
            if(y[j]<i) {
                flag = false;
            }
        }
        if(flag) {
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
}

Measured memory_bytes: 256
//Volume0-0099
import java.util.*;

public class Main {
	public static void main(String[] args) {
	int n,q,a,v,top;
	int[] sum;
	
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		sum = new int[n+2];
		top = n+1;
		sum[top] = Integer.MIN_VALUE;
		q = sc.nextInt();
		for(int i=0;i<q;i++){
			a = sc.nextInt();
			v = sc.nextInt();
			sum[a] += v;
			if(v<0&&a==top){
				top = n+1;
				for(int j=1;j<=n;j++){
					if((sum[j]>sum[top])||(sum[j]==sum[top] && j<top)){
						top=j;
					}
				}
			} else {
				if((sum[a] > sum[top]) || (sum[a] == sum[top] && a < top)){
					top = a;
				}
			}
			System.out.println(top+" "+sum[top]);
		}
	}
}

Measured memory_bytes: 75580
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,K,Q;
  cin >> N >> K >> Q;
  vector<int>A(Q);
  for(int i=0; i<Q; i++){
    cin >> A[i];
  }
  vector<int>array(N);
  for(int i=0; i<N; i++){
    array[i]=K;
  }
  for(int i=0; i<N; i++){
    array[i]-=Q;
  }
  for(int i=0; i<Q; i++){
    array[A[i]-1]++;
  }
  for(int i=0; i<N; i++){
    if(array[i]<=0){
      cout << "No" << endl;
    }
    else{
      cout << "Yes" << endl;
    }
  }
  
    

}

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

using namespace std;
using namespace __gnu_pbds;

#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

struct pair_hash {
    size_t operator()(const pii &p) const {
        return p.s ^ p.f;
    }
};

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<cd> vcd;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef unordered_map<int, int> umpii;
typedef unordered_map<ll, ll> umpll;
typedef unordered_set<int> usi;
typedef unordered_set<ll> usll;
typedef unordered_set<pii, pair_hash> uspii;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = 1e18;
const int inf = 1e9;
const int MX = 100001; //check the limits, dummy

bool bfs(vvi &v, vi &c, vi &p, int s) {
    queue<int> q;
    q.push(s);
    c[s] = 1;
    while(!q.empty()) {
        int cur = q.front(); q.pop();
        F0R(i, sz(v[cur])) {
            int nxt = v[cur][i];
            if(nxt == s) {
                p[s] = cur;
                return true;
            }
            if(!c[nxt]) {
                c[nxt] = 1;
                p[nxt] = cur;
                q.push(nxt);
            }
        }
    }
    return false;
}

vi construct(int i, vi &p) {
    vi res = {i};
    for(int cur = p[i]; cur != i; cur = p[cur]) {
        res.pb(cur);
    }
    return res;
}

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

    int n, m; cin >> n >> m;
    vvi v(n, vi());
    F0R(i, m) {
        int x, y; cin >> x >> y; x--; y--;
        v[x].pb(y);
    }

    int best = inf;
    vi ans;
    F0R(i, n) {
        vi c(n, 0), p(n, -1);
        if(bfs(v, c, p, i)) {
            vi cyc = construct(i, p);
            if(sz(cyc) < best) {
                best = sz(cyc);
                ans = cyc;
            }
        }
    }

    if(ans.empty()) cout << -1 << endl;
    else {
        cout << best << endl;
        F0R(i, sz(ans)) cout << ans[i] + 1 << endl;
    }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>


int main(){

char A[201],B[201];
int k,m,n;
int a,b,i,ka;


while(1){
scanf("%s",A);
if(A[0]=='-')break;

ka=strlen(A);


scanf("%d",&a);
for(i=0;i<a;i++){


scanf("%d",&b);
strncpy(B,A,b);



for(k=0;k<ka;k++){
A[k-b]=A[k];
}

for(m=0;m<b;m++)
{A[m+ka-b]=B[m];}
}
printf("%s\n",A);

}
return 0;
}

    

Measured memory_bytes: 596
n,k = map(int,input().split())
a = list(map(int,input().split()))
dp = [False]*(k+1)
i = a[0]
for i in range(a[0],k+1):
  for j in range(n):
    if i-a[j] < 0:
      break
    if dp[i-a[j]] == False:
      dp[i] = True
      break
print(["Second","First"][dp[k]])

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

int main(){

 char a;
 cin >> a;
 if(a=='C') cout << "G" << endl;
 if(a=='T') cout << "A" << endl;
 if(a=='A') cout << "T" << endl;
 if(a=='G') cout << "C" << endl;

  return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  while (H != 0 || W != 0) {
    if (H == 0 || W == 0) {
      cout << endl;
      cin >> H >> W;
      continue;
    }

    for (int x = 0; x < H; x++) {
      for (int y = 0; y < W; y++) {
        if (x % 2 == 0) {
          if (y % 2 == 0) {
            cout << "#";
          } else {
            cout << ".";
          }
        } else {
          if (y % 2 == 1) {
            cout << "#";
          } else {
            cout << ".";
          }
        }
      }
      cout << endl;
    }
    cout << endl;
    cin >> H >> W;
  }
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
 
using namespace std;
 
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
int main() {
    long long a, b;
    cin >> a >> b;
 
    cout << (a*b) / gcd(a, b) << endl;
 
    return 0;
}

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

n,a,b = li()

print("Alice" if abs(b-a)%2 == 0 else "Borys")

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

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

    int n, m, x, y;
    cin >> n >> m >> x >> y;
    rep(i, n)
    {
        int a;
        cin >> a;
        x = max(x, a);
    }
    rep(i, m)
    {
        int a;
        cin >> a;
        y = min(y, a);
    }
    cout << (x < y ? "No War" : "War") << endl;
}

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m;
    a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2, HELL)
#define size(a) (int) a.size()

struct RGB {
	int r, g, b;
};

int32_t main() { fastio;
	int n; cin >> n;
	string s; cin >> s;

	vector<RGB> pref(n + 1, { 0, 0, 0 }), suff(n + 1, { 0, 0, 0 });

	for (int i = 0; i < n; i++) {
		pref[i + 1] = pref[i];
		if (s[i] == 'R') {
			pref[i + 1].r++;
		} else if (s[i] == 'G') {
			pref[i + 1].g++;
		} else {
			pref[i + 1].b++;
		}
	}

	for (int i = n - 1; i >= 0; i--) {
		suff[i] = suff[i + 1];
		if (s[i] == 'R') {
			suff[i].r++;
		} else if (s[i] == 'G') {
			suff[i].g++;
		} else {
			suff[i].b++;
		}
	}
	int res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int left = i - (j - i) - 1;
			int right = j + (j - i) + 1;
			// deb(left);
			// deb(right);
			// deb(i);deb(j);
			if (s[i] != s[j]) {
				if (s[i] == 'R' and s[j] == 'G') {
					if (left >= 0 and left < n) {
						res += pref[left + 1].b;
					}
					if (right < n and right >= 0) {
						res += suff[right].b;
					}
				} else if (s[i] == 'R' and s[j] == 'B') {
					if (left >= 0 and left < n) {
						res += pref[left + 1].g;
					}
					if (right < n and right >= 0) {
						res += suff[right].g;
					}
				} else if (s[i] == 'G' and s[j] == 'B') {
					if (left >= 0 and left < n) {
						res += pref[left + 1].r;
					}
					if (right < n and right >= 0) {
						res += suff[right].r;
					}
				} else if (s[i] == 'G' and s[j] == 'R') {
					if (left >= 0 and left < n) {
						res += pref[left + 1].b;
					}
					if (right < n and right >= 0) {
						res += suff[right].b;
					}
				} else if (s[i] == 'B' and s[j] == 'G') {
					if (left >= 0 and left < n) {
						res += pref[left + 1].r;
					}
					if (right < n and right >= 0) {
						res += suff[right].r;
					}
				} else if (s[i] == 'B' and s[j] == 'R') {
					if (left >= 0 and left < n) {
						res += pref[left + 1].g;
					}
					if (right < n and right >= 0) {
						res += suff[right].g;
					}
				}
			}
		}
	}	    
	cout << res << endl;
    return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
using Graph = vector<vector<int>>;




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

    int count = 0;

    // 頂点数と辺数
    int N, M; cin >> N >> M;
    vector<int> h(N);
    rep(i,N) cin >> h[i];

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }

    // 頂点 0 をスタートとした探索
    rep(i,N){
      bool check = true;
      int high = h[i];
      rep(j,G[i].size()){
        if(h[i] <= h[G[i][j]]) check = false;
      }
      if(check == true) count++;
    }
    cout << count << endl;


//////////////////////////////////////////////////////
return 0;}


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

int n, a[1025][1025], vis[1025];
bool flag;
bool ok() {
  for (int i = 1; i <= n; i++)
    if (a[i][0] != n) return 0;
  return 1;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n - 1; ++j) cin >> a[i][j];
    a[i][0] = 1;
  }
  for (int z = 0; z <= 0x3f3f3f3f; z++) {
    if (ok()) {
      cout << z << '\n';
      return 0;
    }
    flag = 0;
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; i++) {
      if (vis[i] || a[i][0] == n) continue;
      int x = a[i][a[i][0]];
      if (a[x][a[x][0]] == i && !vis[i] && !vis[x]) {
        a[i][0]++;
        a[x][0]++;
        vis[i] = vis[x] = 2 - 1;
        flag = 1;
      }
    }
    if (!flag) {
      cout << -1 << '\n';
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 4352
from itertools import accumulate

H, W, D = map(int,input().split())
A = [[int(e)-1 for e in input().split()] for _ in range(H)]
Q = int(input())
query = [[int(e)-1 for e in input().split()] for _ in range(Q)]

pos = [-1]*(H*W)

for i, line in enumerate(A):
    for j, a in enumerate(line):
        pos[a] = (i,j)

mp_list = [[0] for _ in range(D)]

for r in range(D):
    res = []
    for k in range(H*W):
        if r + k*D <= H*W - 1:
            res.append(pos[r+k*D])
        else:
            break
    for l in range(len(res)-1):
        i, j = res[l]
        ni, nj = res[l+1]
        mp = abs(ni-i) + abs(nj-j)
        mp_list[r].append(mp)

for i in range(D):
    mp_list[i] = list(accumulate(mp_list[i]))

for left, right in query:
    r = left % D
    q1 = (left-r) // D
    q2 = (right-r) // D
    ans = mp_list[r][q2] - mp_list[r][q1]
    print(ans)

Measured memory_bytes: 48680
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
using ll = long long;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
int main() {
	string s;
	int k;
	cin >> s >> k;
	int n = s.size();
	set<string> st;
	rep(i, n) {
		string t;
		repl(j, i, min(n, i + 100)) {
			t += s[j];
			st.insert(t);
		}
	}
	int i = 1;
	for (auto p : st) {
		if (i == k) {
			cout << p << endl;
			return 0;
		} else
			i++;
	}
	return 0;
}


Measured memory_bytes: 78592
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char n[10001];
int main()
{
	scanf("%s",n);
	int len=strlen(n);
	for(int i=0;i<len;i++)
	{
		if(n[i]=='C')
		{
			for(int j=i+1;j<len;j++)
			{
				if(n[j]=='F')
				{
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	cout<<"No";
	return 0;
}

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

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


Measured memory_bytes: 3112
#include <stdio.h>

int main(void)


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

Measured memory_bytes: 128
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int inf = 1e8;
int start[200200];
int seg[1000010], lazy[1000010];
int a[200200], b[200200];

void update(int idx, int l, int r, int kiri, int kanan, int value)
{
    if(lazy[idx] != 0)
    {
        seg[idx] = min(inf, lazy[idx] + l);
        if(l != r)
        {
            lazy[idx*2] = lazy[idx*2+1] = lazy[idx];
        }
        lazy[idx] = 0;
    }
    if(l > kanan || r < kiri) return;
    if(l >= kiri && r <= kanan) {
        seg[idx] = min(inf, value + l);
        if(l != r)
        {
            lazy[idx*2] = lazy[idx*2+1] = value;
        }
        return;
    }
    int mid = (l+r) / 2;
    update(idx*2, l, mid, kiri, kanan, value);
    update(idx*2+1, mid+1, r, kiri, kanan, value);
    seg[idx] = min(seg[idx*2], seg[idx*2+1]);
}

int query(int idx, int l, int r, int kiri, int kanan)
{
    if(lazy[idx] != 0)
    {
        seg[idx] = min(inf, lazy[idx] + l);
        if(l != r)
        {
            lazy[idx*2] = lazy[idx*2+1] = lazy[idx];
        }
        lazy[idx] = 0;
    }
    if(l > kanan || r < kiri) return inf;
    if(l >= kiri && r <= kanan) return seg[idx];
    int mid = (l+r) / 2;
    int le = query(idx*2, l, mid, kiri, kanan);
    int ri = query(idx*2+1, mid+1, r, kiri, kanan);
    return min(le, ri);
}

int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    int r,c;
    cin >> r >> c;
    for(i=1;i<=r;i++) {
        scanf("%d %d",&x,&y);
        if(x == 1) {
            update(1, 1, c, x, y, inf);
        } else {
            int last = query(1, 1, c, x-1, x-1);
            update(1, 1, c, x, y, last - x + 1);
        }
        int chaeng = seg[1] + i;
        if(chaeng >= inf) chaeng = -1;
        printf("%d\n", chaeng);
    }
    return 0;
}


Measured memory_bytes: 7856
#include<iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	bool flag = false;
	for(int i = 0;i <= 100;i += 4){
		for(int j = 0;j <= 100;j += 7){
			if(i + j == n){
				flag = true;
				break;
			}
		}
		if(flag) break;
	}
	
	if(flag){
		cout << "Yes" << endl;
	}else{
		cout << "No" <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
n = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      result = (a * 500) + (b * 100) + (c * 50)
      if result == X:
        n += 1
print(n)

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

#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);

int main(void) {
	int   A,B,C,D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	if (A < C) A = C;
	if (B > D) B = D;
	if (A > B) i_cout(0);
	else       i_cout(B-A);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
ll inf=1e10;

int main(){
  ll N,A[100000];
  cin>>N;
  for (int i(0);i<N;i++) cin>>A[i];
  int cnt(0);
  for (int i(0);i<N;i++){
    if (A[i]%2==1) cnt++;
  }
  if (cnt%2==1) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        //受け取り
        Scanner sc = new Scanner(System.in);
        int row = sc.nextInt();
        
        int[][] index = new int[row][3];
        
        for(int i=0;i<row;i++){
            index[i][0] = sc.nextInt();
            index[i][1] = sc.nextInt();
            index[i][2] = sc.nextInt();
        }
        
        // 初回実行
        int initX = Math.abs(index[0][1]);
        int initY = Math.abs(index[0][2]);
        
        int d = initX + initY;
        
        if(d>index[0][0] || d%2 != index[0][0]%2){
            System.out.println("No");
            System.exit(0);
        }
        
        
        // 以降の実行
        for(int i=1;i<row;i++){
            int x = Math.abs(index[i][1]-index[i-1][1]);
            int y = Math.abs(index[i][2]-index[i-1][2]);
            int distance = x + y;
            int s = index[i][0]-index[i-1][0];
            
            if(distance>s || distance%2 != s%2){
                System.out.println("No");
                System.exit(0);
            }
        }
        
        System.out.println("Yes");
    }
}


Measured memory_bytes: 93456
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  vector<complex<double>> vp;
  for(auto&& i:irange(0,n)) {
    double x,y;
    cin>>x>>y;
    vp.emplace_back(x,y);
  }
  double ans = 1e9;
  for(auto&& i:irange(0,n)) {
    for(auto&& j:irange(0,i)) {
      auto c = (vp[i] + vp[j]) / 2.0;
      auto r = abs(vp[i] - c);
      for(auto&& k:irange(0,n)) {
        auto rk = abs(vp[k] - c);
        r = max(r, rk);
      }
      ans = min(ans, r);
    }
  }
  for(auto&& i:irange(0,n)) {
    for(auto&& j:irange(0,i)) {
      for(auto&& k:irange(0,j)) {
        double xi,yi,xj,yj,xk,yk;
        xi = vp[i].real();
        xj = vp[j].real();
        xk = vp[k].real();
        yi = vp[i].imag();
        yj = vp[j].imag();
        yk = vp[k].imag();
        double a11 = 2.0 * (xj - xi);
        double a12 = 2.0 * (yj - yi);
        double a21 = 2.0 * (xk - xi);
        double a22 = 2.0 * (yk - yi);
        double b0 = (xj * xj + yj * yj - xi * xi - yi * yi);
        double b1 = (xk * xk + yk * yk - xi * xi - yi * yi);
        double d = a11 * a22 - a12 * a21;
        if (abs(d) < 1e-5) continue;
        double r11 = a22 / d;
        double r12 = -a12 / d;
        double r21 = -a21 / d;
        double r22 = a11 / d;
        double cx = r11 * b0 + r12 * b1;
        double cy = r21 * b0 + r22 * b1;
        complex<double> c(cx, cy);
        double r = abs(vp[i] - c);
        for(auto&& l:irange(0,n)) {
          r = max(r, abs(vp[l] - c));
        }
        ans = min(ans, r);
      }
    }
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#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
    string s; cin >> s;
    int ans = 0;
    int p = 0,g = 0;
    REP(i,s.size()) {
        if (p < g) {
            if (s[i] == 'p') p++;
            else {
                ans++;
                p++;
            }
        } else {
            if (s[i] == 'p') {
                ans--;
                g++;
            }
            else {
                g++;
            }
        }
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 512
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    long double n;
    cin>>n;
    long double x = 100.000000;
    for(int i=1;;i++){
        x+=(x*0.01);
        if(x>=n){
            cout<<i;
            break;
        }
        x = floor(x);
    }
}


Measured memory_bytes: 3692
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


signed main() {
	int n;
	std::cin >> n;
	std::vector<std::vector<int> > g(n,std::vector<int>());
	rep(i,n-1) {
		int a,b;
		std::cin >> a >> b;
		a--;b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	std::vector<int> sub(n);
	// dfs to get size of subtree
	std::function<int(int,int)> dfs = [&] (int i, int par) {
		int sz = 1;
		for(auto to:g[i]) {
			if(to==par) continue;
			sz+=dfs(to,i);
		}
		sub[i] = sz;
		return sz;
	};
	// get leaf
	int leaf = -1;
	rep(i,n) {
		if(g[i].size()==1) {
			leaf=i;
			break;
		}
	}
	int m = dfs(leaf,-1);
	debug(leaf,m,n);
	mint ans = 0;
	rep(i,n) {
		debug(i,sub[i]);
		mint tmp = mint(1)-mint(2).inv().pow(n-1);
		for(auto to:g[i]) {
			if(sub[i]>sub[to]) tmp-=mint(2).inv().pow(n-sub[to]-1)-mint(2).inv().pow(n-1);
			else tmp-=mint(2).inv().pow(sub[i]-1)-mint(2).inv().pow(n-1);
		}
		ans+=tmp/mint(2);
	}
	print(ans);

	return 0;
}


Measured memory_bytes: 27264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  ll A,B,K;
  cin>>A>>B>>K;
  if (A>K){
    cout<<A-K<<" "<<B<<endl;
  }
  else if (B>(K-A)){
    cout<<0<<" "<<B-(K-A)<<endl;
  }
  else{
    cout<<0<<" "<<0<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
                                               //BY THE NAME OF ALLAH
                                               //FAISAL AHAMMED SHAWON
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<set>
#include<map>
#include<iterator>
#include<numeric>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define SQ(a) (a)*(a)
#define pi acos(-1.0)
const int MAX=100001;
const int MOD=1e9+7;
int ara[MAX];
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    else
    gcd(b,a%b);
}
ll lcd(ll a,ll b)
{
    return (a*b)/gcd(a,b);
}

bool f(ll a,ll b)
{
    return a>b;
}
ll max_sum_subarrays(ll ara[],ll n)
{
    ll ans=0,sum=0;
    for(ll k=0;k<n;k++){
        sum=max(ara[k],sum+ara[k]);
        ans=max(ans,sum);
    }
    return ans;
}
ll num_divisors(ll n)
{
    long long cnt=0;
    for(int i=1;i*i<=n;i++)
    {
        if(n%i==0 && i*i==n)
            cnt+=1;
        if(n%i==0 && i*i!=n)
                cnt+=2;
    }
    return cnt;
}
ll comb(ll m, ll n)
{
    ll x = max(m-n,n),ans = 1,i=1;
    for(ll k=m;k>=x+1;k--){
        ans*=k;
        ans/=i;
        i++;
    }
    return ans;
}
ll binsearch(ll low,ll high,ll target)
{
    while(low<=high)
    {
        ll mid=(low+high)/2;
        if(ara[mid]>target)
            high=mid-1;
        else if(ara[mid]<target)
            low=mid+1;
        else return mid;
    }
    return -1;
}
void solve()
{
    int a,b;
    cin>>a>>b;
    vector<string>v(a);
    string ans="";
    for(int i=0;i<a;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    for(int i=0;i<a;i++)
    {
        ans+=v[i];
    }
    cout<<ans<<endl;
}
int main()
{
    fast();
    solve();
    return 0;
}


Measured memory_bytes: 3632
use std::io::{self, Read};

pub struct Scanner<R>
where
    R: Read,
{
    reader: R,
}

impl<R> Scanner<R>
where
    R: Read,
{
    pub fn new(reader: R) -> Self {
        Self { reader }
    }

    pub fn next<T>(&mut self) -> T
    where
        T: ::std::str::FromStr,
        <T as ::std::str::FromStr>::Err: ::std::fmt::Debug,
    {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .unwrap()
    }
}

fn print(v: &Vec<i32>) {
    for i in 0..(v.len()-1) {
        print!("{} ", v[i])
    }
    println!("{}", v[v.len()-1])
}

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let n:i32 = sc.next();
    let mut v: Vec<i32> = (0..n).map(|_| sc.next()).collect();

    for i in 0..n {
        let current = v[i as usize];
        let mut j = i-1;
        while j >= 0 && v[j as usize] > current {
            v[(j+1) as usize] = v[j as usize];
            j -= 1;
        }
        v[(j+1) as usize] = current;
        print(&v);
    }
}



Measured memory_bytes: 5036
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <utility>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
using ll = long long;
using VI = vector<int>;


int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        if (i % 3 == 0 && i % 5 == 0) continue;
        else if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << "\n";
    
    return 0;
}


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

int main(){
	int n, k;
	cin >> n >> k;
	bitset<10> s;
	s.set();
	for(int i = 0; i < k; i++){
		int d;
		cin >> d;
		s.reset(d);
	}
	// cout << s << endl;
	while(1){
		string ans = to_string(n);
		bool flag = true;
		for(auto i : ans){
			if(!s.test(i - '0')){
				flag = false;
				break;
			}
		}
		if(flag){
			cout << ans << endl;
			return 0;
		}
		n++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <string>
#include <cmath>
#define SIZE 6005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

string dp[SIZE];
char str[SIZE];
int pa[SIZE],pb[SIZE];
int pos[SIZE];
bool use[SIZE];

int main()
{
	int n;
	scanf("%d",&n);

	int k;
	scanf("%d",&k);
    if (n%k == 0){
        printf("0\n");
    } else {
        printf("1\n");
    }

    return 0;
}


Measured memory_bytes: 256
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    a, b = Input()
    c1 = a + b
    c2 = a + a -1
    c3 = b + b -1
    print(max(c1, c2, c3))



main()

Measured memory_bytes: 9176
import numpy as np
def main():
    n = int(input())
    a = list(map(int, input().split()))

    ans_list = [0]*n

    for index, i in enumerate(a):
        ans_list[i-1] = str(index+1)
    
    ans = ' '.join(ans_list)
    print(ans)


if __name__ == '__main__':
    main()



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

int main(){
int H,W;
  cin>>H>>W;
  char a[100][100], b[102][102];
  for(int i=0; i<H; i++){
   cin>>a[i];}
  
  for(int i=0; i<H+2; i++){
   for(int j=0; j<W+2; j++){
    b[i][j]='#';}
  }
  
  for(int i=0; i<H; i++){
   for(int j=0; j<W; j++){
    b[i+1][j+1]=a[i][j];}
  }
  
  for(int i=0; i<H+2; i++){
   for(int j=0; j<W+2; j++){
    cout<<b[i][j];
    }
    cout<<endl;}
  
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

bool cmp(const pair<int,int> &a, const pair<int,int> &b) {
    return a.second > b.second;
}

int main() {
    vector<pair<int,int> > v;

    int team, score;
    char comma;
    while(cin >> team >> comma >> score) {
        if(!team && !score) break;
        v.push_back(make_pair(team, score));
    }

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

    int N;
    while(cin >> N) {
        int rank = 1;
        for(int i = 0; i < v.size(); ++i) {
            if(i>0 && v[i-1].second != v[i].second) ++rank;
            if(v[i].first == N) break;
        }
        cout << rank << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <string>
#include <deque>
#include <stack>
#include <cmath>

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (LL i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<LL> VI;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 400040	;
const long double PI = acos(-1.);
const double EPS = 1e-6;
LL mod = 1000LL * 1000 * 1000 + 7;

int n,k;
LL arr[3007];




int main()
{
	//freopen("input.tXXt", "r", stdin);
	ios_base::sync_with_stdio(0);
	cin >> n;
	FOR(i,0,n)
		cin >> arr[i];
	vector<LL> x;
	FOR(i,0,n)
	{
		x.PB(arr[i]);
		while(SZ(x)>2 && x[SZ(x)-2]>x[SZ(x)-1] && x[SZ(x)-3]<x[SZ(x)-2])
		{
			LL t = x[SZ(x)-3]+x[SZ(x)-1]-x[SZ(x)-2];
			x.pop_back();
			x.pop_back();
			x.pop_back();
			x.PB(t);
		}
	}
	LL ans1 = 0, ans2 = 0;
	multiset<LL> foo;
	FOR(i,0,SZ(x))
		foo.insert(-x[i]);
	while(SZ(foo))
	{
		ans1-=*foo.begin();
		foo.erase(foo.begin());
		if(SZ(foo))
		{
			ans2-=*foo.begin();
			foo.erase(foo.begin());
		}
	}
	cout<<ans1-ans2;
	return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    string s;
    cin>>s;
    if(s[0]==s[2])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>

int t,n,m;
vector<int> par,sz;

int top(int x){
	if (par[x] == x) return x;
	else{
		int pos = top(par[x]);
		par[x] = pos;
		return pos;
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> m;
	par = sz = vector<int>(n);
	for (int i=0; i<n; i++){
		par[i] = i;
		sz[i] = 1;
	}
	
	int x,y;
	for (int i=0; i<m; i++){
		cin >> x >> y;
		--x, --y;
		if (top(x) == top(y)) continue;
		else if (sz[top(x)] > sz[top(y)]){ //actually can be optimized by unimportant, O(2) = O(1)
			sz[par[x]] += sz[par[y]];
			par[par[y]] = par[x];
		}else{
			sz[par[y]] += sz[par[x]];
			par[par[x]] = par[y];
		}
		//for (int i=0; i<n; i++) cout << sz[i] << " "; cout << endl;
	}
	
	int ans=0;
	for (int i=0; i<n; i++){
		ans = max(ans, sz[i]);
	}
	
	cout << ans << endl;
	//for (int i=0; i<n; i++) cout << top(i) << " "; cout << endl;
	//for (int i=0; i<n; i++) cout << sz[i] << " "; cout << endl;
	return 0;
}


Measured memory_bytes: 4716