akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};


int N;
ll W;
ll w[110];
ll v[110];
ll dp[110000];

int main () {
  cin >> N >> W;
  rep(i, N) cin >> w[i] >> v[i];

  Rep(i, 110001) {
    dp[i] = INFLL;
  }

  dp[0] = 0;
  rep(i, N) {
    for (int j = 110000; j >= 0; j--) {
      if (j - v[i] >= 0) {
        dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
      }
    }
  }

  ll ans = 0;
  Rep(i, 110001) {    
    if (dp[i] <= W) {
      ans = max(ans, (ll)i);
    }
  }

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

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
struct Node{
  int parent,left,right;
};
Node T[100005];
int n,D[1000005],hei[1000005];

void Preorder(int pp){
  if(pp==-1)return;
  cout<<" "<<pp;
  Preorder(T[pp].left);
  Preorder(T[pp].right);
}


void Inorder(int in){
  if(in==-1)return;
  Inorder(T[in].left);
  cout<<" "<<in;
  Inorder(T[in].right);
}

void Postorder(int po){
  if(po==-1)return;
  Postorder(T[po].left);
  Postorder(T[po].right);
  cout<<" "<<po;
}
int main(){
  int i=0,j=0,k=0,c=0,l=0,r=0,Tc=0;
  int id=0;
  cin>>n;
  for( i=0;i<n;i++){
    T[i].parent=T[i].left=T[i].right=-1;
  }
  for(i=0;i<n;i++){
    cin>>id>>l>>r;
    T[id].right=r;
    if(r!=-1)T[r].parent=id;
    T[id].left=l;
    if(l!=-1)T[l].parent=id;
  }
  for(i=0;i<n;i++){
    if(T[i].parent==-1){
      Tc=i;
    }
  }
  cout<<"Preorder"<<endl;
  Preorder(Tc);
  cout<<endl;
  cout<<"Inorder"<<endl;
  Inorder(Tc);
  cout<<endl;
  cout<<"Postorder"<<endl;
  Postorder(Tc);
  cout<<endl;
  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll h, w;
    cin >> h >> w;
    vs s(h);
    rep(i, h){
        cin >> s[i];
    }
    vvll blankh(h, vll());
    vvll blankv(w, vll());
    vvll acch(h, vll(w, 0));
    vvll accv(h, vll(w, 0));
    rep(i, h){
        ll cnt = 0;
        ll cntobs = 0;
        rep(j, w){
            if(s[i][j] == '#'){
                blankh[i].emplace_back(cnt);
                cntobs++;
                cnt = 0;
            }else{
                cnt++;
                if(j == w-1){
                    blankh[i].emplace_back(cnt);
                }
            }
            acch[i][j] = cntobs;
        }
    }
    rep(i, w){
        ll cnt = 0;
        ll cntobs = 0;
        rep(j, h){
            if(s[j][i] == '#'){
                blankv[i].emplace_back(cnt);
                cntobs++;
                cnt = 0;
            }else{
                cnt++;
                if(j == h-1){
                    blankv[i].emplace_back(cnt);
                }
            }
            accv[j][i] = cntobs;
        }
    }
    ll ans = 0;
    rep(i, h){
        rep(j, w){
            if(s[i][j] == '.'){
                ans = max(ans, blankh[i][acch[i][j]]+blankv[j][accv[i][j]]-1);
            }
        }
    }
    /*
    rep(i, h){
        rep(j, w){
            cerr << blankh[i][acch[i][j]]<< " ";
        }
        cerr << endl;
    }
        cerr << endl;
    rep(i, h){
        rep(j, w){
            cerr << blankv[j][accv[i][j]] << " ";
        }
        cerr << endl;
    }
        cerr << endl;
    rep(i, h){
        rep(j, w){
            cerr << blankh[i][acch[i][j]] +  blankv[j][accv[i][j]] << " ";
        }
        cerr << endl;
    }
    */
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 131328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1)
	{
	    c-=b;
	    if(c<=0)
	    {
	        cout<<"Yes";
	        return 0;
	    }
	    a-=d;
	     if(a<=0)
	    {
	        cout<<"No";
	        return 0;
	    }
	    
	}
}

Measured memory_bytes: 3624
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
a.unshift(0)
res = Hash.new(0)

n.step(1, - 1) do |i|
  if i <= n / 2
    a[i] = ((1..(n / i)).inject(0) {|acc, j| acc + a[j * i] }) % 2
  end

  if a[i] != 0
    res[i] = a[i]
  end
end

puts res.keys.size
puts res.keys.join(" ")


Measured memory_bytes: 38936
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;

