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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


ll n, k;

VI a(200005, -1);
VI b(200005);



int main(){
	
	cin >> n >> k;
	REP(i, n) {
		cin >> b[i];
		b[i]--;
	}
	int cnt = 0;
	a[0] = 0;
	int loop;
	int now = 0;
	int c;

	while (true) {
		
		if (a[b[now]] != -1) {
			loop = cnt - a[b[now]] + 1;
			c = a[b[now]];
			now = b[now];
			break;
		}
		now = b[now];
		cnt++;
		a[now] = cnt;
	}
	if (c >= k) {
		REP(i, 200005) {
			if (a[i] == k) {
				cout << i + 1 << endl;
				return 0;
			}
		}
	}

	k -= c;
	k %= loop;


	if (k == 0) {
		cout << now + 1 << endl;
		return 0;
	}

	while (k) {
		k--;
		now = b[now];
	}
	cout << now + 1 << endl;


	return 0;
}

Measured memory_bytes: 4696
#include <iostream>

using namespace std;

int main() {
    string str, s;
    do {
        getline(cin, s);
        str += s;
    } while (!(s == ""));


    int count[26] = {};

    for (int i = 0; i < str.length(); i++) {
        for (int j = 0; j < 26; j++) {
            if (str[i] == (char) ('a' + j) || str[i] == (char) ('A' + j)) {
                count[j]++;
            }
        }
    }

    for (int i = 0; i < 26; i++) {
        cout << (char) ('a' + i) << " : " << count[i] << "\n";
    }

}

Measured memory_bytes: 3188
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val nx = listOfInt()
    val l = listOfInt()

    var d = 0
    l.forEachIndexed { i, li ->
        d+=li
        if (nx[1] < d) {
            println(i+1)
            return
        }
    }
    println(nx[0]+1)
    return
}

// 入力取得
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() =listOfString().map { it.toInt() }

