akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<ctime>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;

int N, A[100000][3];
ll DP[100001][3];

int main() {
	S(N);
	R(i, N) {
		for (int j = 0; j < 3; j++) scanf("%d", A[i] + j);
	}
	R(i, N + 1) {
		R(j, 3) {
			R(k, 3) {
				if (j != k) {
					DP[i + 1][k] = max(DP[i + 1][k], DP[i][j] + A[i][k]);
				}
			}
		}
	}
	ll ans = 0;
	R(i, 3) ans = max(ans, DP[N][i]);
	PL(ans);
}
	

Measured memory_bytes: 3712
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cmath>
#include<cstdlib>
#include<stack>
using namespace std;
#define ll long long
#define N 1000003
#define INF 0x3f3f3f3f
#define lson rt<<1, l, mid
#define rson (rt<<1)|1, mid+1, r
#define max(a, b) ((a)>(b)?(a):(b))
#define min(a, b) ((a)<(b)?(a):(b))
#define mkp make_pair
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
int n, m, ret, ans=-2, vis[N*3], cnt, d[3*N];
vector<pair<int, int> >g[N*2];
map<pair<int, int>, int>ma;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int i, j, t, x, y, c, xc, yc;
	//freopen("sst.in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin>>n>>m;
	cnt=n+1;
	while(m--){
		cin>>x>>y>>c;
		if(!ma[mkp(x, c)]) ma[mkp(x, c)]=cnt++;	
		xc = ma[mkp(x, c)];
		if(!ma[mkp(y, c)]) ma[mkp(y, c)]=cnt++;
		yc = ma[mkp(y, c)];
		g[x].push_back(mkp(xc, 1));
		g[xc].push_back(mkp(x, 1));
		g[y].push_back(mkp(yc, 1));
		g[yc].push_back(mkp(y, 1)); 
		g[xc].push_back(mkp(yc, 0));
		g[yc].push_back(mkp(xc, 0));		
	}
	
	//int k = 8; for(i=0; i<g[k].size(); i++) cout<<g[k][i].first<<' '<<g[k][i].second<<endl; 
	
	priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > >pri; // first：距离, second: 编号 
	pri.push(mkp(0, 1));	
	
	pair<int, int>pai;
	while(1){
		while(!pri.empty()){
			pai = pri.top();
			pri.pop();
			if(vis[pai.second]==0)
				break;
		}		
		x = pai.second;
		if(x==n){
			ans = pai.first;
			break;
		}
		vis[x] = 1;
		for(i=0; i<g[x].size(); i++){
			y = g[x][i].first;
			if(vis[y])
				continue;
			pri.push(mkp(pai.first+g[x][i].second, y));  
		}
		if(pri.empty())
			break;
	}	
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 95740
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
string s;
using MIte = multimap<vector<char>, int>::iterator;

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

	vector<int> vp;
	for (int i = 0; i != N; i++) {
		int p = 0;
		cin >> p;
		vp.push_back(p);
	}

	int nOK = 0;
	for (int i = 0; i != N; i++) {
		if (vp[i] == i+1) {
			nOK++;
		}
	}

	if (nOK == N-2 || nOK == N) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    int x,h,m,m1,s,s1;  
    public void yatary() {
        Scanner sc = new Scanner(System.in);
        x =sc.nextInt();
        h =x / 3600; 
        m =x % 3600;
        m1 = m / 60;
        s = x % 3600;
        s1 = s % 60;
        System.out.println(h + ":" + m1 + ":" + s1);
    }
    public static void main(String[] args){
    new Main().yatary();
    }
}

Measured memory_bytes: 17164
#include <bits/stdc++.h>
using namespace std;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;     // Initialize result 
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p;    
        y = y>>1; // y = y/2 
        x = (x*x) % p;  // Change x to x^2 
    } 
    return res; 
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);} 

ll modinv(ll a,ll p){return power(a,p-2,p);}

int solve(){
    string s;
    cin>>s;
    if (s=="ARC")
    {
        cout<<"ABC"<<endl;
    }
    else cout<<"ARC"<<endl;
    return 0;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);



    
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    

    // tests(){solve();}
    solve();
    return 0;
}/*#ifndef ONLINE_JUDGE
    #endif*/

    // make_pair make_tuple  tuple<int,int,int> continue resize insert

Measured memory_bytes: 3652
using System;

class Program{
    static int[] seq;
    static long[,] memo;

