akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 105
int dp[MAXN][MAXN][MAXN],N,M,SumR[MAXN][MAXN],SumC[MAXN][MAXN],sx,sy,ans;
char s[MAXN];
int main()
{
	memset(dp,-1,sizeof dp);
	scanf("%d%d",&N,&M);
	for(int i=1;i<=N;i++)
	{
		scanf("%s",s+1);
		for(int j=1;j<=M;j++)
		{
			SumR[i][j]=SumR[i][j-1];
			SumC[i][j]=SumC[i-1][j];
			if(s[j]=='E')
				sx=i,sy=j;
			else if(s[j]=='o')
				SumR[i][j]++,SumC[i][j]++;
		}
	}
	dp[0][0][0]=0;
	int L=sy-1,R=M-sy,U=sx-1,D=N-sx;
	for(int l=0;l<=L;l++)
		for(int r=0;r<=R;r++)
			for(int u=0;u<=U;u++)
				for(int d=0;d<=D;d++)
				{
					if(dp[r][u][d]==-1) continue;
					ans=max(ans,dp[r][u][d]);
					int up=max(d,sx-u-1);
					int down=min(N-u,sx+d);
					int le=max(r,sy-l-1);
					int ri=min(M-l,sy+r);
					if(up>=down||le>=ri) continue;
					if(u<U-d)
						dp[r][u+1][d]=max(dp[r][u+1][d],dp[r][u][d]+SumR[sx-u-1][ri]-SumR[sx-u-1][le]);
					if(d<D-u)
						dp[r][u][d+1]=max(dp[r][u][d+1],dp[r][u][d]+SumR[sx+d+1][ri]-SumR[sx+d+1][le]);
					if(r<R-l)
						dp[r+1][u][d]=max(dp[r+1][u][d],dp[r][u][d]+SumC[down][sy+r+1]-SumC[up][sy+r+1]);
					if(l<L-r)
						dp[r][u][d]=max(dp[r][u][d],dp[r][u][d]+SumC[down][sy-l-1]-SumC[up][sy-l-1]);
				}
	printf("%d\n",ans);
}

Measured memory_bytes: 4864
#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>;
//pow(x,n)
//cout << fixed << setprecision(桁数);

int main() {
    int n;
    cin >> n;
    vector<vector<int>> ame(2,vector<int>(n));
    rep(i,2){
        rep(j,n){
            cin >> ame.at(i).at(j);
        }
    }
    int maxame=0;
    rep(i,n){
        int sum=0;
        rep(j,i+1){
            sum+=ame.at(0).at(j);
        }
        for(int j=i;j<n;++j){
            sum+=ame.at(1).at(j);
        }
        maxame=max(sum,maxame);
    }
    cout << maxame << endl;
}


Measured memory_bytes: 256
S = input()
N = len(S)
a = [0] * (N+1)
index = 0
while index < N:
  tmp = S[index]
  count = 1
  if index < N-1:
    while S[index+count] == tmp:
      count += 1
      if index+count == N:
        break
  if tmp == '<':
    for j in range(count+1):
      a[index+j] = max(a[index+j],j)
  else:
    for j in range(count+1):
      a[index+count-j] = max(a[index+count-j],j)
  index += count
print(sum(a))

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

typedef long long ll;

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

const ll INF = 1LL << 60;

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

    int n; cin >> n;
    vector<int> h(n);
    ll dp[100050]; 
    for(int i=0;i<n;i++){
        cin >> h[i];
        dp[i] = INF;  
    }
    dp[0] = 0;
    for(int i=1;i<n;i++){
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>=2) chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    } 
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;

int als=0;
int w,h,n;
const int Q=1<<19;
struct dt{
	int x,y;
	void R()
	{scanf("%d%d",&x,&y);}
	void Swap()
	{swap(x,y);}
}d[Q];
bool cmp(dt a,dt b)
{return a.y<b.y;}
int vl[Q],vr[Q],vy[Q];
int mx[Q<<1],laz[Q<<1];
#define ls (now<<1)
#define rs (now<<1|1)
#define mid ((l+r)>>1)
#define Mx mx[now]
#define Laz laz[now]
void Pd(int now,int v)
{Laz+=v,Mx+=v;}
void Init(int now,int l,int r)
{
	Laz=0;
	if(l==r){
		Mx=-vy[l];
		return;
	}
	Init(ls,l,mid),Init(rs,mid+1,r);
	Mx=max(mx[ls],mx[rs]);
}
void Inc(int now,int l,int r,int x,int y,int v)
{
	if(x<=l&&y>=r){
		Pd(now,v);
		return;
	}
	if(Laz)Pd(ls,Laz),Pd(rs,Laz),Laz=0;
	if(x<=mid)Inc(ls,l,mid,x,y,v);
	if(y>mid)Inc(rs,mid+1,r,x,y,v);
	Mx=max(mx[ls],mx[rs]);
}
int stl[Q],str[Q];
void Deal()
{
	int maxn=0,lim=w/2;
	sort(d+1,d+n+1,cmp);
	d[n+1]=(dt){0,h};
	d[0]=(dt){0,0};
	
	for(int i=0,j;i<=n+1;i=j){
		j=i;
		int bl=lim,br=w-lim;
		vy[++maxn]=d[i].y;
		while(d[j].y==d[i].y&&j<=n+1){
			
			if(d[j].x<=lim)bl=min(bl,lim-d[j].x);
			if(d[j].x>=lim)br=min(br,d[j].x-lim);++j;
		}
		vl[maxn]=bl,vr[maxn]=br;
	}
//	for(int i=1;i<=maxn;i++)
//		printf("%d %d %d \n",vy[i],vl[i],vr[i]);puts("");
	int tpl=0,tpr=0;
	Init(1,1,maxn);
	for(int i=1;i<=maxn;i++){
		if(i>1)als=max(als,w+vy[i]-vy[i-1]);
		als=max(als,vy[i]+mx[1]);
		while(tpl>1&&vl[i]<vl[stl[tpl]]){
			Inc(1,1,maxn,stl[tpl-1],stl[tpl]-1,-vl[stl[tpl]]);
			--tpl;
		}
		if(tpl)Inc(1,1,maxn,stl[tpl],i-1,vl[i]);
		stl[++tpl]=i;
		while(tpr>1&&vr[i]<vr[str[tpr]]){
			Inc(1,1,maxn,str[tpr-1],str[tpr]-1,-vr[str[tpr]]);
			--tpr;
		}
		if(tpr)Inc(1,1,maxn,str[tpr],i-1,vr[i]);
		str[++tpr]=i;
	}
}
int main()
{
//	freopen("paint.in","r",stdin);
//	freopen("paint.out","w",stdout);
	scanf("%d%d%d",&w,&h,&n);
	for(int i=1;i<=n;i++)
		d[i].R();
	Deal();
	for(int i=1;i<=n;i++)
		d[i].Swap();
	swap(w,h);
	Deal();
	printf("%d",als<<1);
	return 0;
}

