akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
#define NIL -1
#define MAX 40

int A[MAX], B[MAX];
queue<int> C;

void Preorder(int start, int end) {
  int i = 0;
  for (i = start; i <= end; i++) {
    if (A[start] == B[i]) {
      for (int j = i; j > start; j--) {
        swap(B[j-1], B[j]);
      }
      break;
    }
  }

  if (i-(start+1) >= 0 ) Preorder(start+1, i);
  if (end-(i+1) >= 0 ) Preorder(i+1, end);
  C.push(A[start]);
}

int main() {
	int n;
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  for ( int i = 0; i < n; i++ ) scanf("%d", &B[i]);
  Preorder(0, n-1);

  while ( !C.empty() ) {
    if (C.size() == 1) {
      printf("%d", C.front());
      break;
    }
    printf("%d ", C.front());
    C.pop();
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2760
N, M = map(int, input().split())

la = list()
lb = list()
for i in range(N):
    a, b = map(int, input().split())
    la.append(a)
    lb.append(b)

lab = list(zip(la, lb))
lab = sorted(lab, key=lambda x: x[0])

cst = 0
i = 0
while M - lab[i][1] > 0:
    M -= lab[i][1]
    cst += lab[i][0]*lab[i][1]
    i += 1

cst += lab[i][0] * M
print(cst)

Measured memory_bytes: 20524
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		if(n == 1)
		{
			cout << 1 << " " << 1 << endl;
			continue;
		}
		int wmin = 0, wmax = 0;
		int hmin = 0, hmax = 0;
		vector<P> Vec(n - 1);
		for(int i = 0; i < n - 1; ++i)
		{
			cin >> Vec[i].first >> Vec[i].second;
		}
		vector<P> Rect(n);
		Rect[0].first = 0;
		Rect[0].second = 0;
		for(int i = 0; i < n - 1; ++i)
		{
			if(Vec[i].second == 0)
			{
				Rect[i + 1].first = Rect[Vec[i].first].first - 1;
				Rect[i + 1].second = Rect[Vec[i].first].second;
			}
			else if(Vec[i].second == 1)
			{
				Rect[i + 1].first = Rect[Vec[i].first].first;
				Rect[i + 1].second = Rect[Vec[i].first].second - 1;
			}
			else if(Vec[i].second == 2)
			{
				Rect[i + 1].first = Rect[Vec[i].first].first + 1;
				Rect[i + 1].second = Rect[Vec[i].first].second;
			}
			else if(Vec[i].second == 3)
			{
				Rect[i + 1].first = Rect[Vec[i].first].first;
				Rect[i + 1].second = Rect[Vec[i].first].second + 1;
			}
			if(Rect[i + 1].first < wmin)
			{
				wmin = Rect[i + 1].first;
			}
			if(Rect[i + 1].first > wmax)
			{
				wmax = Rect[i + 1].first;
			}
			if(Rect[i + 1].second < hmin)
			{
				hmin = Rect[i + 1].second;
			}
			if(Rect[i + 1].second > hmax)
			{
				hmax = Rect[i + 1].second;
			}
		}
		cout << wmax - wmin  + 1 << " " << hmax - hmin + 1 << endl;
	}
}

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

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

long long fubendo;

