akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e3+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};
int a[maxn][maxn],ver[maxn][maxn],hor[maxn][maxn],kol[maxn][maxn];
int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,m,q;
    cin>>n>>m>>q;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            char c;
            cin>>c;
            a[i][j]=c-'0';
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            ver[i][j]=ver[i-1][j]+ver[i][j-1]-ver[i-1][j-1]+(a[i][j]==1 && a[i][j-1]==1);
            hor[i][j]=hor[i-1][j]+hor[i][j-1]-hor[i-1][j-1]+(a[i][j]==1 && a[i-1][j]==1);
            kol[i][j]=kol[i-1][j]+kol[i][j-1]-kol[i-1][j-1]+a[i][j];
        }
    }
    while(q--){
        int x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        int ve=ver[x2][y2]-ver[x2][y1]-ver[x1-1][y2]+ver[x1-1][y1];
        int ho=hor[x2][y2]-hor[x2][y1-1]-hor[x1][y2]+hor[x1][y1-1];
        cout<<kol[x2][y2]-kol[x2][y1-1]-kol[x1-1][y2]+kol[x1-1][y1-1]-ve-ho<<"\n";
    }
	exit(0);
}


Measured memory_bytes: 71424
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    // 1 + n * (a - 1) >= b
    // n * (a - 1) >= b - 1
    cout << (b - 1 + (a - 2)) / (a - 1) << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define LL long long
#define PI pair<int,int>
#define PL pair<LL,LL>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;

const int MX = 1e5+5;
int a[MX];
int n;

