akhauriyash/Code-Regression huggingface dataset:
n = int(input())
count = 0
def return_level(n):
    level = 0
    while True:
        if (n // (2**level)) % 2 == 1:
            break
        level += 1
    return(level + 1)
while True:
    count += 1
    if n - 1 < 2**count:
        break
# countは最大レベル
to = [[] for _ in range(n-1)]
for i in range(1, n):
    for j in range(i+1,n+1):
        to[i-1].append(return_level(j-i))
for _ in range(n-1):
    print(*to[_])

Measured memory_bytes: 4976
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[]){
    String str = readL();
    str = str.replace("?","D");
    pl(str);
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
  public static int[] Itoi(Integer a[]){
    int[]result=new int[a.length];
    for(int i=0;i<a.length;i++){
      result[i]=a[i];
    }
    return result;
  }
}


Measured memory_bytes: 37048
#include <iostream>
#include <cmath>
#include <cstdio>
#include <stdio.h>
#define MAX 10000


struct Point{
    double x;
    double y;
};

double p[MAX][2];
int ip = 0;

void input_p(Point p0){
    p[ip][0] = p0.x;
    p[ip][1] = p0.y;
    ip += 1;
}

int kock(int n, Point p1, Point p2){
    if(n == 0){
        return 0;
    }
    else{
        Point s, t, u;
        s.x = (2*p1.x + 1*p2.x) / 3.0;
        s.y = (2*p1.y + 1*p2.y) / 3.0;
        t.x = (1*p1.x + 2*p2.x) / 3.0;
        t.y = (1*p1.y + 2*p2.y) / 3.0;
        u.x = (t.x - s.x)*(1.0/2.0) - (t.y - s.y)*(sqrt(3)/2.0) + s.x;
        u.y = (t.x - s.x)*(sqrt(3)/2.0) + (t.y - s.y)*(1.0/2.0) + s.y;

        kock(n-1, p1, s);
        input_p(s);
        kock(n-1, s, u);
        input_p(u);
        kock(n-1, u, t);
        input_p(t);
        kock(n-1, t, p2);
    }
}

int main(){
    int n;
    std::cin >> n;
    Point p1;
    p1.x = 0.0; p1.y = 0.0;
    Point p2;
    p2.x = 100.0; p2.y = 0.0;
    input_p(p1);
    kock(n, p1, p2);
    input_p(p2);
    for(int i=0; i<ip; i++){
        printf("%.8lf %.8lf\n", p[i][0], p[i][1]);
    }
    return 0;
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int i = 0;
	while (a > 0 && c > 0) {
		if (i % 2 == 0) {
			c -= b;
		}
		else {
			a -= d;
		}
		i++;

	}
	if (a <= 0)cout << "No";
	else cout << "Yes";
}

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

using namespace std;

const int md = 1e9 + 7;

void add(int& a, int b) {
  a += b;
  if (a >= md) {
    a -= md;
  }
}

int mul(int a, int b) {
  return (long long)a * b % md;
}

const int N = 200010;

int n;
int f[N];
int c[N];
int last[N];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
  }
  fill_n(last, N, -1);
  f[0] = 1;
  for (int i = 0; i < n; i++) {
    int cur = c[i];
    add(f[i + 1], f[i]);
    int pos = last[cur];
    if (pos >= 0 && pos != i - 1) {
      add(f[i + 1], f[pos + 1]);
    }
    last[cur] = i;
  }
  printf("%d\n", f[n]);
  return 0;
}

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

int main()
{
	int a, b , c , n;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a > b){
		n = a;
		a = b;
		b = n;
	}
	if (b > c){
		n = b;
		b = c;
		c = n;
	}
	if (a > b){
		n = a;
		a = b;
		b = n;
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}


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

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)

int cnt[13] = {};
int place[24];

int Ans() {
  int i = 0, f = 1;

  if (cnt[0] == 0) {
    place[i++] = 0;
  } else {
    return 0;
  }

  FOR(di, 1, 12) {
    if (cnt[di] == 0) {
      continue;
    } else if (cnt[di] == 1) {
      if (f) {
        place[i++] = di;
        f = 0;
      } else {
        place[i++] = 24 - di;
        f = 1;
      }
    } else if (cnt[di] == 2) {
      place[i++] = di;
      place[i++] = 24 - di;
    } else {
      return 0;
    }
  }

  if (cnt[12] == 0) {
    // do nothing
  } else if (cnt[12] == 1) {
    place[i++] = 12;
  } else {
    return 0;
  }

  int ans = 12;
  sort(place, place+i);
  REP(j, i-1) { ans = min(ans, place[j+1] - place[j]); }
  ans = min(ans, 24 - place[i-1]);
  return ans;
}

