akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<vector> 
using namespace std;

const int maxn = 1e5 + 10;
int fa[maxn];
int co[maxn];
bool visit[maxn];
int flag, ans1, ans2;

vector<vector<int > > G(maxn);
int n;

void init()
{
	for(int i = 1; i <= n ;i ++){
		G[i].clear();
		fa[i] = -1;
		co[i] = 0;				//无色 
		visit[i] = false;
		flag = 0;
	}
	co[1] = -1;					//黑 
	co[n] = 1;					//白 
}

void dfs(int x)
{
	if(x == n){
		flag = 1;				//找到了 
		return ;	
	}	
	
	int tmp;
	for(int i = 0; i < G[x].size() ;i ++){
		if(flag == 1){
			break;
		}
		
		tmp = G[x][i];
		if(visit[tmp] == true){
			continue;
		}
		fa[tmp]	= x;
		visit[tmp] = true;
		dfs(tmp);	
		//visit[tmp] = false;
	}
} 

void dfs1(int x)
{
	int tmp;
	for(int i = 0; i < G[x].size() ;i ++){
		tmp = G[x][i];
		//cout<<"tmp "<<tmp<<endl;
		if(visit[tmp] == false && (co[tmp] == 0 || co[tmp] == -1)){
			//cout<<"tmp"<<tmp<<endl;
			ans1 ++;
			co[tmp] = -1;
			visit[tmp] = true;
			dfs1(tmp);
		}
	}
	
} 

void dfs2(int x)
{
	int tmp;
	for(int i = 0; i <G[x].size() ;i ++){
		tmp = G[x][i];
		if(visit[tmp] == false && (co[tmp] == 0 || co[tmp] == 1)){
			ans2 ++;	
			co[tmp] = 1;
			visit[tmp] = true;
			dfs2(tmp);
		}
	}
	
}

int main()
{
	int a, b;
	int cnt, tmp;
	while(scanf("%d",&n) != EOF){
		init();
		for(int i = 0; i < n-1 ;i ++){
			scanf("%d%d",&a, &b);
			G[a].push_back(b);
			G[b].push_back(a); 
		}
//		for(int i = 1; i <= n; i ++){
//			for(int j = 0; j < G[i].size() ;j++){
//				cout<<G[i][j]<<" ";
//			}
//			cout<<endl;
//		}
		
		
		//从1开始dfs找到n的最短路径，树所以只有一条路径 
		visit[1] = true;
		dfs(1);
		
//		for(int i = 0; i < n; i++){
//			cout<<fa[i]<<" ";
//		} 
//		cout<<endl;
		cnt = 0;				//1和n中间的结点个数 
		tmp = fa[n];
		while(tmp != 1){
			cnt ++;
			tmp = fa[tmp];
		}
		//cout<<"cnt "<<cnt<<endl;;
		
		//染色 
		tmp = n;
		int tcnt = cnt / 2;
		for(int i = 1 ; i <= cnt ; i++){
			if(i <= tcnt){
				co[fa[tmp]] = 1;
			} else {
				co[fa[tmp]] = -1;
			} 
			tmp = fa[tmp];
		}
		
		for(int i = 0; i <= n; i++){
			visit[i] = false;
		}
		visit[1] = true;
		visit[n] = true;
		ans1 = 1;
		ans2 = 1;
		dfs1(1);
		dfs2(n);
		
		//cout<<"ans1 "<<ans1<<endl;
		//cout<<"ans2 "<<ans2<<endl;
				
		if(ans1 > ans2){
			printf("Fennec\n");
		} else {
			printf("Snuke\n");
		}
	}
	return 0;	
} 

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}


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

    string n;
    cin >>n;
    ll sum =0;

   for(int i=0;i<(ll)n.size();i++){
       sum +=(ll)n[i]-'0';
      // cout<<sum<<endl;

   }

   if(sum %9 == 0)cout<<"Yes"<<endl;
   else if(n == "0")cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

    

}

Measured memory_bytes: 3732
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    int H, W;
    scanf("%d %d", &H, &W);
    int N;
    scanf("%d", &N);
    int ans = N / max(H, W);
    if (N % max(H, W)) ans++;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

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

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

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

int n;
vector<string> ans;

int check(int bit) {
  bool flag = true;
  int cnt = 0;
  rep(i, n) {
    if ((bit>>i) & 1) {
      ++cnt;
      if (flag == false) return 0;
    } else {
      flag = false;
    }
  }
  return cnt;
}

void rec(int m, int ma, string cur, int bit) {
  if (m == n) {
    if (check(bit) > 0) ans.emplace_back(cur);
    return;
  }
  rep(i, min(ma+2, n)) {
    int mt = (i == ma+1) ? ma+1 : ma;
    rec(m+1, mt, cur+(char)('a'+i), bit | (1<<i));
  }
}

int main() {
  cin>>n;
  rec(0, -1, "", 0);
  sort(ans.begin(), ans.end());
  rep(i, ans.size()) {
    print(ans[i]);
  }

  return 0;
}