int main(){
    cin >> n;
    for(int i=0 ; i<n ; ++i)
        cin >> a[i];
    int ans = 0;
    for(int i=0 ; i<n-1 ; ++i){
        int len = 0;
        while(a[i] >= a[i+1] && i < n-1){
            len++;
            i++;
        }
        ans = max(len,ans);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <cmath>
#include <map>

using ll = long long;

class UnionFind
{
public:
    std::vector<int> mParents; //親の番号、親の場合は-(子の集合のサイズ)
    UnionFind(int num)
    {
        mParents = std::vector<int>(num, -1);
    }

    //Aがどのグループに属しているか
    int root(int A)
    {
        //自分が親ならA
        if (mParents[A] < 0)return A;
        //そうでなければ親のグループ（親を繋ぎ変える）
        return mParents[A] = root(mParents[A]);
    }

    //自分のいるグループの頂点数
    int size(int A)
    {
        //親をとってくる
        return -mParents[root(A)];
    }

    //AとBをくっつける
    int connect(int A, int B)
    {
        //AとBをつなぐのではなくroot(A)とroot(B)をくっつける
        A = root(A);
        B = root(B);
        //既にくっついている
        if (A == B)return false;
        //A>Bにする
        if (size(A) < size(B))std::swap(A, B);

        //Aのサイズを更新
        mParents[A] += mParents[B];
        //Bの親をAにする
        mParents[B] = A;
        return true;
    }
};

int main()
{
    int N, M;
    std::cin >> N >> M;

    std::vector<int> A(M), B(M);

    for (int i = 0; i < M; i++)
    {
        std::cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }

    std::vector<ll> ans(M);
    ans[M - 1] = (ll)N * (N - 1) / 2;

    UnionFind uni(N);
    for (int i = M - 1; i >= 1; i--)
    {
        //つながっていなかったのがつながった時
        if (uni.root(A[i]) != uni.root(B[i]))
        {
            ans[i - 1] = ans[i] - (ll)uni.size(A[i]) * uni.size(B[i]);
            uni.connect(A[i], B[i]);
        }
        else
        {
            ans[i - 1] = ans[i];
        }
    }

    for (int i = 0; i < M; i++)
    {
        std::cout << ans[i] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3328
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort()

cnt = 0
has_zero = False

for item in a_list:
    if item < 0:
        cnt += 1
    elif item == 0:
        has_zero = True

abs_list = list(map(abs, a_list))
abs_list.sort()

if has_zero:
    print(sum(abs_list))
elif cnt % 2 == 0:
    print(sum(abs_list))
else:
    print(sum(abs_list) - 2 * abs_list[0])


Measured memory_bytes: 64752
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};

int main() {
  ll N;
  cin >> N;
  ll d[N];
  REP(i, N) { cin >> d[i]; }
  sort(d, d + N);
  // REP(i, N) { cout << d[i] << ' '; }
  // cout << '\n';
  cout << d[N / 2] - d[N / 2 - 1] << '\n';
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


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

class unionfind {
  vector<int> par;
public:
  void init(int n) {
    for (int i = 0; i < n; i++) par.push_back(i);
  }
  
  void merge(int m, int n) {
    par[find(m)] = find(n);
  }
  
  int find(int n) {
    if (n == par[n]) return n;
    return par[n] = find(par[n]);
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m), y(m), z(m);
  for (int i = 0; i < m; i++) cin >> x[i] >> y[i] >> z[i];
  unionfind t;
  t.init(n);
  for (int i = 0; i < m; i++) {
    t.merge(x[i] - 1, y[i] - 1);
  }
  set<int> s;
  for (int i = 0; i < n; i++) {
    s.insert(t.find(i));
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 6392
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;

int pref[100500];

void solve() {       
    string s;
    cin >> s; int cnt = 0, mx = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            cnt++;
        }
        else {
            mx = max(mx, cnt);
            cnt = 0;
        }
    }                                                          
    cout << max(mx, cnt);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
 
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,cnt=0;
    cin>>n;
    vector <char> s(n);
    for(int i=0;i<n;i++)
    {

        cin>>s[i];

    }
    sort(s.begin(),s.end());
    for(int i=0;i<n;i++)
    {
        if(s[i]!=s[i+1])
            cnt++;
    }
    if(cnt==3)
    cout<<"Three"<<endl;
    else
        cout<<"Four"<<endl;
}


Measured memory_bytes: 3632
#include<iostream>
#define H 200
#define W 100
#define N 100000

using namespace std;

int dp[H][W][2][2];

void init(){
  for(int i=0; i<H; ++i){
    for(int j=0; j<W; ++j){
      dp[i][j][0][0] = 0;
      dp[i][j][0][1] = 0;
      dp[i][j][1][0] = 0;
      dp[i][j][1][1] = 0;
    }
  }
  for(int i=0; i<H; ++i) dp[i][0][0][0] = 1;
  for(int j=0; j<W; ++j) dp[0][j][1][1] = 1;
}

int solve(int& h, int& w){
  for(int i=1; i<h; ++i){
    for(int j=1; j<w; ++j){
      dp[i][j][0][0] = (dp[i-1][j][0][0] + dp[i-1][j][1][0]) % N;
      dp[i][j][0][1] = dp[i][j-1][0][0] % N;
      dp[i][j][1][0] = dp[i-1][j][1][1] % N;
      dp[i][j][1][1] = (dp[i][j-1][0][1] + dp[i][j-1][1][1]) % N;
    }
  }
  return (dp[h-1][w-1][0][0] + dp[h-1][w-1][0][1]
	  + dp[h-1][w-1][1][0] + dp[h-1][w-1][1][1]) % N;
}

int main(){
  int h, w;
  while(1){
    cin >> w >> h;
    if(!w & !h) break;
    init();
    cout << solve(h, w) << endl;
  }
  return 0;
}

Measured memory_bytes: 1472
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define deb(a) cout << a << ": "
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
int n, m;
std::vector<int> g[N];
int vis[N];
set <int> s;
void dfs(int from, int& cnt) {
  vis[from] = 1;
  cnt++;
  for(int to : g[from]) {
    if(vis[to] == 0) {
      dfs(to, cnt);
    }
  }
}
void sliczny() {
  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  s.insert(0);
  for(int i = 1; i <= n; i++) {
    if(vis[i] == 0) {
      int cnt = 0;
      dfs(i, cnt);
      s.insert(cnt);
    }
  }
  int ans = 0;
  // for(auto it : s) {
  //   cout << it << ' ';
  // } cout << endl;
  auto it = s.begin();
  while(next(it) != s.end()) {
    ans += *next(it) - *it;
    it = next(it);
  }
  cout << ans << '\n';
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; 
  for(int t = 1; t <= T; t++) {
    //cout << "Case #" << t << ": ";
    sliczny();
  }
  return 0;
}


Measured memory_bytes: 44132
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n,h;
    cin >> n >> h;
    priority_queue<pair<int,int>> k,t;
    for(int i = 0; i < n; i++){
        int a,b;
        cin >> a >> b;
        k.push({a,i});
        t.push({b,i});
    }
    int sum = 0;
    int mx = 0;
    int ans = 0;
    t.push({-1,-1});
    while(sum < h){
        pair<int,int> x = k.top();
        pair<int,int> y = t.top();
        if(h-sum <= mx){
            sum += mx;
            ans++;
        }
        else if(x.first < y.first && x.second != y.second){
            t.pop();
            sum += y.first;
            ans++;
        }
        else if(x.first < y.first){
            mx = max(mx,y.first);
            t.pop();
        } 
        else{
            ans += (h-sum-mx+x.first-1)/x.first;
            sum += h-sum-mx;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2036
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ac =0;
    int wa =0;
    int tle=0;
    int re=0;
    String s = "";
    for(int i=0;i<n;i++){
      s = sc.next();
      if("AC".equals(s)){
        ac++;
      }else if("WA".equals(s)){
        wa++;
      }else if("TLE".equals(s)){
        tle++;
      }else{
        re++;
      }
    }
    System.out.println("AC x " + ac);
    System.out.println("WA x " + wa);
    System.out.println("TLE x " + tle);
    System.out.println("RE x " + re);
  }
}


Measured memory_bytes: 58656
#include<stdio.h>
int main(void)
{
	int data[3],asc;

	scanf("%d %d %d",&data[0],&data[1],&data[2]);
	while(data[0]>data[1]||data[1]>data[2])
	{
		if(data[0]>data[1])
		{
			asc=data[0];
			data[0]=data[1];
			data[1]=asc;
		}
		if(data[1]>data[2])
		{
			asc=data[1];
			data[1]=data[2];
			data[2]=asc;
		}
	}
		printf("%d %d %d",data[0],data[1],data[2]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2108
# -*- coding: utf-8 -*-
N = int(input())
A_list = list(map(int, input().split()))

low_num = 200
high_num = 1000
have_flag = False
money = 1000
stock = 0
last_money = 1000
for i in range(N):
    if have_flag:
        if high_num <= A_list[i]:
            high_num = A_list[i]
        else:
            have_flag = False
            money = money + stock * high_num
            stock = 0
            low_num = A_list[i]
            last_money = money
    else:
        if low_num >= A_list[i]:
            low_num = A_list[i]
        else:
            have_flag = True
            stock = money // low_num
            money = money % low_num
            high_num = A_list[i]

if have_flag:
    if last_money < money + stock * A_list[N - 1]:
        last_money = money + stock * A_list[N - 1]

print(last_money)

Measured memory_bytes: 9040
//package abc176;

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	static PrintWriter out;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		out=new PrintWriter(System.out);
		
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		
		int ans=0,time=0;
		while(ans<a) {
			ans+=b;
			time+=c;
		}
		out.println(time);
		
		out.close();
		sc.close();
	}

}


Measured memory_bytes: 35764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
    	try(Scanner sc = new Scanner(System.in)) {
    		long[] dp = new long[31];
    		for(int i = 0; i < 31; i++) {
				dp[i] = 0;
			}
			dp[0] = 1;
			dp[1] = 1;
			dp[2] = 2;
			for(int i = 3; i < 31; i++) {
				dp[i] = dp[i-3] + dp[i-2] + dp[i-1];
			}

    		while(true) {
    			int n = sc.nextInt();
    			if(n == 0)	break;
    			dp[n] = (dp[n]+9)/10;
    			System.out.println((dp[n]+364)/365);
    		}

    	}
    }

}




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

int main()
{
  int n;
  cin >> n;
  vector<int> u(n-1);
  vector<int> v(n-1);
  vector<int> w(n-1);
  int i;
  for(i = 0; i < n-1; i++)
  {
    cin >> u.at(i) >> v.at(i) >> w.at(i);
  }
  vector<int> color(n, -1);
  queue<int> que;
  for(i = 0; i < n-1; i++)
  {
    if(i == 0)
    {
      color.at(u.at(0)-1) = 0;
      if(w.at(0)%2==0) color.at(v.at(0)-1) = 0;
      else color.at(v.at(0)-1) = 1;
    }
    else
    {
      if(color.at(u.at(i)-1) == -1 && (color.at(v.at(i)-1) == -1))
      {
        que.push(i);
      }
      else if(color.at(u.at(i)-1) != -1)
      {
        if(w.at(i)%2==0) color.at(v.at(i)-1) = color.at(u.at(i)-1);
        else color.at(v.at(i)-1) = (color.at(u.at(i)-1)+1)%2;
      }
      else if(color.at(v.at(i)-1) != -1)
      {
        if(w.at(i)%2==0) color.at(u.at(i)-1) = color.at(v.at(i)-1);
        else color.at(u.at(i)-1) = (color.at(v.at(i)-1)+1)%2;
      }
    }
  }
  while(!que.empty())
  {
    int k = que.front();
    if(color.at(u.at(k)-1) == -1 && (color.at(v.at(k)-1) == -1))
      {
        que.push(k);
      }
      else if(color.at(u.at(k)-1) != -1)
      {
        if(w.at(k)%2==0) color.at(v.at(k)-1) = color.at(u.at(k)-1);
        else color.at(v.at(k)-1) = (color.at(u.at(k)-1)+1)%2;
      }
      else if(color.at(v.at(k)-1) != -1)
      {
        if(w.at(k)%2==0) color.at(u.at(k)-1) = color.at(v.at(k)-1);
        else color.at(u.at(k)-1) = (color.at(v.at(k)-1)+1)%2;
      }
    que.pop();
  }
  for(i = 0; i < n; i++)
  {
    cout << color.at(i) << endl;
  }
}

Measured memory_bytes: 2432
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;

int a[MaxN + 5];

int erfen(int l,int r,int x,int m)
{
	if(l > r)
	{
		return l;
	}
	int mid,v;
	mid = (l + r) / 2;
	if(a[mid] == x) v = mid;
	else if(a[mid] == x + 1&&m == 0) v = mid;
	else if(a[mid] > x) v = erfen(l, mid - 1,x,m);
	else v = erfen(mid + 1,r,x,m);
	return v;
}

int main()
{
	int c,b,x,n,m,biu,piu;
	while(~scanf("%d",&n))
	{
		for(int i = 1;i <= n;i++)
		{
			scanf("%d",&a[i]);
		}
		sort(a + 1,a + 1 + n);
		biu = a[n] / 2;
		a[0] = 0;
		m = a[n] % 2;
		piu = erfen(1,n,biu,m);
		c = abs(a[piu] * 2 - a[n]);
		b = abs(a[piu - 1] * 2 - a[n]);
		if(b < c||piu == n) piu--;
		printf("%d %d\n",a[n],a[piu]);
	}
	return 0;
}

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

class Cube{
public:
    int f[6];
    Cube(){}
    void roll_z(){ roll(1,2,4,3);}//
    void roll_y(){ roll(0,2,5,3);}// to W
    void roll_x(){ roll(0,1,5,4);}// to N
    void roll(int i, int j, int k, int l){
        int t= f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
    }
};

bool eq( Cube c1, Cube c2){
    for(int i=0; i<6; i++)
    if( c1.f[i] != c2.f[i]) return false;
    return true;
}

bool equal(Cube c1, Cube c2){
    for(int i=0; i<6; i++){
        for(int j=0; j<4; j++){
            if( eq(c1,c2)) return true;
            c1.roll_z();
        }
        if(i % 2 == 0) c1.roll_y();
        else c1.roll_x();
        }
        return false;
}

int main(){
    Cube c1, c2;
    
    for( int i=0; i<6; i++) cin >> c1.f[i];
    for( int i=0; i<6; i++) cin >> c2.f[i];
    
    if( equal(c1,c2)) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
    
}


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

using namespace std;

typedef long long ll;

const int mxN = 2e5;
int n, m;
ll k, a[mxN+1], b[mxN+1];

void test_case() {
	cin >> n >> m >> k;
	for(int i = 0; i < n; ++i) {
		cin >> a[i+1];
		a[i+1] += a[i];
	}
	for(int i = 0; i < m; ++i) {
		cin >> b[i+1];
		b[i+1] += b[i];
	}
	int ans = 0;
	for(int i = 0, j = m; i <= n; ++i) {
		if(a[i] > k) break;
		while(a[i] + b[j] > k) {
			j--;
		}
		ans = max(ans, i + j);
	}
	cout << ans << "\n";
}

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


Measured memory_bytes: 6732
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  vector<ll> a(n),b(m);
  vector<ll> ar(n+1,0),br(m+1,0);
  rep(i,n){
    cin >> a[i];
    ar[i+1] = a[i] + ar[i];
  }
  rep(i,m){
    cin >> b[i];
    br[i+1] = b[i] + br[i];
  }

  ll ans = -1;
  rep(i,n+1){
    ll t = k-ar[i];
    if(t<0) break;
    ll pos = upper_bound(br.begin(),br.end(),t) - br.begin() -1;
    ans = max(ans, i+pos);
  }
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 9592
import java.util.*;
public class Main {
    public static int n;
    public static int s;
    public static int c;
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        while(true){
            c=0;
            n=sc.nextInt();
            s=sc.nextInt();
            if(n==0&&s==0)break;
            else f(0,0,0);
            System.out.println(c);
        }
    }
    public static void f(int m,int a,int t){
        if(a==n){
            if(t==s)++c;
        }
        else {
            for(int i=m;i<10;++i){
                f(i+1,a+1,t+i);
            }
        }
    }
}
//by Tuvshee 12.05.2012
//Sum of Integers

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
    int N, C;  cin >> N >> C;
    int T = 100000;
    vector<vector<int>> channel(C, vector<int>(2*T+1,0));
    for(int i=0; i<N; i++){
        int s, t, c;  cin >> s >> t >> c;
        s*=2;  t*=2;  c--;
        channel[c][s]++;
        channel[c][t]--;
    }

    vector<int> cnt(2*T+1, 0);
    for(int c=0; c<C; c++){
        for(int t=1; t<=2*T; t++){
            channel[c][t] += channel[c][t-1];
            if(channel[c][t]==1 && channel[c][t-1]==0) channel[c][t-1]++;
        }
    }

    int ans = 0;
    for(int t=1; t<=2*T; t++){
        int tmp = 0;
        for(int c=0; c<C; c++){
            tmp += channel[c][t];
        }
        ans = max(ans,tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 24576
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n;
		cin>>n;
		int a[n];
		rep(i,0,n) cin>>a[i];
		sort(a,a+n);
		int ans=0;
		rep(i,0,n-1){
			rep(j,i+2,n){
				int sum = a[i]+a[j];
				int diff = max(a[i],a[j])-min(a[i],a[j]);
				ans += max(0l,a+j-upper_bound(a+i+1,a+j,diff));
				// trace(a[i],a[j],a+j-upper_bound(a+i+1,a+j,diff));
			}
		}
		cout<<ans;
	}   
}     

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc154_c solver = new abc154_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc154_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int A[] = new int[N];

            for (int i = 0; i < N; i++) {
                int idx = in.nextInt();
                A[i] = idx;
            }
            Arrays.sort(A);
            for (int i = 0; i < N - 1; i++) {
                if (A[i] == A[i + 1]) {
                    out.println("NO");
                    return;
                }
            }
            out.println("YES");
        }

    }
}