int main() {
	long long X; cin >> X;
	long long V1 = (X / 500);
	long long V2 = (X % 500) / 5;
	cout << 1000LL * V1 + 5LL * V2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const int maxn=2e7+10;
const LL inf=1e17;
LL x[maxn];
struct AC
{
    struct zp
    {
        int lson,rson;
        LL sum;
    }tree[maxn];
    int cont,root;
    void init()
    {
        cont=0;
        root=-1;
    }
    int newnode()
    {
        tree[cont].lson=tree[cont].rson=-1;
        tree[cont].sum=0;
        cont++;
        return cont-1;
    }
    void update(int &k,LL l,LL r,LL num)
    {
        if(k==-1) k=newnode();
        tree[k].sum++;
        if(l==r) return ;
        LL mid=(l+r)>>1;
        if(num<=mid)
            update(tree[k].lson,l,mid,num);
        else
            update(tree[k].rson,mid+1,r,num);
    }
    LL query(int k,LL l,LL r,LL ql,LL qr)
    {
        if(k==-1) return 0;
        if(l==ql&&r==qr)
            return tree[k].sum;
        LL mid=(l+r)>>1;
        if(qr<=mid)
            return query(tree[k].lson,l,mid,ql,qr);
        else if(ql>mid)
            return query(tree[k].rson,mid+1,r,ql,qr);
        else
            return query(tree[k].lson,l,mid,ql,mid)+query(tree[k].rson,mid+1,r,mid+1,qr);
    }
}ac;
int main()
{
    int n;
    LL m;
    while(~scanf("%d%lld",&n,&m))
    {
        ac.init();
        for(int i=0;i<n;i++)
        {
            scanf("%lld",&x[i]);
            x[i]-=m;
        }
        for(int i=1;i<n;i++)
            x[i]+=x[i-1];
        ac.update(ac.root,-inf,inf,0);
        LL ans=0;
        for(int i=0;i<n;i++)
        {
            ans+=ac.query(ac.root,-inf,inf,-inf,x[i]);
            ac.update(ac.root,-inf,inf,x[i]);
        }
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 98560
#include <stdio.h>
int n, m, x, s[100];
int main() {
	while(scanf("%d%d", &n, &m), n + m) {
		for(int i = 0; i < m; i++) scanf("%d", s + i);
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) scanf("%d", &x), s[j] -= x;
		}
		int f = 1;
		for(int i = 0; i < m; i++) {
			if(s[i] < 0) {
				f = 0; break;
			}
		}
		puts(f ? "Yes" : "No");
	}
}

Measured memory_bytes: 2508
// Problem : A - Remaining Balls
// Contest : AtCoder Beginner Contest 154
// URL : https://atcoder.jp/contests/abc154/tasks/abc154_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

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

#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(nullptr);
#define endl "\n"

int32_t main()
{
	IOS;
	int t = 1;
	//cin >> t;	
	for(int msi = 1; msi <= t; msi++)
	{
		string s, t;
		cin >> s >> t;
		int a, b;
		cin >> a >> b;
		string u; cin >> u;
		if(s == u){
			cout << a-1 <<" "<<b << endl;
		}else{
			cout << a <<" "<<b -1 << endl;
		}
	}	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>//入出力用
using namespace std;
typedef long long llong;//4バイトの符号整数型、64bitの情報格納可
int n, k;//n個数、k台数
llong T[100000];//制約よる荷物の最大個数配列

/*最大積載量の設定*/
int check(llong P) {
    int i = 0;
    for(int j = 0; j < k; j++){
        llong s = 0;//無積載トラック
        while( s + T[i] <= P ){//最大積載量になるまで乗せる
            s += T[i];
            i++;
            if (i == n) return n;//最大個数を乗せたとき
        }
    }
    return i;
}

/*2文探索を使用*/
int solve(){
    llong l = 0;
    llong r = 100000 * 100000;//荷物の個数*1個当たりの最大積載量
    llong mid;
    while (r > l + 1){
        mid = (l + r) / 2;
        int v = check(mid);//mid==Pを決め何個乗せれるか
        if (v >= n) r = mid;
        else l = mid;
    }
    return r;
}

int main(){
    cin >> n >> k;//入力：nの個数取得した後kの台数取得
    for (int i = 0; i < n; i++) cin >> T[i];//n個分荷物追加
    llong ans = solve();
    cout << ans << endl;//結果出力
    return 0;
}



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

using ll = long long;
const int INF = 1<<29;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

class UnionFind {
public:
	UnionFind(size_t size) : v(size, -1) {}
	vector<ll> v;

	ll root(ll x) {
		return (v[x] < 0 ? x : v[x] = root(v[x]));
	}

	bool is_root(ll x) {
		return x == root(x);
	}

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

	void unite(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x != y) {
			if (v[x] > v[y]) swap(x, y);
			v[x] += v[y];
			v[y] = x;
		}
	}

	ll size(ll x) {
		return -v[root(x)];
	}
};

int main() {
	ll N,M;
	cin>>N>>M;
	UnionFind tree=UnionFind(N);
	vector<pair<ll,ll>> a;
	rep(i,M){
		ll t1,t2;
		cin>>t1>>t2;
		a.push_back(make_pair(t1-1,t2-1));
	}

	vector<ll> ans;

	ll c=N*(N-1)/2;
	ans.push_back(c);
	rep(i,M-1){
		if(c==0){
			ans.push_back(c);
			continue;
		}
		auto pa=a[M-i-1];
		bool issame=tree.same(pa.first,pa.second);
		if(!issame){
			ll size1=tree.size(pa.first);
			ll size2=tree.size(pa.second);
			tree.unite(pa.first,pa.second);
			ll newsize=tree.size(pa.first);
			c+=size1*(size1-1)/2;
			c+=size2*(size2-1)/2;
			c-=newsize*(newsize-1)/2;
		}

		ans.push_back(c);
	}


	rep(i,M)p(ans[M-i-1]);

	




	return 0;
}



Measured memory_bytes: 5488
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    int[] w, k;
    int ww, kk;
    void run(){
	while(sc.hasNext()){
	    int i;
	    w = new int[10];
	    k = new int[10];
	    put(w);
	    put(k);
	    ww = w[9]+w[8]+w[7];
	    kk = k[9]+k[8]+k[7];
	    System.out.println(ww+" "+kk);
	}
    }

    void put(int[] a){
	for(int i=0; i<10; i++)
	    a[i] = sc.nextInt();
	Arrays.sort(a);
    }
}