Measured memory_bytes: 7796
#include <stdio.h>

int main() {
    
    int a, p, min, max;
    
    scanf("%d%d", &a, &p);
    
    min = 2 * a;
    max = 4 * a;
    
    if ((p >= min && p <= max) && (p % 2 == 0))
        printf("%s", "Yes");
    else
        printf("%s", "No");
    
    return 0;
}

Measured memory_bytes: 1736
#include <stdio.h>

int main(void){

  int a,b,c,x;
  scanf("%d%d%d",&a,&b,&c);
  if(a>b){
    x=a; a=b; b=x;
  }
  if(b>c){
    x=b; b=c; c=x;
  }
  if(a>b){
    x=a; a=b; b=x;
  }

  printf("%d %d %d\n",a,b,c);
  return(0);
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
int x=max(a,c);
int y=min(b,d);
if((y-x)<=0){
	cout<<0;
}
else{
	cout<<y-x;
}}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <set>
using namespace std;

const string MINUINF = "-";

void chmax(string &a,string b){
	if(a==MINUINF)a = b;
	else if(a.size()<b.size()) a = b;
	else if(a.size()==b.size()){
		if(a<b)a = b;
	}
}

long long match[10] = {2,5,5,4,5,6,3,7,6};
string dp[11000];
 
int main(){

	int N,M;
	cin>>N>>M;
	vector<int> A(M);
	for(int i=0;i<M;i++)cin >> A[i];
	for(int i=0;i<11000;i++)dp[i] = MINUINF;

	dp[0] = "";
	for(int i=0;i<=N;i++){
		if(dp[i] == MINUINF)continue;
		for(auto a:A)chmax(dp[i+match[a-1]],dp[i]+(char)('0'+a));
	}
	cout<<dp[N]<<endl;
	return 0;
}

Measured memory_bytes: 43776
def Condition(W):
    for i in range(len(W)):
        for j in range(i,len(W)):
            if W[i]==W[j] and i!=j:
                print('No')
                return None
    for i in range(len(W)-1):
        k=len(W[i])-1
        if W[i][k]!=W[i+1][0]:
            print('No')
            return None
    print('Yes')    


N=int(input())
W=[]
for i in range (N):
    W.append(input())    
Condition(W)