Measured memory_bytes: 85032
import java.util.*;
public class Main {
    static int max(int a,int b){
        if(a<b)return b;
        else return a;
    }
    static int DP(int N,int W,int[] v,int[] w){
        int[][] dp=new int[101][10001];
        for(int i=N-1;i>=0;i--){
            for(int j=0;j<=W;j++){
                if(j<w[i])dp[i][j]=dp[i+1][j];
                else dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
            }
        }
        return dp[0][W];
    }
    public static void main(String[] args) {
        int N,W;
        int[] w=new int[100],v=new int[100];
        Scanner sc=new Scanner(System.in);
        N=sc.nextInt();
        W=sc.nextInt();
        for(int i=0;i<N;i++){
            v[i]=sc.nextInt();
            w[i]=sc.nextInt();
        }
        System.out.println(DP(N,W,v,w));
    }
}



Measured memory_bytes: 30728
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	private static Scanner s = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");
	public static void main(String[] args) {
		//int a=s.nextInt();			
		String S=s.next();
		boolean a=true;
		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)==55) {
				a=false;
				p("Yes");
				break;
			}
		}
		if(a) {
			p("No");
		}
		/*int N=sc.nextInt();
		for(int i=0;i<N;i++) {
			int x=sc.nextInt();
		}*/
		
		
		
				
		
	}
}


















