akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

// 最小公約数
long lcm(long a, long b) {
	return a / gcd(a, b) * b;
}*/

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

	ll h, w, k;
	cin >> h >> w >> k;

	// dp[i][j]:= jの高さでi番目にたどりつく可能性のある合計の本数
	// 2^7 = 128
	// 計算量 100 * 100 * 10 = 1e5 ちょうどいい
	vector<vector<ll>> dp(w, vector<ll>(h + 1, 0));

	dp[0][0] = 1;

	rep(j, h) {
		// 線を引く→隣は線を引けなくなる 全通りためす
		rep(i, w) {
			rep(bit, 1 << w - 1) {
				//cout << bit << endl;
				//bool next = true;
				bool can = true;
				// 数字が並んでたらアウト
				rep(l, w - 2) {
					//cout << (bit & (1 << i)) << " " << (bit & (1 << (i + 1)));
					if ((bit & (1 << l)) && (bit & (1 << (l + 1)))) {
						can = false;
						//cout << "ここでfalse";
					}
				}
				//cout << endl;
				if (!can) continue;

				/*
				// 同じのが紛れてる
				rep(i, w - 1) {
					if (bit & (1 << i)) {
						// 両端を入れ替える
						dp[i + 1][j + 1] += dp[i][j] % mod;
						//cout << j << "の高さで" << i << "と" << i + 1 << "を結ぶ";
						//next = false;
					}
					else {
						// そのまま下がる
						dp[i][j + 1] += dp[i][j] % mod;
						if (i == w - 2) // 最後の列だけ特別に処理
							dp[i + 1][j + 1] += dp[i + 1][j] % mod;
						//next = true;
						//cout << j << "の高さで" << i << "と" << i + 1 << "を結ばない";
					}
				}*/
				//cout << endl;

				if(i < w - 1 && (bit & (1 << i)))  dp[i + 1][j + 1] = (dp[i+1][j+1] + dp[i][j]) % mod;
				else if (i >= 1 && (bit & (1 << (i - 1)))) dp[i - 1][j + 1] = (dp[i - 1][j + 1] + dp[i][j]) % mod;
				else dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod;
			}
		}
	}

	//if (w == 1) cout << 1 << endl;
	//else 
	cout << dp[k - 1][h] % mod << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    set<string>s;
 for(int i=1;i<=n;i++)
 {
 string t;
 cin>>t;
 s.insert(t);
 }
 cout<<s.size()<<endl;
 return 0;
}

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

#define pb push_back
#define mp make_pair

typedef long long ll;

const ll mod = 1e9 + 7;

int n, m;
vector<int> e[10];
bool used[10];

int dfs(int x)
{
  if(used[x]) return 0;

  bool flag = true;
  for(int i = 1; i <= n; i++){
    if(i != x and !used[i]) flag = false;
  }
  if(flag) return 1;

  used[x] = true;
  
  int ret = 0;
  for(auto u : e[x]){
    ret += dfs(u); 
  }

  used[x] = false;

  return ret;
}

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

  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;

    e[a].pb(b);
    e[b].pb(a);
  }

  cout << dfs(1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>



int main(void) {
    int n, a, b, c, d, cmb;
    while (scanf("%d", &n) != EOF) {
        cmb = 0;
        for (a = 0; a <= 9; a++) {
            for (b = 0; b <= 9; b++) {
                for (c = 0; c <= 9; c++) {
                    for (d = 0; d <= 9; d++) {
                        if (a + b + c + d == n) cmb++;
                    }
                }
            }
        }
        printf("%d\n", cmb);
    }
    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<queue>	
#include<functional>
#include<climits>

using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long
#define pb push_back
#define PB push_back
#define lb lower_bound
#define LB lower_bound
#define ub upper_bound
#define UB upper_bound


//constant
const int MOD = 1000000007;
const int INF = INT_MAX / 2-1;
const double EPS = 1e-9;
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };

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

int w, h;
void dfs(int y, int x, vvi &a, vvi &p);

int main() {
	while (cin >> w >> h, w) {
		vvi a(h, vi(w, 0));
		vvi bp(h, vi(w, 0));
		vvi wp(h, vi(w, 0));
		string buf;
		REP(i, h) {
			cin >> buf;
			REP(j, w)
				if (buf[j] == 'B')
					a[i][j] = 1;
				else if (buf[j] == 'W')
					a[i][j] = -1;
		}
		REP(i,h)
			REP(j,w)
				if(a[i][j]==1)
					dfs(i, j, a, bp);
		REP(i, h)
			REP(j, w)
			if (a[i][j] == -1)
				dfs(i, j, a, wp);
		int bc = 0;
		int wc = 0;
		REP(i, h)
			REP(j, w)
			if (bp[i][j] && wp[i][j])
				continue;
			else if (bp[i][j])
				bc++;
			else if (wp[i][j])
				wc++;
		cout << bc << " " << wc << endl;

	}
	
	
}

void dfs(int y, int x, vvi &a, vvi &p) {
	REP(i,4)
		if(0<=y+dy4[i] && y+dy4[i]<h && 0<=x+dx4[i] && x+dx4[i] <w)
			if(!a[y+dy4[i]][x+dx4[i]] && !p[y+dy4[i]][x+dx4[i]])
				p[y + dy4[i]][x + dx4[i]] = 1, dfs(y + dy4[i], x + dx4[i], a, p);
	return;



}

Measured memory_bytes: 3204
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1e18 + 10;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    ll a, b, n; cin >> a >> b >> n;
    ll x = min(n, b-1);
    ll res = a*x/b - a*(x/b);
    cout << res << ln;
}


