akhauriyash/Code-Regression huggingface dataset:
// I think of what the world could be, A vision of the one I see, A million dreams is all it's gonna take

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int maxn = 1e5 + 10, mod = 998244353;
const int MX = 1 << 17;

int cnt1[MX], cnt2[MX], cnt3[MX], arr[MX];
int n, dp[maxn];
vector<int> v[maxn];

int Pow(int a, int b){
    int ans = 1;
    for(; b; b >>= 1, a = 1ll * a * a % mod)
	if(b&1)
	    ans = 1ll * ans * a % mod;
    return ans;
}
void solve(int *arr){
    int m;
    cin >> m;
    for(int i = 1; i <= n; i++){
	v[i].clear();
    }
    while(m--){
	int a, b;
	cin >> a >> b;
	if(a > b)
	    swap(a, b);
	v[a].PB(b);
    }
    for(int i = n; i >= 1; i--){
	vector<int> vec;
	for(int j : v[i])
	    vec.PB(dp[j]);
	sort(vec.begin(), vec.end());
	vec.resize( unique(vec.begin(), vec.end()) - vec.begin() );
	dp[i] = sz(vec);
	for(int j = 0; j < sz(vec); j++){
	    if(j != vec[j]){
		dp[i] = j;
		break;
	    }
	}
	assert(dp[i] < MX);
	arr[dp[i]] = (arr[dp[i]] + Pow(10, 18 * i)) % mod;
    }
}
void txor(int *a,int tw,bool inv){
    for(int ln=1;(2*ln)<=tw;ln*=2){
	for(int l=0;l<tw;l+=ln+ln){
	    for(int i=0;i<ln;i++){
		int x=a[l+i],y=a[l+ln+i];
		a[l+i]=(x+y) % mod;
		a[l+ln+i]=(x-y) % mod;
	    }
	}
    }
    if(inv){
	int r = Pow(tw, mod-2);
	for(int i=0;i<tw;i++)
	    a[i] = 1ll * a[i] * r % mod;
    }
}

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

    cin >> n;
    solve(cnt1), solve(cnt2), solve(cnt3);

    txor(cnt1, 1<<17, 0);
    txor(cnt2, 1<<17, 0);
    for(int i = 0; i < (1<<17); i++)
	cnt1[i] = 1ll * cnt1[i] * cnt2[i] % mod;
    txor(cnt1, 1<<17, 1);
    int ans = 0;
    for(int i = 0; i < (1<<17); i++)
	ans = (1ll * ans + 1ll * cnt1[i] * cnt3[i]) % mod;
    if(ans < 0)
	ans+= mod;
    return cout << ans << endl, 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const double eps = 1e-9;
vector<double> x, y;
int n;

void update(double rx, double ry, double &ans) {
    double r = 0;
    rep(i, n) {
        chmax(r, hypot(rx - x[i], ry - y[i]));
    }
    chmin(ans, r);
} 

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    x.resize(n); y.resize(n);
    rep(i, n) cin >> x[i] >> y[i];
    
    double ans = 1e9;
    rep(i, n) {
        rep(j, i) {
            double rx = (x[i] + x[j]) / 2.0;
            double ry = (y[i] + y[j]) / 2.0;
            update(rx, ry, ans);

            rep(k, j) {
                double a = hypot(x[i] - x[j], y[i] - y[j]);
                double b = hypot(x[j] - x[k], y[j] - y[k]);
                double c = hypot(x[k] - x[i], y[k] - y[i]);

                if (abs(a + b - c) < eps) continue;
                if (abs(a - b + c) < eps) continue;
                if (abs(-a + b + c) < eps) continue;
                
                double frac = a*a * (b*b + c*c - a*a) + b*b * (c*c + a*a - b*b) + c*c * (a*a + b*b - c*c);
                double rx = a*a * (b*b + c*c - a*a) * x[k] + b*b * (c*c + a*a - b*b) * x[i] + c*c * (a*a + b*b - c*c) * x[j];
                double ry = a*a * (b*b + c*c - a*a) * y[k] + b*b * (c*c + a*a - b*b) * y[i] + c*c * (a*a + b*b - c*c) * y[j];
                rx /= frac;
                ry /= frac;
                update(rx, ry, ans);
            }
        }
    }
    printf("%.15f\n", ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  string s;
  string c;
  
  cin >> a >> s >> c;
  
  char A = a.at(0);
  char S = s.at(0);
  char C = c.at(0);
  
  cout << A << S << C << endl;
}

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

int abs(int x){
  if(x<0){
    x=-x;
  }
  return x;
}