Measured memory_bytes: 27012
#include <cstdio>
#include <algorithm>
using namespace std;
int n, h, a, b[100005], ma, ans;
int main() {
    int i;
    scanf("%d%d", &n, &h);
    for (i=0; i<n; i++) {
        scanf("%d%d", &a, &b[i]);
        ma = max(ma, a);
    }
    sort(b, b+n);
    for (i=n-1; i>=0 && h>0; i--) {
        ans++;
        h -= max(b[i], ma);
    }
    if (h>0) ans += (h+ma-1) / ma;
    printf("%d", ans);
    return 0;
}

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

using namespace std;

bool cmp(pair <int, pair <long long,int>> a , pair <int, pair <long long,int>> b) 
{

	if(a.first == b.first)
		return a.second.first < b.second.first;
	return a.first < b.first;
}

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n , m;
	cin >> n >> m;
	pair <int, pair <long long,int>> a[m];
	for(int i = 0; i < m; ++i){
		cin >> a[i].first >> a[i].second.first;
		a[i].second.second = i;
	}

	sort(a, a + m,cmp);

	string ans[m],other;
	int  curr = a[0].first;
	int cnt = 1;
	for(int i = 0; i < m; ++i) {

		if(a[i].first == curr) {
			int pos = a[i].second.second;
			ans[pos]="";
			for(int j = 0; j < 5 - log10(a[i].first); ++j)
				ans[pos] += "0";
			ans[pos] += to_string(a[i].first);
			other = to_string(cnt);
			for(int j = 0; j < 6 - other.size(); ++j)
				ans[pos] += "0";
			ans[pos] += other;
			++cnt;
		}
		else {

			cnt = 1;
			curr = a[i].first;
			int pos = a[i].second.second;
			ans[pos]="";
			for(int j = 0; j < 5 - log10(a[i].first); ++j)
				ans[pos] += "0";
			ans[pos] += to_string(a[i].first);
			other = to_string(cnt);
			for(int j = 0; j < 6 - other.size(); ++j)
				ans[pos] += "0";
			ans[pos] += other;
			++cnt;
	
		}

	} 

	for(int i = 0; i < m; ++i)
		cout << ans[i] << "\n";
	return 0;
}

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

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

  vector<string> str(H);

  for(int i = 0; i < H; i++){
    cin >> str.at(i);
  }

  vector<bool> row(H, false);
  vector<bool> cell(W, false);

  // 「#」のある行と列をチェック
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(str.at(i).at(j) == '#'){
        row.at(i) = true;
        cell.at(j) = true;
      }
    }
  }

  // チェックの入った行と列の交差するセルは「#」を表示
  for(int i = 0; i < H; i++){
    if(row.at(i)){
      for(int j = 0; j < W; j++){
        if(cell.at(j)){
          cout << str.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
  
}




Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>

using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define ld long double

class Point {
public:
	ld x, y;
	Point(ld x, ld 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 *(ld a) {
		return Point(x * a, y * a);
	}

	bool operator ==(const Point& p) const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}
};

class Segment {
public:
	Point p1, p2;
	Segment(Point p1, Point p2) :
			p1(p1), p2(p2) {
	}
};

ld dot(Point p1, Point p2) {
	return p1.x * p2.x + p1.y * p2.y;
}

ld norm(Point p) {
	return p.x * p.x + p.y * p.y;
}

Point project(Segment s, Point p) {
	Point base = s.p1 - s.p2;
	ld r = dot(p - s.p1, base) / norm(base);
	return s.p1 + base * r;
}

Point reflect(Segment s, Point p) {
	return p + (project(s, p) - p) * 2.0;
}

int main() {

	int p1x, p1y, p2x, p2y;
	scanf("%d %d %d %d", &p1x, &p1y, &p2x, &p2y);
	Point p1(p1x, p1y);
	Point p2(p2x, p2y);
	Segment s(p1, p2);

	int q;
	scanf("%d", &q);

	for (int i = 0; i < q; ++i) {
		int qx, qy;
		scanf("%d %d", &qx, &qy);
		Point p(qx, qy);
		Point ans = reflect(s, p);
		cout << fixed << setprecision(10) << ans.x << " " << ans.y << endl;
	}

	return 0;
}

Measured memory_bytes: 3308
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long int
#define vll vector<long long int>
#define vpi vector<pair<ll,ll>>
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a ; i<b ; ++i)
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

int main() {
    IOS;
    int n; cin >> n;
    map<int,int>mp;
    for(int i=1;i<=100;++i){
        for(int j=1;j<=100;++j){
            for(int k=1;k<=100;++k){
                ll temp = i*i + j*j + k*k + i*j + j*k + i*k;
                if(temp <= 10001) mp[temp]++;
            }
        }
    }
    rep(i,1,n+1) cout << mp[i] << '\n';
}

Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

int n;
pll jobs[200010];
ll sum;
bool valid;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        ll a,b;cin>>a>>b;
        jobs[i]=mp(b,a);
    }
    sort(jobs+1,jobs+1+n);
    valid = true;
    for(int i=1;i<=n;i++){
        ll deadline = jobs[i].fi;
        ll time = jobs[i].se;
        sum+=time;
        if(sum<=deadline){}
        else{valid=false;break;}
    }
    if(valid)cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 3456
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

namespace std {
    template <>
    class hash<std::pair<int, int>> {
    public:
        size_t operator()(const std::pair<int, int>& x) const{
            return hash<int>()(x.first) ^ hash<int>()(x.second);
        }
    };
}

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

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

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

vector<long long> Divisor(long long n) {
    vector<long long> ret;
    for(long long i=1; i*i<=n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n / i);
        }
    }
    return ret;
}