    static long Count(int left, int right){
        if (memo[left, right]!=-1) {
            return memo[left, right];
        }
        if (right-left<=1) {
            memo[left, right]=0;
        } else if (left+2==right) {
            memo[left, right]=seq[left]*seq[left+1]*seq[right];
        } else{
            var min=long.MaxValue;
            for (var sep=left+1; sep<right; sep++) {
                var tmp=Count(left, sep)+Count(sep, right)+seq[left]*seq[sep]*seq[right];
                if (tmp<min) {
                    min=tmp;
                }
            }
            memo[left, right]=min;
        }
        return memo[left, right];
    }


    public static void Main(){
        var n=int.Parse(Console.ReadLine());
        seq=new int[n+1];
        var s=Console.ReadLine().Split(' ');
        seq[0]=int.Parse(s[0]);
        seq[1]=int.Parse(s[1]);
        for (var i=2; i<n+1; i++) {
            s=Console.ReadLine().Split(' ');
            seq[i]=int.Parse(s[1]);
        }

        memo=new long[n+1, n+1];
        for (var i=0; i<n+1; i++) {
            for (var j=0; j<n+1; j++) {
                memo[i, j]=-1;
            }
        }

        Console.WriteLine(Count(0, n));
    }
}

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
using pi = pair<lint, lint>;
const int MAXN = 1050005;
const int mod = 1e9 + 7;

int n, a[MAXN], b[MAXN], w[MAXN];
vector<int> nxt[MAXN];

lint ipow(int x, int p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret;
}

lint dp[MAXN];
lint count(int xv){
	if(nxt[xv].empty()) return 0;
	for(int i=1; i<nxt[xv].size(); i++){
		int s = nxt[xv][i-1];
		int e = nxt[xv][i];
		int cnt = lower_bound(nxt[0].begin(), nxt[0].end(), e) - 
		lower_bound(nxt[0].begin(), nxt[0].end(), s);
		w[i] = w[i-1] + cnt;
	}
	dp[0] = 1;
	lint ret = 1;
	lint sum = dp[0];
	lint dpjwj = 0;
	for(int i=1; i<nxt[xv].size(); i++){
		dp[i] = 1 + w[i] * sum + dpjwj;
		dp[i] %= mod;
		sum += dp[i];
		dpjwj += dp[i] * -w[i];
		sum %= mod;
		dpjwj %= mod;
		dpjwj += mod;
		dpjwj %= mod;
		ret += dp[i];
	}
	return ret % mod;
}


lint gs[MAXN];

int main(){
	dp[1] = dp[2] = 1;
	for(int i=3; i<MAXN; i++) dp[i] = (dp[i-1] + dp[i-2]) % mod;
	scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	for(int i=1; i<=n; i++) b[i] = b[i-1] ^ a[i];
	for(int i=0; i<=n; i++) nxt[b[i]].push_back(i);
	if(b[n] != 0){
		dp[0] = gs[0] = 1;
		for(int i=1; i<=n; i++){
			dp[i] = gs[b[i] ^ b[n]];
			gs[b[i]] += dp[i];
			gs[b[i]] %= mod;
		}
		cout << dp[n] << endl;
		return 0;
	}
	lint ret = ipow(2, nxt[0].size() - 2);
	for(int i=1; i<(1<<20); i++){
		ret += count(i);
	}
	cout << ret % mod << endl;
}


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

int main() {
  char c;
  string S;

  cin >> c;

  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o') {
      S="vowel";
  } else {
      S="consonant";
  }
  
  cout << S << endl;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
def count(x):
    c=0
    while x>0:
        if x%2==0:
            c+=1
            x=x//2
        else:
            break
    return c

ans=0
for i in range(N):
    ans+=count(A[i])
print(ans)

Measured memory_bytes: 4148
#include <iostream>
#include <stdio.h>

#include <string.h>