Measured memory_bytes: 37872
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll& a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n >> k;
    while (n > 0) {
        n /= k;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

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

int main(void) {
	int num, i, p;
	ll ans = 0;
	cin >> num;
	vector<int> a(num), b(num);
	rep(i, num)
		cin >> a[i] >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	p = ((num + 1) >> 1) - 1;
	if (num & 1) {
		ans = b[p] - a[p] + 1;
	}
	else {
		int l = a[p] + a[p + 1];
		int r = b[p] + b[p + 1];
		ans = r - l + 1;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
struct knap{
	long long int value;
	long long int weight;
};
int main(){
	long long int n,w;
	cin>>n>>w;
	knap arr[n];
	long long int dp[n+1][w+1];
	for(int i=0;i<n;i++){
		cin>>arr[i].weight>>arr[i].value;
		dp[i][0]=0;
	}
	for (int i =0; i<=n; i++) 
   { 
       for (int j =0; j <=w; j++) 
       { 
           if (i==0 || j==0) 
               dp[i][j] = 0; 
           else if (arr[i-1].weight <= j) 
                 dp[i][j] = max(arr[i-1].value + dp[i-1][j-arr[i-1].weight],dp[i-1][j]); 
           else
                 dp[i][j] =dp[i-1][j]; 
       } 
   } 
	cout<<dp[n][w]<<"\n";
}

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

int main() {
    int X,Y;
    cin >> X >> Y;
    int ans=2*X;
    for (int i=0; i<X; i++) {
        if (ans==Y) {
            cout << "Yes";
            return 0;
        }
        ans +=2;
    }
    if (ans==Y) {
        cout << "Yes";
    }
    else cout << "No";
}

Measured memory_bytes: 3628
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)
    return divisors


def calc(a, b):
    return a ** 4 + a * (b ** 3) + (a * b) ** 2 + b * (a ** 3) + b ** 4

X = int(input())
# c=a-b
for c in make_divisors(X):
    for b in range(-10000, 10000):
        a = c + b
        if calc(a, b) == X / c:
            print(a, b)
            break

Measured memory_bytes: 9460
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    ll n;
    cin >> n;
    vector<ll> data(n);
    rep(i,0,n){
        cin >> data[i];
    }
    sort(data.begin(),data.end());
    reverse(data.begin(),data.end());
    ll ans=0;
    ll cnt=2;
    if(n==1){
        cout<<"0"<<endl;
        return 0;
    }
    ans+=data[0];
    rep(i,1,n){
        if(cnt==n){
            break;
        }
        ans+=data[i];
        cnt++;
        if(cnt==n){
            break;
        }
        ans += data[i];
        cnt++;
        if(cnt==n){
            break;
        }
    }
    cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4840
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#define rep(a,b) for(ll a=0;a<b;++a)
#define REP(a,b,c,d) for(ll a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_i = pair<int, int>;
int main() {
	int N, A, B; cin >> N >> A >> B;
	cout << min(A, B) << " " << max(0, A + B - N) << endl;


	cin >> N;
}

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

using namespace std;

const int error = 1e9;

class WeightedUnionFind{

private:
    vector<int> rank,p,d;

  public:
      WeightedUnionFind(){};
      WeightedUnionFind(int size){
        rank.resize(size,0);
        p.resize(size,0);
        d.resize(size,0);
        for(int i = 0; i < size; i++){
          p[i] = i;
        }
      }

    bool same(int x, int y){
      return  find(x) == find(y);
    }

    void relate(int x, int y, int z){
      int px = find(x);
      int py = find(y);
      link(px, py, d[y] + z - d[x]);
      find(x);
      find(y);
    }

    int find(int x){
      if(x != p[x]){
        int par = find(p[x]);
        d[x] += d[p[x]];
        p[x] = par;
      }
      return p[x];
    }

    int diff(int x, int y){
      find(x);
      find(y);
      if(same(x,y)){
        return d[x] - d[y];
      }else{
        return error;
      }
    }
private:
    void link(int x, int y, int z){
      if(rank[x] > rank[y]){
        p[y] = x;
        d[y] = -z;
      }else{
        p[x] = y;
        d[x] = z;
        if(rank[x] == rank[y]) rank[y]++;
      }
    }

};

int main(){
    int n, q;

    cin >> n >> q;
    WeightedUnionFind wuf = WeightedUnionFind(n);

    for(int i = 0; i < q; i++){
      int t, x, y, z;
      cin >> t;
      if(t == 0){
        cin >> x >> y >> z;
        wuf.relate(x, y, z);
      }else{
        cin >> x >> y;
        int ans = wuf.diff(x, y);
        if(ans == error)
          cout << "?" << endl;
        else
          cout << ans << endl;
      }
    }
    return 0;
}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
int main(){
  string O,E;
  cin>>O>>E;
  for(int i=0;i<E.size();i++){
    cout<<O[i]<<E[i];
  }
  if(O.size()>E.size()) cout<<O[O.size()-1];
  cout<<endl;
}

Measured memory_bytes: 256
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{  
  int k;
  cin >> k;
  queue<ll> q;
  for(int i = 1; i < 10; i++)
  {
    q.push(i);
  }
  for(int i = 0; i < k; i++)
  {
    ll num = q.front(); q.pop();
    if(i == k - 1) {
      cout << num << endl;
      break;
    }
    ll last = num % 10;
    if(last != 0) q.push(num * 10 + last - 1);
    q.push(num * 10 + last);
    if(last != 9) q.push(num * 10 + last + 1);
  }
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end

int n; vector<int> a;
ll rec(int l,int r,ll x,ll y){
    if(r-l==1)return 0;
    ll res=INF;
    rep(i,l+1,r)chmin(res,rec(l,i,x,x+y)+rec(i,r,x+y,y)+(x+y)*a[i]);
    return res;
}

int main(){
    scanf("%d",&n); a.resize(n);
    rep(i,0,n)scanf("%d",&a[i]);
    printf("%lld\n",rec(0,n-1,1,1)+a[0]+a[n-1]);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <algorithm>

using namespace std;

int r[1001], w[1001];
bool dp[1001];

int w_book(int wait, int n) {
	
	int j_max = 0;
	dp[0] = 1;
	for (int i = 1; i < n; i++) {
		for (int j = wait; j >= w[i]; j--) {
			if (dp[j - w[i]]) {
				dp[j] = 1;
				if (j > j_max) j_max = j;
			}
		}
	}
	return j_max;
}

int main() {
	ifstream fin("input.txt");
	ofstream fout("output.txt");

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

		for (int i = 0; i < 1001; i++) {
			r[i] = 0;
			w[i] = 0;
			dp[i] = 0;
		}

		int time = 0;

		for (int i = 1; i <= n; i++) {
			cin >> r[i] >> w[i];
		}
		sort(r + 1, r + n + 1);
		sort(w + 1, w + n + 1);
		int r_total = 0, w_total = 0;
		for (int i = 1; i <= n; i++) {
			r_total += r[i];
			w_total += w[i];
		}
		if (r[n] <= r_total - r[n]) time = r_total + w_total;
		else time = 2 * r[n] + w_total - w_book(r[n] - (r_total - r[n]), n);

		cout << time << endl;
	}

	return 0;
}

Measured memory_bytes: 1252
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        sc.close();

        int max = Math.max(a, Math.max(k, b));

        int work = max * 3;

        int tmp = work - (a + b + k);

        if (tmp % 2 == 0) {
            System.out.println(tmp / 2);
        } else {
            System.out.println((tmp + 3) / 2);
        }
    }
}

Measured memory_bytes: 22100
K=int(input())
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[K-1])

