akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define cer(x) cerr << x <<endl
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define pb push_back
#define MOD 1e9+7
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
template<class T>inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<class T>inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

int main()
{
	int n; cin >> n;
	vector <vector<pair<int, bool>>>table;
	rep(i, n)
	{
		int a; cin >> a;
		vector<pair<int, bool>> tmp;
		rep(j, a)
		{
			int x, y; cin >> x >> y;
			bool h = y; x--;
			auto p = make_pair(x, h);
			tmp.pb(p);
		}
		table.pb(tmp);
	}
	int ans = 0;
	rep(i, (1 << n))
	{
		bool contr = false;
		rep(j, n)
		{
			if (i & (1<<j))
			{
				for (auto e : table[j])
				{
					if (((i & (1 << e.first)) && !e.second)|| (!(i & (1 << e.first)) && e.second))
					{
						contr = true;
						break;
					}
				}
			}
			if (contr)break;
		}
		if (!contr)
		{
			int c = 0;
			rep(j, n)if (i & (1 << j))c++;
			chmax(ans, c);
		}
	}
	co(ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayDeque;
import java.util.Queue;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        Queue<String> queue = new ArrayDeque<>();
        int i,k;

        while(true)
        {
            String input = sc.next();

            if(input.equals("-")) break;
            
            String[] binput = input.split("");

            for(i=0; i<binput.length; i++) queue.add(binput[i]);

            int m = sc.nextInt();
            int h;
            for(i=0; i<m; i++)
            {
                h = sc.nextInt();
                for(k=0; k<h; k++) queue.add(queue.poll());
            }

            //for(i=0; i<queue.length; i++) System.out.printf(queue.poll());
            for(String a : queue) System.out.printf("%s",a);
            System.out.printf("\n");
            queue.clear();
        }
        sc.close();
    }
}


Measured memory_bytes: 26652
/**
 * Created at 1:14 on 2019/03/06
 */

import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  static int N;

  public static void main(String[] args) {

    int n = sc.nextInt();
    N = n/2;

    ArrayList<Integer> a = new ArrayList(N);
    ArrayList<Integer> b = new ArrayList(N);

    for (int i=0; i<N; i++) {
      a.add(sc.nextInt());
      b.add(sc.nextInt());
    }

    ArrayList<Integer[]> rankingA = getRanking(a); //[0] 個数 [1] 数値
    ArrayList<Integer[]> rankingB = getRanking(b);

    if (!rankingA.get(0)[1].equals(rankingB.get(0)[1])) {
      System.out.println(2 * N - rankingA.get(0)[0] - rankingB.get(0)[0]);
    } else {
      System.out.println(2 * N - Math.max(
              rankingA.get(0)[0] + rankingB.get(1)[0],
              rankingA.get(1)[0] + rankingB.get(0)[0]
      ));
    }

  }

  static ArrayList<Integer[]> getRanking(ArrayList<Integer> list) {
    ArrayList<Integer[]> ranking = new ArrayList(N);
    list.sort(null);
    for (int i=0; i<N;) {
      for (int j=i+1; j<=N; j++) {
        if (j == N || !list.get(j).equals(list.get(i))) {
          ranking.add(new Integer[]{j-i, list.get(i)});
          i = j;
          break;
        }
      }
    }

    ranking.sort((x, y) -> y[0]-x[0]);

    if (ranking.size() == 1) {
      ranking.add(new Integer[]{0, -1});
    }

    return ranking;
  }

}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int x,y;
    x = 0;
    y = 0;
    for(int i = 0; i < n - 1; i++){
        if(a[i] >= a[i+1]){
            x++;
        }
        else{
            y = max(y,x);
            x = 0;
        }
        y = max(y,x);
    }
    cout << y;
}


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

using namespace std;



int main()
{
	int A, B, C, K;

	cin >> A >> B >> C >> K;

	int max_n = max(A, B);
	max_n = max(max_n, C);

	long long ans = A + B + C + max_n * pow(2,K) - max_n;

	cout << ans;

	return 0;
}



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

using namespace std;

using ll = long long;
using vll = vector<ll>;

void A() {
  ll num;
  scanf("%lld", &num);
  printf("%lld\n", (num % 1000 == 0) ? 0 : (1000 - (num % 1000)));
}

void B() {
  string line;
  getline(cin, line);
  ll subs = stoll(line);
  ll ac = 0, wa = 0, tle = 0, re = 0;

  for (auto i = 0; i < subs; ++i) {
    getline(cin, line);
    if (line.compare("AC") == 0) {
      ac++;
    } else if (line.compare("TLE") == 0) {
      tle++;
    } else if (line.compare("WA") == 0) {
      wa++;
    } else {
      re++;
    }
  }

  cout << "AC x " << ac << "\n";
  cout << "WA x " << wa << "\n";
  cout << "TLE x " << tle << "\n";
  cout << "RE x " << re << "\n";
}

