akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<cassert>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)
const double pi=acos(-1);

int lcs(const vector<pii> &pts){
  int n=pts.size();
  vi m(n+1);
  int maxl=0;
  rep(i,n){
    int p=0;
    int f=maxl+1;
    while(f-p>1){
      int x=(f+p)/2;
      if(pts[m[x]].second<pts[i].second){
	p=x;
      }else{
	f=x;
      }
    }
    m[p+1]=i;
    maxl=max(maxl,p+1);
  }
  return maxl;
}

double f(int goalx,int goaly,vector<pii> pts){
  if(0){
    cerr<<"goal:"<<goalx<<" "<<goaly<<endl;
    rep(i,pts.size()){
      cerr<<" "<<pts[i].first<<","<<pts[i].second;
    }
    cerr<<endl;
  }
  double base=(goalx+goaly)*100.0;
  sort(pts.begin(),pts.end());
  int lc=lcs(pts);
  double ans=1e30;
  int lim=min(goalx,goaly)+1;
  assert((int)pts.size()<=lim);
  ans=base+(5*pi-20)*lc;
  if(lc==lim){
    ans+=5*pi;
  }
  return ans;
}


int main(){
  pii x[2];
  rep(i,2){
    cin>>x[i].first>>x[i].second;
  }
  int n;
  cin>>n;
  vector<pii> a(n);
  rep(i,n){
    cin>>a[i].first>>a[i].second;
  }
  if(x[0].first>x[1].first){
    rep(i,2){
      x[i].first=-x[i].first;
    }
    rep(i,n){
      a[i].first=-a[i].first;
    }
  }
  if(x[0].second>x[1].second){
    rep(i,2){
      x[i].second=-x[i].second;
    }
    rep(i,n){
      a[i].second=-a[i].second;
    }
  }
  vector<pii> rec;
  rep(i,n){
    int ax=a[i].first-x[0].first;
    int ay=a[i].second-x[0].second;
    if(ax>=0&&ax<=x[1].first-x[0].first&&ay>=0&&ay<=x[1].second-x[0].second){
      rec.push_back(pii(ax,ay));
    }
  }
  printf("%.15f\n",f(x[1].first-x[0].first,x[1].second-x[0].second,rec));
}