Measured memory_bytes: 3060
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define lowbit(x) (x&(-x))
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define drep(i,x,y) for(int i=x;i>=y;i--)
#define repg(i,x) for(int i=p[x];i;i=e[i].nt)  
using namespace std;
typedef long long LL;
LL read(){
	LL rtn=0;char ch=getchar();
	while(ch>'9'||ch<'0')ch=getchar();
	while(ch<='9'&&ch>='0')rtn=(rtn<<3)+(rtn<<1)+ch-'0',ch=getchar();
	return rtn;
}
const int N=100010;
const LL mod=1e9+7;
int n;
int a[N];
int main(){
#ifdef WK
	freopen("in.txt","r",stdin);
#endif
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	if(a[n]-a[1]>1){
		printf("No\n");
		return 0;
	}
	if(a[n]==a[1]){
		if(2*a[1]<=n||a[1]==n-1){
			printf("Yes\n");
		}else printf("No\n");
	}else{
		int cnt=1;
		while(a[cnt]==a[1])cnt++;cnt--;
		if(a[1]>=cnt&&a[1]<=(n+cnt)/2-1&&a[n])printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef pair<int ,int > P;
typedef long long ll;
string A,B,C;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};


int main(){
	cin >> A >> B >> C;
	cout << A[0] << B[0] << C[0] << "\n";
	return 0;
}

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

int MinMP(int HP, const vector<int>& A, const vector<int>& B, vector<int>& Memo) {
	if (HP <= 0) return 0;
	int N = A.size();
	int ans = 1000000000;
	for (int i = 0; i < N; i++) {
		if (HP <= A[i]) {
			ans = min(ans, B[i]);
		}
		else {
			if (Memo[HP - A[i]] > 0) ans = min(ans, Memo[HP - A[i]] + B[i]);
			else ans = min(ans, MinMP(HP - A[i], A, B, Memo) + B[i]);
		}
	}
	Memo[HP] = ans;
	return ans;
}

int main() {
	int H, N;
	cin >> H >> N;
	vector<int> A(N, 0);
	vector<int> B(N, 0);
	for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

	vector<int> Memo(H + 1, -1);
	cout << MinMP(H, A, B, Memo) << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    int N = read();
    map<string, bool> M;
    bool Over = false;
    string L, S;
    for (int i = 0; i<N; i++) {
        S = read_s();
        if (i != 0 && L[L.length()-1] != S[0]) Over = true;
        if (M[S]) Over = true;
        M[S] = true;
        L = S;
    }
    printf(Over?"No\n":"Yes\n");
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int r, c;

int main(){
	while (cin >> r >> c&&r + c){
		if (r % 2 && c % 2){
			cout << "no" << endl;
		}
		else cout << "yes" << endl;
	}
}

Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


vi f(int N,int A,int B){
  vi res;
  rrep(i,B-1) res.PB(i);

  if(A==1) return res;

  int rem=N-B;
  int p=rem/(A-1);
  int r=rem%(A-1);
  int b=r;
  int c=A-1-r;

  rep(i,b){
    int size=res.size();
    rep(j,p+1){
      res.PB(size+p-j);
    }
  }

  rep(i,c){
    int size=res.size();
    rep(j,p){
      res.PB(size+p-1-j);
    }
  }

  return res;
}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,a,b;
  cin>>n>>a>>b;

  if(a+b>n+1||a*b<n){
    cout<<-1<<endl;
    return 0;
  }

  vi res = f(n,a,b);

  rep(i,res.size()){
    cout<<res[i]+1<<' ';
  }
  cout<<endl;



}

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

class B
{
	static void Main()
	{
		Console.ReadLine();
		var p = Console.ReadLine().Split().Select(int.Parse).ToArray();

		Console.WriteLine(Enumerable.Range(1, p.Length - 2).Count(i => new[] { p[i - 1], p[i], p[i + 1] }.OrderBy(x => x).ElementAt(1) == p[i]));
	}
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(void){
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    
}


Measured memory_bytes: 3116
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	long[][] A = new long[N][2];
    	for(int i = 0; i < N; i++){
    		A[i][0] = sc.nextLong();
    		A[i][1] = sc.nextLong();
    	}
    	sc.close();
    	Arrays.sort(A, (s, t) -> Long.compare(s[0],t[0]));
    	long ans = 0;
    	int sum = 0;
    	for(int i = 0; i < N; i++){
    		if(sum + A[i][1] <= M){
    			ans += A[i][0] * A[i][1];
    			sum += A[i][1];
    		}else if(sum < M){
    			ans += (M - sum) * A[i][0];
    			sum += M - sum;
    		}
    	}
    	System.out.println(ans);
    }
}