int main(){
  int N;
  cin>>N;
  vector<int> x(N),y(N),h(N),zero;
  for(int i=0;i<N;i++){
    cin>>x.at(i)>>y.at(i)>>h.at(i);
    if(h.at(i)==0){
      zero.push_back(i);
    }
  }
  zero.push_back(100);

  for(int Cx=0;Cx<=100;Cx++){
    bool sub=false;
    for(int Cy=0;Cy<=100;Cy++){
      bool flag=true;
      int i=0;
      int k=0;
      while(zero.at(k)==i){
        i++;
        k++;
      }
      int H=h.at(i)+abs(Cx-x.at(i))+abs(Cy-y.at(i));
      //cout<<H<<endl;
      i++;
      while(i<N){
        if(zero.at(k)==i){
          i++;k++;
          continue;
        }
        if(H!=h.at(i)+abs(Cx-x.at(i))+abs(Cy-y.at(i))){
          flag=false;
          break;
        }
        i++;
      }
      /*
      if(flag){
        cout<<"Hello"<<endl;
      }
      */
      if(flag){
        for(int k=0;k<zero.size()-1;k++){
          int i=zero.at(k);
          if(H-abs(Cx-x.at(i))-abs(Cy-y.at(i))>0){
            flag=false;
            break;
          }
        }
      }
      if(flag){
        cout<<Cx<<" "<<Cy<<" "<<H<<endl;
        sub=true;
        break;
      }

      //cout<<Cx<<" "<<Cy<<endl;
    }
    if(sub){
      break;
    }
  }
}


Measured memory_bytes: 256
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
const int N = 55, Mod = 1e9 + 7;
int n, q, LCA[N][N], A[N], B[N], P[N], H[N], F[N];
vector < int > Adj[N];
long long tot;
void DFS(int v, int p)
{
    P[v] = p;
    H[v] = H[p] + 1;
    for (int u : Adj[v])
        if (u != p)
            DFS(u, v);
}
void DFS2(int v, int p)
{
    for (int u : Adj[v])
        if (u != p)
            DFS2(u, v), F[v] += F[u];
    if (!F[v] && p)
        tot = tot * 2LL;
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i < n; i ++)
    {
        int v, u;
        scanf("%d%d", &v, &u);
        Adj[v].push_back(u);
        Adj[u].push_back(v);
    }
    DFS(1, 0);
    for (int i = 1; i <= n; i ++)
        for (int j = 1; j <= n; j ++)
        {
            int v = i, u = j;
            while (v != u)
            {
                if (H[v] < H[u])
                    swap(v, u);
                v = P[v];
            }
            LCA[i][j] = v;
        }
    scanf("%d", &q);
    for (int i = 0; i < q; i ++)
        scanf("%d%d", &A[i], &B[i]);
    long long SM = 0;
    for (int mask = 0; mask < (1 << q); mask ++)
    {
        tot = 1;
        memset(F, 0, sizeof(F));
        for (int i = 0; i < q; i ++)
            if (mask >> i & 1)
                F[A[i]] ++, F[B[i]] ++, F[LCA[A[i]][B[i]]] -= 2;
        DFS2(1, 0);
        if (__builtin_popcount(mask) & 1)
            SM += tot;
        else
            SM -= tot;
    }
    printf("%lld\n", -SM);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 2005

int H,W;
char A[SIZE][SIZE],B[SIZE][SIZE];

int main(){

	scanf("%d %d",&H,&W);

	for(int row = 0; row < H; row++){

		scanf("%s",A[row]);
	}

	for(int row = 0; row < H; row++){

		scanf("%s",B[row]);
	}

	int ans = 0;

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){

			if(A[row][col] != B[row][col])ans++;
		}
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 11068
import java.util.Scanner;

//JOI - Prelim   0522
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            char[] s = sc.next().toCharArray();
            int[] c = { 0, 0 };
            for (int i = 0; i < s.length - 2; i++)
                if (s[i + 1] == 'O' && s[i + 2] == 'I')
                    for (int j = 0; j < 2; j++)
                        if (s[i] == 73 + j)
                            c[j]++;
            System.out.println(c[1] + "\n" + c[0]);
        }
    }
}


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

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

    int N, K;
    cin >> N >> K;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int h;
        cin >> h;
        if (h >= K) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
a=Array.new(5,0)
5.times do |i|
    a[i]=gets.to_i
end

ans=1000
[*0..4].permutation.to_a.each do |perm|
    sum=0
    4.times do |i|
        sum+=(a[perm[i]]+9)/10*10
    end
    ans=[ans,sum+a[perm[4]]].min
end
puts ans


Measured memory_bytes: 14296
import Control.Monad
import Control.Applicative

vertSum table = [sum [row !! i | row <- table] | i <- [0..(length (head table) - 1)]]

processSheet table = rowWithTot ++ [newRow]
    where rowWithTot = map (\row -> row ++ [sum row]) table
          newRow = vertSum rowWithTot

myPrint = mapM_ (putStrLn . unwords . map show)

main = do
    _ <- getLine
    myPrint . processSheet =<< map (map (read :: String->Int) . words) <$> lines <$> getContents

Measured memory_bytes: 5532
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <complex>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;

typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(t,c) for(typeof((c).begin()) t=(c).begin(); t!=(c).end(); ++t)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(t,a,b) for(int t=(a);t<(b);++t)
#define REP(t,n)  FOR(t,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;