int main(void) {
    Int A, B; cin >> A >> B;
    Int GCD = gcd(A, B);
    vector<Int> divisor = Divisor(GCD);
    sort(divisor.begin(), divisor.end());
    vector<Int> ans;
    for (int i = 0; i < divisor.size(); i++) {
        int flag = 1;
        for (int j = 0; j < ans.size(); j++) {
            if (gcd(ans[j], divisor[i]) != 1) flag = 0;
        }
        if (flag) {
            ans.push_back(divisor[i]);
        }
    }
    cout << ans.size() << endl;
}


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

int n, p;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1; i<n; ++i){
		if(i * (i + 1) / 2 >= n){
			p = i;
			break;
		}
	}
//	cout << " " << p << "\n";
	for(int i=1; i<=p; ++i){
		if(i == p * (p + 1) / 2 - n) continue;
		cout << i << "\n";
	}
	if(n == 1) cout << 1 << "\n";
	if(n == 2) cout << 2 << "\n";
}

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

int main( int argc, char *argv[] )
{
int a;
int b;
int c;

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

	cin >> a;
	cin >> b;
	cin >> c;
	if( a + b == c || a + c == b || b + c == a )
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}




Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
from math import gcd
e  =c*d//gcd(c,d)
xa = a//c if a%c else a//c - 1
xb = b//c
ya = a//d if a%d else a//d - 1
yb = b//d
za = a//e if a%e else a//e - 1
zb = b//e
x = xb-xa
y  = yb-ya
z = zb-za
print(b-a+1-x-y+z)

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