Measured memory_bytes: 3636
#include <stdio.h>
/*ABC 139 D*/

int main(void)
{
  int N;
  long count = 0;

  scanf("%d", &N);
  if (N == 1) {
    printf("0\n");
    return 0;
  }

  for (size_t i = 1; i < N; i++) {
    count += i;
  }

  printf("%ld\n", count);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  string s; cin>>s;
  int N = s.size();
  int r = 0;
  int cg = 0;
  int cp = 0;
  REP(i,N){
    if(s[i]=='g'){
      if(cp<cg){ cp++; r++;}
      else{ cg++;}
    }else{
      if(cp<cg){ cp++;}
      else{ cg++; r--;}
    }
  }
  cout << r;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

typedef long long ll;

ll N,K,Q,A[100100];
ll p[100100];

int main(void) 
{
    ll i;
    cin >> N >> K >> Q;
    for(i = 0; i < N; i++) {
        p[i] = 0;
    }
    for(i = 0; i < Q; i++) {
        cin >> A[i];
        p[A[i]-1] ++;
    }
    for(i = 0; i < N; i++) {
        cout << ((p[i] + K - Q > 0)?"Yes":"No") << endl;
    }
}



Measured memory_bytes: 2176
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

otozureta = []

otozureta2 = [0]
for i in range(n):
    otozureta.append(False)
otozureta[0] = True

flag = False
i = 0
loop = 0
looppoint = 0

while not flag:
    genzai = otozureta2[i]
    next = a[genzai] - 1
    otozureta2.append(next)

    if not otozureta[next]:
        otozureta[next] = True
        i = i + 1
    else:
        loop = i - otozureta2.index(next) + 1
        looppoint = otozureta2.index(next)
        flag = True

if k < looppoint:
    print(otozureta2[k] + 1)
else:
    print(otozureta2[((k - looppoint) % loop) + looppoint] + 1)

Measured memory_bytes: 32296
/*
 * 	Roses are red
 * 		Violets are blue
 * 			I cried
 * 				And so did you
 */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=1e9;
const int mod=998244353;
//const int mod=1000000007;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

int a[301][301];
int ptr[301];
int rej[301];
int cnt[301];
void solve() {
	int n,m;
	cin>>n>>m;
	int ans=n;
	rej[0]=1;
	fr(i,1,n) {
		fr(j,1,m)
				cin>>a[i][j];
	}
	fr(i,1,m) {
		fr(i,1,n) {
			if(rej[a[i][ptr[i]]]) {
				while(rej[a[i][ptr[i]]])
					ptr[i]++;
				cnt[a[i][ptr[i]]]++;
			}
		}
		int mm=0;
		fr(i,1,m)
			if(rej[i]==0&&cnt[mm]<cnt[i])
				mm=i;
		ans=min(ans,cnt[mm]);
		rej[mm]=1;
	}
	cout<<ans<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int t,d,l;
    cin >> t >> d >> l;
    if(t==0) return 0;
    int ans=0;
    int x;
    int c=0;
    for(int i=0;i<t;i++){
      if(c>0){
        c--;
        ans++;
      }
      cin >> x;
      if(x>=l){
        c=d;
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3056
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		int k=sc.nextInt();
		int s=sc.nextInt();
		int ans=0;
		for(int x=0; x<=k;x++) {
			for(int y=0;y<=k;y++) {
				int z=s-x-y;
				if(0<=z&&z<=k) {
					ans++;
				}
			}
		} 
		
        System.out.println(ans);
		
	}
	
	
	
	
//----------------------------------------------------------
	static int l_min(int[] a) {
		Arrays.sort(a);
		return a[0];
	}
	static int l_max(int[] a) {
		int l=a.length;
		Arrays.sort(a);
		return a[l-1];
	}
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	

}





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

struct UF {
  vector<int> par, rank;
  int N, M;
  UF(int n, int m) : par(n + m), rank(n + m, 0) {
    N = n; M = m;
    for (int i = 0; i < n + m; ++i) {
      par[i] = i;
    }
  }
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x); y = root(y);

    if (x == y) return;
    if (x >= N) {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
      return;
    }
    if (y >= N) {
      par[x] = y;
      if (rank[x] == rank[y]) rank[y]++;
      return;
    }
    if (rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UF uf(n, m);
  int res = 0;
  for (int i = 0; i < k; ++i) {
    int q, a, b;
    cin >> q >> a >> b;
    a--; b--;
    if (q == 1) {
      if (!uf.same(a, b) && (uf.root(a) >= n && uf.root(b) >= n)) {
        if (res == 0) res = i + 1;
      }
      uf.unite(a, b);
    } else {
      if (!uf.same(a, b + n) && uf.root(a) >= n) {
        if (res == 0) res = i + 1;
      }
      uf.unite(a, b + n);
    }

  }
  cout << res << endl;
}

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

int main()
{
  double N;
  cin >> N;
  double ans = 0.0;

  for (int i = 1;i<=N;i++){
    if (i % 2){
      ans += 1;
    }
  }
  ans = ans / N;
  
  cout << fixed << setprecision(11) << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,ans=0x3f3f3f3f,cnt1,cnt2;
string str;
int main()
{
	scanf("%d",&n);
	cin>>str;
	for(int i=0;i<n;i++)
		if(str[i]=='.') cnt2++;
	for(int i=0;i<n;i++)
	{
		ans=min(ans,cnt1+cnt2);
		if(str[i]=='#') cnt1++;
		else cnt2--;
	}
	ans=min(ans,cnt1+cnt2);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define endl enjoy_codeforces
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    int n;std::cin>>n;
    std::vector<int>a(26);
    while(n--){
        char c;std::cin>>c;
        a.at(c-'a')++;
    }
    long long mod=1'000'000'007;
    long long ans=1;
    for(int x:a){
        ans=ans*(x+1)%mod;
    }
    ans--;
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 256
N,K=map(int,input().split())
r = N//K
q = N%K
if K%2 == 0:
    if K//2 <= q:
        ans = pow(r,3) + pow(r+1,3)
    else:
        ans = pow(r,3) + pow(r,3)
else:
    ans = pow(r,3)
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int h, w; cin >> h >> w;
    REP(i, w+2) cout << "#";
    cout << "\n";
    REP(i, h){
        cout << "#";
        string s; cin >> s;
        cout << s;
        cout << "#\n";
    }
    REP(i, w+2) cout << "#";
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
trueans = float('inf')
for k in [-1,1]:
    sign = k
    ans = 0
    s = 0
    for i in range(n):
        s += a[i]
        if s == 0:
            s = sign
            ans += 1
        elif s//abs(s) == sign:
            pass
        else:
            ans += abs(sign-s)
            s = sign
        sign *= -1
    trueans = min(ans,trueans)
print(trueans)


Measured memory_bytes: 14332
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}"; 
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector< lint >a(n); std::cin >> a;
  std::partial_sum(all(a), a.begin());
  a.insert(a.begin(), 0);
  lint sum = a.back();
  // debug(sum, a);
  lint inf = std::numeric_limits< lint >::max();
  lint ans = inf;
  for (lint x : a) {
    lint y = sum - x;
    lint d = x - y;
    if (d < 0) d = -d;
    cmn(ans, d);
  }
  std::cout << ans << std::endl;
  return 0;
}


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

using namespace std;

int main(){
	int n,pop=-1,ans=0;
	scanf("%d", &n);
	for(int i=0;i<n;i++){
		int t;
		scanf("%d", &t);
		if(pop==t){
			ans++;
			pop = -1;
		}
		else
			pop = t;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
//  Mayank Agarwal
//  IIIT Hyderabad



#include<bits/stdc++.h>
using namespace std;
const long long int M = 1000000007; 
#define ll long long int
#define ld double
#define pb push_back
#define mp make_pair
ll power(ll x, ll y,  ll p) 
{ 
    ll res = 1;      
    x = x % p;   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;x = (x*x) % p; 
    } return res%p; 
} 
ll modinver(ll a,ll b)
{
    return (power(a,1,M)*power(b,M-2,M))%M;
}
void SieveOfEratosthenes(int n) 
{   
    bool prime[10005]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
} 
std::vector<pair<ll,ll>> v[100002];
ll col[100002];
ll flag=0;
void dfs(ll x,ll dis,ll par,ll color)
{
	col[x]=color;
	// cout<<x<<" "<<dis<<" "<<color<<'\n';
	for (int i = 0; i < v[x].size(); ++i)
	{
		if(v[x][i].first!=par)
		{
			if((dis+v[x][i].second)%2==0)
			{
				dfs(v[x][i].first,0,x,0);
			}
			else
			{
				dfs(v[x][i].first,1,x,1);
			}
		}
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    for (int i = 0; i < n-1; ++i)
    {
    	ll a,b,c;
    	cin>>a>>b>>c;
    	v[a].pb(mp(b,c));
    	v[b].pb(mp(a,c));
    }
    for (int i = 0; i <=n; ++i)
    {
    	col[i]=-1;
    }
    dfs(1,0,-1,0);
   for (int i = 1; i <=n; ++i)
   {
   		cout<<col[i]<<'\n';
   }
}


Measured memory_bytes: 11008
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース


*/

//main.cpp----------------------------
#define MAX 100000

int n;
string s;

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

  int r = 0, b = 0;

  rep(i, n) {
    if(s[i]=='R') ++r;
    else ++b;
  }

  if(r>b) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
/*
 * atcoder/abc111_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * M(M<=40)本の長さ{d_1, d_2, ..., d_M}のアームを使って与えられる座標すべてを表現出来るか否か.
 * 出来るとすればその時のアームの配置も答える.
 *
 *        c
 *      c b c
 *    c b c b c
 *  c b c b c b c
 *    c b c b c
 *      c b c
 *        c
 *
 * まず実現の可否について判定する.
 * 上図に示したとおり、長さ1のアームのみを使って到達できる範囲をプロットすると、
 * 1つのアームで到達可能な点は3つのアームで到達可能な点に内包されている.
 * 一方で、2つのアームで到達可能な点は3つのアームで到達可能な点に内包されていないが、
 * 4つのアームで到達可能な点に内包されている.
 * このことから、アーム数が偶数の場合と奇数の場合に到達可能な点は相容れず、
 * すなわち点の原点からのマンハッタン距離が偶数と奇数の点は混在することが出来ない.
 * 長さ1のアームでも不可能なので、それ以上の長さのアームでは不可能だと推測出来る.
 *
 * 座標として巨大な値をすべて生成する必要がある.
 * -10^9 <= X, Y <= 10^9より、マンハッタン距離の最大値はX+Y= 2 * 10^9.
 * これは2進数で31桁あれば十分.
 * これをうまく組み合わせると- 2 * 10^9 <= X+Y <= 2 * 10^9の値はすべて表現出来るはずである.
 *
 * 後はアームの長い方からマンハッタン距離を最小化する方向に配置していく.
 */
int N;
struct P { ll x, y; };
vector<P> PS;
vector<ll> A;
void solve() {
  cin >> N;
  ll x, y;
  loop(n,0,N) {
    cin >>  x >> y; PS.push_back((P){ x, y });
  }
  bool isOdd = abs(PS[0].x + PS[0].y) % 2 == 1;
  bool ok = all_of(PS.begin(), PS.end(), [&](P p) {
    return (abs(p.x + p.y) % 2 == 1) == isOdd;
  });
  if (!ok) {
    cout << -1 << endl;
    return;
  }

  for (ll d=30; d>=0; d--) A.push_back(1<<d);
  if (!isOdd) A.push_back(1);

  int M = A.size();
  cout << M << endl;
  for (auto&& a: A) cout << a << " "; cout << endl;

  for (auto&& point: PS) {
    ll u = point.x + point.y, v = point.x - point.y;
    for (auto&& a: A) {
      int u_sign = 1, v_sign = 1;
      if (u >= 0 and v >= 0) {
        cout << "R";
        u_sign = -1; v_sign = -1;
      }
      if (u >= 0 and v < 0) {
        cout << "U";
        u_sign = -1; v_sign = 1;
      }
      if (u < 0 and v < 0) {
        cout << "L";
        u_sign = 1; v_sign = 1;
      }
      if (u < 0 and v >= 0) {
        cout << "D";
        u_sign = 1; v_sign = -1;
      }
      u += u_sign * a;
      v += v_sign * a;
    }
    cout << endl;
  }
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby

# k = gets.chomp.split(' ').map(&:to_i)

# if k[0] == k[2] * 2 && k[1] == k[3] * 2
#   puts "#{k[0] * k[1] /2} 1"
# else
#   puts "#{k[0] * k[1] /2} 0"
# end


k = gets.chomp.split.map(&:to_i)
l = gets.chomp.split.map(&:to_i)

len = 0
count = 1
l.each do |v|
  len += v
  break if len > k[1]
  count += 1
end

puts count

Measured memory_bytes: 1788
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

int n,m,b,a[li],k,flag,cev;
string s;
char c[1005][1005];
vector<int> v;

int main(void){
	scanf("%d %d",&n,&m);
	FOR{
		for(int j=1;j<=m;j++){
			scanf(" %c",&c[i][j]);
		}
	}
	FOR{
		for(int j=1;j<=m;j++){
			cev=0;
			if(c[i][j]=='#'){printf("%c",c[i][j]);continue;}
			if(c[i-1][j]=='#') cev++;
			if(c[i+1][j]=='#') cev++;
			if(c[i-1][j-1]=='#') cev++;
			if(c[i-1][j+1]=='#') cev++;
			if(c[i+1][j+1]=='#') cev++;
			if(c[i+1][j-1]=='#') cev++;
			if(c[i][j-1]=='#') cev++;
			if(c[i][j+1]=='#') cev++;
			cout<<cev;
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        S: String,
        K: usize,
    }

    let c: &str = &S[K - 1..=K - 1];

    for i in 0..N {
        if &S[i..=i] == c {
            print!("{}", &S[i..=i]);
        } else {
            print!("*");
        }
    }

    println!("");
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,Q;

template<class V,int NV> class SegTree_2 {
public:
	V nolink;
	vector<V> val;
	SegTree_2(){val.resize(NV*2); clear(); nolink=1<<30;};
	void clear() { for(int i=0;i<NV*2;i++) val[i]=1<<20; }
	
	V getval(int k) {
		int e=k+NV;
		V ret=nolink;
		while(e>=1) ret=min(ret,val[e]), e/=2;
		return ret;
	}
	
	void update(int x,int y, V v,int l=0,int r=NV,int k=1) {
		if(l>=r) return;
		if(x<=l && r<=y) val[k]=min(val[k],v);
		else if(l < y && x < r) {
			update(x,y,v,l,(l+r)/2,k*2);
			update(x,y,v,(l+r)/2,r,k*2+1);
		}
	}
};

SegTree_2<int,1<<20> Xs,Ys;



void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	Xs.update(1,N,N);
	Ys.update(1,N,N);
	ll ret=1LL*(N-2)*(N-2);
	
	while(Q--) {
		cin>>i>>x;
		
		if(i==1) {
			y=Ys.getval(x);
			ret-=y-2;
			Xs.update(1,y,x);
		}
		else {
			y=x;
			x=Xs.getval(y);
			ret-=x-2;
			Ys.update(1,x,y);
		}
	}
	
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

a = list(map(int, input().split()))

max_leaf = [0 for i in range(n+1)]
prev_max = 0
must = 0

for i in range(n+1):
    max_leaf[-(i+1)] = prev_max + a[-(i+1)]
    prev_max = max_leaf[-(i+1)]
    must = (must+1) // 2 + a[-(i+1)]


if must != 1:
    print(-1)
else:
    num = 0.5
    ans = 0
    for i in range(n+1):
        if i == 0:
            num = 1
            ans += 1
        else:
            num = min((num-a[i-1])*2, max_leaf[i])
            ans += num

    print(int(ans))


Measured memory_bytes: 20008
/* long long or int */
/* xx 396*/

#include<bits/stdc++.h>
using namespace std;

const int maxn=15;

int n,d;
int val[maxn][maxn];

bool check(int x,int y){
	int ret=0;
	for(int i=0;i<d;i++){
		int sum=(val[x][i]-val[y][i])*(val[x][i]-val[y][i]);
		ret+=sum;
	}
	for(int i=0;i<10000;i++)
		if(i*i==ret) return true;
	return false;
}

int main(){
	ios::sync_with_stdio(false);
	cin>>n>>d;
	for(int i=0;i<n;i++) 
		for(int j=0;j<d;j++) cin>>val[i][j];
	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			if(check(i,j)) ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
val = []
for i in range(n):
    val.append([i for i in map(int,input().split())])
    del(val[i][0])


ans = [[] for i in range(n+1)]

ans[0] = [i+1 for i in range(m)]
for i in range(n):
    for j in val[i]:
        if j in ans[i] :
            ans[i+1].append(j)
        else: pass
print(len(ans[n]))


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

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359

int main() {
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k){
        cout << s << endl;
    }else{
        cout << s.substr(0,k) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

class comb{
private:
    ll mod;
    ll mx;
    vector<ll> F;
    vector<ll> FR;
    
public:
    comb(ll mod=1000000007,ll mx=100000):mod(mod),mx(mx),F(mx+1,1),FR(mx+1,1){
        mk_F();
    }
    
    ll mod_pow(ll a,ll x){
        a%=mod;
        ll ans=1;
        for(int i=0;i<63;i++){
            if(x>>i&1){ans*=a; ans%=mod;}
            a*=a;
            a%=mod;
        }
        return ans;
    }
    
    pll Ex_gcd(ll a,ll b){
        if(b==0){return {1,0};}
        pll ret=Ex_gcd(b,a%b);
        ret.F-=a/b*ret.S;
        return {ret.S,ret.F};
    }
    
    ll prime_R(ll a){
        return mod_pow(a,mod-2);
    }
    
    ll R(ll a){
        ll ret=Ex_gcd(a,mod).F;
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    void mk_F(){
        for(ll i=1;i<=mx;i++){F[i]=F[i-1]*i%mod; FR[i]=R(F[i]);}
    }
    
    ll c(ll n,ll k){
        if(n<k){return 0;}
        if(n==k || k==0){return 1;}
        return F[n]*FR[n-k]%mod*FR[k]%mod;
    }
    
    //mod must be prime
    ll Lucas_C(ll n,ll m){
        ll ret=1;
        while(n>0 || m>0){
            ret*=c(n%mod,m%mod);
            ret%=mod;
            n/=mod; m/=mod;
        }
        return ret;
    }
    
    ll Stirling(ll n,ll k){
        ll ret=0;
        for(ll i=1;i<=k;i++){
            if((k-i)%2){ret-=c(k,i)*mod_pow(i,n)%mod;}
            else{ret+=c(k,i)*mod_pow(i,n)%mod;}
            ret%=mod;
        }
        ret*=R(F[k]);
        ret%=mod;
        if(ret<0){ret+=mod;}
        return ret;
    }
    
    ll Bell(ll n,ll k){
        ll ret=0;
        for(ll i=1;i<=k;i++){ret+=Stirling(n,i); ret%=mod;}
        return ret;
    }
};



int main(){
    comb C(MOD,1e6);
    ll h,w,n;
    cin>>h>>w>>n;
    vector<pll> A(n+2,{1,1});
    A.back()={h,w};
    for(int i=0;i<n;i++){cin>>A[i].F>>A[i].S;}
    vector<ll> dp(n+2,0);
    sort(A.begin(),A.end());
    dp[0]=-1;
    for(int i=1;i<A.size();i++){
        for(int t=0;t<i;t++){
            if(A[t].F<=A[i].F && A[t].S<=A[i].S){
                dp[i]-=dp[t]*C.c(A[i].F+A[i].S-A[t].F-A[t].S,A[i].F-A[t].F)%MOD;
            }
        }
        dp[i]%=MOD;
    }
    if(dp.back()<0){dp.back()+=MOD;}
    cout<<dp.back()<<endl;
    
    return 0;
}


Measured memory_bytes: 16000
package main

import "fmt"

func main() {
	var n, d int
	fmt.Scan(&n, &d)
	if n%(d*2+1) == 0 {
		fmt.Println(n / (d*2 + 1))
	} else {
		fmt.Println(n/(d*2+1) + 1)
	}
}


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

int main() {
    int a, b, ab;
    cin >> a >> b;
    ab = a * b;

    if (ab % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s1[15],s2[15];
    int a,b;
    cin>>a>>b;
    int j=0;
    while(j<a){
        s1[j]=b+'0';
        j++;
    }
    s1[j]='\0';
     j=0;
    while(j<b){
        s2[j]=a+'0';
        j++;
    }
    s2[j]='\0';
    int d=strcmp(s1,s2);
    if(d>=0){
        j=0;
    while(j<b){
        cout<<s2[j];
        j++;
    }
}
else{
    j=0;
    while(j<a){
        cout<<s1[j];
        j++;
    }
}
   return 0;
}


Measured memory_bytes: 3588
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        int h = sc.nextInt();
        int s = sc.nextInt();
        int d = sc.nextInt();
        int n = sc.nextInt();
        int m;
        if (q * 2 < h) {
            m = q * 4;
        } else {
            m = h * 2;
        }
        if (m > s) {
            m = s;
        }
        if (d > m * 2) {
            d = m * 2;
        }
        BigDecimal ans = new BigDecimal("0");
        BigDecimal two = new BigDecimal("2");
        BigDecimal bn = BigDecimal.valueOf(n);
        BigDecimal hn = BigDecimal.valueOf(n / 2);
        BigDecimal bm = BigDecimal.valueOf(m);
        BigDecimal bd = BigDecimal.valueOf(d);
        if (n % 2 == 0) {
            ans = hn.multiply(bd);
        } else {
            ans = hn.multiply(bd);
            ans = ans.add(bm);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s, t;
  cin >> s >> t;
  int ans = sz(t);
  rep(i, sz(s) - sz(t)+1) {
    int cnt = 0;
    for (int j = 0; j < sz(t); j++) {
      if (s[i+j] != t[j]) cnt++;
    }
    chmin(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n,m;
  cin>>n>>m;
  
  vector<pair<ll,pair<ll,ll>>> p;
  rep(i,n){
    ll s,t,x;
    cin>>s>>t>>x;
    p.pb({s-x,{-1,x}});
    p.pb({t-x,{0,x}});
  }

  rep(i,m){
    ll d;
    cin>>d;
    p.pb({d,{1,i}});
  }

  sort(all(p));

  vector<ll> ans(m);
  multiset<ll> se;

  for(auto w : p){
    ll x=w.fi;
    ll y=w.se.fi;
    ll z=w.se.se;
    if(y==-1) se.insert(z);
    else if(y==0) se.erase(se.lower_bound(z));
    else {
      if(se.empty()) ans[z]=-1;
      else ans[z]=*se.begin();
    }
  }

  rep(i,m){
    cout << ans[i] << endl;
  }

}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
        char S[H][W];

        FOR(i, H){
            string str;
            cin >> str;
            str.copy(S[i],W);
        }
        bool isPossible=true;
	FOR(i,H) {
	    FOR(j,W) {
	        if ('#'==S[i][j]){
                        //cout<<"#"<<endl;
                        bool isNextWhite = true;
                        if(i-1>=0){
                            if('#'==S[i-1][j])
                                isNextWhite=false;
                        }
                        if(i+1<H){
                            if('#'==S[i+1][j])
                                isNextWhite=false;
                        }
                        if(j-1>=0){
                            if('#'==S[i][j-1])
                                isNextWhite=false;
                        }
                        if(j+1<W){
                            if('#'==S[i][j+1])
                                isNextWhite=false;
                        }
                        
                        if(isNextWhite)//all is white
                            isPossible=false;
                }
			
	    }
	}
	if(isPossible){
            cout << "Yes" <<endl;
        }else{
            cout << "No" <<endl;
        }
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  vector<pair<LL,LL>> task(n);
  for(auto &p:task) cin >> p.second >> p.first;
  sort(task.begin(),task.end());
  LL t = 0;
  bool flag = true;
  for(auto p:task) {
    t += p.second;
    flag = flag && t <= p.first;
  }
  cout << (flag?"Yes":"No") << endl;
  return 0;
}


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

using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)

template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }


///////////////

#define EPS (1e-10)
#define NEXT(x, i) (x[(i + 1) % x.size()])

template<class T> using CR = const T &;
using P = complex<ld>;
using G = vector<P>;

int sgn(ld a, ld b = 0) {
	if (a > b + EPS) return 1;
	if (a < b - EPS) return -1;
	return 0;
}

ld dot(P a, P b) { return real(conj(a)*b); }
ld cross(P a, P b) { return imag(conj(a)*b); }

int ccw(P a, P b, P c) {
	b -= a;
	c -= a;
	if (sgn(cross(b, c))) return sgn(cross(b, c)); // clockwise(-1) or counter clockwise(1)
	if (sgn(dot(b, c)) == -1) return 2;            // c--a--b
	if (sgn(norm(b), norm(c)) == -1) return -2;    // a--b--c
	return 0;                                      // a--c--b
}

namespace std {
	bool operator < (P a, P b) {
		return sgn(real(a), real(b)) ? real(a) < real(b) : imag(a) < imag(b);
	}
}

ld convex_diameter(CR<G> g) {
	int n = g.size();

	int is = 0, js = 0;
	FOR(i, 1, n) {
		if (imag(g[i]) > imag(g[is])) is = i;
		if (imag(g[i]) < imag(g[js])) js = i;
	}
	ld maxd = norm(g[is] - g[js]);

	int i, maxi, j, maxj;
	i = maxi = is;
	j = maxj = js;
	do {
		if (cross(g[(i+1)%g.size()] - g[i], g[(j+1)%g.size()] - g[j]) >= 0) j = (j + 1) % n;
		else i = (i + 1) % n;
		if (norm(g[i] - g[j]) > maxd) {
			maxd = norm(g[i] - g[j]);
			maxi = i; maxj = j;
		}
	} while (i != is || j != js);
	return sqrt(maxd); /* farthest pair is (maxi, maxj). */
}

//////////////

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	ll n; cin >> n;

	G g(n);
	REP(i,n){
		ld x, y;
		cin >> x >> y;
		g[i] = { x, y };
	}

	cout << convex_diameter(g) << endl;
	return 0;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 5e5 + 5;
const int   mod = 998244353;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {
    return  1ll * a * b % mod;
}
int Pow(int a,int b)    {
    int ans = 1;
    while (b)   {
        if(b & 1)   ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}
int inv(int a,int p)    {
    return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;
}
int Fac[N];
int Inv[N];

int Ckn(int n,int k)    {
    if (n < k)  return  0;
    if (k < 0)  return  0;

    return  mul(Fac[n],mul(Inv[k],Inv[n - k]));
}

typedef pair<int,int>   ii;

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

    Fac[0] = Inv[0] = 1;

    for(int i = 1 ; i < N ; ++i)    Fac[i] = mul(Fac[i - 1],i);     Inv[N - 1] = inv(Fac[N - 1],mod);
    for(int i = N - 2 ; i ; --i)    Inv[i] = mul(Inv[i + 1],i + 1);

    int n;  cin >> n;
    int m;  cin >> m;

    if (n > m)
        swap(n,m);

    int ans = 0;

    for(int i = 0 ; i <= n ; ++i)   {
        int cur = Fac[i];

        cur = mul(cur,Ckn(n,i));
        cur = mul(cur,Ckn(m,i));

        cur = mul(cur,Pow(n + 1,m - i));
        cur = mul(cur,Pow(m + 1,n - i));

        if (i & 1)  sub(ans,cur);
        else        add(ans,cur);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#!python3.4.3

A, B, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))

min_ = min(a) + min(b)

for _ in range(M):
  x, y, c = map(int, input().split(' '))
  tmp = a[x-1] + b[y-1] - c
  
  min_ = min(tmp, min_)
  
print(min_)

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

using namespace std;
typedef long long ll;
typedef long double ld;

const int N = 15;
const int M = 1010;
const int INF = 0x3f3f3f3f;

int dp[1<<N];

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  memset(dp, INF, sizeof dp);
  int n, m;
  cin >> n >> m;
  dp[0] = 0;
  for (int i=1; i<=m; ++i) {
    int a, b, f = 0;
    cin >> a >> b;
    for (int j=0; j<b; ++j) {
      int x;
      cin >> x;
      f |= 1<<(x-1);
    }
    for (int j=0; j<(1<<n); ++j) {
      dp[j|f] = min(dp[j|f], dp[j]+a);
    }
  }
  cout << (dp[(1<<n)-1] == INF ? -1 : dp[(1<<n)-1]) << endl;
  return 0;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pa pair<int,int>
#define F first
#define S second
#define maxth 9999
#define daa n%3
typedef long long ll;

int main()
{
    int n;
    cin>>n;
    int *a=new int [n];
    int *b=new int [n];
    int sum=0;
    rep(i,n)
    {
        cin>>a[i];
        if(i%2==0)
            sum+=a[i];
        else
            sum-=a[i];
    }
    cout<<sum<<" ";
    b[0]=sum;
    for(int i=1; i<n; i++)
    {
        b[i]=2*a[i-1]-b[i-1];
        cout<<b[i]<<" ";
    }
    return 0;
}


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

#define ALL(obj) (obj).begin(), (obj).end()
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,b) for(int i=a; i<=b; i++)
#define drep2(i,a,b) for(int i=a; i>=b; i--)
using ll = long long;
#define pb push_back


int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  int mmax = INT_MIN;
  int mmin = INT_MAX;
  int mmax_index = -1;
  int mmin_index = -1;
  rep(i, N ) {
    cin >> a[i];
    if (a[i] > mmax) {
      mmax = a[i];
      mmax_index = i;
    } else if (a[i] < mmin) {
      mmin = a[i];
      mmin_index = i;
    }
  }
  int ans = 2*N-1;
  cout << ans << endl;

  if ( mmax < abs(mmin) ) {
    rep(i, N) {
      cout << mmin_index + 1 << " " << i + 1 << endl;
    }
    drep2(i, N, 2) {
      cout << i << " " << i - 1 << endl;
    }
  } else {
    rep(i, N ) {
      cout << mmax_index + 1 << " " << i + 1 << endl;
    }
    rep(i,N-1) {
      cout << i + 1 << " " << i + 2 << endl;
    }
  }

}

Measured memory_bytes: 256
n = gets.to_i
k = gets.chomp.split(" ").map(&:to_i)
t = 1
now = 0
max = 0
while t < n do
if k[t-1] >= k[t] then
  t += 1
  now += 1
else 
  t += 1
  if max < now then
  max = now
  end
  now = 0
end
end
if max < now then
  max = now
  end
p max


Measured memory_bytes: 9604
N=int(input())
A=[]
for i in range(1,N+1):
    S,P=input().split()
    P=int(P)
    A.append((S,P,i))
A.sort(key=lambda x:x[1],reverse=True)
A.sort(key=lambda x:x[0])
for i in range(N):
    print(A[i][2])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  char c1,c2;
  cin >> a >> c1 >> b >> c2 >> c;
  if(b>=5){
    cout << "TBD" << endl;
  }
  else if(b<=4){
    cout << "Heisei" << endl;
  }
  }

Measured memory_bytes: 256