void D() {
  ll n;
  scanf("%lld", &n);
  vll nums;
  for (auto i = 0; i < n; ++i) {
    ll num;
    scanf("%lld", &num);
    nums.push_back(num);
  }

  sort(nums.begin(), nums.end(), greater<ll>());
  ll sum_until = 0;
  if (nums.size() % 2 == 0) {
    sum_until = nums.size() / 2;
  } else {
    sum_until = nums.size() / 2;
  }

  ll index = 0;
  ll sum = 0;
  for (auto i = 0; i < sum_until; ++i) {
    sum += nums[i];
    index++;
  }

  ll a_i = 1;
  while (index < n - 1) {
    sum += nums[a_i++];
    index++;
  }

  cout << sum << "\n";
}

int main() {
  D();
  return 0;
}


Measured memory_bytes: 5392
import java.util.*;
import java.io.*;
 
public class Main{
	public static long decrease(int[] c, int D, int[] last){
		long sum = 0;
		for(int j = 0; j < 26; j++){
			sum += c[j]*((D+1)-last[j]);
		}
		return sum;
	}
    
	public static void main(String[] $){
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int[] c = new int[26];
		for(int i = 0; i < 26; i++){
			c[i] = sc.nextInt();
		}
		int[][] s = new int[D][26];
		for(int i = 0; i < D; i++){
			for(int j = 0; j < 26; j++){
				s[i][j] = sc.nextInt();
			}
		}
		int[][][] dplast = new int[D+1][27][26];
		long satisfact = 0;
		long[][] dp = new long[D+1][27];
		int[][] dpsentaku = new int[D+1][27];

		for(int i = 0; i < D; i++){
			for(int j = 0; j < 26; j++){
				if(dp[i][j+1]-decrease(c, i, dplast[i+1][j+1])+s[i][j] < dp[i+1][j]){
					dp[i+1][j+1] = dp[i+1][j];
					dpsentaku[i+1][j+1] = dpsentaku[i+1][j];
					dplast[i+1][j+1] = dplast[i+1][j]; 
				}else{
					dp[i+1][j+1] = decrease(c, i, dplast[i+1][j+1])+s[i][j];
					dpsentaku[i+1][j+1] = j+1;
					dplast[i+1][j+1][j] = i+1;
				}
			}
		}
		for(int i = 0; i < D; i++){
			System.out.println(dpsentaku[i+1][26]);
		}
		
	}
} 

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;

int main(){ 
    ll a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;

    if(v <= w) cout << "NO" << endl;
    else if( ceil( (double)(abs(a-b)) / (double)(v-w) ) <= t) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
int main(int argc, const char *argv[])
{
  char s[100001];
  int n;
  scanf("%s", s);
  n = (int)strlen(s);

  int count1=0, count2=0;
  for (int i = 0; i < n; i++) {
    if(s[i] != (i % 2 ? '0' : '1'))
      count1++;
    if(s[i] != (i % 2 ? '1' : '0'))
      count2++;
  }
  printf("%d\n", count1 > count2 ? count2 : count1);
  return 0;
}

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

int zeta(int i){
    if(i<0)i*=-1;
    return i;
}

int main(){
    long N,K;
    cin>>N>>K;
    long x[N+1];
    for(int i=0;i<N;i++)cin>>x[i];
    x[N]=K;

    sort(x,x+N+1);
    long GAP[N];
    for(int i=0;i<N;i++)GAP[i]=x[i+1]-x[i];
    sort(GAP,GAP+N);

    long ans;
    for(int i=GAP[0];i>0;i--){
        bool b=true;
        for(int j=0;j<N;j++){
            if(GAP[j]%i!=0){
                b=false;
                break;
            }
        }
        if(b){
            ans=i;
            break;
        }
    }
    cout<<ans<<endl;
}

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

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

    int i = 0, ans = 0;
	while (i < n) {
		int j = i;

		while (s[i] == s[j] && j < n) {
			j++;
		}
		ans++;
		i = j;
	}

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

Measured memory_bytes: 512
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#define il inline
#define ll long long
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}