Measured memory_bytes: 17172
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000

int main()
{
  int N, u, v, w;
  cin >> N;
  vector<int> color(N, INF);
  vector<vector<vector<int>>> tree(N, vector<vector<int>>(2, vector<int>(0)));
  for (int i = 0; i < N - 1; ++i)
  {
    cin >> u >> v >> w;
    if (w % 2 == 0)
    {
      tree.at(u - 1).at(0).push_back(v - 1);
      tree.at(v - 1).at(0).push_back(u - 1);
    }
    else
    {
      tree.at(u - 1).at(1).push_back(v - 1);
      tree.at(v - 1).at(1).push_back(u - 1);
    }
  }
  // for (int i = 0; i < N; ++i)
  // {
  //   cout << "i" << i << "\n";
  //   for (int j = 0; j < 2; ++j)
  //   {
  //     cout << "j" << j << "\n";
  //     for (int x: tree.at(i).at(j))
  //     {
  //       cout << x << " ";
  //     }
  //     cout << "\n";
  //   }
  // }

  stack<int> s;
  int next;
  s.push(0);
  color.at(0) = 0;
  while(s.empty() == false)
  {
    next = s.top();
    s.pop();
    for (int i = 0; i < 2; ++i)
    {
      for (int x: tree.at(next).at(i))
      {
        if (color.at(x) == INF)
        {
          color.at(x) = (color.at(next) + i) % 2;
          s.push(x);
        }
      }
    }
  }
  for (int i = 0; i < N; ++i)
  {
    cout << color.at(i) << "\n";
  }
}

Measured memory_bytes: 14848
h,w = map(int,input().split())
maze = [input() for _ in range(h)]

dph = [[0 for _ in range(w)] for _ in range(h)]
dpw = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
  for j in range(w):
    if maze[i][j] == '#':
      continue
    if dpw[i][j] != 0:
      continue
    k = j
    count = 0
    while k< w:
      
      if maze[i][k] == '.':
        count += 1
        k += 1
      else:
        break
    for l in range(j,k):
      dpw[i][l] = count
      
for i in range(w):
  for j in range(h):
    if maze[j][i] == '#':
      continue
    if dph[j][i] != 0:
      continue
    k = j
    count = 0
    while k< h:
      
      if maze[k][i] == '.':
        count += 1
        k += 1
      else:
        break
    for l in range(j,k):
      dph[l][i] = count


ans = 0
for i in range(h):
  for j in range(w):
    ans = max(ans, dpw[i][j] + dph[i][j])
print(ans-1)


Measured memory_bytes: 126680
#include <iostream>
 
using namespace std;
 