Measured memory_bytes: 94832
#include<stdio.h>
#include<string.h>
int main()
{
	char qiu1[10], qiu2[10], qiu[10];
	int a, b,i;
	scanf("%s %s", &qiu1, &qiu2);
	scanf("%d%d", &a, &b);
	scanf("%s", &qiu);
	for (i = 0; i < strlen(qiu); i++)
	{
		if (qiu1[i] != qiu[i])
		{
			printf("%d %d", a, b - 1);
			return 0;
		}
	}
	printf("%d %d", a - 1, b);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N, M;

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

  puts( N==M ? "Yes" : "No" );

  return 0;
}

Measured memory_bytes: 128
function Main(input) {
  input = input.trim().split('\n');
  K = input[0].split(' ')[1];
  Ni = input[1].split(' ');
  if (K >= Ni.length) {
    console.log('0');
    return;
  }
  console.log(Ni.sort((a,b) => b-a).map(Number).slice(K).reduce((a,v) => a + v, 0));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 38736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>>jobs(m);//余裕日数日と報酬の二重配列、m日後まで
  rep(i,n){
    int a,b;
    cin>>a>>b;
    if(a>m)continue;//m日後までに終わらなければ、対象外
    jobs[m-a].push_back(b);
    //jobs配列に期限までの余裕日数日毎に分類し、報酬を入力
  }
  priority_queue<int>q;//プライオリティ・キュー:報酬の最大値を出力
  ll ans=0;//long longなので注意
  for(int i=m-1;i>=0;--i){//後ろからチェックしていく
    for(int b:jobs[i]){//jobs配列から余裕日数日毎に報酬を取り出す
      q.push(b);//プライオリティ・キューに入れていく
    }
    if (!q.empty()){//プライオリティ・キューが空になるまで
      ans+=q.top();//i（後ろから余裕日数日）毎の報酬の最大値を取り出す
      q.pop();//最大値を捨てる
    }
  }
  cout<<ans<<endl;    
  return 0;
}

Measured memory_bytes: 5504
n,m = map(int,input().split())
path = [[]for i in range(n)]
for i in range(m):
    a,b = map(lambda x: int(x)-1,input().split())
    path[a] += [b]
    path[b] += [a]
ans = [-1 for i in range(n)]
depth = [[] for i in range(n)]
visited = [False for i in range(n)]
d=0
ans[0] = -2
depth[0]+=[0]
visited[0]=True
while False in visited:
    for i in depth[d]:
        for j in path[i]:
            if not visited[j]:
                ans[j] = i+1
                depth[d+1] += [j]
                visited[j] = True
    d += 1
print("Yes")
for i in range(1,n):
    print(ans[i])