int main(){
	int n=ci();
	int mn= 1e9, cnt= 0;
	rep(i,1,n){
		int x=ci();
		if( x<mn ){
			cnt++;
			mn=x;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 888
from collections import Counter
N1 = int(input())
a = [input() for i in range(N1)]

N2 = int(input())
b = [input() for i in range(N2)]

counterA = Counter(a)
counterB = Counter(b)

counterA.subtract(counterB)
for c, d in counterA.most_common(1):
    print(max(0,d))

Measured memory_bytes: 3316
w=[ "AKIHABARA","KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR","KIHBARA","KIHABRA","KIHABAR","AKIHBRA","AKIHBAR","AKIHABR","KIHBRA","KIHBAR","KIHABR","AKIHBR","KIHBR"]
print(["NO","YES"][input() in w])

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,M,aa = 1000000,bb = 1000000;
  cin >> A >> B >> M;
  vector<int>a(A);
  vector<int>b(B);
  for(int i=0; i<A; i++){
    cin >> a[i];
    aa = min(aa,a[i]);
  }
  for(int i=0; i<B;i++){
    cin >> b[i];
    bb = min(bb,b[i]);
  }
  int abab = aa+bb,qupon = 1000000;
  for(int i=0; i<M; i++){
    int x,y,z;
    cin >> x >> y >> z;
    qupon = min(a[x-1] + b[y-1] - z,qupon);
  }
  cout << min(abab,qupon) << endl;            
}

Measured memory_bytes: 4048
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;
map<int,int> mp;
struct Edge{
  int v, cost;
};
vector<vector<Edge > > G;
bool used[100005];
bool dfs(int dist, int u){
  used[u] = true;
  bool ok = true;
  for(auto e : G[u]){
    if(mp[e.v] != 0 && mp[e.v] != dist + e.cost){
      return false;
    }
    mp[e.v] = dist + e.cost;
    if(used[e.v]) continue;
    ok &= dfs(mp[e.v], e.v);
  }
  return ok;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  G.resize(N,vector<Edge>());
  REP(i,M){
    int L, R, D;
    cin >> L >> R >> D;
    L--;R--;
    G[R].push_back({L, -D});
    G[L].push_back({R, D});
  }
  bool ok = true;
  REP(i,N){
    if(used[i]) continue;
    mp.clear();
    mp[i] = 0;
    ok &= dfs((int)1e9 + 3, i);
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 18048
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    long long int a[100]={0};
    a[0]=2;
    a[1]=1;
    int i;
    for(i=2;i<=n;i++)
    {
        a[i]=a[i-1]+a[i-2];
    }
    printf("%lld",a[n]);
    return 0;
}


Measured memory_bytes: 128
n=int(input())
P=list(map(int,input().split()))
cnt=0
for i in range(n-1):
    if P[i]==i+1:
        tmp=P[i]
        P[i]=P[i+1]
        P[i+1]=tmp
        cnt+=1
if P[n-1]==n:
    cnt+=1
print(cnt)

Measured memory_bytes: 14008
# Disjoint Set: Union Find Tree
p = []
rank = []

def makeSet(x):
    global p, rank
    p.append(x)
    rank.append(0)

def findSet(x):
    global p
    if x != p[x]:
        p[x] = findSet(p[x])
    return p[x]

def link(x, y):
    global p, rank
    if rank[x] > rank[y]:
        p[y] = x
    else:
        p[x] = y
        if rank[x] == rank[y]:
            rank[y] += 1

def union(x, y):
    link(findSet(x), findSet(y))    

def same(x, y):
    if findSet(x) == findSet(y):
        return 1
    else:
        return 0   

[n, q] = list(map(int, input().split()))
for i in range(n):
    makeSet(i)

for i in range(q):
    [com, x, y] = list(map(int, input().split()))
    if com == 0:
        union(x, y)
    else:
        print(same(x, y))


Measured memory_bytes: 6164
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<ll,ll>
#define endl "\n"
#define MAXN 100005
using namespace std;

ll n,m,arr[MAXN],u,v;
map<ll,ll> mg;
vector<ll> adj[MAXN];

void solve()
{
	cin>>n>>m;
	for(ll i=1;i<=n;i++) cin>>arr[i];
	while(m--)
	{
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
		if(arr[u]>arr[v]) mg[u]++;
		else if(arr[v]>arr[u]) mg[v]++;
	}
	ll cnt=0;
	for(ll i=1;i<=n;i++)
	{
		if(adj[i].size()==0 || mg[i]==adj[i].size())
			cnt++;
	}
	cout<<cnt<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
}


Measured memory_bytes: 15688
s = list(input())

sc = -1
sf = -1

for i in range(len(s)):
    if s[i] == "C":
        sc = i
    elif s[i] == "F":
        sf = i

if (sc == -1) or (sf == -1):
    print("No")
elif sc < sf:
    print("Yes")
else:
    print("No")


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

int N, M, R;
vector<vector<int>> d(300, vector<int>(300, 1e9));

void warshall_floyd() {
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int main() {
    cin >> N >> M >> R;
    vector<int> r(R);
    for (int i = 0; i < R; i++) {
        int x;
        cin >> x;
        r[i] = x - 1;
    }
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    warshall_floyd();
    int ans = 1e9;
    sort(r.begin(), r.end());
    do {
        int sum = 0;
        for (int i = 1; i < R; i++) {
            sum += d[r[i - 1]][r[i]];
        }
        ans = min(ans, sum);
    } while (next_permutation(r.begin(), r.end()));
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] map = new int[n][n];
		long count=0;
		for(int i = 0; i<n; i++){
			for(int j = 0; j<n; j++){
				map[i][j]=sc.nextInt();
			}
		}
		boolean y=true;
		for(int i = 0; i<n; i++){
			for(int j = 0; j<n; j++){
				for(int k = 0; k<n; k++){
					if(i!=j){
						if(map[i][k]+map[k][j]<map[i][j]){
							System.out.println(-1);
							return;
						}else if(map[i][k]+map[k][j]==map[i][j] &&( k!=i && k!=j )){
							y=false;
						}
					}
				}
				if(y){
					count+=map[i][j];
				}
				y=true;
			}
		}
		System.out.println(count/2);
	}
}

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

int main(){
	int a,b;
	cin>>a>>b;
	if(a<b)cout<<"a < b"<<endl;
	if(a>b)cout<<"a > b"<<endl;
    if(a==b)cout<<"a == b"<<endl;
    return 0;
}



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

int main() {
  long long n,k,ans=0;
  cin>>n>>k;
  for(int i=k;i<n+2;i++){
    ans=(ans+i*(n-i+1)+1)%1000000007;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) { return a * b / GCD(a, b); }


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

    int two = 0;
    int four = 0;
    int odd = 0;

    rep(i, n) {
        ll a;
        cin >> a;
        if (a % 4 == 0) four++;
        else if (a % 2 == 0) two++; 
        else odd++;
    }

    if (!two) Yes(four + 1 >= odd);
    else Yes(four >= odd);
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(void) {
	string s, t;
	cin >> s >> t;

	vector<int> a, b;
	
	for (int i = 0; i < s.size(); i++) {
		bool flag = false;
		for (int j = 0; j < s.size(); j++) {
			if (j == i) continue;
			if (s[i] == s[j]) {
				a.push_back(j);
				flag = true;
				break;
			}
		}
		if (!flag) a.push_back(i);
	}

	for (int i = 0; i < t.size(); i++) {
		bool flag = false;
		for (int j = 0; j < t.size(); j++) {
			if (j == i) continue;
			if (t[i] == t[j]) {
				b.push_back(j);
				flag = true;
				break;
			}
		}
		if (!flag) b.push_back(i);
	}

	if (a == b) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 2940
#include <iostream>
#include <ctype.h>
using namespace std;
int main()
{
	char s1[10], s2[10], s3[10];

	cin >> s1 >> s2 >> s3;

	int n = 'A' - 'a';
	cout << (char)(s1[0] + n);
	cout << (char)(s2[0] + n);
	cout << (char)(s3[0] + n);
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);

		int x=sc.nextInt();		//整数x
		int n=sc.nextInt();		//数字列の長さ

		ArrayList<Integer>array=new ArrayList<>();
		for(int i=0;i<n;i++) {
			array.add(sc.nextInt());
		}
		
		for(int i=0;i<100;i++) {
			if(!array.contains(x-i)) {
				System.out.println(x-i);
				break;
			}else if(!array.contains(x+i)) {
				System.out.println(x+i);
				break;
			}
			
		}
    }
}

Measured memory_bytes: 27260
N = int(input())
flag = 0
ans = "No"

for i in range(N):
  tmp1, tmp2 = list(map(int, input().split()))
  if tmp1 - tmp2 == 0:
    flag += 1
  else:
    flag = 0
  if ans == "Yes" or flag >= 3:
    ans = "Yes"
print(ans)

Measured memory_bytes: 9060
n=int(input())
# p^74 p^2q^24 p^2q^4r^4 p^4q^14 
# 2^74 q=2,3,5           q=2,3,5,7,
#3 5 5
#75,5 15,3 25,3 5 5 
from collections import defaultdict
memo=defaultdict(lambda:-1)

def f(x):
    if memo[x]!=-1:return memo[x]
    ret=0;temp=n
    while temp:
        temp//=x
        ret+=temp
    memo[x]=ret
    return ret
ans=0
primes=[2,3]
for i in range(5,101,6):
    for p in primes:
        if i%p:continue
        break
    else:primes.append(i)
    i+=2
    for p in primes:
        if i%p:continue
        break
    else:primes.append(i)
di=[i**2 for i in primes]
qu=[j**2 for j in di]
for p in primes:
    if f(p)>=74:ans+=1
    else:break
def g(a,b):
    global ans
    for p in primes:
        if f(p)>=a:
            for q in primes:
                if f(q)>=b:
                    if q!=p:ans+=1
                    else:continue
        else:break
    return 0
g(2,24)
g(4,14)

for q in range(len(qu)):
    for r in range(q+1,len(qu)):
        a,b=qu[q],qu[r]
        if not (f(primes[q])>=4 and f(primes[r])>=4):continue
        for i,d in enumerate(di):
            if d**2 not in {a,b} and f(primes[i])>=2:ans+=1
print(ans)

Measured memory_bytes: 67804
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007LL

typedef long long ll;
typedef pair<ll,ll> P;

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

	string str;cin >> str;
	ll ans = 0;
	ll now = 0;
	REP(i, str.size()){
		if(str[i] == 'R')now++;
		else now = 0;

		ans = max(ans, now);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>//万能头文件 
using namespace std;

int main(){
	int sum=0,max=0;
	int n;
	cin>>n;
	string a;
	cin>>a; 
	for(int i=0;i<a.length();++i){
		if(a[i]=='I')sum++;
		else sum--;
		if(sum>max)max=sum;
	}
	cout<<max<<endl;
	return 0;
} 

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

template <class T>
inline void read(T &x)
{
	static char ch; 
	while (!isdigit(ch = getchar())); 
	x = ch - '0'; 
	while (isdigit(ch = getchar()))
		x = x * 10 + ch - '0'; 
}

template <class T>
inline void tense(T &x, const T &y)
{
	if (x > y)
		x = y; 
}

template <class T>
inline void relax(T &x, const T &y)
{
	if (x < y)
		x = y; 
}

typedef std::pair<int, int> pii; 

const int MaxN = 2e5 + 5; 

struct node
{
	int l, r, val; 

	node(){}
	node(int a, int b, int c):
		l(a), r(b), val(c) {}

	inline bool operator < (const node &rhs) const
	{
		if (val != rhs.val)
			return val > rhs.val; 
		if (r != rhs.r)
			return r < rhs.r; 
		return l > rhs.l;  
	}

	inline void operator -= (const node &rhs)
	{
		if (rhs.l <= l && r <= rhs.r)
			return (void)(r = l - 1); 
		if (rhs.l >= l)
			tense(r, rhs.l - 1); 
		if (rhs.r <= r)
			relax(l, rhs.r + 1); 
	}
}; 

int n, a[MaxN]; 
std::vector<node> f[MaxN]; 

int main()
{
	read(n); 
	for (int i = 1; i <= n; ++i)
		read(a[i]); 

	f[0].push_back(node(0, 0, 0)); 
	for (int i = 1; i <= n + 1; ++i)
	{
		std::vector<node> cur; 

		for (node lst : f[i - 1])
		{
			int l = lst.l, v = lst.val; 
			int tmin = std::min(l - 1, a[i] - a[i - 1] + l - 1); 
			int tmax = std::max(l - 1, a[i] - a[i - 1] + l - 1); 
			tense(tmax, a[i]); 

			if (tmin >= 0)
				cur.push_back(node(0, tmin, v + 2)); 
			if (tmin < tmax && tmax >= 0)
				cur.push_back(node(std::max(0, tmin + 1), tmax, v + 1)); 
			if (tmax < a[i])
				cur.push_back(node(tmax + 1, a[i], v)); 
		}

		std::sort(cur.begin(), cur.end()); 
		for (int j = 0; j < (int)cur.size(); ++j)
		{
			for (int k = 0; k < j; ++k)
				cur[k] -= cur[j]; 
		}

		for (int j = 0; j < (int)cur.size(); ++j)
			if (cur[j].l <= cur[j].r)
			{
				if (!f[i].empty() && f[i].rbegin()->val == cur[j].val)
					f[i].rbegin()->r = cur[j].r; 
				else
					f[i].push_back(cur[j]); 
			}
	}

	std::cout << f[n + 1][0].val << '\n'; 

	return 0; 
}

Measured memory_bytes: 18176
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<int, int> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    int N; cin>>N;
    vector<int> A(N+1);
    vector<int> B(N+1);
    REP(i,N+1) cin>>A[i];
    REP(i, N) cin>>B[i];
    long long cnt = 0;
    REP(i, N+1) cnt+=A[i];
    for(int i=N-1; i>=0; i--){
        if(B[i]>= A[i+1]){
            B[i] -= A[i+1];
            A[i+1] = 0;
            A[i] = max(0, A[i]-B[i]);
        }
        else{
            A[i+1] = max(0, A[i+1]-B[i]);
        }
    }
    long long res =0;
    REP(i, N+1) res+=A[i];
    cout <<cnt-res<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <math.h>
#include <stdbool.h>

int ASC( void *a,  void *b) {
	return strcmp(*(const char **)a, *(const char **)b);//降順
}
int GCD(int a, int b) {	//最大公約数
	if (b == 0) return a;
	else return GCD(b, a % b);
}
int min(int a, int b ) {
	if (a < b) {
		return a;
	}
	else
		return b;
}
int max(int a, int b) {
	if (a < b)
		return b;
	else
		return a;
}
int main(void)
{
	int n;
	scanf("%d",&n);
	if (n >= 30) {
		printf("Yes");
	}
	else
		printf("No");
	
	
	
	return 0;
}//pd pdp


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      ans = max(ans, abs(A[i] - A[j]));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;
ll n, a, b, c, d;

void solve() {
    ll diff = abs(b - a);
    rep(i, n) {
        if (i * c - (n - 1 - i) * d <= diff && diff <= i * d - (n - 1 - i) * c) {
            cout << "YES" << endl;
            return;
        }
    }
    cout << "NO" << endl;
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        cin >> n >> a >> b >> c >> d;
        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

void Swap(std::vector<int>& Heap, int IndexA, int IndexB)
{
	int Temp = Heap[IndexA - 1];
	Heap[IndexA - 1] = Heap[IndexB - 1];
	Heap[IndexB - 1] = Temp;
}

void MaxHeapify(std::vector<int>& Heap, unsigned int Index)
{
	unsigned int Left = 2 * Index;
	unsigned int Right = 2 * Index + 1;
	unsigned int Largest;
	if(Left <= Heap.size() && Heap[Left - 1] > Heap[Index - 1]){
		Largest = Left;
	}else{
		Largest = Index;
	}
	
	if(Right <= Heap.size() && Heap[Right - 1] > Heap[Largest - 1]){
		Largest = Right;
	}
	
	if(Largest != Index){
		Swap(Heap, Largest, Index);
		MaxHeapify(Heap, Largest);
	}
}

void BuildMaxHeap(std::vector<int>& Heap)
{
	for(unsigned int i = Heap.size() / 2; i > 0; --i){
		MaxHeapify(Heap, i);
	}
}

int main()
{
	int Count = 0;
	std::cin >> Count;
	std::vector<int> Heap(Count);
	for(int i = 0; i < Count; ++i){
		std::cin >> Heap[i];
	}
	
	BuildMaxHeap(Heap);
	
	for(int i = 0; i < Count; ++i){
		std::cout << " " << Heap[i];
	}
	std::cout << std::endl;
	
	return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    vector<int> a(N);
    REP(i, N) a[i] = i + 1;

    for(int i = 0; i < N - 1; i++) {
        for(int j = i + 1; j < N; j++) {
            int k = 0;
            while (true) {
                if(((i >> k) & 1 ) ^ ((j >> k) & 1 )) break;
                k++;
            }
            cout << k + 1 << (j == N - 1 ? "" : " ");
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 512
N, K = map(int, input().split())
Vlist = list(map(int, input().split()))
ret = 0
for l in range(min(N,K)+1):
    for r in range(min(N,K)-l+1):
        tem = Vlist[:l]+Vlist[N-r:]
        tem = sorted(tem)
        tem[:K-l-r] = [max(0, i) for i in tem[:K-l-r]]
        score = sum(tem)
        if ret < score:
            ret = score
print(ret)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
string str,ans;
int n,pos;

string saiki(int S){
  int k=1;
  string res,s;
  while(pos<(int)str.size()&&str[pos]!=')'&&(int)res.size()+S<=n){
    if('0'<=str[pos]&&str[pos]<='9') {
      k=0;
      while('0'<=str[pos]&&str[pos]<='9')k=k*10+str[pos++]-'0';
    }
    else if(str[pos]=='('){
      pos++;
      s=saiki(res.size()+S);
      for(int i=0;i<k&&res.size()+S<=n;i++)res+=s;
      pos++,k=1;
    }
    else {
      for(int i=0;i<k;i++) res+=str[pos];
      pos++,k=1;
    }
  }
  return res;
}

int main(){
  while(1){
    cin>>str>>n;
    if(str=="0"&&n==0)break;
    pos=0;
    ans="";
    ans=saiki(0);
    if(ans.size()<=n)cout<<0<<endl;
    else cout <<ans[n]<<endl;
  }
  return 0;
}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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



ULL m,n,arr[100002];

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

ULL findlcm()
{
    ULL ans = arr[0];
    for (int i = 1; i < n; i++)ans = (((arr[i] * ans)) /(gcd(arr[i], ans)));
    return ans;
}

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i;
    cin >> n >> m;
    for(i=0;i<n;i++)cin >> arr[i],arr[i]/=2ULL;
    ULL lcm=findlcm();
    for(i=0;i<n;i++)
    {
        if((lcm/arr[i])%2ULL == 0)
        {
            cout << "0";
            return 0;
        }
    }
    ULL ans=m/lcm;
    ans=(ans/2ULL)+(ans%2ULL);
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>

using namespace std;

typedef pair<int,int> P;
typedef long long ll;
typedef pair<int,P> PP;

int n,m;


int main()
{

	while(cin>>n>>m){
		if(n==0&&m==0)return 0;
		int h[2000];
		int w[2000];
		vector<int> a;
		vector<int> b;
		vector<P> c;
		vector<P> d;

		int sum=0;
		int hi,wi;
		for(int i=1;i<=n;i++){
			cin>>hi;
			sum+=hi;
			h[i]=sum;
		}
		sum=0;
		for(int i=1;i<=m;i++){
			cin>>wi;
			sum+=wi;
			w[i]=sum;
		}


		for(int i=0;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				a.push_back(h[j]-h[i]);
			}
		}

		for(int i=0;i<=m;i++){
			for(int j=i+1;j<=m;j++){
				b.push_back(w[j]-w[i]);
			}
		}


		sort(a.begin(),a.end());
		sort(b.begin(),b.end());

/*
		for(int i=0;i<a.size();i++){
			cout<<"a[i]"<<a[i]<<endl;
		}
		for(int i=0;i<b.size();i++){
			cout<<"b[i]"<<b[i]<<endl;
		}

*/
		c.push_back(P(a[0],1));
		d.push_back(P(b[0],1));

		for(int i=1;i<a.size();i++){
			if(a[i]==c[c.size()-1].first)c[c.size()-1].second++;
			else c.push_back(P(a[i],1));
		}

		/*
		cout<<endl;
		for(int i=0;i<c.size();i++){
			cout<<c[i].first<<"  "<<c[i].second<<endl;
		}
		cout<<endl;
		*/

		for(int i=1;i<b.size();i++){
			if(b[i]==d[d.size()-1].first)d[d.size()-1].second++;
			else d.push_back(P(b[i],1));
		}
		/*
		for(int i=0;i<d.size();i++){
			cout<<d[i].first<<"  "<<d[i].second<<endl;
		}
		*/

		int i=0,j=0;
		ll ans=0;
		while(i<c.size()&&j<d.size()){
			if(c[i].first==d[j].first){
				ans+=c[i].second*d[j].second;
				i++;j++;
			}
			else if(c[i].first<d[j].first)i++;
			else j++;
		}
		cout<<ans<<endl;
	}



	return 0;
}

Measured memory_bytes: 19716
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e5+100;
int mark[sz];
set<int> st;
int main()
{
    Khela
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n)
    {
        memset(mark,0,sizeof mark);
        int ara[n];
        st.clear();
        for(i=0;i<n;i++){
            cin>>ara[i];
            st.insert(ara[i]);
            ++mark[ara[i]];
        }
        int tot=st.size();
        vector<int> test;
        for(auto xx: st){
            if(mark[xx]>1) test.pb((mark[xx]-1)%2);
        }
        i=0,j=test.size()-1;
        while(i<j){
            p=min(test[i],test[j]);
            test[i]-=p,test[j]-=p;
            if(test[i]==0) ++i;
            if(test[j]==0) --j;
        }
        if(test.size()>0 && test[i]>0){
            tot-=test[i];
        }
        cout<<tot<<endl;
    }





}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	vector< vector<bool> > grid(h, vector<bool>(w, false));
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			if (s[j] == '#') {
				grid[i][j] = true;
			}
		}
	}
	vector< vector<int> > left(h, vector<int>(w, INT32_MAX)), right(h, vector<int>(w, INT32_MIN)), top(h, vector<int>(w, INT32_MAX)), bottom(h, vector<int>(w, INT32_MIN));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (!grid[i][j]) {
				left[i][j] = (j > 0)? min(left[i][j - 1], j): j;
			}
			if (!grid[i][w - 1 - j]) {
				right[i][w - 1 - j] = (w - 1 - j < w - 1)? max(right[i][w - j], w - 1 - j): w - 1 - j;
			}
		}
	}
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			if (!grid[j][i]) {
				top[j][i] = (j > 0)? min(top[j - 1][i], j): j;
			}
			if (!grid[h - 1 - j][i]) {
				bottom[h - 1 - j][i] = (h - 1 - j < h - 1)? max(bottom[h - j][i], h - 1 - j): h - 1 - j;
			}
		}
	}
	int max_num = -1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (grid[i][j]) {
				continue;
			}
			max_num = max(right[i][j] - left[i][j] + bottom[i][j] - top[i][j] + 1, max_num);
		}
	}
	cout << max_num << endl;
}