int main(){
  
  long long N,A,B;
  cin >> N >> A >> B;
  long long ans = N / (A + B) * A;
  
  
  if(N % (A+B) > A){
    ans += A;
    cout << ans;
  }else{
    ans += N % (A+B);
    cout << ans;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll n,m;
  cin >> n >> m;
  vector<P> p(n);
  rep(i,n) cin >> p[i].first >> p[i].second;
  sort(p.begin(),p.end());

  ll ans = 0;
  rep(i,n){
    if(m<=0) break;
    ll a = p[i].first, b = p[i].second;
    ans += a * min(m,b);
    m -= b;
  }
  cout << ans << endl;
}


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

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 11111111111111111
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 10000

int main(void) {
  string s1, s2;

  cin >> s;
  ans = INF;

  FOR(i,0,s.length()) {
	cnt = 0;
	s1 = s;
	s2 = s;
	while (1) {
	  flag = true;
	  FOR(j, 0, s2.length()) {
		if (s2[0] != s2[j]) {
		  flag = false;
		  break;
		}
	  }
	  if (flag) {
		break;
	  }
	  cnt++;

	  FOR(j, 0, s1.length() - 1) {
		if (s1[j] == s[i] || s1[min(j + 1, (ll)s1.length() - 1)] == s[i]) {
		  s2[j] = s[i];
		}
		else {
		  s2[j] = s1[j];
		}
	  }
	  s2.pop_back();
	  s1 = s2;
	}
	ans = min(ans, cnt);
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    ll n; cin >> n;
    map<string, bool> dic;
    for(ll i = 0; i < n; i++) {
        char input[20], str[20]; scanf("%s %s", input, str);
        if(input[0] == 'i') {
            dic[str] = true;;
        } else {
            if(dic[str] == true ) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    
    return 0;
}





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

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

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = [0]
for i, num in enumerate(a):
    b.append(b[i] + a[i])
count = {}
for num in b:
    if num in count:
        count[num] += 1
    else:
        count[num] = 1
ans = int(sum([(i*(i-1))/2 for i in count.values()]))
print(ans)

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

bool isPal(string S) {
  
  int L = S.size();
  
  for (int i = 0; i < L / 2; i++) {
    
    if (S.at(i) != S.at(L - 1 - i)) return false;
    
  }
  
  return true;
  
}

int main() {
  
  string S; cin >> S;
  
  int L = S.size();
  
  string left = S.substr(0, L / 2);
  
  string right = S.substr(L / 2 + 1, L / 2);
  
  if (isPal(S) && isPal(left) && isPal(right)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}

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

using namespace std;
long long a[15];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	int ans=0;
	for(int i=0;i<n-1;i++)ans+=a[i];
	ans+=a[n-1]/2;
	cout<<ans;
	return 0;
}

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

int calc(int n)
{
	int c = 0;
	while (n != 0) {
		n /= 10;
		c++;
	}
	return c;
}

int main()
{
	int n;
	cin >> n;
	int cnt = 0;
	
	for (int i = 1; i <= n; i++) {
		if (calc(i) % 2 != 0)
			cnt++;
	}
	cout << cnt << endl;

}

Measured memory_bytes: 256
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = a; i >= (b); --i)
#define repdl(i, a, b) for(ll i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif
using namespace std;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  string s, t; read(s, t);
  int n = sz(t);
  int ans = n;
  rep(i, 0, sz(s) - sz(t) + 1) {
    string e = s.substr(i, sz(t));
    int v = 0;
    rep(i, 0, n) v += int(e[i] != t[i]);
    chmin(ans, v);
  }
  write(ans);
}



Measured memory_bytes: 3648
s = input()
t = input()

slist,tlist = [[] for _ in range(26)],[[] for _ in range(26)]

for i in range(len(s)):
  slist[ord(s[i])-ord('a')].append(str(i))
  tlist[ord(t[i])-ord('a')].append(str(i))

stargets,ttargets = [],[]
for x in range(26):
  if len(slist[x]) > 0:
    stargets.append(''.join(slist[x]))
  if len(tlist[x]) > 0:
    ttargets.append(''.join(tlist[x]))
stargets.sort()
ttargets.sort()
if stargets == ttargets:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 31792
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
#define mp make_pair
#define pb push_back

using namespace std;

int main() 
{
	int a, b , c;
	scanf("%d%d%d", &a, &b, &c);
	if (a + b >= c)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;

int main() {
  int n;
  cin>>n;
  Graph A(n);
  rep(i,n){
    int a;
    cin>>a;
    A[i].push_back(a-1);
  }
  
  vector<int> dist(n,-1);
  queue<int> que;
  dist[0]=0;
  que.push(0);
  int  state=-1;
  while(!que.empty() && state==-1){
    int v=que.front();
    que.pop();
    for(int nv:A[v]){
      if(dist[nv]!=-1){
        state=2;
        break;
      }
      dist[nv]=dist[v]+1;
      que.push(nv);
      if(nv==1){
        state=1;
        break;
      }
    }
  }
  
  if(state==1) cout<<dist[1]<<endl;
  else cout<<"-1"<<endl;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
using namespace std;
long long n,m,i,j,p[100005],c[100005],s[100005],ans,r,lst;
int main(){
	cin>>n>>m;
	rep(i,n){
		cin>>p[i]>>c[i];
		if(p[i]<=m) r=i;
	}
	i=1;j=n;lst=0;
	while(i<=r&&j>r){
		if(c[i]>=c[j]){
			if(lst!=1){
				lst=1;
				s[i]+=p[j]-p[i];
			}
			c[i]+=c[j];
			s[i]+=s[j];
			j--;
		}
		else{
			if(lst!=-1){
				lst=-1;
				s[j]+=p[j]-p[i];
			}
			c[j]+=c[i];
			s[j]+=s[i];
			i++;
		}
	}
	if(i<=r) ans=s[i]+m-p[i]; else ans=s[j]+p[j]-m;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
function Main(s) {
  s = s.split("\n");
  var a = s[1].split(" ").map(a => +a);
  const n = +s[0];
  var m = Math.max(...a);
  var b = [...a].sort((a,b)=> a-b);
  var c = 9e9;
  for(var i = 0; i < n - 1; i++){
    if(Math.abs(m / 2 - b[i]) < c)c = Math.abs(m / 2 - b[i]);
    else break;
  }
  console.log("%d %d", m, b[i-1]);
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 30272
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;



int main(){
  int N;
  cin >> N;
  int a[N];
  vector<int> v;
  int ans[N];
  REP(i, 0, N){
    cin >> a[i];
    v.push_back(a[i]);
    ans[i] = -1;
  }


  int syo;
  for(int i=N;i>=1;i--){
    syo = N / i;
    if (syo == 1) {
      ans[i-1] = a[i-1];
    }
    else{
      int sum = 0;
      for(int j=syo-1; j>0; j--){ // when syo==2, loop 1 time.
        sum = sum + ans[((j+1) * i)-1];
      }
      if ((sum%2) == a[i-1]) {
        ans[i-1] = 0;
      }
      else{
        ans[i-1] = 1;
      }
    }
  }

  int flag = 0;
  REP(i, 0, N){
    if(ans[i] == 1){
      flag++;
    }
  }

  if (flag == 0) {
    cout << 0 << endl;
  }
  else{
    cout << flag << endl;
    REP(i, 0, N){
      if(ans[i] == 1){
        cout << i+1 << " " << endl;
      }
    }
  }

  return 0;
}


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

int main(){
    int N,K;
    cin >> N >> K;
    int ans = 0;
    vector<int> vec(N);
    for(int i = 0; i < K; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            vec[a-1]++;
        }
    }
    for(int i = 0; i < vec.size(); i++){
        if(vec[i] == 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  long long n,a,b;
  cin >> n >> a >> b;
  
  long long x = a*(n/(a+b));
  long long y = n%(a+b);
  
  if(a==0){
    cout << x << endl;
  }
  else if(y<=a){
    cout << x + y << endl;
  }
  else{
    cout << x + a <<endl;
  }
}

Measured memory_bytes: 256
from itertools import permutations
import numpy as np

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

avg = []
for pair in list(permutations(towns)):
    x_prev = None
    y_prev = None
    dist = 0
    for i, (x, y) in enumerate(pair):
        if i > 0:
            dist += np.sqrt((x-x_prev)**2 + (y-y_prev)**2)
        x_prev = x
        y_prev = y
    
    avg.append(dist)

print('{:.10f}'.format(np.mean(avg)))
        


        


Measured memory_bytes: 27544
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main()
{

    set<int> s;
    vector<int> v;
    int num, num1, num2;
    scanf("%d", &num);

    for (int i = 0; i < num; i++){
        scanf("%d", &num1);
        if (num1 == 0){
            scanf("%d", &num2);
            s.insert(num2);
            ///printf("--%d--", s.size());
            v.push_back(s.size());
        }
        else if(num1 == 1){
            scanf("%d", &num2);
            s.find(num2);
            ///printf("--%d--", s.count(num2));
            v.push_back(s.count(num2));
        }

        else if(num1 == 2){
            scanf("%d", &num2);
            s.erase(num2);
        }
    }

    for (auto val : v){
        cout << val << "\n";
    }

    return 0;
}



Measured memory_bytes: 13096
#include<algorithm>
#include<chrono>
#include<ctime>  
#include<climits>
#include<functional>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
// #include<bits/stdc++.h>
using namespace std;
 
struct Debug{
    int cnt = 0;
    bool on = false;
    char debug[10] = "debug";
    template<class T>
    Debug & operator<<(const T & v) {
        if(on && cnt++ == 0) cerr << "debug: ";
        if(on) cerr << v << ' ';
        return *this;
    }
    Debug & operator<<(ostream&(*pManip)(ostream&)) {
        if(on) cerr << (*pManip);
        cnt = 0;
        return *this;
    }
} debug;
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {if(debug.on){for(auto x : v) debug << x; debug << endl;}}
#define printn(v, n) {if(debug.on){for(int _i = 0; _i < n; _i++) debug << *(v + _i); debug << endl;}}
#define pb push_back


typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<long long> vll;

const int MAXN = 1e6 + 10;

pair<ll, int> cal0(int d1, int d2) {
	ll cnt = 1;
	d1 = d1 + d2;
	while(d1 >= 10) {
		cnt++;
		d1 = d1 / 10 + d1 % 10;
	}
	return {cnt, d1};
}

pair<ll, int> cal(ll c0, int d0) {
	if(c0 == 1) return {0LL, d0};

	ll res_cnt = 0;
	auto tmp = cal0(d0, d0);
	res_cnt += tmp.first * (c0 / 2);

	auto tmp1 = cal(c0 / 2, tmp.second);
	res_cnt += tmp1.first;

	if(c0 % 2) {
		auto tmp2 = cal0(d0, tmp1.second);
		res_cnt += tmp2.first;
		return {res_cnt, tmp2.second};
	}
	else return {res_cnt, tmp1.second};

}

int n;
ll c[MAXN], d[MAXN];

int main(int argc, char * argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cout.tie(nullptr);
    if(argc > 1 && !strcmp(argv[1], debug.debug)) debug.on = true;

    cin >> n;
    ll res = 0;
    rep(i, 0, n) {
    	cin >> d[i] >> c[i];
    	auto tmp = cal(c[i], d[i]);
    	res += tmp.first;
    	d[i] = tmp.second;
    	if(i) {
    		tmp = cal0(d[i - 1], d[i]);
    		res += tmp.first;
    		d[i] = tmp.second;
    	}
    }
    cout << res << endl;



    return 0;
}













Measured memory_bytes: 5888
#include<iostream>  
#include<cstdio>  
#include<cstdlib>  
#include<cstring>  
#include<string.h>  
#include<vector>  
#include<algorithm>   
#define maxn 210000  
#define ll long long
using namespace std;  
vector<ll>q[2];  
ll x[maxn],y[maxn];  
ll bit[100];  
int n;  
ll solve() 
{  
    ll ans=0;  
    for(ll i=0;i<62;i++)  
    {  
        ll tot=0;  
        q[0].clear();q[1].clear();  
        for(ll j=1;j<=n;j++)  
            q[(x[j]>>i)&1].push_back(x[j]);  
        for(ll j=0;j<q[0].size();j++)  
            x[++tot]=q[0][j];  
        for(ll j=0;j<q[1].size();j++)  
            x[++tot]=q[1][j];  
        tot=0;  
        q[0].clear();q[1].clear();  
        for(ll j=1;j<=n;j++)  
            q[(y[j]>>i)&1].push_back(y[j]);  
        for(ll j=0;j<q[0].size();j++)  
            y[++tot]=q[0][j];  
        for(ll j=0;j<q[1].size();j++)  
            y[++tot]=q[1][j];  
        ll len1=1,len2=1,len3=1;  
        ll limit1=1ll<<i;  
        ll limit2=1ll<<(i+1);  
        ll all=(1ll<<(i+1))-1;
        ll sum=0;  
        for(ll i=n;i>=1;i--)  
        {  
            while((((x[i]&all)+(y[len1]&all))<limit1) && (len1<=n)) len1++;  
            while((((x[i]&all)+(y[len2]&all))<limit2) && (len2<=n)) len2++;  
            while(((x[i]&all)+(y[len3]&all)<limit1+limit2) && (len3<=n)) len3++;
            sum+=n-(len1-1-len2+1+len3-1);  
        }    
        if(sum&1) ans+=bit[i];  
    }  
    return ans;  
}  
  
int main()  
{    
    int cas;  
    cas=1; 
    bit[0]=1;  
    for(ll i=1;i<=61;i++)  
    bit[i]=bit[i-1]*2;  
    for(ll ca=1;ca<=cas;ca++)  
    {  
        scanf("%lld",&n);  
        for(ll i=1;i<=n;i++)  
            scanf("%lld",&x[i]);  
        for(ll i=1;i<=n;i++)  
            scanf("%lld",&y[i]); 
       printf("%lld\n",solve()) ;  
    }  
}  

Measured memory_bytes: 6508
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

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

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

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

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


int main() {
	int n;
	cin >> n;
	hei(ll) a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	whei(ll) dp(n ,hei(ll)(2,-INF));
	dp[0][0] = a[0];
	rep(i, 1, n) {
		dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + a[i];
		dp[i][1] = max(dp[i - 1][0] - 2 * a[i - 1], dp[i - 1][1] + 2 * a[i - 1]) + a[i] * -1;
	}
	ll ans = max(dp[n - 1][1], dp[n - 1][0]);
	cout << ans << endl;
	return 0;
}

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


void solve(long long N, std::vector<long long> A){
    vector<int> s(N, 0);
    for (int i = 0; i < N; i++) {
	s[A[i] -1] = i;
    }
    for (int i = 0; i < N; i++) {
        if (i != 0) {
	    cout << " ";
        }
	cout << s[i]+1;
    }
    cout << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int main() {
  int N, M;
  cin >> N;
  vector<int>T(N);
  vector<int>P(M);
  vector<int>X(M);
  vector<int>ans(M);
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> P.at(i) >> X.at(i);
  }
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) {
      if (j + 1 == P.at(i)) {
        ans.at(i) += X.at(i);
      }
      else {
        ans.at(i) += T.at(j);
      }
    }
  }
  for (int i = 0; i < M; i++) {
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 640
s = input()
q = int(input())
flag = True
head = '' # 最終的に先頭に追加されている文字
end = '' # 最終的に末尾に追加されている文字

for i in range(q):
    que = [i for i in input().split()]
    if que[0] == '1':
        flag ^= True # Trueなら通常，Falseは反転状態
    elif que[0] == '2' and flag is True:
        if que[1] == '1':
            head = que[2] + head
        elif que[1] == '2':
            end = end + que[2]
    elif que[0] == '2' and flag is False:
        if que[1] == '1':
            end = end + que[2]
        elif que[1] == '2':
            head = que[2] + head
s = head+s+end
if flag is False:
    s = s[::-1]
print(s)

Measured memory_bytes: 9952
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include<cmath>
#include<functional>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;


int main(){
   int n,m;
   cin >> n >> m;
   cout << n*(n-1) / 2 + m*(m - 1) / 2 << endl;

}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,k;
  cin >> n >> k;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  ll l=-1,r=n;
  while(l+1<r) {
    ll tmp=(l+r)>>1;
    mat dp(n+1,vec(k,0));
    dp[0][0]=1;
    for(ll i=0;i<n;i++) {
      for(ll j=0;j<k;j++) {
        dp[i+1][j]|=dp[i][j];
        if(i!=tmp&&j+a[i]<k) {
          dp[i+1][j+a[i]]|=dp[i][j];
        }
      }
    }
    ll f=0;
    for(ll i=max(k-a[tmp],0LL);i<k;i++) {
      f|=dp[n][i];
    }
    if(f) {
      r=tmp;
    }
    else {
      l=tmp;
    }
  }
  cout << l+1 << endl;
}

Measured memory_bytes: 195928
#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=a;i<=b;++i)
using namespace std;
long long step;
long long a[3];
int main(){
//	freopen("data.in","r",stdin);
//	freopen("bf.out","w",stdout);
	For(i,1,3)
		cin>>a[i];
	sort(a+1,a+4);
	int ans=0;
	while(a[2]<a[3]-1)
		++ans,a[2]+=2;
	sort(a+1,a+4);
	while(a[1]<a[2]-1)
		++ans,a[1]+=2;
	sort(a+1,a+4);
	if(a[1]==a[2]&&a[2]==a[3])
		cout<<ans;
	else
	if(a[2]==a[3]&&a[1]!=a[2])
		cout<<ans+2;
	else
		if(a[1]==a[2]&&a[2]!=a[3])
			cout<<ans+1;
	else
		if(a[1]!=a[2]&&a[2]!=a[3])
			cout<<ans+3;
	return 0;
}

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

AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[0])

n_drink = 0
cost = 0
for A, B in AB:
    remaining = M - n_drink
    if remaining > B:
        n_drink += B
        cost += A * B
    elif remaining <= B:
        cost += A * remaining
        print(cost)
        exit()


Measured memory_bytes: 29028
#include<bits/stdc++.h>
using namespace std;
const int inf=1e9+5;
const int maxn=100005;
int k,a[maxn],dp[maxn];
int mincost(int n)
{
    if(n==1)
        return 0;
    else if(n==2)
        return abs(a[2]-a[1]);
    else if(dp[n]!=-1)
        return dp[n];
    else
    {
        dp[n]=inf;
        for(int i=1;i<=k;i++)
        {
            if(n-i>=0)
            dp[n]=min(dp[n],mincost(n-i)+abs(a[n]-a[n-i]));
        }
    }
    return dp[n];

}
int main()
{
    int n;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    memset(dp,-1,sizeof(dp));
        cout<<mincost(n)<<endl;
    return 0;
}



Measured memory_bytes: 4096
import java.util.*;

public class Main {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
     int a = sc.nextInt();
     int b= sc.nextInt();
     
    
     int min= a*2;
     int max = a*4;
     if(b>max){
          System.out.println("No");
     }else if(b<min){
          System.out.println("No");
     }
     else {
     boolean  ok =false;
     for(int i = min;i<=max;i++){
         if(i%2==0){
             if(b==i){
                 ok=true;
                 break;
             }
         }
     }
     if(ok){
         System.out.println("Yes");
     }else{
         System.out.println("No");
     }
    }
        
    }
}

Measured memory_bytes: 35764
W,H,n = gets.split.map(&:to_i)
dp = [nil, 0, W, 0, H]
n.times do 
  x,y,a = gets.split.map(&:to_i)
  dp[1] = x if x > dp[1] && a == 1
  dp[2] = x if x < dp[2] && a == 2
  dp[3] = y if y > dp[3] && a == 3
  dp[4] = y if y < dp[4] && a == 4
end
  
puts [dp[2] - dp[1], 0].max * [dp[4] - dp[3], 0].max


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define sc second

int n, m, k;
const int mod = 1e9 + 7;

long long res2() {
  long long num = m - 1;
  long long res_x = 0, res_y = 0;
  res_x = (long long)((num + 1) * (2 * num + 4) * num / 12) % mod;
  res_x = res_x * n * n % mod;

  num = n - 1;
  res_y = (long long)((num + 1) * (2 * num + 4) * num / 12) % mod;
  res_y = res_y * m * m % mod;
  return (res_x + res_y) % mod;
}

long long comb(int a, int b) {
  long long res = 1;
  long long top = 1, bot = 1;
  for (int i = 0; i < b; ++i) {
    top = top * (a - i) % mod;
    bot = bot * (b - i) % mod;
  }

  long long binpow = mod - 2, botinv = 1;
  while (binpow) {
    if (binpow & 1)
      botinv = botinv * bot % mod;
    bot = bot * bot % mod;
    binpow >>= 1;
  }
  return (top * botinv) % mod;
}

int main() {
  cin >> n >> m >> k;
  long long res_2 = res2();
  cout << res_2 * comb(n * m - 2, k - 2) % mod << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {


  private void solve(InputReader in, PrintWriter out) {
    int n = in.nextInt();
    boolean flag = false;
    for (int i = 0; i < n; i++) {
      int num = in.nextInt();
      if (num % 2 == 1){
        flag = true;
      }
    }
    out.println(flag ? "first" : "second");
  }


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

  private void run() {

    try (InputReader in = new InputReader(System.in);
         PrintWriter out = new PrintWriter(System.out)) {
      solve(in, out);
    }
  }


  static class InputReader implements AutoCloseable {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
      //reader = new BufferedReader(new FileReader(stream), 32768);
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

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

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

    @Override
    public void close() {
    }
  }

}


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

#define ll long long

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

	ll x, a;
	scanf("%lld %lld", &x, &a);
	puts(x < a ? "0" : "10");
	return 0;
}

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int n;

vi v;

void read() {
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    v.pb(x);
  }
}

void solve() {
  int sol = 0, cmax = -1;
  for(int i = 0; i < n; ++i) {
    cmax = max(cmax, v[i]);
    sol += v[i];
  }
  cout << sol - cmax + cmax / 2;
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
//  cin >> t; //please do not forget to comment this if there are no queries
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) {
	long long g;
	long long c = max(a, b);
	long long d = min(a, b);
	while (true) {
		if (c % d == 0) {
			g = d;
			goto C;
		}
		else {
			c -= d;
			if (c <= d) {
				swap(c, d);
			}
		}
	}
C:
	return g;
}
int main() {
	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll x = abs(c - a), y = abs(b - d);
	ll e = gcd(x, y);
	x /= e; y /= e;
	cout << e*(x + y - 1) << endl;
}

Measured memory_bytes: 256
import math

n, d = input().split()
n = int(n)
d = int(d)

points = []
counter = 0

for i in range(n):
    points.append(input().split())

for p in points:
    for i in range(d):
        p[i] = int(p[i])
        

for p in points:
    for q in points:
        if p == q:
            continue
        dist = 0
        for i in range(d):
            dist += (p[i] - q[i])**2
        
        dist = math.sqrt(dist)
        if dist.is_integer():
            counter += 1

print(int(counter/2))

Measured memory_bytes: 3064
import copy
n,k=map(int,input().split())
l=list(map(int,input().split()))
lr=[[0,[]]]
ll=[[0,[]]]
sumr,suml=0,0
lrr=[]
llr=[]
for i in range(n):
  suml+=l[i]
  sumr+=l[-1-i]
  if l[i]<0:
    llr.append(l[i])
  if l[-1-i]<0:
    lrr.append(l[-1-i])
  llr1=copy.deepcopy(llr)
  lrr1=copy.deepcopy(lrr)
  lr.append([sumr,lrr1])
  ll.append([suml,llr1])
max=-10**10
for i in range(n+1):
  for j in range(n+1):#左からi個右からj個
    if i+j>n or i+j>k:
      pass
    else:
      max1=lr[j][0]+ll[i][0]
      num=k-i-j
      list1=lr[j][1]+ll[i][1]
      list1=sorted(list1)
      for o in range(min(len(list1),num)):
        max1-=list1[o]
        if max1>max:
          max=max1
      if max1>max:
        max=max1
print(max)

Measured memory_bytes: 3444
using System;
using System.Collections.Generic;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        var hs = new HashSet<char>();
        int n = sc.NextInt();

        for (int i = 0; i < n; i++)
        {
            hs.Add(sc.NextChar());
        }

        if (hs.Count == 3)
        {
            Console.WriteLine("Three");
        }

        if (hs.Count == 4)
        {
            Console.WriteLine("Four");
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13396