Measured memory_bytes: 3064
// #include <iostream>
// #include <string>
// #include <math.h>
// #include <map>
// #include <vector>
// #include <tuple>
// #include <algorithm>
// #include <queue>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;
int main(){
  string s;
  cin >> s;
  string res = " ";
  if(s == "Sunny"){
    res = "Cloudy";
  }
  else if(s == "Cloudy"){
    res = "Rainy";
  }
  else{
    res = "Sunny";
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.array;

void main() {
    string[] inputs = split(stdin.readln());
    auto a = to!(int)(inputs[0]),
         op = to!(char)(inputs[1]),
         b = to!(int)(inputs[2]);

    writeln((op == '+') ? (a + b) : (a - b));
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int N,li,ri,i,x=0;
    cin>>N;
    for(i=1;i<=N;i++)
    {
        cin>>li>>ri;
        x=x+ri-li+1;
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

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


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;




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

  string s;
  cin >> s;
  int n = s.size();
  rep(i,n){
    if(!(i%2)&&s[i] == 'L') {cout << "No" << endl;return 0;}
    if((i%2)&&s[i] == 'R') {cout << "No" << endl;return 0;}
  }

  cout << "Yes" << endl;

  return 0;

}


Measured memory_bytes: 256
import bisect
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * (n + 1)
d = [0] * (m + 1)

for i in range(n):
  c[i+1] = c[i]+a[i]
for i in range(m):
  d[i+1] = d[i]+b[i]
  
cnt = 0
  
for i in range(n+1):
  if c[i] > k:
    continue
  e = bisect.bisect_right(d, k-c[i])
  if cnt < i + e -1:
    cnt =  i + e -1
print(cnt)

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

public class Main {
    
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
	    int n = in.readInt();
	    int dq[] = new int[1000000]; 
	    int left = dq.length/2; 
	    int right = left+1; 
	    for(int i = 1; i<=n; i++) {
	    	int x = in.readInt();
	    	if(i%2 == n%2) {
	    		dq[left--] = x; 
	    	}
	    	else dq[right++] = x; 
	    }
	    for(int i = left+1; i<right; i++) {
	    	System.out.print(dq[i]+" ");
	    }
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 50816
N = int(input())
R = [list(map(int,input().split())) for i in range(N) ]
B = [list(map(int,input().split()))  for i in range(N) ]
R.sort(key=lambda x:x[1],reverse=1)
B.sort()
ans = 0
for b in B:
    for r in R:
        if b[1]>r[1] and b[0]>r[0]:
            ans += 1
            R.remove(r)
            break
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (decltype(+n) i = 0; i < (n); i++)
using namespace std;

using vi = vector<int>;
using pii = pair<int, int>;

template <class T>
void COUT(const T &x) { cout << x << endl; }
template <class T>
bool amax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int H, W;
  cin >> H >> W;

  set<pii> rl;
  rep(i, W)rl.emplace(i, i);
  multiset<int> ds;
  rep(_, W)ds.emplace(0);

  rep(k, H) {
    int a, b;
    cin >> a >> b;
    a--;
    int l = -1;
    for(auto it = rl.lower_bound(pii(a, 0)); it != rl.cend() && it->first <= b; it = rl.erase(it)) {
      ds.erase(ds.find(it->first - it->second));
      amax(l, it->second);
    }
    if(l > -1 && b < W) {
      rl.emplace(b, l);
      ds.emplace(b - l);
    }
    COUT(ds.empty() ? -1 : *ds.cbegin() + k + 1);
  }
}

Measured memory_bytes: 22368
#include<iostream>
#define INF 10000000
using namespace std;

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

  int nmin = INF;

  for(int i = 0; i < n; i++){
    int nin, tin;
    cin >> nin >> tin;

    if(tin <= t){
      if(nin <= nmin) nmin = nin;
    }
  }

  if(nmin == INF){
    cout << "TLE" << endl;
  }

  else cout << nmin << endl;

  return 0;

}


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

#define REP(i,j,k) for( int i=j; i<k; i++ )
#define rep(i,j) REP(i,0,j)

using namespace std;

typedef long long LL;
typedef map<LL,LL> MII;

int main(){
	
	LL N,M;
	cin >> N >> M;
	
	MII data;
	
	rep(i,N){
		LL a,b;
		cin >> a >> b;
		data[a] += b;
	}
	
	LL ans = 0;
	
	for( MII::iterator it = data.begin(); it!= data.end(); ++it ){
		
		M -= (*it).second;
		if( M < 0 ) (*it).second += M;
		ans += (*it).first * (*it).second;
		if( M <= 0 ) break;
		
	}
	
	cout << ans << endl;
	
	return 0;
	
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define pii pair<int, int>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
#include <iostream>
#define ll long long
#define mem(f, x) memset(f, x, sizeof(f))
#define INF 0x3f3f3f3f
using namespace std;
const int M = 1e6+50;
const int N = 1e6+50;
const int MAXN = 1e6+50;
int n;
char s[N];
pii add[N], sub[N]; //fi 左括号 se：右括号

bool cmp1( pii p1, pii p2 ){
    if( p1.se == p2.se )
        return p1.fi > p2.fi;
    return p1.se < p2.se;
}

bool cmp2( pii p1, pii p2 ){
    if( p1.fi == p2.fi )
        return p1.se < p2.se;
    return p1.fi > p2.fi;
}

int main( ){
    while( scanf( "%d", &n ) != EOF ){
        int sum = 0, cnt_a = 0, cnt_s = 0;
        for( int i = 1; i <= n; i++ ){
            scanf( "%s", s );
            int len = strlen( s );
            int L = 0, R = 0;
            int st = 0, ed = len-1;
            while( s[st] == ')' && st < len )
                R++, st++, sum--;
            while( s[ed] == '(' && ed >= 0 )
                L++, ed--, sum++;
            int tmp = 0;
            for( int j = st; j <= ed; j++ ){
                if( s[j] == '(' ) tmp++, sum++;
                else tmp--, sum--;
            }
            if( tmp > 0 ) L += tmp;
            else R -= tmp;

            if( L >= R )
                add[cnt_a++] = mk( L, R );
            else
                sub[cnt_s++] = mk( L, R );
        }

        if( sum ){
            printf( "No\n" );
            continue;
        }
        sort( add, add+cnt_a, cmp1 );
        sort( sub, sub+cnt_s, cmp2 );
        bool flag = 0;
        int L = 0;
        for( int i = 0; i < cnt_a; i++ ){
            L -= add[i].se;
            if( L < 0 ){
                flag = 1;
                break;
            }
            L += add[i].fi;
        }
        if( flag ){
            printf( "No\n" );
            continue;
        }
        for( int i = 0; i < cnt_s; i++ ){
            L -= sub[i].se;
            if( L < 0 ){
                flag = 1;
                break;
            }
            L += sub[i].fi;
        }
        if( L )
            flag = 1;
        if( flag )
            printf( "No\n" );
        else
            printf( "Yes\n" );
    }
    return 0;
}


Measured memory_bytes: 11436
#include <iostream>
#include <string>
using namespace std;
int main() {
    int n, i;
    int ans=0;
    string s[3];
    cin >> n >> s[0] >> s[1] >> s[2];
            for (i = 0; i < n; i++) {
                if (s[0][i]==s[1][i]&&s[0][i]==s[2][i]&&s[1][i]==s[2][i]) {
                }else if(s[0][i]==s[1][i]||s[0][i]==s[2][i]||s[1][i]==s[2][i]){
                    ans++;
                }else{
                    ans+=2;
                }
            }



    std::cout << ans << std::endl;

    return 0;
}

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

int main() {
	string s;
	char s1,s2,s3;
	int N;

	getline(cin, s);

	N = s.size();
	N -= 16;

	s1 = s.at(0);
	s2 = s.at(8);
	s3 = s.at(9 + N);

	cout << s1 << s2 << s3 << endl;

}

Measured memory_bytes: 256
N = int(input())

W0 = input()
W = []
W.append(W0)
for i in range(N - 1):
    W1 = input()
    if W0[-1] != W1[0] or W1 in W:
        print("No")
        exit()
    W.append(W1)
    W0 = W1
print("Yes")


Measured memory_bytes: 2940
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    let mut a_arr: Vec<u32> = vec![0; n];
    for i in 0..n {
        let a: u32 = read();
        a_arr[i] = a;
    }
    a_arr.sort();
    let mut before_a = 0;
    let mut res = true;
    for a in a_arr.iter() {
        if before_a == *a {
            res = false;
            break;
        }
        before_a = *a;
    }
    if res {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll MAX(ll a,ll b){
    if(a>b) return a;
    return b;
}
int main(void){
    ll n,x;
    cin>>n>>x;
    ll a[100001];
    for(int i=0;i<n;i++) cin>>a[i];
    a[n]=x;
    sort(a,a+n+1);
    ll z=a[1]-a[0];
    for(int i=1;i<n+1;i++){
        z=gcd(z,a[i]-a[i-1]);
    }
    cout<<z;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main () {
	int argN, argT, argA;
	cin >> argN >> argT >> argA;

	vector<float> argH(argN);
	for (uint i = 0; i < argN; ++i) {
		cin >> argH.at(i);
	}

	int ret = -1;
	float diffTemp = INFINITY;
	for (uint i = 0; i < argN; ++i) {
		float currentDiffTemp = argT - argH.at(i) * 0.006;
		currentDiffTemp -= argA;

		if (abs(currentDiffTemp) < abs(diffTemp)) {
			diffTemp = currentDiffTemp;
			ret = i;
		}
	}

	cout << ret + 1;
}


Measured memory_bytes: 1016
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n;
  ll ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int x,cnt=0;
    cin>>x;
    while(x%2==0){
      cnt++;
      x/=2;
    }
    ans+=cnt;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

#define MAX_N 100

int a[MAX_N], n;

void swap(int start, int target){
    int tmp = a[target];
    for(int i = target - 1; i >= start; --i)
        a[i + 1] = a[i];
    a[start] = tmp;
}

int main(){
    std::cin >> n;
    for(int i = 0; i < n; ++i)
        std::cin >> a[i];
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < i; ++j){
            if(a[j] > a[i]){
                swap(j, i);
                break;
            }
        }
        for(int k = 0; k < n; ++k){
            std::cout << a[k];
            if(k + 1 != n)
                std::cout << " ";
        }
        std::cout << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int K;
	cin >> K;

	if (K == 0) {
		cout << 2 << endl;
		cout << "0 0" << endl;
		return 0;
	}

	cout << 50 << endl;

	vector<int> ret(50);
	int tmp = (K - 1) / 50;
	rep(i, 50) ret[i] = 50 - i + tmp;

	K %= 50;
	if (K > 0) {
		while (K < 50) {
			int maxArg = 0;
			rep(i, 50) {
				if (ret[i] > ret[maxArg]) {
					maxArg = i;
				}
			}
			rep(i, 50) {
				if (i == maxArg) ret[i] -= 50;
				else ret[i]++;
			}
			K++;
		}
	}

	rep(i, 49) cout << ret[i] << ' ';
	cout << ret[49] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
  
int L[500000], R[500000], count;
  
void merge(int S[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i = 0;i < n1;i++) L[i] = S[left+i];
  for(i = 0;i < n2;i++) R[i] = S[mid+i];
  L[n1] = 2000000000;
  R[n2] = 2000000000;
  i = 0; j = 0;
  for(k = left;k < right;k++){
    count++;
    if(L[i] <= R[j]){
      S[k] = L[i];
      i++;
    } else{
      S[k] = R[j];
      j++;
    }
  }
}
 
void mergeSort(int S[], int n, int left, int right){
  if(left+1 < right){
    int mid = (left + right) / 2;
    mergeSort(S, n, left, mid);
    mergeSort(S, n, mid, right);
    merge(S, n, left, mid, right);
  }
}
 
int main()
{
  int S[500000], n, i;
  count = 0;
   
  scanf("%d", &n);
  
  for(i = 0;i < n;i++) scanf("%d", &S[i]);
  
  mergeSort(S, n, 0, n);
 
  for(i = 0;i < n;i++){
    if(i) printf(" ");
    printf("%d", S[i]);
  }
 
  printf("\n");
 
  printf("%d\n", count);
   
  return 0;
}

Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(ll i=0;i< (n);i++)
#define rep1(i,n) for(ll i=1;i<= (n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const static ll MOD = 998244353;

ll modcross(ll a,ll n){
    if(n == 0)return 0;
    if(n % 2 == 1)return a+modcross(a,n-1) % MOD;
    ll t = modcross(a,n/2) % MOD;
    return t*2 % MOD;
}

ll modpow(ll a,ll n){
    if(n == 0)return 1;
    if(n % 2 == 1)return a*modpow(a,n-1) % MOD;
    ll t = modpow(a,n/2) % MOD;
    return t*t % MOD;
}

int main(){
    ll n;cin>>n;
    vector<ll> D(n,0);
    rep(i,n)cin>>D[i];
    map<ll,ll> mp;
    rep(i,n){
        mp[D[i]]++;
    }
    if(D[0] != 0 || mp[0] != 1){
        cout<<'0'<<endl;
        return 0;
    }
    ll ans = 1;
    for(int i = 1;i<n;i++){
        ans *= mp[D[i]-1];
        ans %= MOD;
    }
    cout<<ans%MOD<<endl;
    return 0;
}

Measured memory_bytes: 7296
import java.io.*;
    import java.util.*;
    import java.math.*;
    import java.util.concurrent.*;
     
    class Main
    {
        static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    	static FastScanner sc=new FastScanner(br);
        static PrintWriter out=new PrintWriter(System.out);
    	static Random rnd=new Random();
    	static int maxn=(int)(3501);
    	
    	static long gcd(long a,long b)
    	{
    		if(b==0)
    		{
    			return a;
    		}
    		else
    		{
    			return gcd(b,a%b);
    		}
    	}
    	
        public static void main(String args[]) throws Exception
        {
    		long n=sc.nextLong();long val1=-1,val2=-1,val3=-1;
    		
    		outer:
    		for(long i=1;i<maxn;i++)
    		{
    			for(long j=i;j<maxn;j++)
    			{	
					long prod=(n*i);
					
    				long num=(4*(prod/n))-(prod/i),den=prod;
    				
    				prod=den*j;
    				
    				long num2=(num*(prod/den))-(prod/j),den2=prod;
    				
    				if(num2>0 && den2%num2==0 && den2>0)
    				{
    					val1=i;val2=j;val3=den2/num2;
    					
    					break outer;
    				}
     
					else if(den2<0)
					{
						break;
					}
    			}
    		}
    		
    		out.println(val1+" "+val2+" "+val3);out.close();
        }
    }
    class FastScanner
    {
        BufferedReader in;
        StringTokenizer st;
     
        public FastScanner(BufferedReader in) {
            this.in = in;
        }
    	
        public String nextToken() throws Exception {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(in.readLine());
            }
            return st.nextToken();
        }
    	
    	public String next() throws Exception {
    		return nextToken().toString();
    	}
    	
        public int nextInt() throws Exception {
            return Integer.parseInt(nextToken());
        }
     
        public long nextLong() throws Exception {
            return Long.parseLong(nextToken());
        }
     
        public double nextDouble() throws Exception {
            return Double.parseDouble(nextToken());
        }
    }

Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

class Edge{
public:
    int to;
    long long cost;
    Edge(int v, long long c = 1): to(v), cost(c){}
    ~Edge(){}
    bool operator<(const Edge& e) const{return cost < e.cost;}
};

// Dijkstra's method
// solve minimum distances from root to each vertex
void Dijkstra(
        const std::vector<std::vector<Edge> >& edge,
        std::vector<long long>& dist,
        const int root = 0)
{
    using Pair = std::pair<long long, int>;
    const int V = edge.size();
    const long long infty = 1e+18;

    // initialize
    dist.clear();
    for(int i=0; i<V; i++) dist.push_back(infty);

    std::priority_queue<Pair, std::vector<Pair>, std::greater<Pair> > pq;
    pq.emplace(0, root);

    // update
    while(!pq.empty()){
        long long d = pq.top().first;
        int tmp = pq.top().second;
        pq.pop();

        if(dist[tmp] < d) continue; // not minimum
        dist[tmp] = d;

        for(const Edge& e: edge[tmp]) pq.emplace(dist[tmp] + e.cost, e.to);
    }
}

int main()
{
    ll N, X, Y;
    cin >> N >> X >> Y;
    X--; Y--;

    Vvec<Edge> graph(N);
    for(int i=0; i<N-1; i++){
        graph[i].emplace_back(i+1);
        graph[i+1].emplace_back(i);
    }
    graph[X].emplace_back(Y);
    graph[Y].emplace_back(X);

    Vvec<ll> dist(N, vector<ll>(N));
    for(int i=0; i<N; i++) Dijkstra(graph, dist[i], i);

    vector<ll> ans(N);
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            ans[dist[i][j]]++;
        }
    }

    for(int i=1; i<N; i++) cout << ans[i]/2 << endl;
}

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

int main() {
    int n; cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    
    int c[n] = {0};
    
    if (n == 1) {
        cout << h[0] << endl;
        return 0;
    }
    
    c[1] = abs(h[0] - h[1]);
    
    for (int i = 2; i < n; i++) {
        c[i] = min(c[i - 2] + abs(h[i - 2] - h[i]), c[i - 1] + abs(h[i - 1] - h[i]));
    }
    
    cout << c[n - 1] << endl;
    return 0;
}

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

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<long long>; using vvll = vector<vll>;
template <class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
template <class T> struct Inf { static constexpr T inf() { return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : std::numeric_limits<T>::max(); } };
template <> struct Inf<int> { static constexpr int inf() { return 0x3f3f3f3f; } };
template <> struct Inf<long long> { static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; } };
constexpr int INF = Inf<int>::inf(); constexpr ll BINF = Inf<ll>::inf();
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}
// Preprocessing & "Global" variables {{{
struct Solver {
	Solver() {}
	int solve();
};
// }}}