int main() {
    int a,b; cin >> a >> b;
    cout << ((a%2==1 && b%2==1) ? "Yes":"No") << endl;
    return 0;
}


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

int main()
{
    string S;
    int XY[2];
    cin >> S >> XY[0] >> XY[1];

    vector<vector<int>> steps(2);

    int ind = 0, cnt = 0;
    for (auto ch : S) {
        if (ch == 'F') {
            cnt++;
        } else {
            steps[ind].push_back(cnt);
            cnt = 0;
            ind ^= 1;
        }
    }
    if (cnt > 0) steps[ind].push_back(cnt);    

#define W (8000*2+1)
    int ZERO = 8000;
    bool yes = true;
    for (int i = 0; i < 2; i++) {
        vector<vector<int>> dp(steps[i].size() + 1, vector<int>(W));
        dp[0][ZERO] = 1;
        if (i == 0 && steps[0].size()>0) dp[1][ZERO + steps[0][0]] = 1;
        for (int j = (i ^ 1); j < steps[i].size(); j++) {
            for (int k = 0; k < W; k++) {
                if (dp[j][k]) {
                    if (k - steps[i][j] >= 0) dp[j+1][k - steps[i][j]] = 1;
                    if (k + steps[i][j] <  W) dp[j+1][k + steps[i][j]] = 1;
                }
            }
        }
        if (dp[steps[i].size()][ZERO+XY[i]] != 1) {
            yes = false;
            break;
        }
    }

    cout << (yes ? "Yes" : "No") << endl;
}