Measured memory_bytes: 117544
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
#define ll long long
ll gcd(ll m1,ll m2){
	return (m2==0)? m1:gcd(m2,m1%m2);
}
int main(){
	ll n,t[10000],smp,ans=1;
	cin>>n;
	while(n--){
		cin>>smp;
		ans=smp/gcd(ans,smp)*ans;
	}
	cout<<ans<<endl;
	return 0;
	/*
	smp=2,ans=1,m1=1,m2=2,gcd(2,1),m1=2,m2=1,gcd(1,0),ans=2
	smp=3,ans=2,m1=2,m2=3,gcd(3,2),m1=3,m2=2,gcd(2,1),m1=2,m2=1,gcd(1,0)
	*/
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static PrintWriter out;
    public static FastScanner in;

    private void solve() {
        int n = in.nextInt();
        int l = in.nextInt();

        List<String>list = new ArrayList<>();

        for(int i=0;i<n;i++){
            list.add(in.nextLine());
        }

        Collections.sort(list);
        for(String a:list) out.print(a);
    }

    private void runIO() {
        in = new FastScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        solve();
        out.close();
    }

    private static class FastScanner {
        BufferedReader bufferedReader;
        StringTokenizer stringTokenizer;

        private FastScanner() {
            bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }

        private long nextLong() {
            return Long.parseLong(next());
        }

        private String nextLine() {
            String ret = "";
            try {
                ret = bufferedReader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return ret;
        }
    }

    public static void main(String[] args) {
        new Main().runIO();
    }
}


Measured memory_bytes: 23252
/*
 * Author       : YangDavid
 * Created Time : 2019年07月14日 星期日 20时54分13秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int maxn = 222222;
int outdeg[maxn], n, m, fa[maxn], swp[maxn];
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
bool merge(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return false;
    fa[x] = y;
    return true;
}

vector<pii> e;
vector<pii> G[maxn]; //{to, index}

int anc[maxn];
void dfs(int v, int fath) {
    for(auto g : G[v])
        if(g.first == fath) anc[v] = g.second;
        else dfs(g.first, v);
    if(outdeg[v]) {
        outdeg[v] ^= 1;
        outdeg[fath] ^= 1;
        swp[anc[v]] ^= 1;
    }
}

int main() {
    scanf("%d%d", &n, &m);
    if(m & 1) { puts("-1"); return 0; }
    rep(i, n) fa[i] = i;
    rep(i, m) {
        int x, y;
        scanf("%d%d", &x, &y);
        e.emplace_back(x, y);
        outdeg[x] ^= 1;
        if(merge(x, y)) {
            G[x].emplace_back(y, i);
            G[y].emplace_back(x, i);
        }
    }
    dfs(1, -1);
    rep(i, m) {
        int x, y;
        tie(x, y) = e[i - 1];
        if(swp[i]) swap(x, y);
        printf("%d %d\n", x, y);
    }

    return 0;
}


Measured memory_bytes: 17012
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const int vx[4]={0,1,0,-1},vy[4]={1,0,-1,0};
using namespace std;

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

int main(){
  ll N,X;
  cin>>N>>X;
  
  cout<<3*(N-gcd(N,X))<<endl;
}

Measured memory_bytes: 256
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
U = 2*10**6
MOD = 10**9+7
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
  fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U],MOD-2,MOD)
 
for i in range(U,0,-1):
  fact_inv[i-1] = (fact_inv[i]*i)%MOD
 
def comb(n,k):
  if k < 0 or k > n:
    return 0
  z = fact[n]
  z *= fact_inv[k]
  z %= MOD
  z *= fact_inv[n-k]
  z %= MOD
  return z

n, m = map(int, input().split())
c = collections.Counter(prime_factorize(m))
ans = 1
for i in c.values():
  ans *= comb(i+n-1, n-1)
  ans %= MOD
print(ans)

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

using namespace std;

int f[10];

int search(int x[], int n, int i) {
	if (i == n) return 0;
	for (int j=i+1; j<n; j++) {
		if (x[j] > x[i]) x[j] --;
	}
	return x[i]*f[n-i-1] + search(x, n, i+1);
}

int main() {
	int n;
	int p[10];
	int q[10];

	cin >> n;
	for (int i=0; i<n; i++) cin >> p[i];
	for (int i=0; i<n; i++) cin >> q[i];

	f[1] = 1;
	for (int i=2; i<=n; i++) f[i] = f[i-1] * i;

	int a = search(p, n, 0);
	int b = search(q, n, 0);

	printf("%d", abs(a-b));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
using namespace std;

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

struct Point {
    double x,y;
    Point(){}
    Point(double x, double y) : x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x, y+p.y);}
    Point operator-(Point p) {return Point(x-p.x, y-p.y);}
    Point operator*(double k){return Point(x*k,y*k);}
    Point operator/(double k){return Point(x/k,y/k);}
    double norm(){return x*x+y*y;}
    double abs(){sqrt(norm());}
    bool operator == (const Point &p) const {return equals(x,p.x)&&equals(y,p.y);}
};
typedef Point P;

double norm(P a){return a.x*a.x+a.y*a.y;}
double abs(P a){return sqrt(norm(a));}

// 線分
struct Segment {
    Point p1,p2;
    Segment(){}
    Segment(Point p1, Point p2):p1(p1),p2(p2){}
};

// 内積
double dot(Point a, Point b) {return a.x*b.x + a.y*b.y;}

// 外積
double cross(Point a, Point b) {return a.x*b.y-a.y*b.x;}
// 2直線の直行判定
bool is_orthogonal(Point a1, Point a2, Point b1, Point b2) {
    return equals(dot(a1-a2, b1-b2), 0.0);
}
// 2直線の平行判定
bool is_parallel(Point a1, Point a2, Point b1, Point b2) {
    return equals(cross(a1-a2, b1-b2), 0.0);
}

int ccw(Point p0,Point p1,Point p2) {
    P a = p1-p0;
    P b = p2-p0;
    if(cross(a,b) > EPS) return COUNTER_CLOCKWISE;
    if(cross(a,b) < -EPS) return CLOCKWISE;
    if(dot(a,b) < -EPS) return ONLINE_BACK;
    if(a.norm()<b.norm()) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool is_intersected_ls(Point p1, Point p2, Point p3, Point p4) {
    return (ccw(p1,p2,p3)*ccw(p1,p2,p4) <= 0&&ccw(p3,p4,p1)*ccw(p3,p4,p2) <= 0 );
}

int main() {
    int q;
    cin>>q;
    rep(i,q){
        double x0,y0,x1,y1,x2,y2,x3,y3;
        cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;
        P p0(x0,y0),p1(x1,y1),p2(x2,y2),p3(x3,y3);
        if (is_intersected_ls(p0,p1,p2,p3)) cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n, q;
VI e[200010];
LL tmp[200010];
bool vis[200010];
LL res[200010];

void go(int a, LL x) {
  LL y = x + tmp[a];
  res[a] = y;
  vis[a] = true;
  REP(i, SZ(e[a])) if(!vis[e[a][i]]){
    go(e[a][i], y);
  }
}

void solve() {
  cin >> n >> q;
  REP(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--;b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  REP(_, q) {
    int p;
    LL x;
    cin >> p >> x;
    p--;
    tmp[p] += x;
  }
  go(0,0);
  REP(i, n) cout << res[i] << endl;
}

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


Measured memory_bytes: 25856
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=2e5+5;
ll n,a[N],ans,xr,sum,l=1;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;for(ll i=1;i<=n;i++)cin>>a[i];
    for(ll i=1;i<=n;i++){
        sum+=a[i],xr^=a[i];
        while(sum!=xr)xr^=a[l],sum-=a[l],l++;
        ans+=(i-l+1);
    }
    cout<<ans;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	char w[101];
	int i, j, count = 0;
	
	scanf("%s", w);
	
	for(i = 0; w[i] != '\0'; i++) {
		if(w[i] == ' ') {
			continue;
		}
		count++;
		for(j = i + 1; w[j] != '\0'; j++) {
			if(w[i] == w[j]) {
				count++;
				w[j] = ' ';
			}
		}
		if(count % 2 != 0) {
			count++;
			break;
		}
		count = 0;
	}
	printf(count == 0 ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 128
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
import numpy as np
import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]


def main():
    n,m=inpm()
    s=inpll(m)
    p=inpl()
    k=[]
    cnt = 0
    for i in range(m):
        k.append(s[i][0])
        s[i].pop(0)
    
    for i in range(n+1):
        for lis in combinations(range(n),i):
            a = [0 for _ in range(n)]
            for j in lis:
                a[j] = 1
            key = 0
            for den in range(m):
                b = [0 for _ in range(n)]
                for con in s[den]:
                    b[con-1]=1
                a=np.asarray(a)
                b=np.asarray(b)
                x = np.dot(a,b)
                if x%2 != p[den]:
                    key = 1
                    break
            if key == 0:
                cnt+=1
    print(cnt)

if __name__ == "__main__":
    main()

Measured memory_bytes: 19068
#include <iostream>
#include <vector>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}


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

  char S[H][W];
  rep(i, H) rep(j, W) {
    cin >> S[i][j];
  }

  int ans = H*W;
  rep(bit, 1 << H) {
    int res = 0;
    vector<int> count(H, 0);
    rep(j, W) {
      int idx = 0;
      bool over = false;
      rep(i, H) {
        if (S[i][j] == '1')
          ++count[idx];
        if (count[idx] > K) {
          over = true;
          break;
        }
        if (bit & (1 << i))
          ++idx;
      }
      if (over) {
        idx = 0;
        rep(i, H) {
          count[i] = 0;
          if (S[i][j] == '1')
            ++count[idx];
          if (bit & (1 << i))
            ++idx;
        }
        ++res;
      }
    }
    bool ok = true;
    rep(i, H)
      if (count[i] > K)
        ok = false;
    if (!ok)
      continue;
    chmin(ans, res + __builtin_popcount(bit));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())
string_list=[input() for i in range(N)]
C0=0
C1=0
C2=0
C3=0
for i in string_list:
    if i=='AC':
        C0+=1
    elif i=='WA':
        C1+=1
    elif i=='TLE':
        C2+=1
    elif i=='RE':
        C3+=1

print('AC','','x','',C0)
print('WA','','x','',C1)
print('TLE','','x','',C2)
print('RE','','x','',C3)  

Measured memory_bytes: 16316
main(){int n,k,b,s[101],i;for(;scanf("%d%d",&n,&k),n|k;puts(n?"Yes":"No")){for(i=k;i;)scanf("%d",s+--i);for(i=n*k;i;s[--i%k]-=b)scanf("%d",&b);for(i=k;i;)s[--i]<0?n=0:0;}}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ;
  cin >> n ;
  int ans = 1 ;
  int maxkaisu = 0 ;
  for(int i = 1 ; i <= n  ; i +=1){
    int kaisu = 0;
    int t = i;
    while(true){
      if( t % 2 == 0){
        t /= 2;
        kaisu += 1;
      }
      else{
        if( maxkaisu < kaisu ){
          ans = i;
          maxkaisu = kaisu;
        }
        break;
      }
    }
  }
  cout << ans << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;

int k,ans;

signed main() {
    cin >> k;
    rep1(i,k) rep1(j,k) rep1(l,k) {
        ans += gcd(i,gcd(j,l));
    }
    cout << ans << endl;
}





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

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

g=gcd(*a)
p=max(a)-k
ans='POSSIBLE'
if p>=0:
    if p%g!=0:
        ans='IMPOSSIBLE'
else:
    ans='IMPOSSIBLE'

print(ans)

Measured memory_bytes: 20000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


ll a[510];

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
            }
    }
    sort(begin(ret), end(ret));
    sort(ret.begin(), ret.end(), greater<ll>());
    return (ret);
}

int main(){
    ll n, k;
    cin >> n >> k;
    rep(i, n) cin >> a[i];
    ll s = 0;
    rep(i, n) s += a[i];

    vector<ll> div = divisor(s);

    rep(j, div.size()){
        ll d = div[j];
        ll cost = 0;
        vector<ll> b;
        rep(i, n) b.push_back(a[i] % d);
        sort(b.begin(), b.end());
        vector<ll> l(n+1), r(n+1);
        l[0] = 0, r[n] = 0;
        rep(i, n) l[i+1] += l[i] + b[i];
        rrep(i, n) r[i] += (d - b[i]) + r[i+1];
        rep(i, n+1) if (l[i] == r[i] && l[i] <= k){
            cout << d << endl;
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 100005
#define NIL -1
int main(){
    int n; cin >> n;
    int a; cin >> a;
    cout << n*n - a << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll h, w;
char a[100][100];
bool x[100], y[100];

int main(int argc, char **argv) {
	cin >> h >> w;
	CLEAR(x); CLEAR(y);
	REP(i, h) REP(j, w) {
		cin >> a[i][j];
		y[i] |= (a[i][j] == '#');
		x[j] |= (a[i][j] == '#');
	}
	REP(i, h) if (y[i]) {
		REP(j, w) if (x[j]) cout << a[i][j];
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n; cin >> n;
	map<int, int> m;
	rep(i, 0, n) {
		int p; cin >> p;
		m[p]++;
	}
	ll ans = 0;
	for (auto i : m) {
		int x = i.first, y = i.second;
		if (x > y) ans += y;
		else ans += (y - x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4736
import collections
import math


H,W=map(int,input().split())

c=[list(str(input())) for i in range(H)]
#1<=sy<=R
d=[[0 for j in range(W)]for i in range(H)]
inf=10**6
ans=0
for i in range(H):
    for j in range(W):
        if c[i][j]=='#':
            d[i][j]=-1
        else:
            d[i][j]=inf
            ans+=1


d[0][0]=0
queue=collections.deque([[0,0]])
gy,gx=H-1,W-1

moves=[[1,0],[-1,0],[0,1],[0,-1]]

flag=False
while len(queue)>0:
    now=queue.popleft()
    for i in range(4):
        ny=now[0]+moves[i][0]
        nx=now[1]+moves[i][1]
        
        if 0<=ny and ny<H and 0<=nx and nx<W and c[ny][nx]=='.' and d[ny][nx]==inf:
            d[ny][nx]=d[now[0]][now[1]]+1
            queue.append([ny,nx])
            if ny==gy and nx==gx:
                print(ans-d[ny][nx]-1)
                exit()
print(-1)     

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;
typedef pair<char, char> PCC;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
LL MOD = 1e9+7;
int INF = (1e9) *2+1;
double EPS=1.0e-9;
double PI=atan2(0,-1);

int main()
{
    int n;
    cin>>n;
    string s1,s2,s="T";
    bool re=0;
    while(1)
    {
        if(s=="T")
        {
            if(re)
            {
                s1="."+s1;
                s2="."+s2;
            }
            else
            {
                s1+=".";
                s2+=".";
            }
        }
        else
        {
            if(re)
            {
                if(s1[0]=='.')
                {
                    s1[0]='#';
                }
                else
                {
                    if(s2[0]=='.')
                    {
                        s1[0]='.';
                        s2[0]='#';
                    }
                    else
                    {
                        cout<<"???"<<endl;
                    }
                }
            }
            else
            {
                if(s1[s1.size()-1]=='.')
                {
                    s1[s1.size()-1]='#';
                }
                else
                {
                    if(s2[s2.size()-1]=='.')
                    {
                        s1[s1.size()-1]='.';
                        s2[s2.size()-1]='#';
                    }
                    else
                    {
                        re=1;
                        s1.pop_back();
                        s2.pop_back();
                        s="T";
                        continue;
                    }
                }
            }
        }
        cout<<s1<<endl<<s2<<endl;
        cin>>s;
        if(s=="end") break;
    }
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> k >> a >> b;
    for(i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";

    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
int min_comp(int a,int b){
 if (a <= b){
   return a;
 } else {
   return b;
 }
}
 
int main(){
 int num, i, gyou, retu, siten, syuuten, hanni, tyuuten;
 int p[101], m[101][101];
 
 scanf("%d", &num);
 
 for(i = 1;i <= num; i++){
   scanf("%d %d",&gyou,&retu);
   p[i-1] = gyou;
   p[i]   = retu;
 }

 for(i=1;i<=num;i++){
   m[i][i]=0;
 }

   
 for(hanni=2; hanni<=num; hanni++){
   for(siten=1; siten <= num-hanni+1; siten++){
     syuuten = siten + hanni - 1;
     m[siten][syuuten] = 200000000;
     for(tyuuten = siten; tyuuten <= syuuten-1;tyuuten++){
       m[siten][syuuten] = min_comp( (m[siten][syuuten]),  (m[siten][tyuuten] + m[tyuuten+1][syuuten] + p[siten-1] * p[tyuuten] * p[syuuten]) );
     }
   }
 }

 printf("%d\n", m[1][num]);
 return 0;
}

Measured memory_bytes: 1892
from collections import deque

h,w = map(int,input().split())
base = []

for i in range(h):
  base.append(input())
  
seen = [-1]*(h*w)
q = deque([])
q.append([0,0])
now_ini = base[0][0]

if now_ini == ".":
  seen[0] = 0
elif now_ini == "#":
  seen[0] = 1

while q:
  r,c = q.popleft()
  now = base[r][c]
  
      

      
  if (r+1<h) and (seen[(r+1)*w+c] == -1):
    if now == base[r+1][c]:
      sign = 0
    elif (now != base[r+1][c]) and (now == "."):
      sign = 1
    elif (now != base[r+1][c]) and (now == "#"):
      sign = 2
      
    if sign == 0:
      q.appendleft([r+1,c])
      seen[(r+1)*w+c] = seen[r*w+c]
    elif sign == 1:
      q.append([r+1,c])
      seen[(r+1)*w+c] = seen[r*w+c] + 1
    elif (sign == 2):
      q.append([r+1,c])
      seen[(r+1)*w+c] = seen[r*w+c]
      
  if (c+1<w) and (seen[r*w+c+1] == -1):
    if now == base[r][c+1]:
      sign = 0
    elif now != base[r][c+1] and (now == "."):
      sign = 1
    elif (now != base[r][c+1]) and (now == "#"):
      sign = 2
      
    if sign == 0:
      q.appendleft([r,c+1])
      seen[r*w+c+1] = seen[r*w+c]
    elif sign == 1:
      q.append([r,c+1])
      seen[r*w+c+1] = seen[r*w+c] + 1
    elif (sign == 2):
      q.append([r,c+1])
      seen[r*w+c+1] = seen[r*w+c]
      
      
print(seen[w*h-1])

Measured memory_bytes: 3444
c,d,t,u,sz;
long s;
char x[18],buf[5<<17];
main()
{
	read(0,buf,5<<17);
	while(buf[sz++]!=10)
	{
		t+=1;
		if(buf[sz-1]!=buf[sz])
		{
			s+=(long)t*(t+1)>>1;
			if(buf[sz-1]=='>')s-=t<u?t:u;
			u=t;
			t=0;
		}
	}
	t=17;
	do{
		x[--t]=s%10+'0';
		s/=10;
	}while(s);
	write(1,x+t,17-t);
}


Measured memory_bytes: 640
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>

typedef long long int ll;


using namespace std;

int n;

string t;
string s[8];


void calc(int x,int y){
	if(x<0||y<0||x>=8||y>=8)return;
	//cout<<x<<" "<<y<<endl;
	if(s[y][x]=='1'){
		s[y][x]='0';
		for(int i=1; i<=3; i++){
			calc(x+i,y);
			calc(x-i,y);
			calc(x,y+i);
			calc(x,y-i);
		}
	}
}

int main(){
	cin>>n;
	for(int i=0; i<n; i++){
		for(int j=0; j<8; j++){
			cin>>t;
			s[j]=t;
		}
		int x,y;
		cin>>x>>y;
		calc(x-1,y-1);
		//cout<<"test"<<endl;
		cout<<"Data "<<i+1<<":"<<endl;
		for(int j=0; j<8; j++){
			cout<<s[j]<<endl;
		}
	}
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// 任意の個数の変数をスペース区切りで出力します
void dump() {
  cout << endl;
}
template <class Head, class... Tail>
void dump(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(Tail) != 0)
    cout << " ";
  dump(std::move(tail)...);
}

// ====================================================================

int main() {
  string s;
  cin >> s;
  ll n = 1, a = 0, ab = 0, abc = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') a = (a + n) % MOD;
    if (s[i] == 'B') ab = (ab + a) % MOD;
    if (s[i] == 'C') abc = (abc + ab) % MOD;
    if (s[i] == '?') {
      abc = abc * 3 % MOD;
      abc = (abc + ab) % MOD;
      ab = ab * 3 % MOD;
      ab = (ab + a) % MOD;
      a = a * 3 % MOD;
      a = (a + n) % MOD;
      n = n * 3 % MOD;
    }
    // dump(n, a, ab, abc);
  }
  cout << abc << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include <cmath>
#define MOD 1e9+7
using namespace std;
typedef long long ll;

int main(){

char haiku[19];

for(int i = 0; i<19; i++) {cin >> haiku[i]; if(i == 5 || i==13) haiku[i] = ' ';}

for(int i = 0; i<19; i++) cout << haiku[i];

return 0;
}

Measured memory_bytes: 256