int Solver::solve() {
	int n; cin >> n;
	vi a(n); cin >> a;
	int xsum = 0;
	for (int x : a) xsum ^= x;
	for (int i = 0; i < n; i++)
		cout << (xsum ^ a[i]) << ' ';
	cout << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	Solver solver;
	#ifdef JUDGE_MULTI_CASE
		int t; cin >> t; for (int i = 1; i <= t; i++)
	#endif
	solver.solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

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

// vim: fdm=marker


Measured memory_bytes: 3956
n, m = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)
MOD = 10**9 + 7
a = []
1.upto(n - 1) do |i|
  a.push x[i] - x[i - 1]
end
b = []
1.upto(m - 1) do |i|
  b.push y[i] - y[i - 1]
end
w = []
0.upto(n - 2) do |i|
  w.push i * (n - 2 - i) + n - 1
end
v = []
0.upto(m - 2) do |i|
  v.push i * (m - 2 - i) + m - 1
end
lx = 0
0.upto(n - 2) do |i|
  lx += a[i] * w[i]
end
ly = 0
0.upto(m - 2) do |i|
  ly += b[i] * v[i]
end
s = lx * ly
puts s % MOD


Measured memory_bytes: 19868
/*ID:PROG:LANG:*/
#include<bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 998244353
#define MAXN 100005
using namespace std;
struct Edge{
	int to,nex;Edge(int _=0,int __=0){to=_,nex=__;}
}e[MAXN<<1];
int n,m,ans,s,t,Top,cnt,hd[MAXN],dep[MAXN],dp[MAXN],fa[MAXN],q[MAXN];
int rd(){
	int x=0,tp=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')tp=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x*10+c-'0');c=getchar();}
	return x*tp;
}
void adde(int x,int y){e[++cnt]=Edge(y,hd[x]);hd[x]=cnt;}
void dfs(int now,int f){
	dep[now]=dep[f]+1,fa[now]=f;
	dp[now]=(dep[now]%2)?1:-1;
	for(int i=hd[now];i;i=e[i].nex){
		if(e[i].to!=f){
			if(dep[e[i].to]){
				s=now,t=e[i].to;
				continue;
			}
			dfs(e[i].to,now);
			dp[now]+=dp[e[i].to];
		}
	}
}
void get_tree_ans(){
	if(dp[1]){printf("-1\n");exit(0);}
	for(int i=1;i<=n;i++)ans+=abs(dp[i]);
	printf("%d\n",ans);
}
void jihuan(){
	if(dp[1]%2){printf("-1\n");exit(0);}
	int tmp=-dp[1]/2;
	ans=abs(tmp);
	for(int i=s;i;i=fa[i])dp[i]+=tmp;
	for(int i=t;i;i=fa[i])dp[i]+=tmp;
	for(int i=1;i<=n;i++)ans+=abs(dp[i]);
	printf("%d\n",ans);
}
void ouhuan(){
	if(dp[1]){printf("-1\n");exit(0);}
	for(int i=t;i!=s;i=fa[i])q[++Top]=dp[i],dep[i]=0;
	sort(q+1,q+Top+1);
	int mid=q[(Top+1)/2];
	ans=abs(mid);
	for(int i=1;i<=n;i++)if(dep[i])ans+=abs(dp[i]);
	for(int i=1;i<=Top;i++)ans+=abs(q[i]-mid);
	printf("%d\n",ans);
}
int main(){
	// freopen("testdata.in","r",stdin);
	// freopen("1.out","w",stdout);
	int x,y;
	n=rd(),m=rd();
	for(int i=1;i<=m;i++){
		x=rd(),y=rd();
		adde(x,y),adde(y,x);
	}
	dfs(1,0);
	if(m==n-1){get_tree_ans();return 0;}
	if((dep[t]-dep[s])%2==0)jihuan();
	else ouhuan();
	// printf("%.2lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int main() {
    int n; cin >> n;
    int ans = 1;
    while (ans*2 <= n) {
        ans *= 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3076
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <bitset>
    #include <set>
    #include <map>
    #include <string>
    #include <cmath>
    #include <ctime>
    #include <queue>
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    #define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
     
    const ll SIZE = 1000, INF = 1e9 * 1e9, MOD = 1e9 + 7;
     
    vector<ll> vec;
     
    bool check(int m) {
    	vector<pair<ll, ll>> s;
    	s.push_back({ 0, 0 });
     
    	for (int i = 1; i < vec.size(); i++) {
    		if (vec[i] > vec[i - 1]) {
    			continue;
    		}
    		else {
    			while (s.back().first > vec[i]) s.pop_back();
     
    			if (s.back().first < vec[i]) {
    				s.push_back({ vec[i], 2 });
    				if (m == 1) return false;
    				continue;
    			}
    			if (s.back().first == vec[i]) {
    				ll pr = vec[i];
    				while (s.size() >= 1 && s.back().second == m && s.back().first == pr) {
    					s.pop_back();
    					pr--;
    				}
    				if (pr <= 0) return false;
    				if (s.back().first == pr) s.back().second++;
    				else {
    					if (m == 1) return false;
    					s.push_back({ pr, 2 });
    				}
    			}
    		}
    	}
    	return true;
    }
     
    signed main() {
    	fastInp;
     
    	ll n;
    	cin >> n;
    	vec.resize(n);
    	for (int i = 0; i < n; i++) cin >> vec[i];
     
    	ll l = 0, r = 2e5;
    	while (r - l > 1) {
    		ll mid = (l + r) / 2;
    		if (check(mid)) {
    			r = mid;
    		}
    		else {
    			l = mid;
    		}
    	}
    	
    	cout << r;
    	return 0;
    }

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    int ans = 0;
    for(int i = 0; i < n-2; i++){
        if((p[i] < p[i+1] && p[i+1] < p[i+2]) || (p[i] > p[i+1] && p[i+1] > p[i+2])) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
ll mod=1e9+7;

int main()
{
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<s.length();++i)
    {
        if(s[i]!=t[i])
            ans++;
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
#define int long long
#define rep1(i,a,b) for(int i=a;i<b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
#define mod 1000000009
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int pow(int p,int r,int m){
	int ans=1;
	while(r>0){
     if(r&1){
		 ans=((ans%m)*(p%m))%m;
	 }
	 r=r>>1;
     p=((p%m)*(p%m))%m;
	}
	return ans;
}
signed main() {
	garou;
	int x;
	cin>>x;
	if(x==1)
	cout<<0;
	else if(x==0)
	cout<<1;
}

Measured memory_bytes: 3636
N = int(input())
S = input()

sum = 0
for i in range(1, N):
    if(S[i] == 'E'):
        sum += 1
ans = sum
for i in range(1, N):
    if(S[i - 1] == 'W'):
        sum += 1
    if(S[i] == 'E'):
        sum -= 1
    ans = min(ans, sum)
print(ans)

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
using ll=long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    ll ret=a[0];
    for(int i=1;i<n;i++){
        if(1000000000000000000/ret<a[i]){
            cout<<-1<<endl;
            return 0;
        }
        ret*=a[i];
    }
    if(ret>1000000000000000000){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ret<<endl;
}


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

signed main(){
  int n;cin>>n;
  if(n&1){
    cout<<0<<endl;
    return 0;
  }
  int ans=0;
  for(int i=10;;i*=5){
    ans+=n/i;
    if(i>n)break;
  }
  cout<<ans<<endl;
}


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

int main(){
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> ans(N + 1, 0);
    for(int i = 1; i <= N; i++){
        for(int j = i+1; j <= N; j ++){
            int temp = min(abs(j - i), min(abs(X - i) + 1 +abs(Y -j), abs(X - j) + 1 + abs(Y - i)));
            ans[temp]++;
        }
    }
    for(int i = 1; i < N; i++){
        cout << ans.at(i) <<endl;
    }
    
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define X first
#define Y second
#define INF 1000 * 1000 * 1000
#define LL long long
#define LINF INF * (LL)INF
#define PB push_back
#define SZ(a) ((LL)a.size())
#define INVALID 2392139
const LL MAX = 300005;
const LL minim = -1000 * 1000 - 1;
const LL mod = 1000 * 1000 * 1000 + 7;
const LL zsuv = MAX;
using namespace std;
using namespace __gnu_pbds;
int n;
int main()
{
	cin >> n;
	cout << (n - 2) * 180;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  for(int i=0;i<n-2;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

const Inf = 1 << 60

func main() {
	N, M, R := ReadInt(), ReadInt(), ReadInt()
	r := ReadInts(R)
	for i := 0; i < R; i++ {
		r[i]--
	}
	d := make([][]int, N)
	for i := 0; i < N; i++ {
		d[i] = make([]int, N)
		for j := 0; j < N; j++ {
			d[i][j] = Inf
		}
		d[i][i] = 0
	}
	for i := 0; i < M; i++ {
		a, b, c := ReadInt()-1, ReadInt()-1, ReadInt()
		d[a][b] = c
		d[b][a] = c
	}
	for k := 0; k < N; k++ {
		for i := 0; i < N; i++ {
			for j := 0; j < N; j++ {
				d[i][j] = Min(d[i][j], d[i][k]+d[k][j])
			}
		}
	}

	rIndices := make([]int, R)
	for i := 0; i < R; i++ {
		rIndices[i] = i
	}
	min := Inf
	for NextPermutation(rIndices) {
		dist := 0
		for i := 0; i < R-1; i++ {
			u := r[rIndices[i]]
			v := r[rIndices[i+1]]
			dist += d[u][v]
		}
		min = Min(min, dist)
	}
	fmt.Println(min)
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

func NextPermutation(xs []int) bool {
	k := len(xs) - 2
	for ; k >= 0 && xs[k] >= xs[k+1]; k-- {
	}
	if k < 0 {
		return false
	}
	l := len(xs) - 1
	for ; xs[k] > xs[l]; l-- {
	}
	xs[k], xs[l] = xs[l], xs[k]
	for l, r := k+1, len(xs)-1; l < r; {
		xs[l], xs[r] = xs[r], xs[l]
		l++
		r--
	}
	return true
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 3208
from collections import deque
import sys
sys.setrecursionlimit(10 ** 7)
n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
 
 
colors = [0] * n
def dfs(v, color):
    colors[v] = color
    for to in edges[v]:
        if colors[to] == color:
            return False
        if colors[to] == 0 and (not dfs(to, -color)):
            return False
 
    return True
 
if dfs(0, 1):
    x = colors.count(1)
    print(x * (n - x) - m)
 
else:
    print(n * (n - 1) // 2 - m)

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

int main(){
  int a, b;
  cin >> a >> b;
  int i = 1;
  for(int i=1; i<=10000000; i++){
    if(i*8/100 == a && i*10/100 == b){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mk make_pair
#define PII pair<ll,int>
#define PB push_back
const int maxn=4e3+9;
const int mod=998244353;
vector<int>rr,cc;
int main()
{
	int n,m,k,r[10]={0},c[10]={0},ans=0,cnt=0;
	char s[10][10];
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)if(s[i][j]=='#')cnt++,r[i]++,c[j]++;
	for(int i=0;i<(1<<n);i++)
	{
		rr.clear();
		int sum=cnt;
		int now=1,ss=i;
		while(ss)
		{
			if(ss&1)sum-=r[now],rr.PB(now);
			now++;
			ss>>=1;
		}
		for(int j=0;j<(1<<m);j++)
		{
			int sum1=sum;
			cc.clear();
			now=1,ss=j;
			while(ss)
			{
				if(ss&1)sum1-=c[now],cc.PB(now);
				now++;
				ss>>=1;
			}
			for(int j:rr)
			{
				for(int k:cc)
				{
					sum1+=(s[j][k]=='#'?1:0);
				}
			}
			if(sum1==k)ans++;
//			cout<<"?"<<i<<' '<<j<<' '<<sum<<endl;	
		}
		
	}
	printf("%d\n",ans);
}

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

using namespace std;

int main()
{
    int n;
    int step = 0, maxStep = 0, buf = 0;

    cin >> n;
    for(int i = 0; i < n; ++i) {
        int h;
        cin >> h;

        if(buf >= h) ++step;
        else step = 0;

        maxStep = max(maxStep, step);
        buf = h;
    }

    cout << maxStep << '\n';
}

Measured memory_bytes: 256
import math

N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

MOD = 1000000007

dic1 = {}
a_zero = 0
b_zero = 0
both_zero = 0

for a, b in AB:
    if a == 0 and b != 0:
        a_zero += 1
    elif a != 0 and b == 0:
        b_zero += 1
    elif a == 0 and b == 0:
        both_zero += 1
    else:
        g = math.gcd(a, b)
        a //= g
        b //= g

        if b < 0:
            a, b = -a, -b

        if (a, b) in dic1:
            dic1[(a, b)] += 1
        else:
            dic1[(a, b)] = 1

pair = []
used = set()

for key, val in dic1.items():
    if key in used:
        continue

    a, b = key
    used.add((a, b))
    cnt = 0

    if a < 0:
        c, d = -b, -a
    else:
        c, d = b, a

    if (-c, d) in dic1:
        cnt += dic1.get((-c, d), 0)
        used.add((-c, d))

    pair.append((val, cnt))


all_cnt = 1
for cnt1, cnt2 in pair:
    all_cnt *= pow(2, cnt1, MOD) + pow(2, cnt2, MOD) - 1
    all_cnt %= MOD

if a_zero != 0 or b_zero != 0:
    all_cnt *= pow(2, a_zero, MOD) + pow(2, b_zero, MOD) - 1
    all_cnt %= MOD

all_cnt += both_zero
all_cnt %= MOD

print((all_cnt - 1) % MOD)


Measured memory_bytes: 122108
N,W = map(int,input().split())
table = [ list(map(int,input().split(" "))) for i in range(N)]
N += 1
W += 1
dp = [[0 for i in range(W)] for j in range(N)]

for i in range(1,N):
    for j in range(W):
        if(j- table[i-1][0] >= 0):
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-table[i-1][0]]+table[i-1][1])
        else:
            dp[i][j] = dp[i-1][j]


print(dp[N-1][W-1])


Measured memory_bytes: 171784