Measured memory_bytes: 248448
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0);\
cin.tie(0);\
cout.tie(0);
#define ll long long   
#define endl '\n'  
using namespace std;
const int N = 100+ 5;
int  n, m, k,r = 0, b = 0;
int main()
{
	IO
		cin >> n >> m >> k; 
	char  arr[N][N]; 
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> arr[i][j];
		}
		
		
	}
	int  way1 = (1 << n);
	int  way2 =  (1 << m);
	int  ans = 0; 

	for(int  mask = 0 ;mask < way1 ;mask++)
	{
		for (int mask2 = 0; mask2 < way2; mask2++)
		{
			int  cur = 0;
			for (int i = 0; i < n; i++)
			{
				if ((mask&(1 << i)))continue; 
				for (int j = 0; j < m; j++)
				{
					if ((mask2&(1 << j)))continue; 
					if (!(mask & (1 << i)) && !(mask2 & (1 << j)))
					{
						if(arr[i][j]!='.')
						cur++;
					}
				}
			}
			if (cur == k)
				ans++; 

		}
		
    }
	cout << ans << "\n"; 

}

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

char in[10];

bool qu(int i){
	printf("%d\n", i);
	fflush(stdout);
	scanf("%s", in);
	if (in[0] == 'M')return false;
	else if (in[0] == 'F')return true;
	else exit(0);
}

int main(){
	int n;
	scanf("%d", &n);
	bool o = qu(0);
	int l = 1, r = n - 1 >> 1;
	while (r > l){
		int m = l + r >> 1;
		if (qu(m << 1) == o)l = m + 1;
		else r = m;
	}
	l <<= 1;
	qu(l - 1);
	qu(l);
	qu(l + 1);
}

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