int main() {
  int n;
  cin >> n;
  REP(i, n) {
    int tmp;
    cin >> tmp;
    cnt[tmp]++;
  }

  cout << Ans() << endl;

  return 0;
}


Measured memory_bytes: 256
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define all(vec) vec.begin(),vec.end()
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;


void virus(){

    ll a,b,c;
    cin>>a>>b>>c;
    cout<<(ll)(c*(ceil((ld)a/(ld)b)));
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
           cerr << "\n Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

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

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

  vector<vector<int>> hyou (H, vector<int>(W, 0));

  for(int i=0; i < a; i++){
    hyou.erase(hyou.begin() + 0);
  }

  for(int i=0; i < hyou.size(); i++){
    for(int j=0; j < b; j++){
      hyou.at(i).erase(hyou.at(i).begin() + 0);
    }
  }

  int ans = 0;

  for(int i=0; i < hyou.size(); i++){
    ans += hyou.at(i).size();
  }

  cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    int i;
    int s[n];
    for(i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if (x == y) {
            s[i] = 1;
        }
        else {
            s[i] = 0;
        }
    }

    string ans = "No";
    for(i = 0; i < n-2; i++) {
        if (s[i] == 1 && s[i+1] == 1 && s[i+2] == 1) {
            ans = "Yes";
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()
{
    int k;
    cin>>k;
    int a,b;
    cin>>a>>b;
    for(int i=1;;i++)
    {
        if((k*i)>=a&&(k*i)<=b)
        {
            cout<<"OK"<<endl;
            break;
        }
        else if((k*i)>b)
        {
            cout<<"NG"<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3596
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace atcoder;
using namespace std;
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;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) {
            os << ',';
        }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    int N, Q;
    cin >> N >> Q;
    dsu uf(N);
    for(int _ = 0; _ < Q; _++) {
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0) {
            uf.merge(u, v);
        } else {
            cout << uf.same(u, v) << "\n";
        }
    }
}

Measured memory_bytes: 3888
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String oldID = scan.nextLine();
        String newID = scan.nextLine();

        for(int i = 0; i < oldID.length(); i++) {
            if(oldID.charAt(i) != newID.charAt(i)) {
                System.out.println("No");
                scan.close();
                return;
            }
        }
        System.out.println("Yes");
        scan.close();
        return;
    }
}

Measured memory_bytes: 35252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int N, M, Q; cin >> N >> M >> Q;
  vector<int> a(Q);
  vector<int> b(Q);
  vector<int> c(Q);
  vector<int> d(Q);
  rep(i, Q) cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  vector<int> A(10);
  int ans = 0;
  for (int i1 = 1; i1 <= M; i1++){
    for (int i2 = i1; i2 <= M; i2++){
      for (int i3 = i2; i3 <= M; i3++){
        for (int i4 = i3; i4 <= M; i4++){
          for (int i5 = i4; i5 <= M; i5++){
            for (int i6 = i5; i6 <= M; i6++){
              for (int i7 = i6; i7 <= M; i7++){
                for (int i8 = i7; i8 <= M; i8++){
                  for (int i9 = i8; i9 <= M; i9++){
                    for (int i10 = i9; i10 <= M; i10++){
                      A = {i1,i2,i3,i4,i5,i6,i7,i8,i9,i10};
                      int sum = 0;
                      rep(i, Q){
                        if(A.at(b.at(i)-1)-A.at(a.at(i)-1) == c.at(i)) sum += d.at(i);
                      }
                      ans = max(ans, sum);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <map>
#include <string>

int n, a;
int A[51];
long long dp[51][51][2600];

int main() {
    std::cin >> n >> a;
    
    for(int i = 0; i < n; ++i)
        std::cin >> A[i];
    
    dp[0][0][0] = 1;
    
    long long sum = 0;
    for(int i = 0; i < n; ++i) {
        for(int k = 0; k <= 49; ++k) {
            for(int j = 0; j < 2501; ++j) {
                if(j + A[i] <= 2500)
                    dp[i + 1][k + 1][j + A[i]] += dp[i][k][j];

                dp[i + 1][k][j] += dp[i][k][j];
            }
        }
        
    }

	for(int k = 1; k <= 50; ++k) {
    	sum += dp[n][k][a * k];
	}
    
    std::cout << sum << std::endl;
}


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

int main() {
    int N; cin >> N;
	vector<long long> A(100100, 0);
	long long sum = 0;
	for(int i=0; i<N; ++i) {
	    long long a; cin >> a;
		A[a] += 1;
		sum += a;
	}

	int Q; cin >> Q;
	while(Q--) {
	    long long b,c; cin >> b >> c;
		sum += (c - b) * A[b];
		A[c] += A[b];
		A[b] = 0;

		cout << sum << '\n';
	}
}


Measured memory_bytes: 4032
#include<iostream>
using namespace std;
int main(void) {
    // ??????????????¨??????input
    int n, m;
    cin >> n >> m;
    // ??????a???input
    int a[n][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    // ??????b???input
    int b[m];
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }
    // ?¨????????????????
    for (int i = 0; i < n; i++) {
        int result = 0;
        for (int j = 0; j < m; j++) {
            result += a[i][j] * b[j];
        }
        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

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

const int INF = 1001001001;

int main(){
    int N, C;
    cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C));
    for(int i = 0; i < C; ++i){
        for(int j = 0; j < C; ++j){
            cin >> D[i][j];
        }
    }
    // 色を0...C-1にしておく
    vector<vector<int>> c(N, vector<int>(N));
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    
    // 0, 1, 2(mod3)に塗られている色の個数を調べておく
    vector<int> zero(30, 0), one(30, 0), two(30 ,0);
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            int temp = ((i + 1) + (j + 1)) % 3;
            switch(temp){
                case 0:
                    zero[c[i][j]]++;
                    break;
                    
                case 1:
                    one[c[i][j]]++;
                    break;
                    
                default:
                    two[c[i][j]]++;
                    break;
            }
        }
    }
    
    int ans = INF;
    // 色を決める
    for(int a = 0; a < C; ++a){             // 0(mod3)
        for(int b = 0; b < C; ++b){         // 1(mod3)
            if(b == a)      continue;
            for(int c = 0; c < C; ++c){     // 2(mod3)
                if(c == a || c == b)        continue;
                
                int temp = 0;
                
                // 0(mod3)
                for(int i = 0; i < C; ++i){
                    if(i == a)      continue;
            
                    // 色iを色aに変えるコスト
                    temp += D[i][a] * zero[i];
                }
                
                // 1(mod3)
                for(int i = 0; i < C; ++i){
                    if(i == b)      continue;
                    
                    temp += D[i][b] * one[i];
                }
                
                // 2(mod3)
                for(int i = 0; i < C; ++i){
                    if(i == c)      continue;
                    
                    temp += D[i][c] * two[i];
                }
                
                ans = min(ans, temp);
            }
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1280
N = int(input())
S = input()

left = 0
max_left = 0

for i in S:
    if i == ')':
        left += 1
        max_left = max(max_left, left)
    else:
        left -= 1

right = 0
max_right = 0

for i in S[::-1]:
    if i == '(':
        right += 1
        max_right = max(max_right, right)
    else:
        right -= 1

ans = '(' * max_left  + S +  ')' * max_right

print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const ll maxn=2*1e5+5;
const ll inf=99999999999;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<int> uid(l, r); return uid(rng); }
template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) { return out << "(" << a.F << ", " << a.S << ")"; }
template <class A> ostream& operator << (ostream& out, const vector<A> &v) { 
out << "["; for (int i=0;i<v.size();i++) { if(i) out << ", "; out << v[i]; } return out << "]"; } 


void solve(){


	ll n;
	cin>>n;
	map<ll,ll> mp;
	vector<ll> v(n);
	for (int i=0;i<n;i++){
		cin>>v[i];
		mp[v[i]]++;
	}
	ll ans=0;
	ll lim=1e6+5;
	for (int i=0;i<n;i++){
		if (mp[v[i]]>1) continue;
		bool ok=1;
		vector<ll> fact;
		for (int j=1;j*j<=v[i];j++){
			if (v[i]%j==0){
				fact.pb(j);
				if (j*j!=v[i]) fact.pb(v[i]/j);
			}
		}
		
		for (auto j:fact){
			if (j!=v[i] && mp.find(j)!=mp.end()){
				ok=0;
				break;
			}
		}
		ans+=ok;
	}
	cout<<ans<<endl;
	
	return;
}

int main(){ 
    
    #ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 
	
	//T{ solve(); }
	solve();
	
	
	return 0;
}

Measured memory_bytes: 17164
N = int(input())
A = list(map(int, input().split()))
M = max(A); m = min(A)
if M - m > 1:
  print('No')
elif M - m == 1:
  c = A.count(m)
  if 2*M - N <= c < M:
    print('Yes')
  else:
    print('No')
else:
  if m == N-1:
    print('Yes')
  elif N >= 2*m:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 13964
#include <bits/stdc++.h>
using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
//const int mod=998244353;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;
using V=vector<int>;
using Vl=vector<ll>;
using VV=vector<vector<int>>;
using VVl=vector<vector<ll>>;

struct UnionFind{
    vector<int> d;
    UnionFind(int n=0):d(n,-1){}
    int root(int x){
        if(d[x]<0)return x;
        return d[x]=root(d[x]);
    }
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return false;
        if(d[x]>d[y])swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    bool same(int x,int y){return root(x)==root(y);}
    int usize(int x){return -d[root(x)];}
};

int main(){
    int n,m;cin >>n>>m;
    UnionFind uni(n);
    for (int i = 0; i < m; ++i) {
        int a,b;cin >>a>>b;
        a--;b--;
        uni.unite(a,b);
    }
    int ans=-1;
    for (int i = 0; i < n; ++i) {
        ans=max(ans,uni.usize(i));
    }
    cout <<ans <<endl;
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  int n,m; cin >> n >> m;
  string s;
  vector<string> a; for(int i=0;i<n;i++) { cin >> s; a.push_back(s); }
  vector<string> b; for(int i=0;i<m;i++) { cin >> s; b.push_back(s); }

  for(int i=0;i+m<=n;i++) {
    for(int j=0;j+m<=n;j++) {
      int chk=1;
      for(int k=0;k<m;k++) {
        if(a[j+k].substr(i,m) != b[k]) {
          chk *= 0;
          break;
        }  
      }
      
      if(chk == 1) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;



//DONT WASTE YOUR TIME......i said don't waste -_- 
//prove yourself remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

// fortunately or unfortunately tu sabse badaah chodu h ....ek number ka chutiyaa -_-

const ll N= 1e6+55,mod = 1e9+7;

map<string,ll>mm;
map<string,ll>:: iterator it;
int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	ll n,m,i,j,k,a,b,c,x,y,z;
	string s;
	cin>>n;
	while(n--){
		cin>>s;
		mm[s]++;
	}
	cin>>m;
	while(m--){
		cin>>s;
		mm[s]--;
	}
	j=0;
	for(it=mm.begin();it!=mm.end();it++){
		j=max(j,it->second);
	}
	cout<<j<<"\n";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    int h[n+2]={0};
    for (i=1;i<=n;i++)
        cin>>h[i];
    int st,cnt,cur,ans=0;
    while (1)
    {
        int f=0,pre[n+2]={0};
        st=0;
        cnt=0;
        cur=0;
        bool flag=false;
        for (i=1;i<=n;i++)
        {
            if (h[i]==0)
            {
                cnt++;
                //f=0;
                pre[st]-=cur;
                pre[i]+=cur;
                ans+=cur;
                cur=0;
                if (flag)
                    break;
            }
            else
            {
                flag=true;
                if (f==0)
                    st=i;
                if (cur==0)
                    cur=h[i];
                else
                    cur=min(cur,h[i]);
                f=1;
            }
        }
        if (cnt==n)
            break;
        if (cur>0)
        {
            pre[st]-=cur;
            pre[i]+=cur;
            ans+=cur;
        }
        cnt=0;
        for (i=1;i<=n;i++)
        {
            pre[i]+=pre[i-1];
            h[i]+=pre[i];
            if (h[i]==0)
                cnt++;
        }
        if (cnt==n)
            break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N;
	cin >> N;
	vector<int>V(N + 3);
	vector<int>W(N + 3);
	V[0] = 0;
	W[0] = 0;
	for (int i = 1; i <= N; ++i) {
		cin >> V[i];
		W[i] = W[i-1]+abs(V[i] - V[i - 1]);
	}
	V[N + 1] = 0;
	W[N + 1] += W[N]+abs(V[N + 1] - V[N]);
	for (int i = 1; i <= N; ++i) {
		int ans = W[N + 1] - abs(V[i] - V[i - 1]) - abs(V[i + 1] - V[i]) + abs(V[i + 1] - V[i - 1]);
		cout << ans << endl;
	}
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<vector>


using namespace std;

int main(){
  string s;
  vector<string> ans;
  int num;
  int shuffle;
  while(1){
    cin >> s;
    if(s == "-") break;
    cin >> num;
    for (int i = 0; i < num; i++){
      cin >> shuffle;
      s += s.substr(0, shuffle);
      // cout << s << endl;
      s.erase(0, shuffle);
      // cout << s << endl;
    }
    ans.push_back(s);
  }

  for(vector<string>::size_type i = 0; i < ans.size(); i++)
    cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 3212
import * as fs from 'fs';

namespace AtCoder.abc001 {

    export class Program {

        constructor(private readonly args: string[]) {
        }

        /**
         * in
         *
         * out
         *
         */
        main(this: Program): void {

            const n: number = +this.args[0];
            const s: any = {};
            const set = new Set();

            let ans: number = 0;
            for (let i = 1; i <= n; i++) {
                set.add(this.args[i]);
                const keihin = this.args[i];
                if (!s[keihin]) {
                    ans+=1;
                    s[keihin]='find';
                }
            }

            console.log(set.size);

        }
    }
}

const args: string[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg: AtCoder.abc001.Program = new AtCoder.abc001.Program(args);
prg.main();


Measured memory_bytes: 90936
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

void dfs(int node, int dad, vector<vector<int>> &g, vector<bool> &color) {
    for(auto it: g[node])
        if(it != dad) { /// it este de alta culoare
            color[it] = 1 - color[node];
            dfs(it, node, g, color);
        }
}

int main() {
    //freopen("a.in", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vector<vector<int>> g(n + 1);
    for(int i = 1; i < n; i ++) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    vector<bool> color(n + 1, 0);
    dfs(1, 0, g, color);
    int nodes = 0, whichcolor = 1;
    for(int i = 1; i <= n; i ++)
        if(color[i])
            nodes ++;
    if(n - nodes < nodes) {
        whichcolor = 0;
        nodes = n - nodes;
    }

    int rest1 = 0, rest2 = 0;
    for(int i = 1; i <= n; i += 3)
        rest1 ++;
    for(int j = 2; j <= n; j += 3)
        rest2 ++;
    int mn = min(rest1, rest2);

    vector<int> ans(n + 1, 0);
    vector<bool> vis(n + 1, 0);
    if(mn > nodes) {
        int nr = 3;
        for(int i = 1; i <= n; i ++)
            if(color[i] == whichcolor) {
                vis[nr] = 1;
                ans[i] = nr;

                nr += 3;
            }
    } else {
        int nr = 1;
        if(mn == rest2)
            nr = 2;
        for(int i = 1; i <= n; i ++) {
            if(color[i] == whichcolor) {
                if(nr > n)
                    nr = 3;
                vis[nr] = 1;
                ans[i] = nr;

                nr += 3;
            }
        }
    }

    int j = 1;
    for(int i = 1; i <= n; i ++) {
        while(j <= n && vis[j])
            j ++;
        if(ans[i] == 0) {
            ans[i] = j;
            vis[j] = 1;
        }
        cout << ans[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 22144
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
char s[maxn];
int main() {
	scanf("%s",s + 1);
	if (s[3] == s[4] && s[5] == s[6]) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
def main():
    X, Y = map( int, input().split())
    if Y < X*2:
        print("No")
        return
    if (Y-X*2)%2 == 0:
        if (Y-X*2)//2 <= X:
            print("Yes")
            return
    print("No")
        
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
n,a,b,c=gets.split.map &:to_i
ans=[]
q=$<.map &:chomp
n.times{|i|
case q[i]
when "AB" then a>1||a==1&&b==0 ? (a-=1;b+=1;ans<<"B") : b>1||a==0&&b==1 ? (a+=1;b-=1;ans<<"A") : a==0&&b==0 ? (puts "No";exit) : q[i+1]=="AC" ? (a+=1;b-=1;ans<<"A") : (a-=1;b+=1;ans<<"B")
when "AC" then a>1||a==1&&c==0 ? (a-=1;c+=1;ans<<"C") : c>1||a==0&&c==1 ? (a+=1;c-=1;ans<<"A") : a==0&&c==0 ? (puts "No";exit) : q[i+1]=="AB" ? (a+=1;c-=1;ans<<"A") : (a-=1;c+=1;ans<<"C")
when "BC" then b>1||b==1&&c==0 ? (b-=1;c+=1;ans<<"C") : c>1||b==0&&c==1 ? (b+=1;c-=1;ans<<"B") : b==0&&c==0 ? (puts "No";exit) : q[i+1]=="AB" ? (b+=1;c-=1;ans<<"B") : (b-=1;c+=1;ans<<"C")
end
}
puts "Yes"
puts ans

Measured memory_bytes: 28240
import java.util.*;

public class Main {

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

        int k = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();

        int result = (b / k) * k;

        if (result >= a && result <= b){
            System.out.println("OK");
        }else{
            System.out.println("NG");
        }

    }
}

Measured memory_bytes: 35692
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main()
{
	ll N, sum = 0; cin >> N;
  	vector<ll> A(N + 1), B(N);
  	for (int i = 0; i < N + 1; i++) {
    	cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
    	cin >> B[i];
    }  
    for (int i = 0; i < N; i++) {
    	if (A[i] > B[i]) {
        	sum += B[i];
          	A[i] -= B[i];
          	B[i] = 0;
        } else {
        	sum += A[i];
          	B[i] -= A[i];
          	A[i] = 0;
          	if (A[i + 1] > B[i]) {
            	sum += B[i];
              	A[i + 1] -= B[i];
              	B[i] = 0;
            } else {
            	sum += A[i + 1];
              	B[i] -= A[i + 1];
              	A[i + 1] = 0;
            }
        }
    }
  	cout << sum << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define vi   vector<int>
#define vvi  vector<vi >
#define vvvi vector<vvi >
#define pii  pair<int,int>
#define INF  (int)1e9
#define MOD  (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vi a(n+1);
	vi b(n);
	REP(i,n+1) cin>>a[i];
	REP(i,n) cin>>b[i];
	
	llong ans=0;
	REP(i,n){
		if(a[i]<b[i]){
			ans+=a[i];
			b[i]-=a[i];
		}else{
			ans+=b[i];
			b[i]=0;
		}
		
		if(a[i+1]<b[i]){
			ans+=a[i+1];
			a[i+1]=0;
		}else{
			ans+=b[i];
			a[i+1]-=b[i];
		}
	}
	
	cout<<ans<<endl;
}

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


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

    int ret = 0;
    for (int i = 1; i < 10; i++)
    {
        for (int j = 1; j < 10; j++)
        {
            if (n == i * j){
                ret = 1;
            }
        }
        
    }
    
    cout << ((ret == 1) ? "Yes": "No") << endl;
    
}



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

int main(){
  map<string, int> map;
  int N; cin >> N;
  for(int i=0; i<N; i++){
    string s; cin >> s;
    map[s]++;
  }
  int M; cin >> M;
  for(int i=0; i<M; i++){
    string t; cin >> t;
    map[t]--;
  }
  int ans = -200;
  for(auto ite=map.begin(); ite!=map.end(); ++ite){
    ans = max(ans, ite->second);
  }
  cout << max(0, ans) << endl;
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


MOD = 10 ** 9 + 7


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = []
    C = [0] * N

    def make_divisors(n):
        divisors = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)

        # divisors.sort()
        return divisors

    for i in range(N):
        if A[N - i - 1] == 1:
            if C[N - i - 1] == 0:
                B.append(N - i)
                D = make_divisors(N - i)
                for d in D:
                    C[d - 1] += 1
                    C[d - 1] %= 2
        else:
            if C[N - i - 1] == 1:
                B.append(N - i)
                D = make_divisors(N - i)
                for d in D:
                    C[d - 1] += 1
                    C[d - 1] %= 2
    print(len(B))
    print(*B, sep=" ")


if __name__ == "__main__":
    main()


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

using namespace std;

//#define FILE_IO

int N, ans;
vector <int> edg[100005];
int bts[100005];

void DFS(int nod, int fth)
{
    int msk = 0;
    int val = 0;
    for(auto nxt: edg[nod])
    {
        if(nxt == fth)  continue;
        DFS(nxt, nod);
        for(int b = val + 1; b < 20; b++)
            if( ((1 << b) & msk) && ((1 << b) & bts[nxt]) )
                val = b + 1;
        msk |= bts[nxt];
    }

    while( (1 << val) & msk )   val++;
    bts[nod] = 1 << val;
    for(int b = val + 1; b < 20; b++)
        if( (1 << b) & msk )
            bts[nod] |= (1 << b);
    ans = max(ans, val);
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i < N; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        edg[x].push_back(y);
        edg[y].push_back(x);
    }

    DFS(1, 0);
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 11776
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    for (int i = 0; i < X; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < Y; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < Z; i++) {
        cin >> C[i];
    }

    vector<ll> v;
    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            v.push_back( A[i] + B[j] );
        }
    }
    sort(all(v));
    reverse(all(v));


    sort(all(C));
    reverse(all(C));
    vector<ll> cands;
    for (int i = 0; i < min(K, (int)v.size()); i++) {
        for (int j = 0; j < min(K, Z); j++) {
            cands.push_back(v[i] + C[j]);
        }
    }

    sort(all(cands));
    reverse(all(cands));

    for (int i = 0; i < K; i++) {
        cout << cands[i] << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 43368
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

int n, k;
int cnt[100];

int main()
{
  cin >> n >> k;
  for(int i = 0 ; i < k ; i++) {
    int d;
    cin >> d;
    while(d--) {
      int a;
      cin >> a;
      cnt[--a]++;
    }
  }
  int ans = 0;
  for(int i = 0 ; i < n ; i++)
    ans += !cnt[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
let input = require('fs').readFileSync('/dev/stdin', 'utf8');

let array = input.split(" ").map(x => Number(x));
const w = array[0];
const h = array[1];
const x = array[2];
const y = array[3];
const r = array[4];

const res = (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h)? "Yes" : "No";

console.log(res);





Measured memory_bytes: 15368
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
#define mp make_pair
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    ll n,k;
    cin>>n>>k;


    unordered_set<ll> divn,divk;
    divn = divv(n);
    divk = divv(k);
    ll sum=1;
    for(auto it:divk) if(divn.count(it)) if(isPrime(it)) sum++;
    pr(sum);
}


Measured memory_bytes: 768
#include <stdio.h>

int main(void){
    int a,b,d,r;
    double f;
    
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    
    printf("%d %d %.5f\n",d,r,f);
}

Measured memory_bytes: 1828
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str;
        int i,j;
        int[] num = new int[4];
        int a;
        int[][] s = new int[3][10];
        int[][] h = new int[3][10];
        int[][] c = new int[3][10];
        int[][] d = new int[3][10];
        str = scan.nextLine();
        a = Integer.valueOf(str);
        for(i = 0; i < a; i++){
            str = scan.nextLine();
            String[] card = str.split(" ", 0);
            for(j = 0; j < 4; j++){
                num[j] = Integer.valueOf(card[j]);
            }
            switch(num[0]){
                case 1:
                    s[num[1]-1][num[2]-1] += num[3];
                    break;
                case 2:
                    h[num[1]-1][num[2]-1] += num[3];
                    break;
                case 3:
                    c[num[1]-1][num[2]-1] += num[3];
                    break;
                case 4:
                    d[num[1]-1][num[2]-1] += num[3];
                    break;
            }
        }

        for(i = 0; i < 3; i++){
            for(j = 0; j < 10; j++){
                System.out.print(" "+s[i][j]);
            }
            System.out.println();
        }
        System.out.println("####################");
        for(i = 0; i < 3; i++){
            for(j = 0; j < 10; j++){
                System.out.print(" "+h[i][j]);
            }
            System.out.println();
        }
        System.out.println("####################");
        for(i = 0; i < 3; i++){
            for(j = 0; j < 10; j++){
                System.out.print(" "+c[i][j]);
            }
            System.out.println();
        }
        System.out.println("####################");
        for(i = 0; i < 3; i++){
            for(j = 0; j < 10; j++){
                System.out.print(" "+d[i][j]);
            }
            System.out.println();
        }
        //System.out.println("####################");
        
        scan.close();
    }
}


Measured memory_bytes: 27160
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	vector<long long> a(n,0);
	long long temp = 0;
	vector<int> b(n);
	for(long long i=0;i<n;i++){
		cin>>temp;
		temp--;
		b[i] = temp;
		a[temp]++;
	}
	long long ans=0;
	for(long long i=0;i<n;i++){
		if(a[i]>1){
			ans+=(a[i]*(a[i]-1))/2;
		}
	}
	for(int i=0;i<n;i++){
		cout<<ans-a[b[i]]+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 4992
import sys
input = sys.stdin.readline

def solve():
    ordA = ord('a')

    N = int(input())
    Ss = input().rstrip()
    Q = int(input())
    querys = [tuple(input().split()) for _ in range(Q)]

    idEle = 0
    def _binOpe(x, y):
        return x | y
    def makeSegTree(numEle):
        numPow2 = 2 ** (numEle-1).bit_length()
        data = [idEle] * (2*numPow2)
        return data, numPow2
    def setInit(As):
        for iST, A in enumerate(As, numPow2):
            data[iST] = A
        for iST in reversed(range(1, numPow2)):
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def _update1(iA, A):
        iST = iA + numPow2
        data[iST] = A
    def update(iA, A):
        _update1(iA, A)
        iST = iA + numPow2
        while iST > 1:
            iST >>= 1
            data[iST] = _binOpe(data[2*iST], data[2*iST+1])
    def getValue(iSt, iEn):
        L = iSt + numPow2
        R = iEn + numPow2
        ans = idEle
        while L < R:
            if L & 1:
                ans = _binOpe(ans, data[L])
                L += 1
            if R & 1:
                R -= 1
                ans = _binOpe(ans, data[R])
            L >>= 1
            R >>= 1
        return ans

    data, numPow2 = makeSegTree(N)
    As = [(1<<(ord(S)-ordA)) for S in Ss]
    setInit(As)

    anss = []
    for tp, *vs in querys:
        if tp == '1':
            i, c = vs
            i = int(i)
            update(i-1, 1<<(ord(c)-ordA))
        else:
            L, R = vs
            L, R = int(L), int(R)
            v = getValue(L-1, R)
            anss.append(bin(v).count('1'))

    print('\n'.join(map(str, anss)))


solve()


Measured memory_bytes: 57888
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
vector<int> generate(int N, int S, int W){
  vector<int> a(N);
  int g = S;
  for(int i=0; i<N; i++) {
    a[i] = (g/7) % 10;
    if( g%2 == 0 ) { g = (g/2); }
    else           { g = (g/2) ^ W; }
  }
  return a;
}

int main(){
  int N, S, W, Q;
  while(cin >> N >> S >> W >> Q && N){
    vector<int> a = generate(N, S, W);
    if(__gcd(10, Q) == 1){
      vector<int> d(N);
      for(int i = N - 1, e = 1; i >= 0; i--, e = e * 10 % Q){
        d[i] = a[i] * e % Q;
      }
      vector<int> sum(N + 1, 0);
      for(int i = 0; i < N; i++){
        sum[i + 1] = (sum[i] + d[N - 1 - i]) % Q;
      }
      map<int, int> cnt;
      ll ans = 0;
      cnt[0] = 1;
      for(int i = 0; i < N; i++){
        if(a[N - 1 - i] != 0) ans += cnt[sum[i + 1]];
        cnt[sum[i + 1]]++;
      }
      cout << ans << endl;
    }else if(Q == 2 || Q == 5){
      ll ans = 0;
      int head = 0;
      for(int i = 0; i < N; i++){
        if(a[i] != 0) head++;
        if(a[i] % Q == 0) ans += head;
      }
      cout << ans << endl;
    }else{
      assert(false);
    }
  }
  return 0;
}

Measured memory_bytes: 6328
#include <bits/stdc++.h>
using namespace std;
int main (){
  int64_t N,i,num,ans;

  cin >> N;
  vector<int64_t> deff(N);
  for(i=0;i<N;i++){
    cin >> deff.at(i);
  }
  num=N/2;
  sort(deff.begin(),deff.end());
  ans=deff.at(num)-deff.at(num-1);

  cout << ans<<endl;




  return 0;
}


Measured memory_bytes: 1152
L,R=gets.split.map(&:to_i)

lp=L%2019
rp=R%2019
if rp<=lp || R-L>=2019
  rp+=2019
end

m=2019
(lp..(rp-1)).each do |i|
  ((i+1)..rp).each do |j|
    m=[m,i*j%2019].min
  end
end

puts m

Measured memory_bytes: 1788
import Control.Applicative

apply_maybe :: (a -> b) -> Maybe a -> Maybe b
apply_maybe _ Nothing = Nothing
apply_maybe f (Just a) = Just $ f a

sge' :: [Int] -> Maybe Int
sge' [_] = Just 0
sge' (a:(r@(b:_))) | b <= a     = apply_maybe (b +) $ sge' r
sge' (a:(r@(b:_))) | b == a + 1 = apply_maybe (1 +) $ sge' r
sge' _                          = Nothing

sge :: [Int] -> Int
sge l@(0:_) = case sge' l of
    Nothing -> -1
    Just r  -> r
sge _ = -1

main :: IO ()
main = do
    n <- readLn
    a <- mapM (\_->readLn) [1..n]
    putStrLn $ show $ sge a


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

namespace ConsoleApp15
{
    class Class358
    {
        static void Main()
        {
            var T = Console.ReadLine().Select(x => x == '?' ? 'D' : x).ToArray();
            Console.WriteLine(string.Join("",T));

        }
    }
}


Measured memory_bytes: 33640