Measured memory_bytes: 21248
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    set<string> s;
    string S;
    char last = -1;
    bool ans = true;
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> S;
        if( s.count(S) != 0 || (last != -1 && S[0] != last) ) {
            ans = false;
        }
        s.insert(S);
        last = S.back();
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
  cin>>A[i];
  }
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    int a=0;
    for(int i=1;i<N;i++){
    a+=A[i];
    }
    if(a>A[0]){
    cout<<"Yes"<<endl;
    }
    else{
    cout<<"No"<<endl;
    }
  
  
  
  

}


Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  set<int> st;
  int query; cin >> query;

  for (int i = 0; i < query; ++i) {
    int op, x; cin >> op >> x;
    if (op == 0) {
      st.insert(x);
      cout << st.size() << '\n';
    } else if (op == 1) {
      cout << (st.find(x) != st.end()) << '\n';
    } else if (op == 2) {
      st.erase(x);
    } else {
      int r; cin >> r;
      auto it1 = st.lower_bound(x);
      auto it2 = st.upper_bound(r);

      for (auto it = it1; it != it2; ++it) {
        cout << *it << '\n';
      }
    }
  }

  return 0;
}


Measured memory_bytes: 12512
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int day,mon[]={31,29,31,30,31,30,31,31,30,31,30,31},now,ans;
    for(;;){
    ans=0;
    cin>>now>>day;
    if(now==0)break;
    for(int i=0;i<now-1;i++){
        ans+=mon[i];
    }
    ans+=day;
    ans=ans%7;
    if(ans==1)printf("Thursday\n");
    if(ans==2)printf("Friday\n");
    if(ans==3)printf("Saturday\n");
    if(ans==4)printf("Sunday\n");
    if(ans==5)printf("Monday\n");
    if(ans==6)printf("Tuesday\n");
    if(ans==0)printf("Wednesday\n");
}
}

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