struct UnionFind{
    vector<long long> root;
    vector<long long> sizes;
    UnionFind(long long n): root(n + 1), sizes(n + 1,1){
        for(long long i = 0; i <= n; i++) root[i] = i;
    }
    long long find(long long x){
        if(x == root[x]) return x;
        return root[x] = find(root[x]);
    }
    void unite(long long x, long long y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        fubendo -= sizes[x]*sizes[y];
        if(sizes[x] < sizes[y]) swap(x,y);
        root[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(long long x, long long y){
        return find(x) == find(y);
    }
};

int main(){
    //input
    long long N, M;
    cin >> N >> M;
    long long i,A[M+1],B[M+1];
    for(i=1; i<=M; i++){
        cin >> A[i] >> B[i];
    }

    //calc
    fubendo = N*(N-1)/2;
    long long fuben_when[M+1];
    UnionFind uf(N);
    for(i=M; i>=1; i--){
        fuben_when[i]=fubendo;
        uf.unite(A[i],B[i]);
    }
    
    //answer
    for(i=1; i<=M; i++){
        cout << fuben_when[i] << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 5496
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		String s = sc.next();
		int a = Integer.valueOf(s.substring(0, 1));
		int b = Integer.valueOf(s.substring(1, 2));
		int c = Integer.valueOf(s.substring(2, 3));
		int d = Integer.valueOf(s.substring(3, 4));
		String op1 = "", op2 = "", op3 = "";
		
		if ((a + b + c + d) == 7) {
			op1 = "+";
			op2 = "+";
			op3 = "+";
		} else if ((a + b + c - d) == 7) {
			op1 = "+";
			op2 = "+";
			op3 = "-";
		} else if ((a + b - c + d) == 7) {
			op1 = "+";
			op2 = "-";
			op3 = "+";
		} else if ((a - b + c + d) == 7) {
			op1 = "-";
			op2 = "+";
			op3 = "+";
		} else if ((a + b - c - d) == 7) {
			op1 = "+";
			op2 = "-";
			op3 = "-";
		} else if ((a - b + c - d) == 7) {
			op1 = "-";
			op2 = "+";
			op3 = "-";
		} else if ((a - b - c + d) == 7) {
			op1 = "-";
			op2 = "-";
			op3 = "+";
		} else {
			op1 = "-";
			op2 = "-";
			op3 = "-";
		}
		
		System.out.println(a+op1+b+op2+c+op3+d+"=7");

		sc.close();
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    int n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    int cnt_odd = 0;
    int cnt_4m  = 0;
    rep(i, n){
        if(a[i] % 2 == 1){
            cnt_odd++;
        }
        else if(a[i] % 4 == 0){
            cnt_4m++;
        }
    }

    if(cnt_4m >= cnt_odd || (cnt_odd == cnt_4m + 1 && cnt_odd + cnt_4m == n)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
sec = []
for i in range(k):
  l,r = map(int,input().split())
  sec.append([l,r])

mod = 998244353
dp = [0]*(n+1)
dp[0],dp[1] = 0,1
cumsum = [0]*(n+1)
cumsum[1] = 1
for i in range(2,n+1):
  for l,r in sec:
    if i>l:
      dp[i] += cumsum[i-l]-cumsum[max(0,i-r-1)]
  cumsum[i] = (dp[i]+cumsum[i-1])%mod
print(dp[n]%mod)

Measured memory_bytes: 24956
/*C - Go to School*/

#include <bits/stdc++.h>

using namespace std;

int main(){
	
	int students;
	int pos;

	cin >> students;

	vector <int> orden(students);

	for (int i = 0; i < students; ++i)
	{
		cin >> pos;
		pos--;

		orden[pos] = i + 1;
	}

	for (int i = 0; i < students; ++i)
		cout << orden[i] << ' ';
	

	return 0;
}

Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from fractions import Fraction

class UnionFind:

    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.height = [0 for i in range(n)]
        self.size = [1 for i in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        self.par[x] = self.find(self.par[x])
        return self.par[x]

    def getsize(self, x):
        return self.size[self.find(x)]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.height[x] < self.height[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = self.par[x]
            self.size[x] += self.size[y]
            if self.height[x] == self.height[x]:
                self.height[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

class BIT:
    def __init__(self, N):
        self.N = N
        self.bit = [0 for _ in range(N+1)]
    def add(self, x, a):
        while x <= self.N:
            self.bit[x] += a
            x += x & -x
    def sum(self, x):
        ret = 0
        while x > 0:
            ret += self.bit[x]
            x -= x & -x
        return ret

N, M = map(int, input().split())
ab = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: -x[1])
ans, bit, uf = 0, BIT(M), UnionFind(M+2)
for a, b in ab:
    i = M-a+1
    if 0 < i and bit.sum(i) < i:
        ans += b
        if bit.sum(i-1) == bit.sum(i):
            lb, ub = i, i+1
        else:
            lb, ub = 0, i
            while lb+1 < ub:
                mid = (lb+ub)//2
                if uf.same(mid, ub):
                    ub = mid
                else:
                    lb = mid
        bit.add(lb, 1)
        uf.unite(lb, ub)
print(ans)


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

typedef long long ll;

#define PB push_back
#define MP make_pair

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int n, x; cin >> n >> x;
    vector<int> c(n);
    for (int i = 0; i < n; ++i) cin >> c[i];
    c.PB(x);
    sort(c.begin(), c.end());
    vector<int> d;
    for (int i = 1; i <= n; ++i) {
        d.PB(c[i] - c[i - 1]);
    }
    if (d.size() == 1) cout << d.front() << "\n";
    else {
        int ans = gcd(d[0], d[1]);
        for (int i = 1; i < n; ++i) {
            ans = gcd(ans, gcd(d[i], d[i - 1]));
        }
        cout << ans << "\n";
    }
}

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

#[fastout]
fn main() {
    input! {
        n: usize,
        s: String,
    }

    let ans = if n % 2 == 0 && s[..n / 2] == s[n / 2..] {
        "Yes"
    } else {
        "No"
    };

    println!("{}", ans);
}


Measured memory_bytes: 2072
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

class Main {

	public static void main(String[] args) {
		Set<Long> setA = new TreeSet<Long>();
		Set<Long> setB = new TreeSet<Long>();
		try (Scanner sc = new Scanner(System.in)){
			int times = sc.nextInt();
			for (int i=0; i<times; i++) setA.add(sc.nextLong());
			times = sc.nextInt();
			for (int i=0; i<times; i++) setB.add(sc.nextLong());
			ArrayList<Long>  a = new ArrayList<Long>(setB);
			for (int i=0; i<times; i++) {
				Long l = a.get(i);
				boolean check = setA.contains(l);
				if (check) setA.remove(l);  //重複した場合削除
				else setA.add(l);
			}
			a = new ArrayList<Long>(setA);
			for (int i=0; i<a.size(); i++) System.out.println(a.get(i));
		}
	}
}


Measured memory_bytes: 203336
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> x(n);
	rep(i, n) {
		cin >> x[i];
	}
	ll ans = 0;
	rep(i, n - 1) {
		ans += min(b, (x[i + 1] - x[i])*a);
	}
	cout << ans << endl;
}

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


int main() {
    int n; cin >> n;
    vector<ll> v(n);
    rep(i,n){
        cin >> v.at(i);
    }
    ll ans=0;
    rep(i,n){
        while(v.at(i)%2==0){
            v.at(i)/=2;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
template<typename T> void show(T e){ cout << e << endl; }
template<typename T> void show(const vector<T>& v){ for(const auto& e : v){ cout << e << " "; } cout << endl; }
template<typename T> void show(const vector<vector<T>>& vv){ for(const auto& v : vv){ show(v); } }
template<class Iter> void show(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
const ll DVSR = 10e9+7;

class Bit {
  public:
  Bit(int size);
  ll sum(int i);
  void add(int i, ll x);
  private:
  ll size;
  vector<ll> tree;
};

Bit::Bit(int n) {
  size = n;
  tree = vector<ll>(n+10);
};

ll Bit::sum(int i) {
  i = i+1;
  ll s = 0;
  while (i > 0) {
    s += tree[i];
    i -= i & -i;
  }
  return s;
};

void Bit::add(int i, ll x) {
  i = i+1;
  while (i <= size) {
    tree[i] += x;
    i += i & -i;
  }
};

class RBit {
  public:
  RBit(int n, Bit *bit);
  void add(ll x, int left, int right);
  ll sum(int i);
  ll get(int i);
  private:
  Bit *bit0;
  Bit *bit1;
};

RBit::RBit(int n, Bit *bit) {
  bit0 = bit;
  bit1 = new Bit(n);
};

void RBit::add(ll x, int left, int right) {
  bit0->add(left, -x*(left-1));
  bit1->add(left, x);
  bit0->add(right+1, x*right);
  bit1->add(right+1, -x);
};

ll RBit::sum(int i) {
  return bit1->sum(i)*i + bit0->sum(i);
};
ll RBit::get(int i) {
  return this->sum(i) - (i > 0 ? this->sum(i-1) : 0);
};

int main(int argc, char const *argv[])
{
  ll N, D, A; cin >> N >> D >> A;
  vector<pair<ll,ll>> LIN(N);
  vector<ll> POS(N);
  auto init = new Bit(N);

  REP(i, N) {
    ll a, b;
    cin >> a >> b;
    LIN[i] = pair<ll,ll>(a, b);
  }
  sort(LIN.begin(), LIN.end());
  REP(i, N) {
    POS[i] = LIN[i].first;
    init->add(i, LIN[i].second);
  }
  auto rbit = new RBit(N, init);

  ll res = 0;
  REP(i, N) {
    ll hp = rbit->get(i);
    // show(hp);
    if (hp > 0) {
      ll atc_cnt = hp / A + (hp%A > 0 ? 1 : 0);
      auto it = upper_bound(POS.begin(), POS.end(), POS[i]+2*D);
      int right = (it - POS.begin()) - 1;
      // show(right);
      rbit->add(-A*atc_cnt, i, right);
      res += atc_cnt;
    }
  }
  show(res);
  return 0;
}


Measured memory_bytes: 8064
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int main()
{
	int a,b;
	cin>>a;cin>>b;
	cout<<b*2-a<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 9;
inline int read()
{
    int data = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        data = (data << 3) + (data << 1) + ch - '0';
        ch = getchar();
    }
    return f * data;
}
int p[109], v[109];
ull dp[maxn];
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("data.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    int n = read(), w = read();
    for (int i = 1; i <= n; ++i)
        p[i] = read(), v[i] = read();
    for (int i = 1; i<= n; ++i)
        for (int j = w; j >= p[i]; --j)
            dp[j] = max(dp[j], dp[j - p[i]] + v[i]);
    cout << dp[w] <<'\n';
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}


Measured memory_bytes: 4412
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
long long a,b,c,k,s;
int main()
{
	cin>>a>>b>>c>>k;
	if(k%2)
		s=b-a;
	else
		s=a-b;
	cout<<s;
	return 0;
}

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

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

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

  if (s == "KIHBR" || s == "KIHBRA" || s == "KIHBAR" || s == "KIHBARA"
      || s == "KIHABR" || s == "KIHABRA" || s == "KIHABAR" || s == "KIHABARA"
      || s == "AKIHBR" || s == "AKIHBRA" || s == "AKIHBAR" || s == "AKIHBARA"
      || s == "AKIHABR" || s == "AKIHABRA" || s == "AKIHABAR" || s == "AKIHABARA") {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
	int K;
	cin>>K;
	vll A;
	for(int i=0;i<K;i++){
		ll a;
		cin>>a;
		A.pb(a);
	}
	reverse(A.begin(),A.end());
	if(K==1){
		if(A[0]==2)
			cout<<"2 3"<<endl;
		else
			cout<<-1<<endl;
		return 0;
	}
	if(A[0]!=2LL){
		cout<<-1<<endl;
		return 0;
	}
	ll mini=2,maxi=3;
	if(A[1]==2)
		maxi=2;
	else if(A[1]==3);
	else{
		cout<<-1<<endl;
		return 0;
	}
	for(int i=1;i<K;i++){
		ll prev=A[i-1],now=A[i];
		//miniは、現時点でのmini以上で最小のnowの倍数
		if(mini%now)
			mini=mini-(mini%now)+now;
		//maxiは、現在のmaxi+prev未満で最大のnowの倍数
		maxi=maxi+prev-1;
		if(maxi%now)
			maxi=now*(maxi/now);
		if(mini>maxi){
			cout<<-1<<endl;
			return 0;
		}/*
		cout<<"prev="<<prev<<" "<<"now="<<now<<endl;
		cout<<mini<<" "<<maxi<<endl;*/
	}
	cout<<mini<<" "<<maxi+A.back()-1LL<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
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<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

string replaceOtherStr(std::string &replacedStr, std::string from, std::string to) {
    const ll pos = replacedStr.find(from);
    const ll len = from.length();
 
    if (pos == (ll)std::string::npos || from.empty()) {
        return replacedStr;
    }
 
    return replacedStr.replace(pos, len, to);
}


signed main() {
    ll n, d;
    cin >> n >> d;
    vll x(n), y(n);
    ll r = 0;
    
    rep(i, n) {
        cin >> x[i] >> y[i];
        
        if (sqrt(x[i]*x[i] + y[i]*y[i]) <= d) r++;
    }
    
    mes (r);
   
    
    
}

Measured memory_bytes: 6484
n = int(input())

d = dict()
for i in range(1,n+1):
    s, p = input().split()
    if s in d:
        d[s].append((int(p), i))
    else:
        d[s] = [(int(p), i)]

d = sorted(d.items(), key=lambda x:x[0])
d = [sorted(x[1], reverse=True)  for x in d]

for xs in d:
    for x in xs:
        print(x[1])

Measured memory_bytes: 3064
#![allow(non_snake_case)]

use std::io;

macro_rules! parse_tuple {
    ($($t: ty),+) => ({
        let mut a_str = String::new();
        io::stdin().read_line(&mut a_str).expect("read error");
        let mut a_iter = a_str.split_whitespace();
        (
            $(
                a_iter.next().unwrap().parse::<$t>().expect("parse error"),
            )+
        )
    })
}

fn main() {
    let (A, B) = parse_tuple!(usize, usize);
    if A > 8 || B > 8 {
        println!(":(");
    } else {
        println!("Yay!");
    }
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;

namespace Practice
{
    public struct Vector2
    {
        public float X;
        public float Y;
        public Vector2(float x, float y)
        {
            X = x;
            Y = y;
        }
        public float Length()
        {
            return (float)Math.Sqrt(X * X + Y * Y);
        }
        public static Vector2 Normalize(Vector2 v)
        {
            float l = v.Length();
            return new Vector2(v.X / l, v.Y / l);
        }
        public static Vector2 operator +(Vector2 a, Vector2 b)
        {
            return new Vector2(a.X + b.X, a.Y + b.Y);
        }
        public static Vector2 operator- (Vector2 a, Vector2 b)
        {
            return new Vector2(a.X - b.X, a.Y -b.Y);
        }
        public static Vector2 operator* (Vector2 a, float f)
        {
            return new Vector2(a.X * f, a.Y * f);
        }
        public static Vector2 operator /(Vector2 a, float f)
        {
            return new Vector2(a.X / f, a.Y / f);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        
        static void SolveA(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Vector2 a = new Vector2(0f, 0f);
            Vector2 b = new Vector2(100f, 0f);
            WriteLine(a);
            Koch(n, a, b);
            WriteLine(b);
        }
        private static void Koch(int d, Vector2 a, Vector2 b)
        {
            if( d == 0)
            {
                return;
            }
            Vector2 tmp = (b - a);
            Vector2 n = Vector2.Normalize(tmp);

            Vector2 s = a + n * tmp.Length() / 3f;
            Vector2 t = a + n * tmp.Length() * 2f / 3f;
            Koch(d - 1, a, s);
            WriteLine(s);
            Vector2 u = new Vector2();
            double rad = Math.PI * 60.0 / 180;
            u.X = (float)((t.X - s.X) * Math.Cos(rad) - (t.Y - s.Y) * Math.Sin(rad) + s.X);
            u.Y = (float)((t.X - s.X) * Math.Sin(rad) + (t.Y - s.Y) * Math.Cos(rad) + s.Y);

            Koch(d - 1, s, u);
            WriteLine(u);
            Koch(d - 1, u, t);
            WriteLine(t);
            Koch(d - 1, t, b);
        }
        private static void WriteLine(Vector2 v)
        {
            string sz = v.X.ToString("F8") + " " + v.Y.ToString("F8");
            Console.WriteLine(sz);
        }
    }

}



Measured memory_bytes: 9312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=1e6+5;

ll a[MAX];
int main()
{
    int t,k;
    while(cin>>t>>k)
    {
        for(int i=0;i<t;i++)scanf("%lld",&a[i]);
        sort(a,a+t);
        ll ans=1e18;
        for(int i=k-1;i<t;i++)
        {
            ans=min(ans,a[i]-a[i-k+1]);
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 1024
/**
 * How Many Islands?
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;

import static java.lang.Integer.parseInt;

public class Main {

	static final int[] V = {-1, -1, -1, 0, 0, 1, 1, 1};
	static final int[] H = {-1, 0, 1, -1, 1, -1, 0, 1};
	static final char CHECKED = 'C';

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int w = parseInt(line.substring(0, line.indexOf(' ')));
			int h = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((w | h) == 0) break;

			char[][] map = new char[h + 2][w + 2];
			for (int i = 1; i < h + 1; i++) {
				line = br.readLine();
				for (int j = 0; j < w; j++) {
					map[i][j + 1] = line.charAt(j * 2);
				}
			}

			int count = 0;
			for (int i = 1; i < h + 1; i++) {
				for (int j = 1; j < w + 1; j++) {
					if (map[i][j] == '1') {
						Queue<int[]> queue = new ArrayDeque<int[]>();
						queue.offer(new int[]{i, j});
						map[i][j] = CHECKED;
						while (!queue.isEmpty()) {
							int[] curr = queue.poll();
							for (int k = 0; k < V.length; k++) {
								int ny = curr[0] + V[k];
								int nx = curr[1] + H[k];
								if (map[ny][nx] == '1') {
									queue.offer(new int[]{ny, nx});
									map[ny][nx] = CHECKED;
								}
							}
						}
						count++;
					}
				}
			}
			System.out.println(count);
		} //end while
	} //end main
}

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

int main() {
    int a, b, c, d; cin >> a >> b >> c >> d;
    while (1) {
        c -= b;
        if (c <= 0) break; 
        a -= d;
        if (a <= 0) break;
    }
    if (a <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3632
l, R, d = gets.split.map(&:to_i)

f = []
e = 1
g = 1
h = []
count = 0

while g < R
f << d * e
g = d * e
e += 1

end

f.each do |i|
  if i >=  l && R >= i
    h << i
    count += 1
  end
end

puts count



Measured memory_bytes: 14228
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <memory.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int,P> PP;
const int INF = 1 << 29;

int svalue[200];
int sweight[200];
int nvalue[200];
int nweight[200];

int dp[110][110][1010];
vector<P> Normalize(const vector<P> &v){
  int n =  v.size();
  int pre = -1;
  vector<P> res;
  for(int i = 0; i < n; i++){
    if(v[i].second <= pre) continue;
    pre = v[i].second;
    res.push_back(v[i]);
  }
  return res;
}

int getv(const vector<P> &v, int limit){
  int n = v.size();
  int ub = n;
  int lb = 0;
  if(v[0].first > limit) return -INF;
  while(ub - lb > 1){
    int mb = (ub + lb) / 2;
    if(v[mb].first <= limit) lb = mb;
    else ub = mb;
  }
  return v[lb].second;
}

int main(){
  int limit, n, m, X;
  string s;
  while(cin >> limit >> n >> m >> X && (limit || n || m || X)){
    rep(i, n){
      cin >> s >> sweight[i] >> svalue[i];
    }
    rep(i, m){
      cin >> s >> nweight[i] >> nvalue[i];
    }
    memset(dp, -1, sizeof(dp));
    dp[0][0][0] = 0;
    rep(i, m){
      rep(j, i + 1){
	rep(k, limit + 1){
	  if(dp[i][j][k]== -1) continue;
	  if(k + nweight[i] <= limit){
	    dp[i+1][j+1][k+nweight[i]] 
	      = max(dp[+1][j+1][k+nweight[i]], dp[i][j][k] + nvalue[i]);
	  }
	  dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]);
	}
      }
    }
    vector<P> vec;
    for(int i = X; i <= m; i++){
      for(int j = 0; j <= limit; j++){
	if(dp[m][i][j] != -1) vec.push_back(P(j, dp[m][i][j]));
      }
    }
    sort(vec.begin(), vec.end());
    vec = Normalize(vec);
    
    int res = 0;
    rep(i, n){
      res = max(res ,svalue[i] + getv(vec, limit - sweight[i]));
    }
    
    rep(i, n) {
      rep(j, n){
	if(i == j) continue;
	int v = svalue[i] + svalue[j];
	int w = sweight[i] + sweight[j];
	res = max(res, v + getv(vec, limit - w));
      }
    }
    cout << res << endl;
  }
  return 0;
}
  

Measured memory_bytes: 0
N = int(input())
s = [input() for i in range(N)]

s_sorted = list(map(''.join, list(map(sorted, s))))

s_dict = dict()
for k in s_sorted:
    if k in s_dict:
        s_dict[k] += 1
    else:
        s_dict[k] = 1

cnt = 0
for k in s_dict:
    cnt += sum(range(s_dict[k]))

print(cnt)

Measured memory_bytes: 38540
//http://keita-matsushita.hatenablog.com/entry/2017/04/19/150537
//勉強させていただいた記事

#include <bits/stdc++.h>

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

//等差数列を使うことでtまでの総和はO(1)で求まるようだ……
//数列の数ではなく現在のtに着目する
//tまでの総和がXを超えなかったらそれは全部とんでもたどり着かないと言うことと同義であるため

int main(){
    ll X,time=0,p=0;
    cin>>X;


    while(p<X){
        time++;
        p=(time*(time+1))/2;
    }
    cout<<time<<endl;


    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
use strict;
use warnings;
use utf8;

my $AC_count = 0;
my $WA_count = 0;
my $TLE_count = 0;
my $RE_count = 0;
while (my $input = <STDIN>) {
    chomp $input;
    last unless $input;
    if ($input eq "AC") {
        $AC_count++;
    }
    if ($input eq "WA") {
        $WA_count++;
    }
    if ($input eq "TLE") {
        $TLE_count++;
    }
    if ($input eq "RE") {
        $RE_count++;
    }
}

print "AC x $AC_count\n";
print "WA x $WA_count\n";
print "TLE x $TLE_count\n";
print "RE x $RE_count\n";


Measured memory_bytes: 5156
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	
	register long i, j;
	long d, n, c = 0;
	
	scanf("%ld", &n);
	i = n;
	while (i--) {
		scanf("%ld", &d);
		if (d & 1) {
			for (j = 3; j * j < d; j += 2) {
				if (0 == d % j) {
					break;
				}
			}
			if (j * j > d) {
				c++;
			}
		} else if (d == 2) {
			c++;
		}
	}
	printf("%ld\n", c);

	return 0;
}

Measured memory_bytes: 596
a,b = map(int,input().split())
p = 2019
for i in range (a,b+1) :
    if i%673 == 0 and b-a > 2 :
        print(0)
        exit(0)
    elif i%2019 == 0 :
        print(0)
        exit(0)

for j in range (a,b) :
    for k in range (j+1,b+1) :
        p = min(p,(j*k)%2019)

print(p)

Measured memory_bytes: 3060
#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);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    long long i, j, k, n, m, t, x, y, z, s=0, c=0, l;
    cin >> n;
    if(n==1)
        cout << "Hello World\n";
    else if(n==2)
    {
        cin >> x >> y;
        cout << x+y << endl;
    }
}


Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int m; cin >> m;
  cout << 48 - m << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;
int main()
{
	int N;
	cin >> N;

	string s;
	cin >> s;
	
	int count = 0;
	for (int i = 0; i < N; i++) {
		if ('R' == s.at(i)) {
			count++;
		}
	}


	if (2*count > N) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

#define INF_LL (int64)1e18
//#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


constexpr int64 mod = 1e9+7;

int main(void) {
    string s;
    cin >> s;
    vector<int64> cnt(s.size(), 0);
    int64 sL = 0, sR = 0, p = 0;
    REP(i, s.size()) {
        if (s[i] == 'L') sL++;
        else sR++;
        if (i+1 < s.size() && s[i] == 'R' && s[i+1] == 'L') {
            cnt[p+1] += (sL+1)/2;
            cnt[p] += sL/2;
            cnt[i] += (sR+1)/2;
            cnt[i+1] += sR/2;
            p = i;
            sL = 0; sR = 0;
        }
    }
    cnt[p+1] += (sL+1)/2;
    cnt[p] += sL/2;
    REP(i, s.size()) {
        cout << cnt[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();

		System.out.println(t+s);
	}

	public static long f5(long n) {
		if(n%5!=0) {
			return 0;
		}else{
			return 1+f5(n/5);
		}
	}
}




Measured memory_bytes: 21844
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<pair<long double, int> , null_type,less<pair<long double, int> >, rb_tree_tag,tree_order_statistics_node_update> 
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const ll INF = ll(1e16);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
} 
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r; 
}
template<typename T_vector> // neal
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());
 
    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}

void solve(){
	int n;
	cin >> n;
	rep(i, n) cout << "ACL";
	
}

	


int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 3568
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))


typedef long long lint;

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

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


lint n, m, ina, inb;
vector<lint> a, b;
vector<bool> flag;
vector<bool> eflag;
bool allvisited;

lint dfs(lint now, lint len) {//nowから先に何個それがあるか
	allvisited = 1;
	rep(i, n) {
		if (!flag[i]) {
			allvisited = 0;
			break;
		}
	}
	if (allvisited)return 1;

	lint ret = 0;
	rep(i, m) {
		if (a[i] == now && !eflag[i] && !flag[b[i]-1]) {
			eflag[i] = 1;
			flag[b[i]-1] = 1;
			ret += dfs(b[i], len + 1);
			eflag[i] = 0;
			flag[b[i]-1] = 0;
		}
		else if (b[i] == now && !eflag[i] && !flag[a[i]-1]) {
			eflag[i] = 1;
			flag[a[i]-1] = 1;
			ret += dfs(a[i], len + 1);
			eflag[i] = 0;
			flag[a[i]-1] = 0;
		}
	}
	return ret;
}

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

	cin >> n >> m;
	flag.push_back(1);
	rep(i,n-1)flag.push_back(0);
	rep(i, m) {
		cin >> ina >> inb;
		a.push_back(ina);
		b.push_back(inb);
		eflag.push_back(0);
	}

	co(dfs(1, 0));

	gc();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

#define ALL(V) (V).begin(),(V).end()

using namespace std;

typedef pair<int,int> ii_t;

#define MAX 100010
#define RMAX 1000
char is_prime[MAX];
#define PMAX 100000
int prime[PMAX];

long long order=0;

void dfs2(
        int h, int w, int k,
        int j,
    vector<char> &row,
    vector<char> &col,
    vector<string> &vec,
    int &answer){
    if (j<w) {
    col[j] = 0;
    dfs2(h,w,k,j+1,row,col,vec,answer);
    col[j] = 1;
    dfs2(h,w,k,j+1,row,col,vec,answer);
    }else{
        int cnt = 0;
        for (int ii=0;ii<h;ii++)
            for (int jj=0;jj<w;jj++){
                order++;
                if (!row[ii] && !col[jj] && vec[ii][jj]=='#')
                    cnt ++;
            }
        if (k == cnt)
            answer++;

    }
}
void dfs1(
        int h, int w, int k,
        int i,
    vector<char> &row,
    vector<char> &col,
    vector<string> &vec,
    int &answer){
    if (i<h) {
    row[i] = 0;
    dfs1(h,w,k,i+1,row,col,vec,answer);
    row[i] = 1;
    dfs1(h,w,k,i+1,row,col,vec,answer);
    }else{
        dfs2(h,w,k,0,row,col,vec,answer);
    }
}

int main() {

    int h,w,k;
    cin >> h >> w >> k;
    vector<string> vec(h);
    for (int i=0;i<h;i++)
        cin >> vec[i];
    int answer = 0;
    vector<char> row(h,0);
    vector<char> col(w,0);

    dfs1(h,w,k,0,row,col,vec,answer);

    //cerr << "order : " << order << endl;
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1) {
		a = 14;
	}
	if (b == 1) {
		b = 14;
	}
	if (a > b) {
		cout << "Alice" << endl;
	}
	if (a < b) {
		cout << "Bob" << endl;
	}
	if (a == b) {
		cout << "Draw" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
l = list(map(int,input().split()))

ans = sum(l)

counter = Counter(l)
q = int(input())
for i in range(q):
    b,c = map(int,input().split())
    ans += (c-b)*counter[b]
    print(ans)
    counter[c] += counter[b]
    counter[b] = 0


Measured memory_bytes: 93908
e=Hash.new [];$_.split.map{|v|e[v]+=[$.-2]}while gets;n=$.;a=[0]*(n-1);(1..n).map{|w|u={};e[v=w.to_s].map{|j|u[a[j]]=1};t=1;e[v].map{|j|1>a[j]&&(t+=1until$\==u[t];a[j]=t;t+=1)}};p a.max;$><<a*$/

Measured memory_bytes: 195612
# review
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    ans = 0
    OK = [True for i in range(10**6+1)]
    CNT = [0 for i in range(10**6+1)]
    for x in A:
        CNT[x] += 1
        if CNT[x] == 1:
            for i in range(2, 10**6+1):
                if i*x > 10**6:
                    break
                OK[i*x] = False
    for x in A:
        if CNT[x] == 1 and OK[x]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 218040
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
const int twx=100+100;
const int inf=0x3f3f3f3f;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
int n;
char s[twx][twx];
char ans[twx];
int cnt=0;
int asd[twx][twx];
int changdu=inf;
void init()
{
	n=read();
    f1(1,n,i)
    {
        scanf("%s",s[i]);
    }
}
void work()
{
	f1(1,n,i)
	{
		int x=strlen(s[i]);
		f1(0,x-1,j)
		{
			int qwe=s[i][j]-'a';
			asd[qwe][i]++;//第i个字符串中的字母出现了多少次 
		}
	}
	f1(0,25,j)//求出第j个字符最少出现次数
	{
		changdu=inf;
		f1(1,n,k)
		{
			changdu=min(changdu,asd[j][k]);
		}
		//cout<<changdu<<endl;
		f1(1,changdu,k)
		{
			//cout<<char(j+97);
			ans[cnt++]=char(j+97);
		}
	}
}
void print()
{
	sort(ans,ans+cnt);
	cout<<ans;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	init();
	work();
	print();
	return 0;
}

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

int main() {


//long long a,b;
//int *num=new int[4];
//char *s=new char[3];
string s;
cin >> s;

string list[17]={"AKIHABARA","AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA","AKIHABR","AKIHBRA","KIHBARA","AKIHBAR","KIHABRA","KIHABAR","AKIHBR","KIHBRA","KIHABR","KIHBAR","KIHBR"};
int flag=0;
for(string a:list){
const char* c=s.c_str();
const char* b=a.c_str();

if(strcmp(c,b)==0){flag=1;
//cout << a << endl;

}
}
if(flag)
cout << "YES" << endl;
else
cout << "NO" << endl;


}


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

typedef long long ll;
typedef long long ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;

struct Node
{
    int node, len;
    Node() {node = len = 0;}
    Node(int node, int len) {this -> node = node, this -> len = len;}
};
typedef vector<Node> vg;

#define MAX 1
#define NON 0
#define MOD 1000000007

#define FOR(type, i, a, b) for(type i = a; i < b; i++)
#define FORR(type, i, b, a) for(type i = b; i > a; i--)
#define FORE(type, i, a, b) for(type i = a; i <= b; i++)
#define FORRE(type, i, b, a) for(type i = b; i >= a; i--)

#define testBit(n, bit) ((n >> bit) & 1)
#define flipBit(n, bit) (n ^ (1ll << bit))
#define randomize mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

ll pow5(ll a){
    return a * a * a * a * a;
}

main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll x; cin >> x;
    FORE(ll, sm, -3981, 3981){
        FORE(ll, bi, sm, 3981){
            if (pow5(bi) - pow5(sm) == x) {
                cout << bi << ' ' << sm; return 0;
            }
        }
    }
}

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

int main() {
    int h,w;cin>>h>>w;
    int a[2003][2003];
    rep(i,h){
        string s;cin>>s;
        rep(j,w){
            if(s[j]=='#')a[i][j]=0;
            else a[i][j]=1;
        }
    }
    int ans = 0;
    int cc=1;
    int tt=0;
    rep(i,h)rep(j,w){
        int tmp = 0;
        if(a[i][j]==1){
            ++tmp;
        cc=1;
        while(a[i-cc][j]==1 && i-cc>=0){
            ++tmp;
            ++cc;
        }
        cc=1;
        while(a[i+cc][j]==1 && i+cc<=h-1){
            ++tmp;
            ++cc;
        }
        cc=1;
        while(a[i][j-cc]==1 && j-cc>=0){
            ++tmp;
            ++cc;
        }
        cc=1;
        while(a[i][j+cc]==1 && j+cc<=w-1){
            ++tmp;
            ++cc;
        }
        }
        ans=max(ans,tmp);
        ++tt;
      if(ans>=1960 && tt>=100000)break;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 19216
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int h = Integer.parseInt(in.next());
		int w = Integer.parseInt(in.next());
		int k = Integer.parseInt(in.next());
		char[][] grid = new char[h][w];
		for(int i = 0; i < h; i++) {
			grid[i] = in.next().toCharArray();
		}
		int ans = 0;
		for(int i = 0; i < (1 << (h)); i++) {
			for(int j = 0; j < (1 << (w)); j++) {
				if(count(grid, h, w, i, j) == k) ans += 1;
			}
		}
		System.out.println(ans);
	}
	public static int count(char[][] grid, int h, int w, int ii, int jj) {
		int cnt = 0;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if((ii & (1 << i)) == 0) {
					if((jj & (1 << j)) == 0) {
						if(grid[i][j] == '#') cnt += 1;
					}
				}
			}
		}
		return cnt;
	}
}

Measured memory_bytes: 35436