int main(void){
    std::string dance;
    std::cin >> dance;

    for (int i = 0; i < dance.length(); i++){
        if ((i) % 2 == 1 && dance[i] != 'L' && dance[i] != 'U' && dance[i] != 'D'){
            printf("No \n");
            return 0;
        }
        else if ((i) % 2 == 0 && dance[i] != 'R' && dance[i] != 'U' && dance[i] != 'D'){
            printf("No \n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 764
(stdin => {
  // Define Function
  const less = (a, b) => a < b

  const getA = (pred1, pred2) => {
    return (pred1 && pred2)
      ? `Yes`
      : `No`
  }
  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const Z = inputs[0].split(' ')
  const A = parseInt(Z[0], 10)
  const B = parseInt(Z[1], 10)
  const C = parseInt(Z[2], 10)

  console.log(getA(less(A, B), less(B, C)))

  // console.log(getA(more(A, B), more(B, C)))
})(require('fs').readFileSync('/dev/stdin', 'utf8'))



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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var xys = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var x1 = xys[0];
            var y1 = xys[1];
            var x2 = xys[2];
            var y2 = xys[3];

            var x = x2 - x1;
            var y = y2 - y1;

            var x3 = x2 - y;
            var y3 = y2 + x;

            var x4 = x3 - x;
            var y4 = y3 - y;

            Console.WriteLine($"{x3} {y3} {x4} {y4}");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11348
import sys
input=sys.stdin.readline
s=int(input())
if s<=10**9:
    print(0,0,1,0,0,s)
else:
    INF=10**9
    x_2=(INF+s-1)//INF
    a=x_2*INF-s
    x_3=1
    y_2=a
    y_3=INF
    print(0,0,x_2,y_2,x_3,y_3)
    


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

A = list(input().split())

def insertion_sort(l):
    for i in range(0, len(l) - 1):
        x = i + 1
        while x != 0 and int(l[x][1]) < int(l[x - 1][1]):
            temp = l[x]
            l[x] = l[x - 1]
            l[x - 1] = temp
            x -= 1
    return l


def babble_sort(l):
    for i in range(0, len(l)):
        for j in reversed(range(i+1, len(l))):
            b = int(l[j][1])
            a = int(l[j - 1][1])
            if b < a:
                t = l[j]
                l[j] = l[j-1]
                l[j-1] = t
    return l

def is_stable(a, l):
    for i in range(0, len(a)):
        if a[i] != l[i]:
            return False
    return True

def print_with_space(l):
    print(' '.join(str(x) for x in l))

B = insertion_sort(A[:])

babbled = babble_sort(A[:])
print_with_space(babbled)

if is_stable(B, babbled):
    print('Stable')
else:
    print('Not stable')

def selection_sort(l):
    for i in range(0, len(l)):
        minj = i
        for j in range(i, len(l)):
            if int(l[j][1]) < int(l[minj][1]):
                minj = j
        t = l[i]
        l[i] = l[minj]
        l[minj] = t
    return l

selected = selection_sort(A[:])
print_with_space(selected)

if is_stable(B, selected):
    print('Stable')
else:
    print('Not stable')

Measured memory_bytes: 7888
def medians(nums, n):
    median_left = nums[(n + 1)//2]
    median_right = nums[(n + 1)//2 - 1]
    return median_left, median_right


if __name__ == '__main__':
    n = int(input())
    nums = list(map(int, input().split()))
    median_left, median_right = medians(sorted(nums), n)
    for i in nums:
        print(median_left) if i < median_left else print(median_right)

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

using namespace std;

const int max_n = 333, inf = 1000111222;

int n, m, k;
char a[max_n][max_n];
int ans[max_n][max_n];
vector<int> v;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d%d", &n, &m, &k);
    v.push_back(-1);
    for (int i = 0; i < n; ++i) {
        scanf("%s", a[i]);
        bool ok = false;
        for (int j = 0; j < m; ++j) {
            if (a[i][j] == '#') {
                ok = true;
                break;
            }
        }
        if (ok) {
            v.push_back(i);
        }
    }
    for (int i = 1; i < v.size(); ++i) {
        int lx = v[i - 1] + 1;
        int rx = v[i];
        if (i + 1 == v.size()) {
            rx = n - 1;
        }
        vector<int> pos;
        pos.push_back(-1);
        for (int j = 0; j < m; ++j) {
            if (a[v[i]][j] == '#') {
                pos.push_back(j);
            }
        }
        for (int j = 1; j < pos.size(); ++j) {
            int ly = pos[j - 1] + 1;
            int ry = pos[j];
            if (j + 1 == pos.size()) {
                ry = m - 1;
            }
            for (int x = lx; x <= rx; ++x) {
                for (int y = ly; y <= ry; ++y) {
                    ans[x][y] = k;
                }
            }
            --k;
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            printf("%d ", ans[i][j]);
        }
        puts("");
    }
    return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct WEdge {
  int from, to;
  double weight;
  WEdge(int from, int to, double weight) : from(from), to(to), weight(weight) {}
};

// Verified at AOJ-GRL1A.
tuple<vector<double>, vector<int>>
ShortestPath(vector<vector<WEdge>>& graph, int s) {
  int n = graph.size();
  vector<double> distances(n, DBL_MAX);
  vector<int> parents(n, -1);
  struct State {
    int v, parent;
    double weight;
  };
  auto compare_state = [](State s1, State s2) {
    return s1.weight > s2.weight;
  };
  priority_queue<State, vector<State>, decltype(compare_state)>
      pq(compare_state);

  pq.push(State({s, -1, 0}));
  vector<int> visited(n);
  while(!pq.empty()) {
    State s = pq.top();
    pq.pop();
    if (visited[s.v]) continue;
    visited[s.v] = true;
    distances[s.v] = s.weight;
    parents[s.v] = s.parent;
    for (const auto& e : graph[s.v]) {
      if (visited[e.to]) continue;
      State next = State({e.to, s.v, s.weight + e.weight});
      pq.push(next);
    }
  }
  return make_tuple(distances, parents);
}

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

  cout << fixed << setprecision(10);

  vector<double> xs(2);
  vector<double> ys(2);
  vector<double> rs(2);
  cin >> xs[0] >> ys[0] >> xs[1] >> ys[1];
  int n;
  cin >> n;
  xs.resize(n + 2);
  ys.resize(n + 2);
  rs.resize(n + 2);
  for (int i = 0; i < n; i++) {
    cin >> xs[i + 2] >> ys[i + 2] >> rs[i + 2];
  }

  vector<vector<WEdge>> graph(n + 2);
  for (int i = 0; i < n + 2; i++) {
    for (int j = 0; j < n + 2; j++) {
      if (i == j) continue;
      double dx = xs[i] - xs[j];
      double dy = ys[i] - ys[j];
      double d2 = dx * dx + dy * dy;
      double r = rs[i] + rs[j];
      double r2 = r * r;
      double w = max(sqrt(d2) - sqrt(r2), 0.0);
      graph[i].push_back(WEdge(i, j, w));
    }
  }

  vector<double> dists;
  tie(dists, ignore) = ShortestPath(graph, 0);
  cout << dists[1] << endl;
}

Measured memory_bytes: 26732
#include <iostream>
#include <cstdlib>

using namespace std;
int main(){
int x,a,b;

	//for(;cin>>x>>a>>b;){
		cin>>x>>a>>b;
		if(abs(a-x)<abs(b-x)){
		
			cout << 'A' <<endl;
		}else {cout << 'B' <<endl;}
		
	//}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int gcd(int x, int y) {
	return y == 0 ? x : gcd(y, x%y);
}
int main() {
	int p, q, r=1;
	cin >> p >> q;
	q = q / gcd(q, p);
	for (int i = 2; i*i <= q; ++i) {
		if (q%i == 0) {
			r *= i;
			while (q%i == 0) q /= i;
		}
	}
	cout << r * q << endl;
}


Measured memory_bytes: 3100
aList = raw_input().split(' ')
bList = raw_input().split(' ')
cList = raw_input().split(' ')
for i in range(6):
    aList[i] = int(aList[i])
for j in range(6):
    bList[j] = int(bList[j])
for k in range(6):
    cList[k] = int(cList[k])
aS = aList[3] * 3600 + aList[4] * 60 + aList[5] - aList[0] * 3600 - aList[1] * 60 - aList[2]
bS = bList[3] * 3600 + bList[4] * 60 + bList[5] - bList[0] * 3600 - bList[1] * 60 - bList[2]
cS = cList[3] * 3600 + cList[4] * 60 + cList[5] - cList[0] * 3600 - cList[1] * 60 - cList[2]
aHour = aS / 3600
aMinute = (aS - aHour * 3600) / 60
aSecond = aS - aHour * 3600 - aMinute * 60
bHour = bS / 3600
bMinute = (bS - bHour * 3600) / 60
bSecond = bS - bHour * 3600 - bMinute * 60
cHour = cS / 3600
cMinute = (cS - cHour * 3600) / 60
cSecond = cS - cHour * 3600 - cMinute * 60
print aHour, aMinute, aSecond
print bHour, bMinute, bSecond
print cHour, cMinute, cSecond


Measured memory_bytes: 4272
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main()
{
    fio;
    ll n,m;
    cin>>n>>m;
    ll k = m/2;
    ll p = min(n,k);
    ll h = m - p*2;
    if(h>=4)
        p = p + h/4;
    cout<<p<<endl;
    return 0;
}



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

vector<vector<int>> to(100005);

void dfs(vector<int> &d, queue<int> &q) {
    while (!q.empty()) {
        int current = q.front();
        q.pop();
        for (int v:to[current]) {
            if (d[v] != -1) continue;
            d[v] = current;
            q.push(v);
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    int a, b;
    rep(i, m) {
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    vector<int> d(n + 5, -1);
    queue<int> q;
    q.push(0);
    d[0] = 0;
    dfs(d, q);

    bool ok = true;
    rep(i, n) {
        if (i == 0) continue;
        if (d[i] == -1) ok = false;
    }
    cout << (ok ? "Yes" : "No") << endl;

    rep(i, n) {
        if (i == 0) continue;
        cout << d[i] + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10124
#include<bits/stdc++.h>
using namespace std; 
int n;
long long h[100010];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=2;i<=n;i++)
	{
		if(h[i-1]<h[i])	h[i]--;
	}
	for(int i=1;i<n;i++)
	{
		if(h[i]>h[i+1])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n;
  cin >> n;
  ll res = INF;
  for (int i = 1; i <= min(1000000LL, n); i++) {
    if (n % i == 0) chmin(res, i - 1 + n / i - 1);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define out(x) cout << x << '\n'
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
//---------------------------------------------------------------------------------------------------
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
//---------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------
void solve()
{
  lli a = 0, b = 0, c = 0, h = 0, x, k, d, n = 0, w = 0, ans = 0, count = 0;
  string s = "", t = "";
  vector<pair<lli, lli>> pr;
  map<lli, lli> mp;
  set<lli> st;

  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> s;
  if (s == "RRR")
  {
    out(3);
  }
  else if (s == "RRS" || s == "SRR")
  {
    out(2);
  }
  else
  {
    if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
      out(1);
    else
      out(0);
  }
  // if (n)
  // {
  //   out("Yes");
  // }
  // else
  // {
  //   out("No");
  // }
}

//---------------------------------------------------------------------------------------------------
signed main()
{
  solve();
}

Measured memory_bytes: 3648
a,b=map(int,input().split())
s=input()
Flag=True
for i in range(a+b+1):
    if i==a:
        if s[i]!='-':
            Flag=False
            break
    else:
        if s[i] =='-':
            Flag=False
            break 
if Flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
A,B = map(int,input().split())
count = 0
for _ in range(A):
  N = list(map(int, input().split()))
  N.pop(0)
  if count == 0:
    K1 = set(N)
    count += 1
  else:
    K2 = set(N)
    K1 = K1 & K2
print(len(K1))

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int w, a, b;
  cin >> w >> a >> b;
  if(a > b)swap(a, b);
  if(a <= b && b <= a + w)cout << 0 << endl;
  else cout << b - a - w << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		double num1 = sc.nextDouble();
		System.out.printf("%f %f\n",num1 * num1 * Math.PI,2 * Math.PI * num1);
		sc.close();
	}	
}


Measured memory_bytes: 28324
# coding: utf-8
# Your code here!
H,W=map(int,input().split())

A=[]
for _ in range(H):
    A.append(list(map(int,input().split())))

ans=[]
for h in range(H):
    for w in range(W):
        if A[h][w]%2==1:
            A[h][w]-=1
            if w==W-1:
                if h==H-1:
                    pass
                else:
                    A[h+1][w]+=1
                    ans.append([h+1,w+1,h+2,w+1])
            else:
                A[h][w+1]+=1
                ans.append([h+1,w+1,h+1,w+2])

print(len(ans))
for item in ans:
    print(*item)


Measured memory_bytes: 30288
N = int(input())
S = [input() for i in range(N)]
ans_set = sorted(S[0])

for k in range(1, N):
    new_set = []
    check_set = sorted(S[k])
    start = -1
    for i in range(len(ans_set)):
        j = start
        while j != len(check_set)-1:
            j += 1
            if ans_set[i] == check_set[j]:
                new_set.append(ans_set[i])
                start = j
                break
    ans_set = new_set

print(''.join(ans_set))


Measured memory_bytes: 3064
from math import gcd
from functools import reduce


def get_LCM(l):
    def lcm(a, b):
        return (a * b) // gcd(a, b)

    return reduce(lcm, l, 1)


if __name__ == '__main__':
    n = int(input())
    l = list(map(int, input().split()))
    print(get_LCM(l))



Measured memory_bytes: 6332
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0516*/
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    while(1){
        int n,k;
        cin >> n >> k;
        if((n==0)&&(k==0)) break;
        int s[n+1];
        s[0]=0;
        rep(i,n){
            int a;
            cin >> a;
            s[i+1]=s[i]+a;
        }
        int res=-1001001001;
        for(int i=0; i+k<n+1; i++){
            int temp=0;
            temp = s[i+k]-s[i];
            if(temp>res) res = temp;
        }

        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3384
from math import gcd, sqrt, ceil
from functools import reduce

# def sieve(n):
#     A = list(range(n+1))
#     for i in range(2, n+1 ,2):
#         A[i] = 2
#     for j in range(3, ceil(sqrt(n+1))+1, 2)[::-1]:
#         for i in range(j, n+1, j):
#             A[i] = j
#     return A

# def factorize(n, A):
#     factors = set()
#     while n != 1:
#         f = A[n]
#         factors.add(f)
#         n //= f
#     return factors

def factorize(n):
    factors = set()
    if n % 2 == 0:
        factors.add(2)
        n //= 2
    while n % 2 == 0:
        n //= 2
    for i in range(3, ceil(sqrt(n + 1)) + 1):
        if n % i == 0:
            factors.add(i)
            n //= i
        while n % i == 0:
            n //= i
    if n > 2:
        factors.add(n)
    return factors

_, *aa = map(int, open(0).read().split())

def main(aa):
    pair_co = True
#     A = sieve(10**6)
#     all_factors = [0] * (10**6+1)
    all_factors = set()
    for a in aa:
        factors = factorize(a)
#         factors = factorize(a, A)
        for factor in factors:
            if factor in all_factors:
                pair_co = False
                break
            else:
                all_factors.add(factor)
        if not pair_co:
            break
    if pair_co:
        return 'pairwise coprime'
    elif reduce(gcd, aa) == 1:
        return 'setwise coprime'
    else:
        return 'not coprime'

print(main(aa))

Measured memory_bytes: 220016
///in the name of Allah the most beneficent the most merciful.
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
#define base 139
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case #%lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
#define out(x) cout << #x << " -> " << x << endl;
using namespace std;
const ll N = 200010, M = 2000005;
ll a, b;
int solve()
{
	cin>>a>>b;
	cout<<a*b<<endl;
	return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int ret = solve();
	return 0;
}
/*

*/


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

int main(void)
{
    long long N;
    cin >> N;
    vector<long long> v(N);
    for (long long i = 0; i < N; i++)
    {
        cin >> v[i];
    }

    long long pre1 = 0;
    long long pre2 = 0;
    long long prenum1, prenum2;
    vector<long long> count1(100001);
    vector<long long> count2(100001);
    for (long long i = 0; i <= N/2; i++)
    {
        count1[v[2*i]]++;
    }
    for (long long i = 1; i < 100001; i++)
    {
        if (count1[i] > pre1)
        {
            pre1 = count1[i];
            prenum1 = i;
        }
    }

    for (long long i = 0; i <= (N/2) - 1; i++)
    {
        count2[v[2*i+1]]++;
    }
    for (long long i = 1; i < 100001; i++)
    {
        if (count2[i] > pre2)
        {
            pre2 = count2[i];
            prenum2 = i;
        }
    }

    long long ans;
    if (prenum1 == prenum2)
    {
        long long prepre1 = 0;
        long long prepre2 = 0;
        for (long long i = 1; i < 100001; i++)
        {
            if (count1[i] > prepre1 && i != prenum1)
            {
                prepre1 = count1[i];
            }
        }
        for (long long i = 1; i < 100001; i++)
        {
            if (count2[i] > prepre2 && i != prenum2)
            {
                prepre2 = count2[i];
            }
        }
        ans = min(N - prepre1 - pre2, N - prepre2 - pre1);
    }
    else
    {
        ans = N - pre1 - pre2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5632
a,b,c = map(int,input().split())
time = 0
biscuit = 0
kakeru = 1

if c < a:
    print(0)
else:
    while time < c+0.5:
        biscuit += b
        time += a
        if time > c+0.5:
            biscuit -= b
            break
    print(biscuit)

Measured memory_bytes: 3060
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String[] s = sc.next().split("");
  String[] n = {"a","b","c"};
  Arrays.sort(s);
  if(Arrays.equals(s,n)){
System.out.print("Yes");
  }else{
System.out.print("No");
  }
}
}

Measured memory_bytes: 21716
#include<stdio.h>
#define LEN 100010

int partition(int *A,int p,int r){
  int x = A[r];
  int i=p-1;
  int j,k;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      k=A[i];
      A[i]=A[j];
      A[j]=k;
    }
  }
  k=A[i+1];
  A[i+1]=A[r];
  A[r]=k;
  return i+1;
}

int main(){
  int A[LEN];
  int p,r;
  int i,j,n;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);

  p=0;
  r=n-1;
  j=partition(&A[0],p,r);

  printf("%d",A[0]);
  for(i=1;i<n;i++){
    if(i==j)printf(" [%d]",A[i]);
    else printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 992
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

vector<int> A;
vector<vector<int>> G;

int dfs(int par, int cur){
    if(G[cur].size() == 1 && G[cur][0] == par) return A[cur];
    bool isInf = false;
    for(int v: G[cur]){
        if(v == par) continue;
        
        if(dfs(cur, v) < A[cur]) isInf = true;
    }
    
    if(isInf) return inf;
    else return A[cur];
}

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    A.resize(N);
    G.resize(N);
    rep(i, N){
        cin >> A[i];
    }
    
    rep(i, N - 1){
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    vector<int> R;
    rep(i, N) {
//        cout << i << ": " << dfs(-1, i) <<  endl;
        if(dfs(-1, i) == inf) R.pb(i + 1);
    }
    
    voutput(R);
    
    return 0;
}

Measured memory_bytes: 640
n=int(input())
l=[[0,0,0]]
for _ in range(n):
    l.append(list(map(int,input().split())))

for i in range(1,n+1):
    k=abs(l[i][1]-l[i-1][1])+abs(l[i][2]-l[i-1][2])
    t=l[i][0]-l[i-1][0]
    if k>t or k%2!=t%2:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 85460
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	vector<ll> a(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	sort(rall(a));

	ll sum = a[0] / 2;
	for (ll i = 1; i < n; i++)
	{
		sum += a[i];
	}

	println(sum);
}


Measured memory_bytes: 256
R,G,B,N = gets.split.map(&:to_i)

ans = 0

0.upto(N/R) do |x|
  0.upto((N-R*x)/G) do |y|
    tmp = N-R*x-G*y
    if tmp%B == 0
      ans += 1
    end
  end
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
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; }
 
ll MOD = 1000000007;
ll INF =1<<30;
ll dp[110][100100];
 
int main(){
    int x;
    cin >> x;
    int cnt = 0;
    int t = 0;
    for(int i = 1;i<100100000;i++){
         cnt +=i;
      t++;
         if(cnt>=x) {
              cout << t <<endl;
              return 0;
         }
    }
}

Measured memory_bytes: 3612
# import sys
# sys.setrecursionlimit

getarr = lambda _f: list(map(_f, input().split()))

n, k, q = getarr(int)
r = [k - q for _ in range(n)]
for _ in range(q):
    p = int(input()) - 1
    r[p] += 1
print(*[('Yes' if s > 0 else 'No') for s in r], sep="\n")


Measured memory_bytes: 59168
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		// 計算
		long result = 0;
		result = max(a*b, c*d);

		
		// 出力
		System.out.println(result);
	}

	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


Measured memory_bytes: 21072
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
    int n,c;
    cin>>n>>c;
    vector<pair<int,int>>v(c);
    rep(i,c)v[i].second=(i+1);
    vector<tuple<int,int,int>>g(n);
    rep(i,n)cin>>get<0>(g[i])>>get<1>(g[i])>>get<2>(g[i]);
    sort(g.begin(),g.end());
    rep(i,n){
        int s=get<0>(g[i]);
        int t=get<1>(g[i]);
        int C=get<2>(g[i]);
        rep(j,c){
            if(v[j].first<s){
                v[j]={t,C};
                break;
            }
            else if(v[j].first==s&&v[j].second==C){
                v[j]={t,C};
                break;
            }
        }
    }
    int cnt=0;
    rep(i,c){
        if(v[i].first)++cnt;
    }
    cout<<cnt<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define N 100000
using namespace std;
int head,tail,an;
struct P{
  int t;
  int id; 
};
int main(){
  int n,q;
  P Q[N];
  string s[N];
  cin>>n>>q;
  for(int i=0;i<n;i++){
    cin>>s[i]>>Q[i].t;
    Q[i].id=i;
    tail++;
  }
  while(tail!=head){
    int a=Q[head%N].t;
    Q[head%N].t-=q;
    if(Q[head%N].t<=0)an+=min(a,q),cout<<s[Q[head%N].id]<<' '<<an<<endl;
    else Q[tail++%N]=Q[head%N],an+=q;
    head++;
  }
  return 0;
}

Measured memory_bytes: 5104
def main():
    n = int(input())
    a = list(map(int, input().split()))
    max_a = max(a)
    ideal_comb = []
    if max_a % 2 == 0:
        ideal_comb.append(max_a // 2)
    else:
        ideal_comb.append(max_a // 2)
        ideal_comb.append(max_a // 2 + 1)

    diff = [0] * n

    for i in ideal_comb:
        for j in range(n):
            if a[j] == max_a:
                diff[j] += 10 ** 10
            else:
                diff[j] += abs(a[j] - i)

    tmp = diff.index(min(diff))

    print(max_a, a[tmp])

    


if __name__ == "__main__":
    main()

Measured memory_bytes: 62704
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep_r(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define INF 2e9
 
using namespace std;
 
typedef long long ll;

int main(){
	int n;
	cin >> n;
	
	vector<int> v(8);
	int v_9 = 0;
	
	rep(i ,n){
		int a;
		cin >> a;
		if(3200 <= a)
			v_9++;
		else{
			rep(i,8){
				if(400*i <= a && a < 400 + 400*i)
					v[i]++;
				
			}
		}			
	}
	
	sort(all(v) ,greater<int>());
	int ans1 = 0, ans2 = 0;
	
    for(int i = 0 ;v[i] != 0; i++){
		ans1++;
	}
	ans2 = ans1 + v_9;
	
	cout << max(ans1 ,1) << " " << ans2 << endl;
	
	return 0;
	
}
	
	
	

Measured memory_bytes: 256
H, W, K = gets.split.map(&:to_i)
as = []
start = nil
result = nil
H.times do |i|
    as[i] = gets.chomp.split('')
    next if start
    j = as[i].index('S')
    if j
        start = [i, j]
        result = [i, H-1-i, j, W-1-j].min
    end
end

updated = [start]
K.times do
    break if updated.length == 0
    nup = []
    updated.each do |i, j|
        [[i-1, j], [i+1, j], [i, j-1], [i, j+1]].each do |ii, jj|
            next if as[ii][jj] != '.'
            result = [result, ii, H-1-ii, jj, W-1-jj].min
            if result == 0
                puts 1
                exit
            end
            as[ii][jj] = 'x'
            nup.push([ii, jj])
        end
    end
    updated = nup
end

puts (result - 1)/K + 2

Measured memory_bytes: 52092
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int MAXN = 200005;

int n;
char str[MAXN];
int dp[MAXN][6];

string sub(int l, int r){
	string x;
	for(int i=l; i<l+r; i++) x.push_back(str[i]);
	return x;
}

int main(){
	scanf("%s", str);
	n = strlen(str);

	for(int i=1; i<=n; i++){
		for(int j=1; j<=5; j++){
			if(i == j){
				dp[i][j] = 1;
				continue;
			}
			dp[i][j] = -1e9;
			for(int k=1; k<=6; k++){
				if(i >= j && i >= j + k &&
					sub(i - j, j) != sub(i - j - k, k)){
					dp[i][j] = max(dp[i][j], dp[i-j][k] + 1);
				}
			}
		}
	}
	cout << *max_element(dp[n], dp[n] + 6) << endl;
}


Measured memory_bytes: 5120
N, K = map(int, input().split())
D = list(map(int, input().split()))

L=[]
for i in range(0, 10):
    if i not in D:
        L.append(str(i))    

L.sort()

i = N
while True:
    if set(list(str((i)))) <= set(L):
        print(i)
        break
    i += 1  

Measured memory_bytes: 3060
#include<stdio.h>

#define N 100

int main(){
  int i,j,n,num[N],tmp,count=0;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }

  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(num[j]<num[j-1]){
    tmp=num[j];
    num[j]=num[j-1];
    num[j-1]=tmp;
    count++;
      }
    }
  }
  for(i=0;i<n-1;i++){
    printf("%d ",num[i]);
  }
  printf("%d",num[n-1]);
  
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 600
r, c = map(int, input().split())
table = [list(map(int, input().split())) for _ in range(r)]
c_sum = [0]*c
for i in range(r):
    for j in range(c):
        c_sum[j] += table[i][j]
for i in table:
    print(*i, end=' ')
    print(sum(i))
print(*c_sum, end=' ')
print(sum(c_sum))


Measured memory_bytes: 6232