int main(void){
    string s, ans="CODEFESTIVAL2016";
    int cnt = 0;
    cin >> s;
    for(int i=0; i<16; i++){
        if(s[i] != ans[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b; cin >> a >> b;
    if(a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
import Control.Applicative
import Text.Printf
import Debug.Trace

fib n
  | n >= 1  = fib (n-1) + fib (n-2)
  | n >= -1 = 1
  | otherwise = 0xdeadbeef

mo = 1000000007 :: Integer

comb = fmap fib [0..8]


solve_ 1 w = take w $ [comb !! (w-2),comb !! max 0 (w-3)] ++ zs
  where zs = 0:zs
solve_ h w =
  let dp = solve_ (h-1) w
      c m n q = comb !! max 0 m * comb !! max 0 n * dp !! max 0 q `mod` mo
      left = ((c (w-2) 0 0) + (c (w-3) 0 1)) `mod` mo
      right = ((c (w-2) 0 (w-1)) + (c (w-3) 0 (w-2))) `mod` mo
      mid = [((c (x-2) (w-x-2) (x-1)) + (c (x-1) (w-x-2) x) + (c (x-1) (w-x-3) (x+1))) `mod` mo|x<-[1..w-2]]
--  in trace ("list:" ++ show (left:mid++[right])) (left:mid++[right])
  in left:mid++[right]

solve h w k = solve_ h w !! (k-1)

main = do
  [h,w,k] <- fmap (read :: String -> Int) . words <$> getLine
  if w == 1 then
    printf "1\n"
  else printf "%d\n" $ solve h w k `mod` mo



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

void solve() {
    int i, j, n, m, k, ans, x, t;
    cin >> n >> x >> t;
    if (n % x == 0) {
        cout << (n / x) * t << endl;
        return;
    }
    cout << (n / x + 1) * t << endl;

    return;
}

int32_t main() {
    solve();
}

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

// Data structure for Max Heap
struct PriorityQueue 
{
private:
	// vector to store heap elements
	vector<int> A;

	// return parent of A[i]
	// don't call this function if i is already a root node
	int PARENT(int i) 
	{ 
		return (i - 1) / 2; 
	}

	// return left child of A[i]	
	int LEFT(int i) 
	{ 
		return (2 * i + 1); 
	}

	// return right child of A[i]	
	int RIGHT(int i) 
	{ 
		return (2 * i + 2); 
	}

	// Recursive Heapify-down algorithm
	// the node at index i and its two direct children
	// violates the heap property
	void heapify_down(int i)
	{
		// get left and right child of node at index i
		int left = LEFT(i);
		int right = RIGHT(i);

		int largest = i;

		// compare A[i] with its left and right child
		// and find largest value
		if (left < size() && A[left] > A[i])
			largest = left;

		if (right < size() && A[right] > A[largest])
			largest = right;

		// swap with child having greater value and 
		// call heapify-down on the child
		if (largest != i) {
			swap(A[i], A[largest]);
			heapify_down(largest);
		}
	}

	// Recursive Heapify-up algorithm
	void heapify_up(int i)
	{
		// check if node at index i and its parent violates 
		// the heap property
		if (i && A[PARENT(i)] < A[i]) 
		{
			// swap the two if heap property is violated
			swap(A[i], A[PARENT(i)]);
			
			// call Heapify-up on the parent
			heapify_up(PARENT(i));
		}
	}
	
public:
	// return size of the heap
	unsigned int size()
	{
		return A.size();
	}

	// function to check if heap is empty or not
	bool empty()
	{
		return size() == 0;
	}
	
	// insert key into the heap
	void push(int key)
	{
		// insert the new element to the end of the vector
		A.push_back(key);

		// get element index and call heapify-up procedure
		int index = size() - 1;
		heapify_up(index);
	}

	// function to remove element with highest priority (present at root)
	void pop()
	{
		try {
			// if heap has no elements, throw an exception
			if (size() == 0)
				throw out_of_range("Vector<X>::at() : "
						"index is out of range(Heap underflow)");

			// replace the root of the heap with the last element
			// of the vector
			A[0] = A.back();
			A.pop_back();

			// call heapify-down on root node
			heapify_down(0);
		}
		// catch and print the exception
		catch (const out_of_range& oor) {
			cout << "\n" << oor.what();
		}
	}

	// function to return element with highest priority (present at root)
	int top()
	{
		try {
			// if heap has no elements, throw an exception
			if (size() == 0)
				throw out_of_range("Vector<X>::at() : "
						"index is out of range(Heap underflow)");

			// else return the top (first) element
			return A.at(0);	// or return A[0];
		}
		// catch and print the exception
		catch (const out_of_range& oor) {
			cout << "\n" << oor.what();
		}
	}
};

// Max Heap C++ implementation
int main()
{
	PriorityQueue pq;

  string operacao; int valor;
  while(cin >> operacao){
    if (operacao == "insert"){
      cin >> valor;
      pq.push(valor);
    } else if (operacao == "extract"){
      cout << pq.top() << endl;
      pq.pop();
    } else {
      break;
    }
  }
	return 0;
}


Measured memory_bytes: 7020
import sys
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, M = mi()
    print((1<<M)*(1800*M+100*N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61820
def multiply(list1, list2):
    sum = 0
    for s in range(len(list1)):
        sum += int(list1[s] * list2[s])
    return sum


n, m, l = map(int, input().split())
list1 = [[0]*(m) for i in range(n)]
list2 = [[0]*(l) for i in range(m)]
list3 = [[0]*(l) for i in range(n)]
for i in range(n):
    list4 = list(map(int,input().split()))
    for j in range(m):
        list1[i][j] = list4[j]


for i in range(m):
    list4 = list(map(int,input().split()))
    for j in range(l):
        list2[i][j] = list4[j]


for i in range(n):
    for j in range(l):
        list3[i][j] = multiply([list1[i][x] for x in range(m)], [list2[x][j] for x in range(m)])
        if j==l-1:
            print(list3[i][j], end='')
        else:
            print(list3[i][j], end=' ')
    print()


Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(int i=0;i<(int)n;++i)
#define _rep1(i,k,n) for(int i=k;i<(int)n;++i)
#define _rep2(i,k,n,d) for(int i=k;d>0?i<(int)n:i>(int)n;i+=d)
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n, q; cin >> n >> q;
    vector<ll> C(n);
    rep(i, n){
        cin >> C[i];
        C[i]--;
    }
    vector<ll> left(q), right(q);
    rep(i, q){
        cin >> left[i] >> right[i];
        left[i]--;
    }

    // Mo's algorithm
    vector<ll> order(q);
    iota(order.begin(), order.end(), 0);
    sort(order.begin(), order.end(), [&](ll i, ll j){
        if(left[i] / (ll)sqrt(n) != left[j] / (ll)sqrt(n)) return left[i] < left[j];
        else return right[i] < right[j];
    });

    vector<ll> ans(q), counter(n);
    ll l = 0, r = 0, score = 0;
    for(ll i : order){
        while(l < left[i]){
            counter[C[l]]--;
            if(counter[C[l]] == 0) score--;
            l++;
        }
        while(l > left[i]){
            l--;
            if(counter[C[l]] == 0) score++;
            counter[C[l]]++;
        }
        while(r < right[i]){
            if(counter[C[r]] == 0) score++;
            counter[C[r]]++;
            r++;
        }
        while(r > right[i]){
            r--;
            counter[C[r]]--;
            if(counter[C[r]] == 0) score--;
        }
        ans[i] = score;
    }
    for(ll a : ans){
        cout << a << '\n';
    }
}

Measured memory_bytes: 27164
n=int(input())
al=list(map(int,input().split()))
tl=[0]*9
for a in al:
    if a<3200:
        tl[a//400]|=1
    else:
        tl[8]+=1
print(sum(tl[0:-1]) if sum(tl[0:-1])>0 else 1,sum(tl))

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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

void solve(){
    int n;
    string s;
    cin>>n;
    cin>>s;
    if(n&1){
        printf("No\n");
    }else{
        int flag = 1;
        for(int i=0;i<n/2;i++){
            if(s[i] != s[i+n/2]){
                flag = 0;break;
            }
        }
        if(flag){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
    
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
  //  freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
  //  printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    LL N, M;
    cin >> N >> M;
    priority_queue<LL, vector<LL>, less<LL>> q;
    REP(i, N) {
        LL x;
        cin >> x;
        q.push(x);
    }
    REP(i, M) {
        LL top = q.top();
        q.pop();
        q.push(top/2);
    }
    LL res = 0;
    for(;!q.empty();q.pop()) {
        res += q.top();
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1400
#include<iostream>
using namespace std;
int main(){
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
		s1[0]-=32;
		s2[0]-=32;
		s3[0]-=32;
	 cout<<s1[0];
	 cout<<s2[0];
	 cout<<s3[0];
return 0;
      
}

      

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc126/tasks/abc126_e

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x);      // xの根をrx
        int ry = root(y);      // yの根をry
        if (rx == ry)
            return; // xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] =
            ry; // xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

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

// X, Yのグループが何個あるか調べればいい
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;

    UnionFind tree(n + 1);
    set<int> st;

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        tree.unite(x, y);
    }
    for (int i = 1; i <= n; i++) {
        st.insert(tree.root(i));
    }
    cout << st.size() << endl;

    return 0;
}

Measured memory_bytes: 5376
x , n= map(int,input().split())
p = list(map(int,input().split()))
ans = []
if n == 0:
    print(x)
else:
    for i in range(-10,102):
        if i in p:
            pass
        else:
            ans.append(i)
    sa = []
    for i in range(len(ans)):
        sa.append(abs(ans[i]-x))
    MIN=min(sa)
    for i in range(len(ans)):
        if MIN == abs(ans[i]-x):
            print(ans[i])
            break

Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

ll val(ll a[],vector<ll> &dp,ll i){
    if(dp[i]!=-1) 
    return dp[i];
    
    return dp[i]=min(val(a,dp,i-1)+abs(a[i]-a[i-1]),val(a,dp,i-2)+abs(a[i]-a[i-2]));
}

int main() {
    fastio
    
	ll n,i,j,x,t,k,m,y;
	cin>>n;
	
	ll a[n];
	vector<ll> dp(n,-1);
	
	for(j=0;j<n;j++)
	cin>>a[j];
	
	if(n==2){
	    cout<<abs(a[1]-a[0]);
	    exit(0);
	}
	
	dp[1]=abs(a[1]-a[0]);
	dp[2]=abs(a[2]-a[0]);
	
	cout<<val(a,dp,n-1);
	
	return 0;
}


Measured memory_bytes: 7900
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int32_t main(){
	ios::sync_with_stdio(0);
	int n; cin >> n;
	string st;
	cin >> st;
	int ans = 0;
	for(int i=0; i<n-2; ++i)
		if(st.substr(i, 3)=="ABC") ++ans;
	cout << ans << endl;
}


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

template <typename First, typename Second, typename Third>
struct triple
{
    First first;
    Second second;
    Third third;
};
#define ll long long
using namespace std;

void solve(){
     ll x,mx=0,r;
     int A[8]={0};
     cin>>x;
     for(int i=0;i<x;i++){
         cin>>r;
         if(r<400)
            A[0]++;
         else if(r<800)
            A[1]++;
         else if(r<1200)
            A[2]++;
         else if(r<1600)
            A[3]++;
         else if(r<2000)
            A[4]++;
         else if(r<2400)
            A[5]++;
         else if(r<2800)
            A[6]++;
         else if(r<3200)
            A[7]++;
         else 
            mx++;
     }
     int mn=0;
     for(int i=0;i<8;i++){
         if(A[i]!=0)
            mn++;
     }
     if(mn!=0)
         cout<<mn<<" "<<(mn+mx);
     else 
         cout<<1<<" "<<mx;
}
int main()
{

    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Debug.Trace

traceQ :: (Show a) => String -> a -> a
-- traceQ label a = trace (label ++ ": " ++ show a) a
traceQ _ a = a

traceZ :: String -> a -> a
-- traceZ = trace
traceZ _ a = a

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

type Mms = (Int, Int, Int, Int)
gMin   (x, _, _, _) = x
gMax   (_, x, _, _) = x
gShift (_, _, x, _) = x
gDir   (_, _, _, x) = x

solve :: Int -> Int -> [Int] -> Int -> [[Int]] -> [Int]
solve valX valK rs valQ tas = vals

  where

    states = scanl op (0, (0, valX, 0, -1)) rs
      where
        op (t, mms) r = (r, mmsUpd valX (r - t) mms)

    valueA :: Int -> Mms -> Int -> Int
    valueA t (minA, maxA, shift, dir) a = min valX (max 0 v)
      where v = min maxA (max minA a) + shift + t * dir

    findInterval :: Int -> [(Int, Mms)] -> [(Int, Mms)]
    findInterval t [s] = [s]
    findInterval t ss1@(_ : ss2@((r2, _) : _))
      | t >= r2  = findInterval t ss2
      | t <  r2 = ss1

    procTa :: Int -> Int -> [(Int, Mms)] -> (Int, [(Int, Mms)])
    procTa t a states =
      let newStates@((r, mms) : _) = findInterval t states
          v = valueA (t - r) mms a
          res = (v, newStates)
      in (traceZ ("procTa: " ++ show (t, res)) res)

    vals = map fst $ tail $ scanl op (0, (traceQ "states" states)) tas
      where
        op (_, ss) [t, a] = procTa t a ss


mmsUpd :: Int -> Int -> Mms -> Mms
mmsUpd _    r (minA, maxA, shift, -1) = (newMinA, maxA, newShift,  1)
  where (newMinA, newShift) | r - shift < minA = (minA, shift - r)
                            | maxA < r - shift = (maxA, -maxA)
                            | otherwise        = (r - shift, shift - r)
mmsUpd valX r (minA, maxA, shift,  1) =
  let (minB, maxB, shiftB) = (valX - maxA, valX - minA, -shift)
      (minB', maxB', shiftB', _) = mmsUpd valX r (minB, maxB, shiftB, -1)
  in (valX - maxB', valX - minB', -shiftB', -1)

main :: IO ()
main = do
  conts <- B.getContents
  let [valX] : [valK] : rs : [valQ] : tas = map bsReadInts (B.lines conts)
      answer = solve valX valK rs valQ tas
  putStr $ unlines $ map show answer


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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  ll n, m, v, p;
  std::cin >> n >> m >> v >> p;
  vi a(n);
  rep(i, n) std::cin >> a[i];
  sort(a.rbegin(), a.rend());
  int l = 0, r = n;
  while (r - l != 1) {
    int mid = (l + r) / 2;
    if (mid + 1 <= p) {
      l = mid;
      continue;
    } else if (a[mid] + m < a[p-1]) {
      r = mid;
      continue;
    }
    ll vote = p - 1 + n - mid;
    ll sum = 0;
    srep(i, p-1, mid)
      sum += a[mid] + m - a[i];
    if (vote * m + sum >= v * m) 
      l = mid;
    else
      r = mid;
  }
  std::cout << l + 1 << "\n";
}


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


using namespace std;

int main() {

	int64_t N,M;
	cin >> N >> M;

	vector<int64_t> check(N, 0), fail_ch(N, 0);
	int64_t success = 0, fail = 0;
	for (int64_t i = 0; i < M; i++) {
		int64_t a;
		string s;
		cin >> a >> s;

		if (check[a - 1] == 0) {
			if (s == "AC") {
				check[a - 1]++;
				success++;
			}
			else {
				fail_ch[a - 1]++;
			}
		}
	}
	for (int i = 0; i < N; i++) if (check[i]==1) fail += fail_ch[i];

	cout << success << " " << fail;
	return 0;

}

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

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

#define fst first
#define snd second
#define pb push_back

const int maxn=1000005,maxm=306;
const double pi=acos(-1.0);
const ll mod=1000000007;
const double eps=1e-8;




int main()
{
	int i,j;
	scanf("%d %d",&i,&j);
	printf("%d\n",i*j);
    return 0;
}


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

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

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

    int d = 0;
    for (char c: s) {
        d += (c - '0');
        d %= 9;
    }
    cout << (d == 0 ? "Yes": "No") << "\n";
    return 0;
}

Measured memory_bytes: 3708
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second

constexpr int mod = 1000000007;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value


void solve() {

	ll N, A, B;

	cin >> N >> A >> B;

	cout << min(N * A, B) << endl;

	return;

}

int main() {

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

	solve();

	return 0;

}


Measured memory_bytes: 256
// AOJ 2164 Revenge of the Round Table
// 2018.3.22 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int gcd(int a, int b)
{
	int r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

#define M 1000003

int n, k;
int inv[1002];
int dpa[1002][1002], dpb[1002][1002], dp[1002];

void calc()
{
	int i, j, t, sa, sb;

    memset(dpa, 0, sizeof(dpa));
    memset(dpb, 0, sizeof(dpb));
    memset(dp, 0, sizeof(dp));

    sa = 1, sb = 0;
    dpa[1][1] = 1;
    dpb[1][1] = 0;
 
    for (i = 2; i <= n; i++) {
        dpa[i][1] = sb, dpb[i][1] = sa;
		t = sa, sa = sb, sb = t;
        for (j = 2; j <= k; j++) {
            dpa[i][j] = dpa[i-1][j-1];
            sa = sa + dpa[i][j]; if (sa >= M) sa -= M;
            dpb[i][j] = dpb[i-1][j-1];
            sb = sb + dpb[i][j]; if (sb >= M) sb -= M;
        }
    }

    for (i = 1; i <= n; i++) for (j = 1; j <= k; j++) {
		dp[i] += dpb[i][j]; if (dp[i] >= M) dp[i] -= M;
	}
 
    for (i = 1; i <= n; i++) for (j = 1; j < k; j++) {
		dpb[i][j+1] += dpb[i][j]; 
		if (dpb[i][j+1] >= M) dpb[i][j+1] -= M;
    }
 
    for (i = 1; i <= n; i++) {
		t = i; if (t > k) t = k; 
        for (j = 1; j <= t; j++) {
            dp[i] += dpb[i-j][k-j]; if (dp[i] >= M) dp[i] -= M;
        }
    }
}

int main()
{
	int i;
	long long ans, s;

    inv[1] = 1; for (i = 2; i <= 1000; i++)
		inv[i] = M - (long long)(M/i) * inv[M%i] % M;

	while (n = in()) {
		k = in();

		s = 0;
	    if (k >= n) k = n-1, s = 2;
		calc();
		ans = 0; for (i = 0; i < n; i++) ans = (ans + (dp[gcd(i, n)] << 1)) % M;
        printf("%lld\n", (s + ans * inv[n]) % M);
	}
	return 0;
}


Measured memory_bytes: 9544
#include<stdio.h>
int main(){
	int a,n,i;
	scanf("%d",&n);
	for(a=0;a<n;a++){
		int b,c=0,low[10][2]={0},f[10][2],x=0;
		for(i=0;i<10;i++){scanf("%d",&low[i][0]);}
		low[0][1]=0;
		b = low[0][0];
		for(i=1;i<10;i++){
			if(low[i][0]<b && low[i][0]<c){
				if(x == 0){printf("NO\n");break;}
				else{
					i = f[x-1][0];
					b = f[x-1][1];
					c = low[i][0];
					x--;
				}
			}
			else if(low[i][0]<b && low[i][0]>c){c = low[i][0];}
			else if(low[i][0]>b && low[i][0]<c){b = low[i][0];}
			else if(low[i][0]>b && low[i][0]>c){
				f[x][0] = i;
				f[x][1] = b;
				b = low[i][0];
				x++;
			}
		}
		if(i == 10){printf("YES\n");}
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int l = in.nextInt();
		System.out.println(solve(n, l));
		in.close();
	}

	private static int solve(int n, int l) {
		int r = 0;
		int e = 99999;
		for (int i = 1; i <= n; i++) {
			int a = l + i - 1;
			r += a;
			if (Math.abs(e) > Math.abs(a))
				e = a;
		}
		return r - e;
	}

}


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

using namespace std;
using ll = long long;

int N, K, R, S, P;

int calc_score(char T){
  
  if(T=='r'){
    return P;
  }else if(T=='s'){ 
    return R;
  }else if(T=='p'){
    return S;
  }

}

int main(){
  cin >> N >> K >> R >> S >> P;
  string T;
  cin >> T;
  
  int score = 0;
  
  bool wins[K];
  for(int i=0; i<K; i++) wins[i] = false;
  
  for(int i=0; i<N; i++){
    if(T[i]!=T[i-K] || wins[i%K]==false){
      score += calc_score(T[i]);
      wins[i%K] = true;
    }else {
      wins[i%K] = false;
    }
  }
    
  cout << score << endl;
  return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>                                                                          
using namespace std;
int main()
{
  int A,B;
  cin >> A >> B;
  string S;
  cin >> S;
  int count=0;
  if(S.at(A)=='-'){
    count++;
  }
  for(int i=0; i<S.size(); i++){
    if(i!=A){
      if(S.at(i)=='0')
        count++;
      else if(S.at(i)=='1')
        count++;
      else if(S.at(i)=='2')
        count++;
      else if(S.at(i)=='3')
        count++;
      else if(S.at(i)=='4')
        count++;
      else if(S.at(i)=='5')
        count++;
      else if(S.at(i)=='6')
        count++;
      else if(S.at(i)=='7')
        count++;
      else if(S.at(i)=='8')
        count++;
      else if(S.at(i)=='9')
        count++;
    }
  }
  if(count==S.size())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
  ll N; cin >> N;
  vector<P> a(N); rep(i,N) cin >> a[i].fi >> a[i].sc;
  SORT(a);

  // 最小公倍数でわる
  rep(i,N){
    if(a[i].fi == 0 and a[i].sc == 0) continue;
    ll tmp = gcd(abs(a[i].fi), abs(a[i].sc));
    a[i].fi /= tmp;
    a[i].sc /= tmp;
  }

  // map;
  ll zero = 0;
  map<P,ll> map;
  rep(i,N){
    if(a[i].fi == 0 and a[i].sc == 0){
      zero++;
      continue;
    }
    else if(a[i].fi == 0 and a[i].sc != 0){
      a[i].sc = -1;
    }
    else if(a[i].fi != 0 and a[i].sc == 0){
      a[i].fi = 1;
    }
    else if(a[i].fi < 0 and a[i].sc < 0){
      a[i].fi = abs(a[i].fi); a[i].sc = abs(a[i].sc);
    }
    else if(a[i].fi < 0 and a[i].sc > 0){
      a[i].fi = -a[i].fi; a[i].sc = -a[i].sc;
      // ll tmp = a[i].fi; a[i].fi = a[i].sc; a[i].sc = tmp;
    }
    map[mp(a[i].fi , a[i].sc)]++;
  }

  /*
  for(auto p : map){
    cout << p.fi.fi << " " << p.fi.sc << " " << p.sc << endl;
  }
  */

  // 相方の個数を数える
  ll ans = 1;
  for(auto p : map){
    auto a = -p.fi.sc; auto b = p.fi.fi; auto c = p.fi.sc; auto d = -p.fi.fi;
    if(map[mp(a,b)] > 0 or map[mp(c,d)] > 0){
      ll cnt = modpow( 2 , p.sc , MOD ) - 1
      + modpow(2, map[mp(a,b)], MOD) - 1
      + modpow(2, map[mp(c,d)] , MOD) - 1;
      cnt++;
      cnt %= MOD;
      ans *= cnt;
      ans %= MOD;
      map.erase(mp(a,b)); map.erase(mp(c,d));
    }
    else{
      ans *= modpow(2, p.sc , MOD);
      ans %= MOD;
      map.erase(mp(a,b)); map.erase(mp(c,d));
    }
  }
  ans = ans + MOD - 1;
  ans %= MOD;
  ans += zero;
  ans %= MOD;
  cout << ans << endl;
}


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

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

int H, W;

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

    while (1) {
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break ;
        }
        REP(i, H) {
            REP(j, W) {
                cout << '#';
            }
            cout << '\n';
        }
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    string b=a;
    a="";
    int x=b.size();
    int i;
    for (i=0;i<x;i++)
		a=b[i]+a;
    for(int i=0;i<x;i++)
	{
        if(a[i]=='b')
			a[i]='d';
        else if(a[i]=='d')
			a[i]='b';
        else if(a[i]=='p')
			a[i]='q';
        else if(a[i]=='q')
			a[i]='p';
    }
    if(a==b)
		cout<<"Yes"<<endl;
    else
		cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; } /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; } /* 8,7,6,5.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int main(void)
{
	int k, x;
	scanf("%d %d", &k, &x);

	int i, first, last;
	first = x - k + 1;
	last = x + k - 1;
	for (i = first; i <= last; i++)
	{
		printf("%d ", i);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
N,M=map(int,input().split())
A_B=[list(map(int,input().split())) for i in range(N)]

c=0
y=0

A_B_sorted=sorted(A_B)

for ab in A_B_sorted:
    c+=ab[1]
    y+=ab[0]*ab[1]

    if c>=M:
        print(y-ab[0]*(c-M))
        break


Measured memory_bytes: 28648
#include <stdio.h>
#include <vector>
#include <stack>
#define MAX 100010
#define INFTY 10000000
#define NIL -1

using namespace std;

int N;
int M;
vector<int> V[MAX];
int color[MAX];

int dfs(int s, int t)
{
	stack<int> S;
	S.push(s);
	color[s] = t;
	
	while (!S.empty()) {
		int u = S.top(); S.pop();
		for (int i=0; i<V[u].size(); i++) {
			int v = V[u][i];
			if (color[v] == NIL) {
				color[v] = t;
				S.push(v);
			}
		}
	}	
}

void assignColor()
{
	int id =1;
	for (int i=0; i<N; i++) {
		color[i] = NIL;
	}
	for (int u=0; u<N; u++) {
		if (color[u] == NIL) dfs(u, id++);
	}
}


int main()
{
	int i, n, u, v;	
	scanf("%d %d", &N, &M);	
	for (i = 0; i < M; i++) {
		scanf("%d %d", &n, &v);
		V[n].push_back(v);
		V[v].push_back(n);
	}
	
	assignColor();
	
	int Q;
	scanf("%d", &Q);
	for (i = 0; i < Q; i++) {
		scanf("%d %d", &u, &v);
		/*
		if (dfs(u, v) == 1) {
			puts("yes");
		}
		else {
			puts("no");
		}*/
		if (color[u] == color[v]) {
			puts("yes");			
		}
		else {
			puts("no");
		}
	}

	return 0;
}

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

int N,Q;

void children(int i,vector<int> &count,vector<vector<int>> &A,int parent=-1) {
  for (int x:A.at(i)) {
    if (x!=parent) {
      count.at(x)+=count.at(i);
      children(x,count,A,i);
    }
  }
}

int main() {
  cin >> N >> Q;
  vector<vector<int>> A(N);
  for (int i=0;i<N-1;i++) {
    int a,b;cin >> a >> b;
    A.at(a-1).push_back(b-1);
    A.at(b-1).push_back(a-1);
  }
  vector<int> count(N,0);
  for (int i=0;i<Q;i++) {
    int p,x;cin >> p >> x;
    count.at(p-1)+=x;
  }
  children(0,count,A);
  for (int i=0;i<N;i++) {
    if (i==N-1) cout << count.at(i) << endl;
    else cout << count.at(i) << " ";
  }
}

Measured memory_bytes: 32896
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
#define FOR(i, a, n) for (ll i=(ll)a;i<(ll)n;i++)
#define REP(i, n) FOR(i, 0, n)

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

    int ans = 0;

    REP(i, n){
        int l, r; cin >> l >> r;
        ans += r-l+1;
    }
    cout << ans << endl;   
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char a[7];
    int f=0;
    scanf("%s",&a);
    if(a[2]!=a[3]) f++;
    if(a[4]!=a[5]) f++;
    if(f==0){
        printf("Yes\n");
    }else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i <= (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>
#define lint int64_t

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

  vector<int> pi;
  vector<string> si;

  rep(i,M){
    int tmppi;
    string tmpsi;
    cin >> tmppi >> tmpsi;

    pi.push_back(tmppi);
    si.push_back(tmpsi);
  }

  vector<int> WAcnts(N+1,0);
  vector<bool> isAC(N+1,false);
  rep(i,M){
    int qNo = pi.at(i);

    if(si.at(i) == "WA" && isAC.at(qNo) == false) WAcnts.at(qNo)++;
    if(si.at(i) == "AC") isAC.at(qNo) = true;
  }

  int ansACcnts = 0;
  int ansWAcnts = 0;
  rep2(i,1,N){
    if(isAC.at(i) == true){
      ansACcnts++;
      ansWAcnts += WAcnts.at(i);
    }
  }

  cout << ansACcnts << " " << ansWAcnts << endl;

  return 0;
}


Measured memory_bytes: 6512
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

int main() {
    SS(ll,H,W)
    if(H*W%3==0){
        p(0);
        return 0;
    }
    ll ans=max(H,W);
    ll a[3];
    
    if(H%3!=0)chmin(ans,1*W);
    
    if(W%3!=0)chmin(ans,1*H);
    
    for(ll i=1;i<H;i++){
        a[0]=i*W;
        if(W%2==0){
            a[1]=a[2]=(H-i)*(W/2);
        }else{
            a[1]=(H-i)*(W/2);
            a[2]=(H-i)*(W/2+1);
        }
        sort(a,a+3);
        chmin(ans,a[2]-a[0]);
    }
    for(ll i=1;i<W;i++){
        a[0]=i*H;
        if(H%2==0){
            a[1]=a[2]=(W-i)*(H/2);
        }else{
            a[1]=(W-i)*(H/2);
            a[2]=(W-i)*(H/2+1);
        }
        sort(a,a+3);
        chmin(ans,a[2]-a[0]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
map<int,int> M;
int main()
{
	int re=0,n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		M[t]++;
	}
	for(map<int,int>::iterator it=M.begin();it!=M.end();it++)
	{
		int k=it->first;
		int v=it->second;
		int ss=0;
		if(v==k) ss=0;
		else if(v>k)
		{
			ss=v-k;
		}
		else
		{
			ss=v;
		}
		re+=ss;
	}
	cout<<re<<endl;
	return 0;
}


Measured memory_bytes: 4736
main = do
  str <- getLine
  let [s, t] = words str
  str <- getLine
  let [a, b] = map read (words str) ::[Int]
  u <- getLine
  if u == s
    then putStrLn $ unwords $ map show [a-1, b]
    else putStrLn $ unwords $ map show [a, b-1]

Measured memory_bytes: 508
N,W = map(int, input().split())
wv = []
V = 0
for x in range(N):
    w,v = map(int, input().split())
    wv.append([w,v])
    V += v

INF = 10**9+1

DP = [[INF]*(V+1) for _ in range(N+1)]

for i in range(N):
    for j in range(V):
        if j >= wv[i][1]:
            DP[i+1][j] = min(DP[i][j], DP[i][j-wv[i][1]]+wv[i][0])
        else:
            DP[i+1][j] = min(DP[i][j], wv[i][0])
        
ans = 0
for i in range(N+1):
    for j in range(V+1):
        if DP[i][j] <= W:
            ans = max(ans, j+1)
print(ans)

Measured memory_bytes: 152600
n,m,c = map(int,input().split())
b = [i for i in map(int,input().split())]
a = []
for j in range(n):
    a.append( [i for i in map(int,input().split())] )


ans = [0]*(n)
count = 0
for i in range(n) :
    for j in range(m):
        ans[i] += a[i][j] * b[j]
    if ans[i] + c > 0 :
        count += 1 
print(count)

Measured memory_bytes: 3064
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_D&lang=jp
 *
 * Why isn't this accepted by JudgeInput#19 ???
 */

import java.util.*;

public class Main {

        int[] A;
        long count = 0;

        void merge(int left, int mid, int right) {
                int n1 = mid - left;
                int n2 = right - mid;
                int[] L = new int[n1+1];
                int[] R = new int[n2+1];
                for (int i = 0; i < n1; i++) L[i] = A[left + i];
                for (int i = 0; i < n2; i++) R[i] = A[mid + i];
                L[n1] = Integer.MAX_VALUE;
                R[n2] = Integer.MAX_VALUE;
                int i = 0, j = 0;
                for (int k = left; k < right; k++) {
                        if (L[i] <= R[j]) {
                                A[k] = L[i];
                                i++;
                        } else {
                                count += n1 - i; // count !!!!!!!!!!!
                                A[k] = R[j];
                                j++;
                        }
                }
        }

        void mergeSort(int left, int right) {
                if (left + 1 < right) {
                        int mid = (left + right) / 2;
                        mergeSort(mid, right);
                        mergeSort(left, mid);
                        merge(left, mid, right);
                }
        }

        void run() {
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                A = new int[n];
                for (int i = 0; i < n; i++) {
                        A[i] = sc.nextInt();
                }
                mergeSort(0, A.length);
                System.out.println(count);
        }

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

}


Measured memory_bytes: 101848
#include <cstdio>
#define sqrt __builtin_sqrt
using namespace std;

int main(int argc, char** argv)
{
	int n, d, ans = 0;
	scanf("%d%d", &n, &d);
	for(int i=0; i<n; i++)
	{
		long long x, y;
		scanf("%lld%lld", &x, &y);
		if(sqrt(double(x * x + y * y)) <= d)
			ans ++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2156