const LL mod = 1000000007;

LL gcd(LL a, LL b) { if (a%b == 0) { return b; } else return gcd(b, a%b); }
LL lcm(LL a, LL b) { return a / gcd(a, b)*b; }

#define Yes_ cout<<"Yes"<<endl; return 0;
#define No_ cout<<"No"<<endl; return 0;


#define YES_ cout<<"YES"<<endl; return 0;
#define NO_ cout<<"NO"<<endl; return 0;

#define POSSIBLE cout<<"POSSIBLE"<<endl; return 0;
#define IMPOSSIBLE cout<<"IMPOSSIBLE"<<endl; return 0;



const int MAX_N = 55556;
int prime[MAX_N]; bool is_prime[MAX_N + 1];
int pownum[MAX_N];

int num = 0;
void sieve(int n) {
	REP(i, MAX_N) { is_prime[i] = true; }
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			prime[num++] = i;
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
				//pownum[j]++;
			}
		}
	}
}

bool is__prime(int n) {
	for (int i = 2; i*i<n; i++) {
		if (n%i == 0) {
			return false;
		}
	}
	return n != 1;
}
int N;
int main() {
	cin >> N;
	sieve(55555);
	LL sum = 0;

	for (int i=0; i<num; i++) {

		if (prime[i] % 5 == 1) {
			cout << prime[i] << endl;
			//sum += prime[num - 1];
			N--;
		}
		if (N == 0) { break; }
	}

	//debug(is__prime(sum));
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int cmp(const void*a,const void*b)
{
    return *(int*)b-*(int*)a;
}
int main()
{
    int n,m,i,k=0,j,flag=0;
    int count[105],coun[105],cou[105];
    char s[105][15],t[105][15];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s",s[i]);
    }
    scanf("%d",&m);
    for(i=0;i<m;i++)
    {
        scanf("%s",t[i]);
    }
    for(i=0;i<n;i++)
    {
        count[i]=0;
        for(j=0;j<n;j++)
        {
            if(strcmp(s[i],s[j])==0)
            {
                count[i]++;
            }
        }
    }
    for(i=0;i<m;i++)
    {
        coun[i]=0;
        for(j=0;j<m;j++)
        {
            if(strcmp(t[i],t[j])==0)
            {
                coun[i]++;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        flag=0;
        for(j=0;j<m;j++)
        {
            if(strcmp(s[i],t[j])==0)
            {
                cou[k]=count[i]-coun[j];
                if(cou[k]<0)
                    cou[k]=0;
                k++;
                flag=1;
                break;
            }
        }
        if(flag==0)
        {
            cou[k]=count[i];
            k++;
        }
    }
    qsort(cou,n,sizeof(cou[0]),cmp);
    printf("%d",cou[0]);
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N,Q;

vector<ll> G[200005];
ll cnt[200005];
ll ans[200005];

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

    cin >> N >> Q;

    for (int i = 0;i < N-1;i++){
        ll a,b; cin >> a >> b;
        G[a].push_back(b);
    }

    for (int i = 0;i < Q;i++){
        ll p,y; cin >> p >> y;
        cnt[p] += y;
    }

    queue<P> que; //node, sum

    que.push(P(1,cnt[1]));
    ans[1] = cnt[1];
    while(que.size()){
        P p = que.front(); que.pop();
        ll now = p.first;
        ll sum = p.second;
        for (int i = 0;i < G[now].size();i++){
            ll to = G[now][i];
            ll s = sum+cnt[to];
            ans[to] = s;
            que.push(P(to,s));
        }
    }

    for (int i = 1;i <= N;i++){
        cout << ans[i] << " ";
    }

    cout << endl;

    return 0;

}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  string s; cin>>s;
  ll n=s.size();
  n--;
  for(ll i=n; i>=0; i--){
    if(i%2!=0) continue;
    ll m=i/2;
    if(s.substr(0,m)==s.substr(m,m)){
      cout<<i<<endl;
      return 0;
    }
  }
  
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;

main()
{
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n,m,x,y,i,j;
cin>>n>>m;
vector<ll> v[m];
for(i=0;i<m;i++)
{
	cin>>x;
	for(j=0;j<x;j++)
	{
		cin>>y;
		y--;
	
	v[i].push_back(y);
	}
}
ll p[m],ans=0;
for(i=0;i<m;i++)
cin>>p[i];
for(x=0;x<(1<<n);x++)
{
	ll f=1;
	for(i=0;i<m;i++)
	{
		ll cnt=0;
		for(auto j:v[i])
		{
			if(x&(1<<j))
			cnt++;
		}
		if(cnt%2!=p[i])
		f=0;
	}
	if(f)
	ans++;
}
cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
#define MAXX 1000005
 
#define PI   3.14159265358979323846264338327950
 
#define PB push_back
#define PF push_front
#define F first
#define S second
 
#define fixx(n) fixed << setprecision(n)
 
#define ll 	 long long
const int INF = INT_MAX;
const int mod = 1e9 + 7;
 
 
 
int main()
{
	FAST;
	int t;
	t = 1;
	cin >> t;
	string s = "ACL";
	while(t --){
		cout << s;
	}
	
	return 0;
}

Measured memory_bytes: 3648
# 122a https://atcoder.jp/contests/abc122/tasks/abc122_a

# 入力
b = input()

# 処理
if b == 'A':
    answer = 'T'
elif b == 'T':
    answer = 'A'
elif b == 'C':
    answer = 'G'
elif b == 'G':
    answer = 'C'
else:
    answer = '入力値は　A, C, G, T　のいずれかを選択'

# 出力
print(answer)

Measured memory_bytes: 8952
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;


int main()
{
	int Max = 101010;
	vector<int> prime(Max, 1);
	prime[0] = 0; prime[1] = 0;
	for (int i = 2;i < Max;i++){
		if (!prime[i]) continue;
		for (int j = i * 2;j < Max;j += i) prime[j] = 0;
	}
	vector<int> a(Max, 0);
	rep(i, Max) {
		if (i % 2 == 0) continue;
		if (prime[i] == 1 and prime[(i + 1) / 2] == 1)
			a[i] = 1;
	}
	vector<int> s(Max + 1, 0);
	s[0] = 0;
	for (int i = 0;i < Max;i++) {
		s[i+1] = s[i] + a[i];
	}
	int q; cin >> q;
	vector<int> ans(q);
	rep(i, q) {
		int a, b;
		cin >> a >> b;
		b++;
		ans[i] = s[b] - s[a];
	}
	rep(i, q)cout << ans[i] << endl;
}



Measured memory_bytes: 4828
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

typedef long long ll;
int cnt[45];
ll arr[MAX];

bool check(ll mask, ll pos){return (bool)(mask & (1LL<<pos));}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ll n, k;

    cin>>n>>k;

    for(int i = 0; i < n; i++){
        cin>>arr[i];
        for(int j = 0; j <= 40; j++){
            if(check(arr[i], j))
                cnt[j]++;
        }
    }

    ll lg = (int) log2(k), temp = 0;

    for(int i = 40; i >= 0; i--){
        if(cnt[i] * 2 < n){
            ll t = (1LL << i);
            if(temp + t <= k)
                temp += t;
        }
    }

    ll sum = 0;
    for(int i = 0; i < n; i++){
        sum = (sum + (arr[i] ^ temp));
    }

    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#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 REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n >> m;
    k = m * 1900 + (n - m) * 100;
    ans = k * pow(2, m);
    cout << ans << endl;
}

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

import itertools
import numpy as np

n, m, x = list(map(int, input().split()))

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

# print(data)
ans = 10**6*12
for i in itertools.product([0, 1], repeat=n):
    # print(i)
    data_tmp = np.zeros(m+1, dtype=np.int)
    for index in range(len(i)):
        if i[index] == 0:
            continue
        data_tmp += data[index, :]

    if np.all((data_tmp[1:] >= x)):
        ans = min(ans, data_tmp[0])
        # print(data_tmp)

if ans == 10**6*12:
    print(-1)
else:
    print(int(ans))


Measured memory_bytes: 27248
N = int(input())
X = list(map(int,input().split()))

D = {}
for x in X:
    if x in D.keys():
        D[x] += 1
    else:
        D[x] = 1

l = [[0,0]]
for i,d in enumerate(sorted(D.items())):
    l.append([d[0],l[i][1]+d[1]])
    if l[i][1]+d[1] >= N/2+1:
        break
m2 = l[-1][0]
if l[-2][1] == N/2:
    m1 = l[-2][0]
else:
    m1 = m2

b = (m1+m2)/2
for x in X:
    if x <= b:
        print(m2)
    else:
        print(m1)

Measured memory_bytes: 52700
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
    int n;
    cin>>n;
    V<int> a(n),b(n),c(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>b[i];
    for(int i=0;i<n;i++)cin>>c[i];
    ll ans=0;
    sort(all(a));sort(all(c));
    for(int i=0;i<n;i++){
        ll itl=lower_bound(all(a),b[i])-a.begin();
        ll itr=c.end()-upper_bound(all(c),b[i]); 
        ans+=itr*itl;
        //cout<<
    }
    cout<<ans<<endl;
    }


Measured memory_bytes: 1408
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;

int main() {

    map<string, string>ans = { {"Sunny","Cloudy"},{"Cloudy","Rainy"},{"Rainy","Sunny"} };
    string S;
    cin >> S;
    cout << ans[S];

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll mod=1e9+7;
const ll N = 2e5+10;




void solve(){
    
    string s;
    cin>>s;
    s=="ABC"?cout<<"ARC\n":cout<<"ABC";
    
    
}
        
        

int main(){
    
        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
        ll T=1;
        //cin>>T;
        while(T--){
            solve();
        }
            
            
        return 0;
}



Measured memory_bytes: 3640
#include <cstdio>
#include <algorithm>
#include <cmath>

int W, H, N;
int ans = 0;

int main(){
	scanf("%d%d%d", &W, &H, &N);
	
	int tmp_w, tmp_h;
	for(int i = 0; i < N; ++i){
		int x, y;
		scanf("%d%d", &x, &y);
		if(i == 0){
			tmp_w = x, tmp_h = y;
			continue;
		}

		int w_diff = tmp_w - x, h_diff = tmp_h - y;

		if(w_diff > 0 && h_diff > 0){
			ans += std::max(w_diff, h_diff);
		}
		else if(w_diff < 0 && h_diff < 0){
			ans += std::max(-w_diff, -h_diff);
		}
		else{
			ans += abs(w_diff) + abs(h_diff);
		}

		tmp_w = x, tmp_h = y;
	}

	printf("%d\n", ans);

	return 0;
}



Measured memory_bytes: 2716
function main(input){
  var a = parseInt(input.split(" ")[0], 10);
  var op = input.split(" ")[1];
  var b = parseInt(input.split(" ")[2], 10);
  
  if (op == "+"){
    console.log(a+b);
  }else{
    console.log(a-b);
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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



int main() {
    int n, k, q;
    cin >> n >> k >> q;
    
    vector<int> re(n+1,k-q);
    rep(i,q) {
        int a;
        cin >> a;
        
        re[a]++;
    }
    
    for(int i = 1; i <= n; i++) {
        if(re[i] > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int k = n%10;
    if(k == 0 || k == 1 || k == 6 || k == 8) {
        cout << "pon" << endl;
    } else if (k == 3) {
        cout << "bon" << endl;
    } else {
        cout << "hon" << endl;
    }
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

struct fenwick{
    int n;
    vector<ll> t;
    fenwick(int n_):n(n_),t(n+1){}
    void update(int i,ll x){
        for(;i<=n;i+=i&-i){
            t[i]=max(t[i],x);
        }
    }
    ll query(int i){
        ll res=0;
        for(;i>0;i-=i&-i) res=max(res,t[i]);
        return res;
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int> h(n),a(n);
    for(auto& it:h) cin>>it;
    for(auto& it:a) cin>>it;
    fenwick tr(n);
    forn(i,n){
        tr.update(h[i],tr.query(h[i])+a[i]);
    }
    cout<<tr.query(n);
    return 0;
}



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

int main() {
    string s;
    cin >> s;
    int p1, p2;
    for(int i=0; i<s.size(); ++i) {
        if(s[i] == 'A') {
            p1 = i;
            break;
        }
    }
    for(int i=s.size()-1; i>=0; --i) {
        if(s[i] == 'Z') {
            p2 = i;
            break;
        }
    }
    cout << p2 - p1 + 1 << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int M=1e9+7,N=50005,K=405;
int n,k,m,a[N],cnt[N],sum[N],sum2[N],dp1[N],inv[N],dp2[N],fac[N],f[N][K],g[N][K],p[N];
int ksm(int x,int y){
	if (!y)return 1;
	int z=ksm(x,y/2);
	z*=z;z%=M;
	if (y&1)z*=x;
	return z%M;
}
signed main(){
	fac[0]=1;
//	for (int i=1;i<=n;i++)fac[i]=fac[i-1]*i%M,inv[i]=ksm(fac[i],M-2);
	scanf("%lld%lld%lld",&n,&k,&m);
	for (int i=1;i<=n;i++)fac[i]=fac[i-1]*i%M,inv[i]=ksm(fac[i],M-2);	
	for (int i=1;i<=m;i++)scanf("%lld",&a[i]);
	int num=0;
	for (int i=1;i<=m;i++){
		num+=!cnt[a[i]];
		cnt[a[i]]++;
		if (i>k){
			num-=cnt[a[i-k]]==1;
			cnt[a[i-k]]--;
		}
		if (num==k){
			int ans=n-m+1;
			for (int i=1;i<=n-m;i++)(ans*=k)%=M;
			printf("%lld\n",ans);
			return 0;
		}
	}
	memset(cnt,0,sizeof cnt);
	int k1=m,k2=m;
	for (int i=1;i<=m;i++){
		if (cnt[a[i]]){
			k1=i-1;
			break;
		}
		cnt[a[i]]=1;
	}
	memset(cnt,0,sizeof cnt);
	for (int i=m;i;i--){
		if (cnt[a[i]]){
			k2=m-i;
			break;
		}
		cnt[a[i]]=1;
	}
	p[0]=1;
	for (int i=1;i<=n;i++)p[i]=p[i-1]*k%M;	
	if (k1==m){
		if (n<k){
			puts("0");
			return 0;
		}
        f[0][0]=1;
        int tmp=0,ans=(n-m+1)*p[n-m]%M;
        for (int i=1;i<=n;i++){
            for (int j=1;j<k;j++){
                (f[i][j]+=f[i-1][j-1]*(k-j+1)%M)%=M;
                (f[i][j]+=sum[k]+M-sum[j-1])%=M;
                (g[i][j]+=g[i-1][j-1]*(k-j+1))%=M;
                (g[i][j]+=sum2[k]+M-sum2[j-1])%=M;
                if (j>=m)(g[i][j]+=f[i][j])%=M;
            }
            for (int j=1;j<=k;j++){
                sum[j]=(sum[j-1]+f[i][j])%M;
                sum2[j]=(sum2[j-1]+g[i][j])%M;
            }
        }
        for (int j=0;j<k;j++)(tmp+=g[n][j])%=M;
        (tmp*=ksm(fac[k]*inv[k-m]%M,M-2))%=M;
        printf("%lld\n",(ans-tmp+M)%M);
		return 0;
	}
	f[0][k1]=1;
	for (int i=1;i<=k1;i++)g[0][i]=1;
	for (int i=1;i<=n;i++){
		for (int j=k-1;j;j--){
			f[i][j]=(g[i-1][j]+f[i-1][j-1]*(k-j+1))%M;
			g[i][j]=(g[i][j+1]+f[i][j])%M;
		}
		dp1[i]=(dp1[i-1]*k+f[i-1][k-1])%M;
	}
	memset(f,0,sizeof f);
	memset(g,0,sizeof g);
	f[0][k2]=1;
	for (int i=1;i<=k2;i++)g[0][i]=1;
	for (int i=1;i<=n;i++){
		for (int j=k-1;j;j--){
			f[i][j]=(g[i-1][j]+f[i-1][j-1]*(k-j+1))%M;
			g[i][j]=(g[i][j+1]+f[i][j])%M;
		}
		dp2[i]=(dp2[i-1]*k+f[i-1][k-1])%M;
	}
	int ans=0;
	for (int i=0;i<=n-m;i++)
		(ans+=dp1[i]*p[n-m-i]+dp2[n-m-i]*p[i]-dp1[i]*dp2[n-m-i])%=M;
	printf("%lld\n",(ans+M)%M);	
}

Measured memory_bytes: 319872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
}comb(100010);
mint f(int nn,int kk){
    mint res=comb(nn,kk);
    res*=comb.fact[kk];
    return res;
}
int main(){
    vector<int> G[100010];
    int n,k;cin >> n >> k;
    for(int i=0;i<n-1;i++){
        int a,b;cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    stack<P> s;
    s.push({0,-1});
    vector<bool> used(100010,false);
    used[0]=true;
    mint ans=1;
    while(!s.empty()){
        int now=s.top().first;
        int par=s.top().second;
        s.pop();
        for(auto next: G[now]){
            if(used[next]) continue;
            used[next]=true;
            s.push({next,now});
        }
        int nn=(par==-1) ? k : k-2;
        int kk=(par==-1) ? G[now].size()+1 : G[now].size()-1;
        ans*=f(nn,kk);
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 8568
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define MAX 10000003
#define pb push_back
// #define mp make_pair
#define mem(x,y) memset(x,y,sizeof(x))
#define lcm(a,b) (a*b)/__gcd(a,b)
#define set_bit_count(x) __builtin_popcount(x)
#define str_rev(str) reverse(str.begin(),str.end())
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x-1;i>=y;i--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fastio;
    int n;
    cin>>n;
    int arr[n+5];
    for(int i=0;i<=n;i++)
        arr[i]=0;
    int val;
    for(int i=1;i<n;i++)
    {
        cin>>val;
        arr[val]++;
    }
    for(int i=1;i<=n;i++)
        cout << arr[i] << endl;
    return 0;
}

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

using namespace std;
using LL = long long;
const int Max_A=5010;
const int Max_N=55;
const LL INF=1e18;

struct node{
	int silver, num;
	LL now_time;
	node(int s, int v, LL t): silver(s), num(v), now_time(t) {}
	bool operator>(const node& v) const{
		if(now_time == v.now_time) return silver > v.silver;
		return now_time > v.now_time;
	} 
};

struct edge{
	int to, cost;
	LL time;
	edge(int to, int cost, LL time): to(to), cost(cost), time(time) {}
};

LL dist[Max_A][Max_N];
vector<vector<edge>> G;
vector<int> C;
vector<LL> D;
priority_queue<node,vector<node>,greater<node>> q;

void dijkstra(){
	while(!q.empty()){
		node v=q.top(); q.pop();
		int S=v.silver, n=v.num;
		LL T=v.now_time;
		if(dist[S][n]<T) continue;
		int nS=min(Max_A-1,S+C[n]);
		if(dist[nS][n]>T+D[n]){
			node v_plus(nS,n,T+D[n]);
			dist[nS][n]=T+D[n];
			q.push(v_plus);
		}
		rep(i,G[n].size()){
			int next=G[n][i].to, c=G[n][i].cost;
			LL t=G[n][i].time;
			if(S<c) continue;
			if(dist[S-c][next]<=T+t) continue;
			dist[S-c][next]=T+t;
			node nv(S-c,next,T+t);
			q.push(nv);
		}
	}
}

int main(){
	int N, M, S;
	cin >> N >> M >> S;
	G.resize(N);
	rep(i,M){
		int u, v, a;
		LL b;
		cin >> u >> v >> a >> b;
		u--; v--;
		G[u].emplace_back(v,a,b);
		G[v].emplace_back(u,a,b);
	}
	C.resize(N), D.resize(N);
	rep(i,N) cin >> C[i] >> D[i];
	rep(i,Max_A){
		rep(j,Max_N) dist[i][j]=INF;
	}
	S=min(S,Max_A);
	dist[S][0]=0;
	node st(S,0,0); q.push(st);
	dijkstra();
	vector<LL> ans(N-1,INF);
	rep(i,Max_A){
		rep(j,N-1) ans[j]=min(ans[j],dist[i][j+1]);
	}
	rep(i,N-1) cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 9448
#include<stdio.h>

#define max(a,b) ((a)>(b)?(a):(b))

int main(){
		int n,i;
		long long a[100000],ans=0;
		scanf("%d",&n);
		for(i=0;i<n;i++)scanf("%lld",&a[i]);
		long long tmp=0;
		for(i=0;i<n;i++){
				if(a[i]==0){
						ans+=tmp/2;
						tmp=0;
				}else tmp+=a[i];
		}
		ans+=tmp/2;
		printf("%lld\n",ans);
		return 0;
}


Measured memory_bytes: 896
/*
1. I'm the Future Red Coder :)
2. Hopefully, I'll be Yellow Soon.
*/
#include<bits/stdc++.h>
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
ll power(ll a,ll b,ll m=mod) {
    if (b==0) return 1;
    ll c = power(a,b>>1,m);
    c = (c*c)%m;
    if (b&1) return (c*a)%m;
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}
/*struct node {
    int l,r,nq;
};
bool compare(const node& a,const node& b) {
    if (a.r != b.r) return a.r<b.r;
    return a.l<b.l;
}*/
/* ******* DSU START ****** */
/*
const int dsusize = (int)1e5+5;
struct node {
    int data;
    int rk,pn;
}dsu[dsusize];
//ll fans;
void initialize(int n) {
    REP(i,1,n) {
        dsu[i].data = 1;
        dsu[i].rk = 0;
        dsu[i].pn = i;
    }
}
int fnd(int i) {
    if (dsu[i].pn != i) dsu[i].pn = fnd(dsu[i].pn);
    return dsu[i].pn;
}
void unn(int i,int j) {
    i = fnd(i);
    j = fnd(j);
    if (i!=j) {
        //fans -= dsu[i].data*dsu[j].data;
        if (dsu[i].rk>dsu[j].rk) {
            dsu[j].pn = i;
            dsu[i].data += dsu[j].data;
        }
        else {
            dsu[i].pn = j;
            dsu[j].data += dsu[i].data;
            if (dsu[i].rk==dsu[j].rk) {
                dsu[j].rk++;
            }
        }
    }
}
*/
/* ******* DSU END****** */

const int N = (int)2e5+5;
const int Q = 250;
void solve() {
    int a,b;
  cin>>a>>b;
  if (a>b) swap(a,b);
  if ((a+b)&1) cout<<"IMPOSSIBLE";
  else cout<<((a+b)/2);
}
int main() {
    //freopen("class_treasurer.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int cmmdc(int a,int b)
{
    int r;
    while(b)
    {
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
int main()
{
    int n,i,x,z,k,maxim;
    cin>>n>>k>>z;
    maxim=z;
    for(i=2;i<=n;i++)
    {
        cin>>x;
        maxim=max(maxim,x);
        z=cmmdc(z,x);
    }
    if(maxim<k)
        cout<<"IMPOSSIBLE";
    else
    {
        if(k%z==0)
            cout<<"POSSIBLE";
        else
            cout<<"IMPOSSIBLE";
    }
    return 0;
}


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

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>>a(h,vector<char>(w));
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin >> a.at(i).at(j);
  vector<vector<int>>cost(h,vector<int>(w,100000));
  cost.at(0).at(0)=a.at(0).at(0)=='#';
  for(int i=1;i<h;i++)
    cost.at(i).at(0)=cost.at(i-1).at(0)+(a.at(i-1).at(0)=='.'&&a.at(i).at(0)=='#');
  for(int i=1;i<w;i++)
    cost.at(0).at(i)=cost.at(0).at(i-1)+(a.at(0).at(i-1)=='.'&&a.at(0).at(i)=='#');
  for(int i=1;i<h;i++){
    for(int j=1;j<w;j++){
      if(a.at(i-1).at(j)==a.at(i).at(j)||a.at(i).at(j-1)==a.at(i).at(j))
        cost.at(i).at(j)=min(cost.at(i-1).at(j)+(a.at(i-1).at(j)=='.'&&a.at(i).at(j)=='#'),cost.at(i).at(j-1)+(a.at(i).at(j-1)=='.'&&a.at(i).at(j)=='#'));
      else
        cost.at(i).at(j)=min(cost.at(i-1).at(j),cost.at(i).at(j-1))+(a.at(i-1).at(j)=='.'&&a.at(i).at(j)=='#');
    }
  }
  cout << cost.at(h-1).at(w-1) << endl;
  /*for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)
    cout << cost.at(i).at(j);
    cout << '\n';
  }*/
  return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll a[20][20];
ll dp[(1ll<<16)+10];

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

  rep( i, N ) rep( j, N )
    std::cin >> a[i][j];

  rep( i, 1ll<<N ) {
    ll sum = 0;

    rep( j, N ) rep( k, j ) if( (i>>j&1) && (i>>k&1) ) {
      sum += a[j][k];
    }

    dp[i] = sum;

    for( ll j = (i-1)&i; j > 0; j = (j-1)&i ) {
      chmax( dp[i], dp[j]+dp[i^j] );
    }
  }

  std::cout << dp[(1ll<<N)-1] << endl;

  return 0;
}

Measured memory_bytes: 4156
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
# mod = 998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"
INF = 1<<32-1
# INF = 10**18

def main():
    n = int(ipt())
    x,y = map(int,ipt().split())
    mas = [x+y,x-y,-x-y,y-x]
    ma = 0
    for _ in range(n-1):
        x,y = map(int,ipt().split())
        cpr = [-y-x,y-x,x+y,x-y]
        for i in range(4):
            if mas[i]+cpr[i] > ma:
                ma = mas[i]+cpr[i]
        for i in range(4):
            if mas[i] < cpr[i-2]:
                mas[i] = cpr[i-2]

    print(ma)
    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 76128
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll H;
    cin >> H;

    int cnt = 0;
    while (H > 1) {
        H /= 2LL;
        cnt++;
    }

    ll ans = 1;
    ll st = 2;
    repd(i, 1, cnt + 1) {
        ans += st;
        st *= 2LL;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vector<string>A(n);
    vector<string>B(m);
    REP(i,n){
        cin >> A[i];
    }
    REP(i,m){
        cin >> B[i];
    }
    int flag;
    string msg= "Yes";
    REP(i,n-m+1){
        REP(j,n-m+1){
            flag= 1;
            REP(k,m){
                REP(l,m){
                    if(A[i+k][j+l]!=B[k][l]) flag= 0;
                }
            }
            if(flag==1){
                cout << msg << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

int N;
int A[SIZE];
int table[SIZE];


int main(){

	scanf("%d",&N);

	for(int i = 1; i < SIZE; i++){

		table[i] = 0;
	}

	for(int i = 0; i < N; i++){

		scanf("%d",&A[i]);
		table[A[i]]++;
	}

	int ans = N;
	int num_2 = 0;

	for(int i = 1; i < SIZE; i++){
		if(table[i] <= 1)continue;

		//table[i] >= 2;
		if(table[i]%2 == 0){

			//2枚にする
			ans -= (table[i]-2);
			num_2++;

		}else{

			//1枚にする
			ans -= (table[i]-1);
		}
	}

	if(num_2%2==0){ //2枚同士のペアを作る

		ans -= num_2;
	}else{ //1枚のカードを1つ犠牲にする必要あり

		ans -= (num_2+1);
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int[] nums = ReadLineParseIntArray();
        Array.Sort(nums);
        int ans = nums[2] - nums[1];
        nums[0] += nums[2] - nums[1];
        if ((nums[2] + nums[0]) % 2 == 0)
            ans += (nums[2] - nums[0]) / 2;
        else
            ans += (nums[2] + 1 - nums[0]) / 2 + 1;
        WriteLine(ans);
    }

    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

Measured memory_bytes: 13396
n,x,y=map(int,input().split())
a=[0]*(n)
for i in range(1,n):
  for j in range(i+1,n+1):
    s=min(j-i,abs(x-i)+abs(y-j)+1,abs(x-j)+abs(y-i)+1)
    a[s]+=1
for i in range(1,n):
  print(a[i])


Measured memory_bytes: 3444
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, H);
    IN(ll, W);
    IN(ll, N);
    A2IN(ll, X, ll, Y, N);
    vvi A(H + 1);
    REP(i, N)
    {
        A[X[i]].push_back(Y[i]);
    }
    ll y = 1;
    for (ll i = 2; i <= H; ++i)
    {
        bool ok = true;
        FOR(a, A[i])
        {
            if (a <= y)
            {
                OUT(i - 1);
                return 0;
            }
            ok &= a != y + 1;
        }
        y += ok;
    }
    OUT(H);
}

Measured memory_bytes: 14336
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


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


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

    int h[101000];
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }

    int res = 0;
    int res_tmp = 0;
    for(int i = 0; i < N-1; i++){
        if(h[i] >= h[i+1]){
            res_tmp++;
        }
        else{
            res_tmp = 0;
        }
        res = max(res, res_tmp);
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 640