int main(){
	int n;
	cin >> n;
	vector< int > a(n), a_dum(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a_dum[i] = a[i];
	}
	if (prev_permutation(a_dum.begin(), a_dum.end())) {
		for (int i = 0; i < n; i++) cout << (i == 0 ? "" : " ") << a_dum[i] << flush;
		cout << endl;
	}
	for (int i = 0; i < n; i++) cout << (i == 0 ? "" : " ") << a[i] << flush;
	cout << endl;
	if (next_permutation(a.begin(), a.end())) {
		for (int i = 0; i < n; i++) cout << (i == 0 ? "" : " ") << a[i] << flush;
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3120
s=input()
ans=""
import sys
for i in range(2**3):
    tmp=s[0]
    tmp_sum=(int(s[0]))
    for j in range(len(s)-1):
        
        if (i >> j) & 1:
            tmp+="+"
            tmp_sum+=int(s[j+1])
        else:
            tmp+="-"
            tmp_sum-=int(s[j+1])
        tmp+=s[j+1]
    # print(tmp,tmp_sum)
    if tmp_sum==7:
        print(tmp+"=7")
        sys.exit()

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>
using namespace std;
using ll = long long;

int F(int a, int b);

int main() {
	ll N;
	cin >> N;
	vector<int> FF;
	if (N == 1) {
		cout << 1 << endl;
		return 0;
	}
	
	for (ll i = 0; i <= sqrt(N); i++) {
		if (N % (i + 1) == 0) FF.push_back(F((i + 1), N / (i + 1)));
	}
	cout << (int)*min_element(FF.begin(), FF.end()) << endl;
	return 0;
}

int F(int a, int b) {
	string sa = to_string(a);
	string sb = to_string(b);
	return max(sa.size(), sb.size());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target ("avx")
#pragma GCC target ("avx2")
#pragma GCC target ("fma")
#pragma GCC optimize ("Ofast")
#pragma GCC optimization ("unroll-loops, no-stack-protector")
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
template <class T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n; 
ll a[100005];
vll adj[100005];
void dfs(ll u, ll p){
	ll sum = 0, mx = 0;
	for (ll i = 0; i < adj[u].size(); i++){
		ll v = adj[u][i]; if (v == p) continue;
		dfs(v, u); mx = max(mx, a[v]); sum += a[v];
	}
	ll ops = min(sum - mx, sum / 2);
	if (adj[u].size() == 1) return;
	if (a[u] > sum){
		cout << "NO\n"; exit(0);
	}
	if ((sum - a[u] > ops) && (adj[u].size() > 1)){
		cout << "NO\n"; exit(0);
	}
	a[u] = 2 * a[u] - sum;
	if (a[u] < 0){
		cout << "NO\n"; exit(0);
	}
}
int main(){
	cin >> n;
	for (ll i = 0; i < n; i++) cin >> a[i];
	if (n == 2){
		if (a[0] == a[1]) cout << "YES\n";
		else cout << "NO\n"; 
		return 0;
	}
	for (ll i = 0; i < n - 1; i++){
		ll u, v; cin >> u >> v; u--; v--;
		adj[u].pb(v); adj[v].pb(u);
	}
	for (ll i = 0; i < n; i++){
		if (adj[i].size() > 1){
			dfs(i, i); 
			if (a[i] != 0) cout << "NO\n";
			else cout << "YES\n";
			return 0;
		}
	}
}

Measured memory_bytes: 16432
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll fac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
    ll h,w,n;cin >> h >> w >> n;
    vl v(h*w,0);
    ll count=0;
    rep(i,n){
        ll a;cin >> a;
        for(int j=count;j<count+a;j++){
            v[j]=i+1;
        }
        count+=a;
    }
    vvl g(h,vl(w));
    vl acc(w);
    rep(i,h){
        for(int j=w*i;j<w*(i+1);j++){
            acc[j-w*i]=v[j];
        }
        if(i%2==1)reverse(all(acc));
        for(int j=0;j<w;j++){
            g[i][j]=acc[j];
        }
    }
    rep(i,h){
        rep(j,w){
            cout << g[i][j] << " ";
        }
        cout << endl;
    }
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

ll dp[10][102][1001];

int main()
{
    dp[0][0][0] = 1;

    rep(k, 10)
    {
        rep(i, 101)
        {
            rep(j, 1001)
            {
                if (j + i <= 1000 && k + 1 < 10)
                    dp[k + 1][i + 1][j + i] += dp[k][i][j];
                dp[k][i + 1][j] += dp[k][i][j];
            }
        }
    }

    int n, s;
    while (cin >> n >> s, n)
    {
        OP(dp[n][101][s]);
    }
    return 0;
}


Measured memory_bytes: 11072
<?php

fscanf(STDIN, '%d', $n);
$line = trim(fgets(STDIN));
$max = 10000;
$A = new \SplFixedArray($n + 1);
$B = new \SplFixedArray($n + 1);
$C = new \SplFixedArray($max + 1);
foreach (explode(' ', $line) as $i => $m) {
    $m = (int)$m;
    $A[$i + 1] = $m;
    //要素数をカウント
    $C[$m] = $C[$m] + 1;
}

//Cの各値を累積和に更新
for ($i = 1; $i <= $max; $i++) {
    $C[$i] = $C[$i] + $C[$i - 1];
}

//BをA => C経由で更新
for ($i = $n; $i > 0; $i--) {
    $a = $A[$i];
    $c = $C[$a];
    $B[$c] = $a;
    $C[$a] = $C[$a] - 1;
}

$str = array();
for ($i = 1; $i <= $n; $i++) {
    $str[] = $B[$i];
}
echo implode(' ', $str), PHP_EOL;

Measured memory_bytes: 486524
#include<iostream>
#include <math.h>
#define int long long int
using namespace std;
signed main()
{
    int X,Y,i;
    cin >> X >> Y;
    for(i=0;i<100;i++)
    {
        int temp=pow(2,i-1)*X;
        if(temp>Y)
        {
            cout << i-1 << "\n";
            break;
        }
    }
    return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long K, long long Q, std::vector<long long> A){
    vector<long long> tmp(N,K);
    for(int i=0;i<N;++i){
        tmp[i] -= Q;
    }
    for(int i=0;i<Q;++i)tmp[A[i]-1]++;
    for(int i=0;i<N;++i){
        if(tmp[i]>0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> A(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, Q, std::move(A));
    return 0;
}


Measured memory_bytes: 2176