Measured memory_bytes: 63616
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,x;
int main()
{
    cin >> n;
    m=n;
    while (m>0)
    {
        x+=m%10;
        m/=10;
    }
    if (n%x==0)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[] nk = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = nk[0];
        int K = nk[1];
        string res = "";
        int r;
        int q = N;
        while (0 < q)
        {
            r = q % K;
            res += r.ToString();
            q /= K;
        }
        Console.WriteLine(string.Join("", res.Reverse()).Length);
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<62;
int main(){
    int n,d;
    cin>>n>>d;
    d= 2*d + 1;
    n = (d-1)+n;
    cout << n/d << endl;
    return 0;
}



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

int main() {
    int N; cin >> N;
    map<int, int> ma;
    rep(i, 0, N) {
        int a; cin >> a;
        ma[a]++;
    }
    int ans = 0;
    for(auto itr = ma.rbegin(); itr != ma.rend(); ++itr) {
        int v = itr -> first;
        int b = 1;
        while(b <= v) b *= 2;
        if(v == b - v) {
            ans += ma[v] / 2;
        } else {
            int n = min(ma[v], ma[b - v]);
            ma[b - v] -= n;
            ans += n;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<string> blue(n);
    for (int i = 0; i < n; i++) {
        cin >> blue[i];
    }
    int m;
    cin >> m;
    vector<string> red(m);
    for (int i = 0; i < m; i++) {
        cin >> red[i];
    }
 
    int ans = 0;
    auto calc = [&](string s) {
        int buf = 0;
        for (string t: blue) {
            if (t == s) buf++;
        }
        for (string t: red) {
            if (t == s) buf--;
        }
        return buf;
    };
 
    for (string t: blue) {
        ans = max(ans, calc(t));
    }
 
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    vector<int> a(N);
    map<string, int> color;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        if(a[i] < 400) {
            if(!color.count("gray")) color["gray"] = 1;
            else color["gray"]++;
        }
        else if(a[i] < 800) {
            if(!color.count("brown")) color["brown"] = 1;
                else color["brown"]++;
        }
        else if(a[i] < 1200) {
            if(!color.count("green")) color["green"] = 1;
            else color["green"]++;
        }
        else if(a[i] < 1600) {
            if(!color.count("cyan")) color["cyan"] = 1;
            else color["cyan"]++;
        }
        else if(a[i] < 2000) {
            if(!color.count("blue")) color["blue"] = 1;
            else color["blue"]++;
        }
        else if(a[i] < 2400) {
            if(!color.count("yellow")) color["yellow"] = 1;
            else color["yellow"]++;
        }
        else if(a[i] < 2800) {
            if(!color.count("orange")) color["orange"] = 1;
            else color["orange"]++;
        }
        else if(a[i] < 3200) {
            if(!color.count("red")) color["red"] = 1;
            else color["red"]++;
        }
        else {
            if(!color.count("free")) color["free"] = 1;
            else color["free"]++;
        }
    }
    if(!color.count("free")) cout << color.size() << ' ' << color.size() << endl;
    else cout << max(1, (int)color.size() - 1) << ' ' << color.size() - 1 + color["free"] << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;

set<int> st;
void divisor(int n){
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            st.insert(i);
            st.insert(n/i);
        }
    }
}
int gcd(int x, int y) {
    if (y == 0)return x;
    else return gcd(y, x % y);
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    set<int> st,ss;
    for(int i=1;i*i<=a;i++){
        if(a%i==0){
            st.insert(i);
            st.insert(a/i);
        }
    }
    for(int i=1;i*i<=b;i++){
        if(b%i==0){
            ss.insert(i);
            ss.insert(b/i);
        }
    }
    set<int> x;
    for(auto it:st){
        if(ss.count(it))x.insert(it);
    }
    //for(auto it:x)cout<<it<<' ';
    //cout<<endl;
    vector<int> g;
    for(auto it:x){
        if(g.size()==0)g.push_back(it);
        else{
            bool ok=true;
            for(auto num:g){
                if(gcd(num,it)!=1){
                    ok=false;
                    break;
                }
            }
            if(ok)g.push_back(it);
        }
    }
    //for(auto it:g)cout<<it<<' ';
    cout<<g.size()<<endl;

}

Measured memory_bytes: 1152
#include <ext/pb_ds/assoc_container.hpp> 	// Common file
#include <ext/pb_ds/tree_policy.hpp> 		// Including tree_order_statistics_node_update
#include<bits/stdc++.h>
#define int            		long long
#define x              		first
#define y              		second
#define all(aaa)       		(aaa).begin(),(aaa).end()
#define REP(i,sss,eee) 		for(int i=sss;i<=eee;++i)
#define pb             		push_back
#define pii            		pair<int,int>
#define vi             		vector<int>
#define speed          		ios_base::sync_with_stdio(0);cin.tie(0);
#define N              		1000000007
using namespace __gnu_pbds;
using namespace std;
template <class T>
T MAX(T a, T b){return ((a>b)?a:b);}
template <class T>
T MIN(T a, T b){return ((a<b)?a:b);}
template <class T>
T MOD(T a){return ((a>=0)?a:(-1*a));}
template <class T>
void SWAP(T &a,T &b){T temp=a;a=b;b=temp;}

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

long long ex(long long a, long long b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	long long tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
long long inv(long long k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
/*****************default********************/
int solve()
{
	int n;cin>>n;
	double fact=380000.0;
	double ans=0.00;
	REP(i,0,n-1)
	{
		string tmp;double val;
		cin>>val>>tmp;
		if(tmp=="JPY"){ans+=val;}
		else{
			ans+=(val*fact);
		}
	}
	printf("%.10lf\n",ans);
}
signed main(){
	speed
	int tt=1;
	//cin>>tt;
	while(tt--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

const MOD = 1000000007

func main() {
	sc := NewScanner()
	N, M := sc.nextInt(), sc.nextInt()
	breaked := make(map[int]bool)
	for i := 0; i < M; i++ {
		breaked[sc.nextInt()] = true
	}
	dp := make([]int, N+1)
	dp[0] = 1
	for now := 0; now < N; now++ {
		for next := now + 1; next <= N && next <= now+2; next++ {
			if !breaked[next] {
				dp[next] += dp[now]
				dp[next] %= MOD
			}
		}
	}
	fmt.Println(dp[N])
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,ans;
  ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    int h;
    cin>>h;
    if(h>a){ans+=h-a;}
    a=h;
  }
  cout<<ans;
}

Measured memory_bytes: 256