Measured memory_bytes: 5744
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M; cin >> N >> M;
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    vector<int> indices(N);
    bitset<300> omit;
    vector<int> counter(M);
    int ans = 1e9;
    for (int i = 0; i < M; i++) {
        fill(begin(counter), end(counter), 0);
        for (int j = 0; j < N; j++) {
            while (omit.test(A[j][indices[j]])) indices[j]++;
            counter[A[j][indices[j]]]++;
        }
        int sport = max_element(begin(counter), end(counter)) - begin(counter);
        ans = min(ans, counter[sport]);
        omit.set(sport);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdbool.h>

int main() {

  int N=0,M=0,A=0,B=0;
  int H[100000]={0};
  bool great[100000]={false};
  int count=0;
  scanf("%d %d",&N,&M);
  for(int i=0;i<N;i++){
    great[i]=true;
  }
  for(int i=0;i<N;i++) scanf("%d",&H[i]);
  for(int i=0;i<M;i++){
    scanf("%d %d",&A,&B);
    if(H[A-1]<=H[B-1]){
      great[A-1]=false;
    }
    if(H[A-1]>=H[B-1]){
      great[B-1]=false;
    }
  }
  for(int i=0;i<N;i++){
    if(great[i]) {
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s;cin>>s;
  	int counts=0,countt=0;
  	for(int i=0;i<s.size();i++){
    	if(s.at(i)=='S'){
        	counts++;
        }else if(s.at(i)=='T' && countt<counts){
        	countt++;
        }
    }
    cout<<s.size()-countt*2<<endl;
}

Measured memory_bytes: 640
#from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    k = ii()
    s = input()
    if len(s) <= k:
        print(s)
    else:
        ans = s[:k]
        ans+='...'
        print(ans)








main()




Measured memory_bytes: 10020
#include<bits/stdc++.h>
#define in inline
#define re register
using namespace std;
in int read() {
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9') {
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
int n,m,rt[200002],head[200002],a[200002],ls[20000002],rs[20000002],ans[200002],u,v,cnt,tot,s[20000002],la,r[200002],val[20000002];
struct edge{
	int to,next;
}e[400002];
inline void bu(re int x,re int y){
	e[++tot].to=y;
	e[tot].next=head[x];
	head[x]=tot;
}
inline int insert(re int v,re int l,re int r,re int x,re int vv) {
	int y=++cnt;
	s[y]=s[x]+1;val[y]=max(val[x],vv);
	if(l==r){
	val[y]=max(val[y],vv);
	return y;}
	ls[y]=ls[x];
	rs[y]=rs[x];
	int mid=(l+r)>>1;
	if(v<=mid)ls[y]=insert(v,l,mid,ls[x],vv);
	else rs[y]=insert(v,mid+1,r,rs[x],vv);
	return y;
}
inline int find(re int p,re int l,re int r,re int x){
	if(!p)return 0;
	if(r<=x)return val[p];
	re int mid=l+r>>1;
	if(x>mid)return max(find(ls[p],l,mid,x),find(rs[p],mid+1,r,x));
	else return find(ls[p],l,mid,x);
}
inline void dfs(re int x,re int y){
	ans[x]=find(rt[y],1,1e9+1,a[x]);
	rt[x]=insert(a[x]+1,1,1e9+1,rt[y],ans[x]+1);
	ans[x]=max(ans[x],ans[y]);
	for(re int i=head[x];i;i=e[i].next)
		if(e[i].to!=y)dfs(e[i].to,x);
}
int main(){
	n=read();
	for(re int i=1;i<=n;++i)a[i]=read();
	for(re int i=1;i<n;++i){
		u=read();
		v=read();
		bu(u,v);
		bu(v,u);
	}
	dfs(1,1);
	for(re int i=1;i<=n;++i)printf("%d\n",ans[i]+1);
}


Measured memory_bytes: 134980
import java.util.*;
import java.util.stream.*;

public class Main {
    static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
        List<Integer> MN = numbers();
        List<Integer> mn = numbers();

        print((MN.get(0) - mn.get(0)) * (MN.get(1) - mn.get(1)));
    }

    public static List<Integer> numbers() {
        List<Integer> integers = new ArrayList<>();
        for(String item: getLine().split(" ")) {
            integers.add(toInt(item));
        }
        return integers;
    }

    public static void add(int[][] a, int[] n, int[] m) {
        for(int i = 0; i < n.length; i++) {

        }
    }

    public static int sum(int[][] a, int[] n, int[] m) {
        int sum = 0;
        for(int i=0; i<n.length; i++) {
            for(int j=0; j<m.length; j++) {
                if(n[i] == 1 && m[j] == 1) {
                    sum += a[i][j];
                }
            }
        }

        return sum;
    }

    public static int getInt() {
        return scan.nextInt();
    }

    public static String getLine() {
        return scan.nextLine();
    }

    public static int toInt(String str) {
        return Integer.parseInt(str);
    }

    public static long toLong(String str) {
        return Long.parseLong(str);
    }

    public static void print(String str) {
        System.out.println(str);
    }

    public static void print(int num) {
        print("" + num);
    }
}


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

int n,m;

struct kuzi{
	string s;
	int n;
	kuzi(string a,int b){s=a;n=b;}
};

void solve(){
	vector<kuzi> K;
	for(int i=0;i<n;i++){
		string s;
		int d;
		cin>>s>>d;
		K.push_back(kuzi(s,d));
	}
	vector<string> M;
	for(int i=0;i<m;i++){
		string s;
		cin>>s;
		M.push_back(s);
	}
	int res=0;

	for(int i=0;i<m;i++){
		for(int j=0;j<K.size();j++){
			string s1=M[i],s2=K[j].s;

			bool ok=true;
			for(int z=0;z<s1.size();z++){
				if(s2[z]=='*') continue;
				if(s1[z]!=s2[z]){ok=false;break;}
			}
			if(ok){res+=K[j].n; break;}
		}
	}
	cout<<res<<endl;
}




int main(){
	while(cin>>n>>m){
		if(n==0 && m==0) break;
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
a = [int(x) for x in input().split()]
count = 0
a.append(0)
if (N+1==len(a))and(2<=N):
    for i in range(1,N):
        if (a[i-1]==a[i]):
            a[i] += 1
            if a[i] > 10000:
                a[i] = 1
            if a[i]==a[i+1]:
                a[i] += 1
                if a[i] > 10000:
                    a[i] = 1
            count += 1
    print(count)

Measured memory_bytes: 3064
(defmacro defsolver (name vars &body body)
  `(defun ,name ()
     (let (,@(mapcar #'list
            vars
            (mapcar (constantly '(read))
                vars)))
       ,@body)))

(defsolver solution-b2 (n)
  (let ((l (list)))
    (dotimes (i n l)
      (push (list (read) (read) (+ i 1)) l))
    (setf l (sort l #'(lambda (x y)
			(or
			 (and
			  (string= (nth 0 x) (nth 0 y))
			  (> (nth 1 x) (nth 1 y)))
			 (string< (nth 0 x) (nth 0 y))))))
    (loop for x in l do (format t "~a~%" (nth 2 x)))))

(solution-b2)

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

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;

    int rail[N+2][N+2] = {};
    int li, ri;
    rep(i, M) {
        cin >> li >> ri;
        rail[li][ri]++;
    }

    int acc[N+2][N+2] = {};
    for (int i=1; i<=N; i++) for (int j=1; j<=N; j++) {
        acc[i][j] = acc[i][j-1] + acc[i-1][j] - acc[i-1][j-1] + rail[i][j];
    } 

    int S[Q], E[Q];
    rep(i, Q) cin >> S[i] >> E[i];

    rep(i, Q) {
        int s = S[i], e = E[i];
        cout << acc[e][e] - acc[s-1][e] - acc[e][s-1] + acc[s-1][s-1] << endl;
    }

    return 0;
}



Measured memory_bytes: 3712
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
int n,l[105];
int ok(int a,int b,int c){
	if(a==b||b==c||a==c) return 0;
	int s=a+b+c;
	return s-max(max(a,b),c)>max(max(a,b),c);
}
main(){
	while(~getI(n)){
		F(i,0,n) getI(l[i]);
		int ans=0;
		F(i,0,n) F(j,i+1,n) F(k,j+1,n)ans+=ok(l[i],l[j],l[k]);
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 3836
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 555;
string s;
int dp[MAXN][MAXN];

// [l, r)
bool dfs(int l, int r) {
	int& ret = dp[l][r];
	if (ret >= 0) return ret;
	if (r-l == 0) return ret = 1;
	if (s[l] != 'm' || s[r-1] != 'w') return ret = 0;
	ret = 0;
	for (int m = l+1; m < r-1; m++) {
		if (s[m] == 'e') {
			if (dfs(l+1, m) && dfs(m+1, r-1)) {
				return ret = 1;
			}
		}
	}
	return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    memset(dp, -1, sizeof(dp));
    if (dfs(0, s.size())) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;
    return 0;
}

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

#define pb push_back

const int N = 3e3+5;

string s , t;
char a[N] , b[N];
int dp[N][N];
vector<char> vec;

int LCS(int n , int m){
  if(dp[n][m] != -2) return dp[n][m];
  if(!n || !m) return dp[n][m] = 0;
  if(a[n] == b[m]) return dp[n][m] = max(dp[n][m],1+LCS(n-1,m-1));
  return dp[n][m] = max(dp[n][m],max(LCS(n-1,m),LCS(n,m-1)));
}

void rec(int n , int m){
  if(!n || !m) return;
  if(a[n] == b[m]) vec.pb(a[n]) , rec(n-1,m-1);
  else if(dp[n][m] == dp[n-1][m]) rec(n-1,m);
  else if(dp[n][m] == dp[n][m-1]) rec(n,m-1);
}

int main(){

  ios_base::sync_with_stdio(),cin.tie(0);

  cin >> s >> t;
  for(int i = 0 ; i < N ; i++)
    for(int j = 0 ; j < N ; j++) dp[i][j] = -2;
  for(int i = 0 ; i < s.size() ; i++) a[i+1] = s[i];
  for(int i = 0 ; i < t.size() ; i++) b[i+1] = t[i];
  
  LCS(s.size(),t.size()) , rec(s.size(),t.size());

  for(int i = vec.size()-1 ; i >= 0 ; i--) cout << vec[i];
  cout << "\n";

}


Measured memory_bytes: 39192
// abc157_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> rank;
    vector<int> size; // size[i]: iが親なら連結成分の数

    UnionFind(int N) : par(N), rank(N), size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {par[i] = i; rank[i] = 0; size[i] = 1;}
    }

    int find(int x) { // データxが属する木の根を再帰で得る：find(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = find(x); //xの根をrx
        int ry = find(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま

        // rank[rx] >= rank[ry] となるように rx と ry を swap
        if(rank[rx] < rank[ry]) swap(rx, ry);

        // 同じ高さだったならばまとめたことによって高さ +1
        if(rank[rx] == rank[ry]) ++rank[rx];

        par[ry] = rx; // root rx に ry の木をつなぐ
        size[rx] += size[ry];
        size[ry] = 0;

    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }

    int get_size(int x){
        int rx = find(x);
        return size[rx];
    }
};

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, M, K;
    cin >> N >> M >> K;

    vector<vector<int>> nglist(N);
    UnionFind uf(N);

    REP(i, M){
        int a, b;
        cin >> a >> b;
        a--; b--;
        nglist[a].emplace_back(b);
        nglist[b].emplace_back(a);
        uf.unite(a, b);
    }

    REP(i, K){
        int a, b;
        cin >> a >> b;
        a--; b--;
        nglist[a].emplace_back(b);
        nglist[b].emplace_back(a);
    }

    vector<set<int>> uflist(N);
    REP(i, N){
        int idx = uf.find(i);
        uflist[idx].insert(i);
    }

    vector<int> ans(N);
    REP(i, N){
        int idx = uf.find(i);
        int n = uf.get_size(i);

        ans[i] = n-1;
        for (auto v: nglist[i]){
            if (uflist[idx].find(v) != uflist[idx].end()){
                ans[i]--;
            }
        }
    }

    print_line(ans, N);

    return 0;
}


Measured memory_bytes: 18432
#memo roiti 886942
while 1:
    try:
        xa,ya,xb,yb,xc,yc,xd,yd=map(float,raw_input().split())
        print 'NO' if (xd<xa or xb<xc or yd<ya or yb<yc) else 'YES'
    except:
        break

Measured memory_bytes: 6284
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>

using namespace std;

int main(void) {
  int K, X;
  cin >> K >> X;
  for (int i = -1 * (K - 1); i <= K - 1; i++) {
    cout << X + i << " ";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string n;int A,k;
int g(int a,int b){A=6;while(b--)A*=(a-b)*9,A/=b+1;return A/6;}
int f(int i,int a){int A=n.size()-i;return (A<a?0:!a?1:n[i]=='0'?f(i+1,a):f(i+1,a-1)+(n[i]-'1')*g(A-1,a-1)+g(A-1,a));}
main(){cin>>n>>k;cout<<f(0,k);}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	long long n;
	cin >> n;
	vector<long long>v(n);
	for (long long i = 0;i < n;i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	long long sum=0;
	for (long long i = 0;i < n;i++) {
		sum = sum + v[i];
	}
	cout << v[0] << " " << v[n-1] << " " << sum << endl;
}

Measured memory_bytes: 3216
// https://atcoder.jp/contests/abc135/tasks/abc135_d

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int S_MAX = 1e5;
const int MOD = 1e9+7;

char S[S_MAX + 1];

int N;
int dp[S_MAX + 1][13];

void solve() {
  N = strlen(S);
  dp[0][0] = 1;
  REP(i, N) REP(j, 13) {
    int ks, kt;
    if (S[i] == '?') {
      ks = 0; kt = 9;
    } else {
      ks = kt = S[i] - '0';
    }
    FOR(k, ks, kt) {
      int j2 = (j * 10 + k) % 13;
      dp[i + 1][j2] = (dp[i + 1][j2] + dp[i][j]) % MOD;
    }
  }
  // DUMP2D(dp, N + 1, 13);
  printf("%d\n", dp[N][5]);
}

void input() {
  scanf("%s", S);
}

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


Measured memory_bytes: 5376
/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<int>
#define pint        	pair<int, int>
#define umint        	unordered_map<int, int>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define fj(x)			for(int j=0; j<x; j++)
#define fn(n, x)		for(int i=n; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// #include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

vector<vint> dp;
unordered_map<int, vint> dict;

pint dfs(int node, int parent){

	int white=1, black = 1;
	for(auto i:dict[node]){
		if(i==parent)
			continue;
		
		pint p = dfs(i, node);
		black*=p.first;
		white*=(p.first+p.second);

		black%=mod; white%=mod;
	}
	return make_pair(white, black);
}

int32_t main() {

    om_shree_ganeshaya_namah();

    in(n);
    dp = vector<vint>(n+1, vint(2));
    f(n-1){
    	in(u); in(v);
    	dict[u].push_back(v);
    	dict[v].push_back(u);
    }

	pint p = dfs(1, 0);
	int ans = (p.first+p.second)%mod;
	cout<<ans;    

}

Measured memory_bytes: 24444
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

int main() {
    cin>>S;
    cout<<(S == "AAA" || S == "BBB" ? "No" : "Yes")<<endl;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
s = input()
ar = [[0 for i in range(3)] for j in range(1000)]
kakunin = [0 for i in range(1000)]
index = 0
res = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            a = s.find(str(i))

            if a == -1:
                continue

            b = s[a+1:len(s)].find(str(j))
            if b == -1:
                continue
            c = s[a+b+2:len(s)].find(str(k))
            if c != -1:
                # print(str(a) + "  "+ str(b) + "  " + str(c))
                # print(str(i) + "  " + str(j) + "   "+ str(k))
                # print()
                res += 1
print(res)


Measured memory_bytes: 21000
// https://misteer.hatenablog.com/entry/AGC001-B
#include <iostream>
using namespace std;
using ll = long long;

long long reflect(ll A, ll B) {
    if(A > B) {
        swap(A, B);
    }
    long long ref = B / A;
    if(B % A == 0) {
        return (ref * 2 - 1) * A;
    } else {
        return ref * 2 * A + reflect(B % A, A);
    }
}

int main() {
    long long N, X;
    cin >> N >> X;
    cout << N + reflect(X, N - X) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll>mp;
ll n,m,a,b,c,ra[100000],fa[100000],ans;
ll find(ll x){
    if(x==fa[x])return x;
    else return fa[x]=find(fa[x]);
}
void uni(ll x,ll y){
    x=find(x),y=find(y);
    if(x==y)return ;
    if(ra[x]<ra[y])swap(x,y);
    fa[y]=fa[x];
    if(ra[x]==ra[y]){
        ra[x]++;
    }
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++)fa[i]=i;
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        a--,b--;
        uni(a,b);
    }
    for(int i=0;i<n;i++){
        mp[find(fa[i])]=1;
    }
    for(auto x:mp)ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/******************************head*******************************/
const int maxn=505;
char s[maxn][maxn];
char s1[maxn][maxn],s2[maxn][maxn];
int n,m;
int main(){
	read(n);read(m);
	rep(i,1,n)scanf("%s",s[i]+1);
	rep(i,1,n)rep(j,1,m)
		s1[i][j]=s2[i][j]=s[i][j];
	rep(i,1,n){
		if(i&1)
			rep(j,1,m-1)
				s1[i][j]='#';
		else
			rep(j,2,m)s2[i][j]='#';
		s1[i][1]='#';
		s2[i][m]='#';
	}
	rep(i,1,n)puts(s1[i]+1);puts("");
	rep(i,1,n)puts(s2[i]+1);
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
const int inf = 0x3f3f3f3f;
const int maxn = 2009;
struct node
{
    int pre, to;
} edge[maxn << 1];
int head[maxn], tot;
int n, x, y;
int cnt[maxn], dis[maxn];
bool done[maxn];
priority_queue<pii> pq;
void add(int u, int v)
{
    edge[++tot] = node{head[u], v};
    head[u] = tot;
    edge[++tot] = node{head[v], u};
    head[v] = tot;
}
void dijkstra(int s)
{
    memset(done, 0, sizeof(done));
    memset(dis, 0x3f, sizeof(dis));
    dis[s] = 0;
    pq.push(make_pair(0, s));
    while (!pq.empty())
    {
        int u = pq.top().second;
        pq.pop();
        if (done[u])
            continue;
        done[u] = true;
        for (int i = head[u]; i; i = edge[i].pre)
        {
            int v = edge[i].to;
            if (dis[v] > dis[u] + 1)
            {
                dis[v] = dis[u] + 1;
                pq.push(make_pair(-dis[v], v));
            }
        }
    }
    for (int i = 1; i <= n; ++i)
        if (i != s && dis[i] < inf)
            cnt[dis[i]]++;
}

int main()
{
    scanf("%d%d%d", &n, &x, &y);
    for (int i = 1; i < n; ++i)
        add(i, i + 1);
    add(x, y);
    for (int i = 1; i <= n; ++i)
        dijkstra(i);
    for (int i = 1; i < n; ++i)
        printf("%d\n", cnt[i] / 2);
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

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

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

	bool same=true;
	vector<bool> v(26,false);
	for (int i = 0; i < s.size(); i++){
		v[s[i]-'a']=true;
		if(i>0&&s[i-1]!=s[i])same=false;
	}

	if(same){
		cout<<0<<endl;
		return 0;
	}


	int ans=1000000;
	for (char i = 'a'; i <= 'z'; i++){
		if(v[i-'a']==false)continue;
		string t=s;
		int si=s.size();
		int mm=0;
		while(1){
			bool con=false;
			for (int j = 0; j < si-1; j++){
				if(t[j]==i||t[j+1]==i){
					t[j]=i;
				}else{
					con=true;
				}
			}
			si--;
			mm++;
			if(!con)break;
		}
		chmin(ans,mm);
	}

	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
import sys
k = int(input())

a = [0]*k
a[0] = 7 % k

for i in range(1, k):
    a[i] = (10*a[i-1]+7) % k

for i in range(k):
    if a[i] == 0:
        print(i+1)
        sys.exit()
print(-1)

Measured memory_bytes: 48424
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,m,t;
	cin>>n>>m>>t;
	vi in(n);
	rep(i,n)cin>>in[i];
	int out=in[0]-m;
	rep(i,n-1)out+=max(0,in[i+1]-in[i]-2*m);
	cout<<out+max(t-(in[n-1]+m),0)<<endl;
}

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

int n;
vector<lint> a;

int main() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    // dp[i][j]:[0,i),[j,n)を掘った段階からの"X-Y"
    vector<vector<lint>> dp(n + 1, vector<lint>(n + 1, 0));
    // i:掘る合計
    for (int i = n - 1; i >= 0; i--) {
        // j:左から掘る個数
        for (int j = 0; j <= i; j++) {
            dp[j][n - i + j] =
                max(a[j] - dp[j + 1][n - i + j], a[n - i + j - 1] - dp[j][n - i + j - 1]);
        }
    }
    cout << dp[0][n] << endl;
}

Measured memory_bytes: 70784
N = int(input())
A = [int(x) for x in input().split()]
sq = 0
even = 0
odd = 0
for a in A:
  if a % 4 == 0:
    sq += 1
  elif a % 2 == 0:
    even += 1
  else:
    odd += 1
if even:
  print('Yes' if sq >= odd else 'No')
else:
  print('Yes' if sq >= odd - 1 else 'No')

Measured memory_bytes: 14252
A, B, C, D, E, F = map(int, input().split())

water = []
for a in range(31):
    for b in range(31):
        if 100 * a * A + 100* b * B <= F:
            water.append(100 * a * A + 100 * b * B)
water = list(set(water))
water.remove(0)

sugar = []

for c in range(3001):
    for d in range(3001):
        if c * C + d * D <= F:
            sugar.append(c * C + d * D)
sugar = list(set(sugar))
sugar.remove(0)

memo = []
for w in water:
    for s in sugar:
        if w + s <= F and s/(w+s) <= E/(100+E):
            memo.append([s/(s+w),w+s, s])
memo.sort(reverse=True)
if len(memo) == 0:
    print(100 * A, 0)
else:
    print(memo[0][1], memo[0][2])

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++){
  	cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout << vec.at(n-1) - vec.at(0) << endl;
  
}



Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long long n, k;
int a[200001];
int f[200001];

int main( int argc, char *argv[] )
{
    int c = 1;
    int l = -1;

    scanf( "%lld %lld", &n, &k );
    for( int i=1; i<=n; i++ )
        scanf( "%d", &a[i] );

    for( int i=1; i<=n; i++ ) {
        f[c] = i;
//printf( "%d\n", c );
        c = a[c];
        if( f[c] > 0 ) {
            l = i + 1;
            break;
        }
    }

//printf( "c = %d\n", c );
//printf( "l = %d\n", l );
//for( int i=1; i<=n; i++ )
//printf( "a[%d] = %d     f[%d] = %d\n", i, a[i], i, f[i] );

    int lim = l - f[c];
//    printf( "cycle = %d\n", lim );

    if( k < l ) {
        c = 1;
        for( int i=0; i<k; i++ ) c = a[c];
        printf( "%d\n", c );
        exit( 0 );
    }

    k -= l - 1;

    for( int i=0; i<(k%lim); i++ ) c = a[c];

    printf( "%d\n", c );
}


Measured memory_bytes: 3296
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
map<vector<int>,long long>mp;
int n;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		vector<int>v(26);
		for(int j=0;j<10;j++)
		{
			v[s[j]-'a']++;
		}
		mp[v]++;
	}
	long long ans=0;
	for(map<vector<int>,long long>::iterator it=mp.begin();it!=mp.end();it++)
	{
		if((it->second)==1)
		{
			continue;
		}
		ans+=(it->second)*(it->second-1)/2;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

vi g[2000];
vi dep(2000);

void dfs(int v, int p = -1)
{
  for(int e : g[v]){
    if(e == p) continue;
    dep[e] = dep[v] + 1;
    dfs(e, v);
  }
}

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

  rep(i, n-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  int ans = n;
  if(k%2 == 0){
    rep(i, n){
      dep[i] = 0;
      dfs(i);

      int cnt = 0;
      rep(j, n) if(k/2 < dep[j]) cnt++;
      ans = min(ans, cnt);
    }
  }else{
    rep(i, n) for(int e : g[i]) if(i < e){
      dep[i] = dep[e] = 0;
      dfs(i, e);
      dfs(e, i);
  
      int cnt = 0;
      rep(j, n) if((k-1)/2 < dep[j]) cnt++;
      ans = min(ans, cnt);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdlib>
using namespace std;
typedef long long ll;
ll n;
int main()
{
    ll n,m;
    cin>>n>>m;
    if(m<n)
        puts("No");
    else
    {
        puts("Yes");
    }
    
    //system("pause");
    return 0;
}

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

H_t = input().split()
H = [int(s) for s in H_t]
#print(H)

ma = [0]*N

good_count = 0

#print(H_M)

for j in range(M):
    a, b = map(int, input().split())
    
    ma[a-1] = max(ma[a-1], H[b-1]) # つながった展望台の中で一番高い展望台を保持する
    ma[b-1] = max(ma[b-1], H[a-1]) 
    
    
for i in range(N):
    if H[i] > ma[i]:
        good_count +=1
print(good_count)
    

Measured memory_bytes: 20756
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
class E { static void Main() { new J(); } }
class J
{
	int F() { return int.Parse(Console.ReadLine()); }
	int[] G() { return Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray(); }
	public J()
	{
		Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
		for (var x = 1; x < 10; x++)
			for (var y = 1; y < 10; y++)
				Console.WriteLine("{0}x{1}={2}", x, y, x * y);
		Console.Out.Flush();
	}
}

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

int main() {
	int n;
	cin >> n;
	vector<int> L(n);
	for (int i = 0; i < n; i++)cin >> L[i];
	sort(L.begin(), L.end());
	int minsum = 0;
	for (int i = 0; i < n - 1; i++)minsum += L[i];
	if (minsum > L[n-1])cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
    //static List<string> str = new List<string>();
	static void Main(string[] args)
	{
		// 入力フェーズ
		//int N = Int32.Parse(Console.ReadLine()); // 夏休みの日数
		string[] input = Console.ReadLine().Split(' '); // N,W
		int N = Int32.Parse(input[0]);
		int W = Int32.Parse(input[1]);
		int[] weight = new int[N];
		int[] value = new int[N]; // 重さと価値の入力値
		for(int i=0; i<N; i++){
			string[] items = Console.ReadLine().Split(' ');
			weight[i] = Int32.Parse(items[0]);
			value[i] = Int32.Parse(items[1]);
		}
//Console.WriteLine(height.Count + "");

//i番目までの品物のうち、重さの総和がW以下になるように選んだ時の価値の総和の最大値
		long[,] dp = new long[N+1,W+1];

// 初期値設定
		//dp[0,0] = 0;
		for(int i=0; i<=N; i++)
		{
			dp[i, 0] = 0;
		}

		for(int i=1; i<=N; i++)
		{
			// i番目までの品物から選ぶ
			for(int j=0; j<=W; j++)
			{
				// 重さの総和がj以下になるように選ぶ
				if(j>=weight[i - 1])
				{
					// i番目の品物の重さがj以下なら、i番目の品物を選んだ時と選ばなかった時の大きい方を採用する
					dp[i,j] = Math.Max(
											dp[i-1, j] // 選ばなかったとき
											, dp[i-1, j - weight[i-1]] + value[i-1] // 選んだ時
					);
				}
				else
				{
					// i番目は選べないのでそのまま
					dp[i,j] = dp[i-1, j];
				}

				//Console.WriteLine(i + ", " + j + "：" + dp[i, j]);
			}

		}

		//long maxHappy = Math.Max(dp[N,0], Math.Max(dp[N,1], dp[N,2]));
		Console.WriteLine(dp[N, W] + "");

    }

}


Measured memory_bytes: 89056
#!/usr/bin/env python3

# input
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for _ in range(m):
    a, b = map(int, input().split())
    p.append(a)
    x.append(b)

# calc
sumt = sum(t)
for i in range(m):
    print(sumt-t[p[i]-1]+x[i])


Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    char a,b;
    scanf("%c %c",&a,&b);
    if (a == 'H' || a == 'D' && b == 'H' || b == 'D'  )
    {


        if (a=='H' && b=='H')
        {
            printf("H\n");
        }
        else if (a=='D' && b=='H')
        {
            printf("D\n");
        }
        else if (a=='D' && b=='D')
        {
            printf("H\n");
        }
        else
            printf("D\n");
    }
    else
        return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans = 0;
    if(n < a+b) ans = min(n,a);
    else {
        ans = a* (n/(a+b));
        if(n%(a+b) != 0) ans += min(n%(a+b),a);
    }


    cout<<ans<<endl;
}

Measured memory_bytes: 256
// Author: drunken_legend
 
#include <bits/stdc++.h>
using namespace std;
#define lli long long int

int main()
{
    int n,k;
    cin >>n>>k;
    std::vector<int> v(n);
    for (int i = 0; i < n; ++i)
    {
    	/* code */cin>>v[i];
    }
    std::vector<int> dp(n,INT_MAX);
    dp[0]=0;
    dp[1]=abs(v[1]-v[0]);
    for(int i=2;i<n;i++){
    	for(int j=i-1,jump=0;j>=0 && jump<k;j--,jump++){
    		dp[i]=min(dp[i],dp[j]+abs(v[i]-v[j]));
    	}
    }
    cout<<dp[n-1];

    return 0;
}
 

Measured memory_bytes: 4024
// https://atcoder.jp/contests/abc109/tasks/abc109_a
#include <bits/stdc++.h>
using namespace std;
using P = pair<double, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    if ((a * b) % 2 == 0) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }

    return 0;
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    int N = 0 ;
    cin >> N;
    int t[N+1],x[N+1],y[N+1];
    //initialize
    t[0]= 0;
    x[0]= 0;
    y[0]= 0;
    
    for(int i=0;i<N;i++){
        cin >> t[i+1]>>x[i+1]>>y[i+1];
    }
    
    bool flg = false;
    
    for(int i= 0;i<N;i++){
        int dt  = t[i+1]-t[i];
        int dist0 =x[i+1]+y[i+1];
        int dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
        if(t[i+1]%2 != dist0%2) {
            flg = false;
            break;
        }
        else if( dt < dist ) {
            flg =false;
            break;
        }
        else{
            flg = true;
        }
    }
    
    if(flg)
        cout << "Yes"<<endl;
    else
        cout << "No"<<endl;
    
}


Measured memory_bytes: 1408
n = gets.to_i
s = Array.new
hash = Hash.new
max = 0
n.times{|i|
  s = gets.chomp
  if !hash.include?(s)
    hash[s] = 1
  else
    hash[s] = hash[s] + 1
  end
  if hash[s] > max
    max = hash[s]
  end
}

ans = Array.new
hash.each{ |key, value|
  if value == max
    ans.push(key)
  end
 }

ans = ans.sort
ans.each{|str|
  puts str
}

Measured memory_bytes: 33896
L=["A","B","C","D","E"]
while True:
    dic={}
    for c in L:
        s1,s2=map(int,raw_input().split())
        if s1==s2==0:break
        dic[s1+s2]=c
    if s1==s2==0:break
    m=max(dic)
    print dic[m],m

Measured memory_bytes: 4228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

bool check(string s) {
  for (int i = 0; i < int(s.size()); i++) {
    if (s[i] != s[0]) return false;
  }
  return true;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  const string col = "rgb";
  string s;
  while (cin >> s, s != "0") {
    int n = s.size();
    map<string, int> dis;
    queue<string> que;
    dis[s] = 0;
    que.emplace(s);
    int ans = -1;
    while (!que.empty()) {
      s = que.front(); que.pop();
      if (check(s)) {
        ans = dis[s];
        break;
      }
      for (int i = 0; i + 1 < n; i++) {
        if (s[i] == s[i + 1]) continue;
        for (int j = 0; j < 3; j++) {
          if (s[i] != col[j] && s[i + 1] != col[j]) {
            string ns = s;
            ns[i] = ns[i + 1] = col[j];
            if (dis.find(ns) != dis.end()) continue;
            dis[ns] = dis[s] + 1;
            que.emplace(ns);
          }
        }
      }
    }
    if (ans < 0) cout << "NA" << endl;
    else cout << ans << endl;
  }

  return 0;
}


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

int main() {
  int N,ans=0;
  cin >> N;
  vector<int> L(N);
  rep(i,N) cin >> L[i];
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      for(int k=j+1;k<N;k++){
        vector<int> vec(3);
        vec[0]=L[i];
        vec[1]=L[j];
        vec[2]=L[k];
        if(vec[0]!=vec[1] && vec[1]!=vec[2] && vec[2]!=vec[0]) {
          sort(vec.begin(),vec.end());
          if(vec[0]+vec[1]>vec[2]) {
            //cout << i << j << k << endl;
            ans++;
          }
        }
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
/*
..#..
.#.#. 
#.#.#
 */
int a,b;
//白がa,黒がb
cin>>a>>b;
a--;b--;
vector<vector<char>> s(100,vector<char>(100,'#'));
for(int i=50;i<100;i++)for(int j=0;j<100;j++)s[i][j]='.';
for(int i=0;i<49;i+=2){
    if(a==0)break;
    for(int j=0;j<100;j++){
        if(j%2==0){
            s[i][j]='.';
            a--;
        }
        if(a==0)break;
    }
}
for(int i=51;i<100;i+=2){
    if(b==0)break;
    for(int j=0;j<100;j++){
        if(j%2==0){
            s[i][j]='#';
            b--;
        }
        if(b==0)break;
    }
}
cout<<100<<" "<<100<<endl;
 for(int i=0;i<100;i++){
  for(int j=0;j<100;j++)cout<<s[i][j];
  cout<<endl;
 }
}


Measured memory_bytes: 256
<?php 
$n = fgets(STDIN);
$a = fgets(STDIN);

$arr = explode(" ", $a);
rsort($arr);

$alice = 0;
for ($i=0; $i < $n; $i=$i+2) {
  $alice = $alice + $arr[$i];
}
$bob = 0;
for ($i=1; $i < $n; $i=$i+2) {
  $bob = $bob + $arr[$i];
}
echo $alice-$bob;
?>


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

int cho[10][1000];
int cnt[10];
int cnt1[10];
int g[10];

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  string s;
  rep(i, h) {
    cin >> s;
    rep(j, w) cho[i][j] = s[j] - '0';
  }
  int n = pow(2, h-1);
  int ans = 1001001001;
  bool con1, con;
  rep(i, n) {
    int temp = i, gnum = 0;
    rep(j, h) {
      g[j] = gnum; if (temp % 2 == 1) gnum++;
      temp /= 2;
    }
    int atemp = gnum; gnum++;
    rep(m, gnum) cnt[m] = 0;
    rep(j, w) {
      con1 = false; con = false;
      rep(m, gnum) cnt1[m] = 0;
      rep(m, h) {
        cnt1[g[m]] += cho[m][j];
        if (cnt1[g[m]] > k) {con1 = true; break;}
      }
      if (con1) break;
      rep(m, gnum) {
        cnt[m] += cnt1[m];
        if (cnt[m] > k) {con = true; break;}
      }
      if (con) {
        rep(m, gnum) cnt[m] = 0;
        j--; atemp++;
      }
    }
    if (con1) continue;
    ans = min(atemp, ans);
  }
  if (ans == 1001001001) cout << 0 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import java.io.IOException;
import java.util.Scanner;

class Main {

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

		Scanner scane = new Scanner(System.in);

		boolean judge =true;

		while (judge) {
			int a = scane.nextInt();
			String str = scane.next();
			int b = scane.nextInt();
		switch (str) {
		case "+":
			System.out.println(a+b);
			break;
		case "-":
			System.out.println(a-b);
			break;
		case "*":
			System.out.println(a*b);
			break;
		case "/":
			System.out.println((int)(a/b));
			break;
		case "?":
			judge = false;
			break;

		}
		}


	}
}

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

int n;
int A[ 100 ];

int main()
{
	cin >> n;
	FOR( i, 0, n )
	{
		cin >> A[ i ];
	}
	
	FOR( i, 0, n )
	{
		FOR( j, i, n )
		{
			int t1 = A[ i ];
			int t2 = A[ j ];
			A[ j ] = t1;
			A[ i ] = t2;
			bool ok = true;
			FOR( k, 1, n )
			{
				if ( A[ k ] != k + 1 )
					ok = false;
			}
			A[ i ] = t1;
			A[ j ] = t2;
			if ( ok )
			{
				//cout << i << ' ' << j << "\n";
				cout << "YES\n";return 0;
			}
		}
	}
	
	cout << "NO\n";
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int m[100][100];

int main() {
	int n;
	int i;
	for(i=1;n=in();i++){
		cout<<"Case "<<i<<":"<<endl;
		int x=0,y=0,num=1;
		while(x!=n&&y!=n){
//cout<<x<<" "<<y<<endl;
			m[x][y]=num++;
			if(x==0){
				if(y==0)x++;
				else if(y%2==0){x++;y--;}
				else y++;
			}else if(y==0){
				if(x%2==0) x++;
				else{x--;y++;}
			}else{
				if((x+y)%2==0){x++;y--;}
				else{x--;y++;}
			}
		}
		num=n*n;
		x=y=0;
		while(x!=n&&y!=n){
			m[n-x-1][n-y-1]=num--;
			if(x==0){
				if(y==0)x++;
				else if(y%2==0){x++;y--;}
				else y++;
			}else if(y==0){
				if(x%2==0) x++;
				else{x--;y++;}
			}else{
				if((x+y)%2==0){x++;y--;}
				else{x--;y++;}
			}
		}
		for(y=0;y<n;y++){
			for(x=0;x<n;x++){
				printf("%3d",m[x][y]);
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
// #pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  long double a, b;
  cin >> a >> b;
  cout << (long long)floor(a * b) << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 3736