akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdio>

int n, m;

char a[51][51], b[51][51];

int main(){

  std::cin >> n >> m;
  for(int i = 0; i < n; i++)
    scanf("%s", a[i]);
  for(int i = 0; i < m ; i++)
    scanf("%s", b[i]);

  int res = 0;
  bool can = false;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){

      if(i + m > n || j + m > n) continue;
      res = 0;
      for(int k = 0; k < m; k++){

        for(int l = 0; l < m; l++){
          if(a[i + k][j + l] == b[k][l])
          ++res;
        }
      }
      if(res == m*m){
        can = true;
        break;
      }
    }
  }

  if(can) std::cout << "Yes\n";
  else std::cout << "No\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;


vector<bool> seen;
int dfs(vector <vector <int>> &G, int v) {
  	int size = 1,p = 0;
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        
        //dfs(G, next_v); // 再帰的に探索
      	p = dfs(G,next_v);
      	size += p;
    }
  return size;
}

int main() {
  int n,m;
  cin >> n >> m;
  vector <vector <int>> group(n);

   seen.assign(n, false);
  
  REP(i,m){
    int a;
    int b;
    cin >> a >> b;
    a -= 1;
    b -= 1;
    group.at(a).push_back (b);
    group.at(b).push_back (a);
  }
  
  int ans = 0;
  REP(i,n){
    if(seen[i] == false){
      ans = max(ans,dfs(group,i));
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 23492
#include <bits/stdc++.h>
#define ll long long
#define m 1000000007
using namespace std;
const int mmax = 200005;
ll n;
ll a[mmax];
ll f[mmax][3];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //freopen("test.inp", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        f[i][1] = (f[i-1][1]+a[i])%m;
    }
        for (int i = 1; i <= n; i++) {
            f[i][2] = ((f[i-1][1]*a[i])%m+f[i-1][2])%m;
        }
    cout << f[n][2]%m;
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  if(S=="hi" || S=="hihi" || S=="hihihi" || S=="hihihihi" || S=="hihihihihi"){
     cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >>d;
  if(a < c){
    cout <<max(min(d-c,b-c),0);
  }else{
    cout << max(min(d-a,b-a),0);
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,ave,acu_ave;
    scanf("%d %d",&a,&b);
    if((a+b)%2==0)
       {
           ave=(a+b)/2;
           printf("%d\n",ave);


    }
    else
    {
        ave=(a+b)/2;
        acu_ave=ave+1;
        printf("%d\n",acu_ave);
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <set>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    set<string> s;
    for(int i=0; i<N; i++){
        string t;
        cin >> t;
        s.insert(t);
    }

    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 19180
#include <cstdio>
#include <iostream>
#include <map>
using namespace std;

typedef long long LL;

map <LL, LL> rec[20][2];
LL pow10[20];

inline LL DP(int len, LL dif, bool pre) {
  if (len == 0) return (dif == 0);
  if (len == 1) return (dif == 0) * (10 - pre);
  if (rec[len][pre].count(dif)) return rec[len][pre][dif];
  LL ans = 0, t = pow10[len - 1] - 1, nxt;
    for (int i = pre; i <= 9; i ++)
      for (int j = 0; j <= 9; j ++) {
	nxt = dif - t * (j - i);
	if (nxt % 10 == 0) ans += DP(len - 2, nxt / 10, 0);
      }
  rec[len][pre][dif] = ans;
  return ans;
}

int main() {
  int D;
  pow10[0] = 1;
  for (int i = 1; i <= 18; i ++) pow10[i] = pow10[i - 1] * 10;
  scanf("%d", &D);
  LL ans = 0;
  for (int i = 1; i <= 18; i ++) ans += DP(i, (LL)D, 1);
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int pos;
vector<int> pre, in ,post;

void rec(int l, int r)
{
    if( l>=r )
        return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l,m);
    rec(m+1,r);
    post.push_back(root);
}

void solve()
{
    pos = 0;
    rec( 0, pre.size() );
    for(int i=0; i<pre.size(); ++i){
        if( i )
            cout << " ";
        cout << post[i];
    }
    cout << endl;
}


int main()
{
    int n, k;
    cin >> n;
    for(int i=0; i<n; ++i){
        cin >> k;
        pre.push_back(k);
    }

    for(int i=0; i<n; i++){
        cin >>k;
        in.push_back(k);
    }

    solve();

    return 0;
}



Measured memory_bytes: 3144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class287
    {
        static List<int>[] G;
        static int count = 0;
        static int N;
        static void Main()
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            N = NM[0];
            int M = NM[1];
            G = new List<int>[N];
            for (int i = 0; i < N; i++) G[i] = new List<int>();
            for(int i = 0; i < M; i++)
            {
                var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int a = r[0] - 1;
                int b = r[1] - 1;
                G[a].Add(b);
                G[b].Add(a);
            }
            bool[] bb = new bool[N];
            DFS(0, 0, bb, 1);

            Console.WriteLine(count);
        }
        static void DFS(int now,int last,bool[] b,int g)
        {
            bool[] bb = new bool[N];
            Array.Copy(b, bb, N);
            bb[now] = true;
            if (g == N) { count++;return; }
            foreach(int i in G[now])
            {
                if (i == last) continue;
                if (!bb[i])
                {
                    DFS(i, now, bb, g+1);
                }
            }

        }
    }
}


Measured memory_bytes: 11348
//我是菜鸡
#include<bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto p:st)
#define debug(q,x) cout<<q<<x<<endl
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int maxn = 1e3+5;
const int MOD = 1e9 + 7;
const double ext = 1e-6;
void deprint() {
	//ofstream cout("E:\\acm dream\\debug.txt");
	return;
}
int main() {
	//ifstream cin("E:\\acm dream\\in.txt");
	//ofstream cout("E:\\acm dream\\out.txt");
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n,x;
	while (cin >> n) {
		set<int>a;
		bool flag = true;
		_for(i, 0, n) {
			cin >> x;
			if (a.count(x)) {
				flag = false;
			}else a.insert(x);
		}
		if (flag)cout << "YES\n";
		else cout << "NO\n";
	}
	return 0;
}

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

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int H,W,m; cin >> H >> W >> m;
    vector<int> h(m),w(m);
    map<Pi,bool> used;
    rep(i,m){
        cin >> h[i] >> w[i];
        h[i]--;
        w[i]--;
        used[{h[i],w[i]}] = true;
    }
    vector<int> cnth(H),cntw(W);
    rep(i,m){
        cnth[h[i]]++;
        cntw[w[i]]++;
    }
    int maxh = *max_element(cnth.begin(),cnth.end());
    int maxw = *max_element(cntw.begin(),cntw.end());
    vector<int> v1,v2;
    rep(i,H){
        if(cnth[i] == maxh) v1.push_back(i);
    }
    rep(i,W){
        if(cntw[i] == maxw) v2.push_back(i);
    }
    int ans = maxh+maxw-1;
    int cnt = 0;
    for(auto u : used){
        if(cnth[u.first.first] == maxh && cntw[u.first.second] == maxw) cnt++;
    }
    if(cnt != (int)(v1.size()*v2.size())) ans++;
    cout << ans << endl;
}



Measured memory_bytes: 30816
#include <bits/stdc++.h>
using namespace std ;
inline long long Readin() {
	long long K = 0 , F = 1 ; char C = ' ' ;
	while( C < '0' or C > '9' ) F = C == '-' ? -1 : 1 , C = getchar() ;
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ;
	return F * K ;
}
inline long long Min( long long A , long long B ) { return A < B ? A : B ; }
inline long long Max( long long A , long long B ) { return A > B ? A : B ; }
inline long long Abs( long long A ) { return A < 0 ? -A : A ; }

int main() {
	long long K = Readin() , N = Readin() , Ans = 1 ;
	if( K == 1 ) return not printf( "%lld\n" , N ) ;
	for(register long long i = 2 , I = sqrt(N) ; i <= I ; ++i ) {
		register int Tot = 0 ;
		while( N % i == 0 ) {
			N /= i ;
			++Tot ;
		}
		for(register int j = 1 ; j <= Tot / K ; ++j )
			Ans *= i ;
	}
	return not printf( "%lld\n" , Ans ) ;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

double calc_dist(pair<double, double> p1, pair<double, double> p2){

  double dx = p1.first - p2.first;
  double dy = p1.second - p2.second;
  return sqrt(dx*dx + dy*dy);
};

int N, K;
vector<pair<double, double>> p;
vector<double> c;

int calc_cost(double x, double y, double T){

  int res = 0;

  for(int i = 0; i < N; i++){
      if(c[i] * calc_dist(make_pair(x, y), p[i]) <= T + 1e-9) res++;
  }
  return res;
}

const double one = 1.0 + 1e-11;
const double eps = 1e-8;

bool ok(double time){

  for(int i = 0; i < N; i++){
    if(calc_cost(p[i].first, p[i].second, time) >= K) return true;
  }

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

      // ２つの交点
      // iの半径
      double r1 = time / c[i];
      double r2 = time / c[j];

      double x1 = p[i].first;
      double y1 = p[i].second;
      double x2 = p[j].first;
      double y2 = p[j].second;
      
      double d = sqrt((x1-x2) * (x1-x2) + (y1-y2) * (y1-y2));

      if(r1+r2<d) continue;
      if(r1+d<r2) continue;
      if(d+r2<r1) continue;
      double s=(r1+r2+d)/2;
      double a=sqrt(s*(s-r1)*(s-r2)*(s-d));
      double h=a/d*2;
      double d2=sqrt(r1*r1-h*h);
      double dx1=(x2-x1)/d;
      double dy1=(y2-y1)/d;
      double dx2=dy1;
      double dy2=-dx1;
      for(int cx=-1;cx<=1;cx+=2) {
        for(int cy=-1;cy<=1;cy+=2) {
          double tx=x1+cx*d2*dx1+cy*h*dx2;
          double ty=y1+cx*d2*dy1+cy*h*dy2;
          if(calc_cost(tx,ty,time)>=K) return 1;
        }
      }
    }
  }

  return false;
}


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

  cin >> N >> K;

  double x, y, tc;
  for(int i = 0; i < N; i++){
    cin >> x >> y >> tc;
    p.push_back(make_pair(x, y));
    c.push_back(tc);
  }

  double left = 0;
  double right = 1e9;

  while(right - left > 1e-10){

    double mid = (left + right) / 2.0;

    if(ok(mid)){
      right = mid;
    }else{
      left = mid;
    }

  }

  cout << setprecision(16) << right << endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 100005
#define inf  1e9+7
using namespace std;

int main (){
	
	//freopen("t.txt","r",stdin);
	int n,k; 
	cin>>n>>k;
	int a[MAXN];
	long long dp[MAXN];
	for (int i=1;i<=n;i++){
		cin>>a[i];
		dp[i]=inf;
	}
	dp[1]=0;
	dp[2]=abs(a[2]-a[1]);
	for (int i=3;i<=n;i++){
		for (int j=1;j<=k;j++ ){
		if ( i>j )
		dp[i] = min (dp[i], (dp[i-j]+ abs(a[i]-a[i-j])) );
	  }
	}
	
	//for (int i=1;i<=n;i++)
	cout<<dp[n];
}


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

int n;
string s, t;
vector<char> c;

int main(){

    cin >> n >> s >> t;

    for (int i=0; i<s.size(); i++){
        c.push_back(s.at(i));
        c.push_back(t.at(i));
    }

    for (auto x: c){
        cout << x;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,l;
int main(){
  cin>>n;
  for(long long i=1;i<=3500;i++){
    for(long long j=1;j<=3500;j++){
      k=4*i*j-n*j-n*i;
      l=i*j*n;
      if(k>0&&l%k==0){
        cout<<i<<' '<<j<<' '<<l/k<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
K,S=map(int,input().split())
z=list(range(K+1))
ans=[]
for i in z:
  s_z=S-i
  if s_z<0:
    pass
  elif K<s_z:
    if (K+1)>(s_z-K):
      ans.append(2*K-s_z+1)
  else:
    ans.append(s_z+1)
print(sum(ans))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n; cin >> n;
    map<int, set<int>> m;
    REP(i, n) {
        int a; cin >> a; --a;
        m[i].insert(a);
    }
    int ans = 0;
    REP(i, n) EACH(j, m[i]) {
        if (m[j].count(i) > 0) ++ans;
    }
    assert(ans % 2 == 0);
    cout << ans/2 << endl;
}


Measured memory_bytes: 14336
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

int N,x[20],y[20],f[20],M;

int main(){
	while(cin>>N&&N){
		int cx=10,cy=10;
		rep(i,N)f[i]=0;
		rep(i,N)cin>>x[i]>>y[i];
		rep(i,N)if(cx==x[i]&&cy==y[i])f[i]=1;
		cin>>M;
		rep(i,M){
			char d;int l;
			cin>>d>>l;
			rep(j,l){
				if(d=='E')cx++;
				if(d=='N')cy++;
				if(d=='W')cx--;
				if(d=='S')cy--;
				rep(k,N)if(cx==x[k]&&cy==y[k])f[k]=1;
			}
		}
		int ans=1;
		rep(i,N)if(!f[i])ans=0;
		cout<<(ans?"Yes":"No")<<endl;
	}
}

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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 1e6 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int n, m;

ll lcm(ll x, ll y){
  return (x * y) / __gcd(x, y);
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  cin >> n >> m;
  ll t = 1;
  vector<int> a(n+1);
  For(i, 1, n) {
    cin >> a[i]; a[i] /= 2; t = lcm(t, a[i]);
    if (t > m){
      cout << 0; return 0;
    }
  }
  For(i, 1, n){
    if ( (t / a[i]) % 2 == 0){
      cout << 0; return 0;
    }
  }
  cout << ((m / t) + 1) / 2;

}




Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ls (o << 1)
#define rs (o << 1 | 1)
#define mid ((L + R) >> 1)
using namespace std;
typedef long long LL;
const int N = 200500;
const int mod = 1e9 + 7;
int a[N];
int n;
int main() {
#ifdef TEST
	freopen("input.txt", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
	}
	sort(a, a + n);
	int L = 0, ans = 0;
	for (int i = 0; i < n; ++i) {
		while (L < i && a[i] - a[L] > 2) L++;
		ans = max(ans, i - L);
	}
	cout << ans + 1 << endl;
	return 0;
}


Measured memory_bytes: 640
def main():
    n = int(input())
    a = list(map(int, input().split()))
    result = 1
    if 0 in a:
        print(0)
        return
    for number in a:
        result *= number
        if result > 10 ** 18:
            print(-1)
            return
    print(result)

main()


Measured memory_bytes: 21592
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
vector<int> L;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  L.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());

  int ans = 0;
  for (int i = 2; i < N; i++) {
    for (int j = i - 1; j >= 0; j--) {
      int k = upper_bound(L.begin(), L.begin() + j, L[i] - L[j]) - L.begin();
      if (k != j) {
        ans += (j - k);
      }
    }
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define Vi vector<int>

using namespace std;

const int N=(1<<20)+10,mod=1e9+7;
int n,mx,a[N],ans,sum[N]; Vi p[N];

int dp(Vi x){
	if (!x.size()) return 0;
	int s1=0,s2=0,f=1;
	rep (i,0,(int)x.size()-1){
		f=((ll)s2*sum[x[i]]%mod+mod-s1+1)%mod;
		s1=(s1+(ll)f*sum[x[i]]%mod)%mod;
		s2=(s2+f)%mod;
	}
	return a[n]?f:s2;
}

int main(){
	scanf("%d",&n);
	rep (i,1,n){
		scanf("%d",&a[i]),a[i]^=a[i-1];
		p[a[i]].push_back(i);
		sum[i]=sum[i-1]+(!a[i]);
	}
	if (!a[n]){
		ans=1;
		rep (i,1,(int)p[0].size()-1) ans=(ans+ans)%mod;
	}
	mx=1<<20;
	int st,ed;
	if (a[n]) st=ed=a[n]; else st=1,ed=mx-1;
	rep (i,st,ed) ans=(ans+dp(p[i]))%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 38516
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 200005;
int n;
pii niz[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
    cin >> n;
    for(int i=1;i<=n;i++)cin >> niz[i].fi >> niz[i].se;
    for(int i=3;i<=n;i++){
        if(niz[i].fi == niz[i].se && niz[i - 1].fi == niz[i - 1].se && niz[i - 2].fi == niz[i - 2].se){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
N = 4
ARR = [20, 11, 9, 24]

N = int(input())
ARR = list(map(int, input().split()))


def calculate(n, arr):
    s = arr[0]
    for i in range(1, n):
        s = s ^ arr[i]

    result = []

    for i in range(n):
        result.append(str(arr[i] ^ s))

    print(" ".join(result))


calculate(N, ARR)


Measured memory_bytes: 35764
def main():
  import sys
  input=sys.stdin.buffer.readline
  n=int(input())+1
  data=[0]*n*2
  def update(i,x):
    i+=n
    data[i]=x
    i//=2
    while i:
      data[i]=data[i*2]|data[i*2+1]
      i//=2
  def query(l,r):
    l+=n
    r+=n
    s=0
    while l<r:
      if l&1:
        s|=data[l]
        l+=1
      if r&1:
        r-=1
        s|=data[r]
      l//=2
      r//=2
    return bin(s).count('1')
  for i,c in enumerate(input()[:-1],n):data[i]=2**(c-97)
  for i in range(n-1,0,-1):data[i]=data[i*2]|data[i-~i]
  s=[]
  for _ in range(int(input())):
    q,a,b=input().split()
    if q[0]>49:s+=query(int(a)-1,int(b)),
    else:update(int(a)-1,2**(b[0]-97))
  print('\n'.join(map(str,s)))
main()

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

// cout << "hogehoge" << '\n';  // "endl" executes flush in addition to line break.
int main() {
  cin.tie(nullptr);               // Do not flush "cout" when processing "cin".
  // ios::sync_with_stdio(false); // Be careful when using both "cin/cout" and "scanf/printf".

  int n;
  cin >> n;

  int cnt = 0;
  bool ok = false;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      cnt++;
    } else {
      cnt = 0;
    }
    if (cnt == 3) {
      ok = true;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


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

int main(void){

  int sec;
  int h, m, s;
  cin >> sec;
  h = sec/3600;
  m = sec/60 - h*60;
  s = sec - h*3600 - m*60;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}

  

Measured memory_bytes: 1164
/** Which of the favors of your Lord will you deny ? **/

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

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define F first
#define S second

#define ALL(x)      (x).begin(), (x).end()
#define READ        freopen("alu.txt", "r", stdin)
#define WRITE       freopen("vorta.txt", "w", stdout)

#ifndef ONLINE_JUDGE
#define DBG(x)      cout << __LINE__ << " says: " << #x << " = " << (x) << endl
#else
#define DBG(x)
#define endl "\n"
#endif

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);

inline void optimizeIO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const int nmax = 2e5+7;

int main()
{
    optimizeIO();

    int d,t,s;
    cin>>d>>t>>s;


    if(t*s>=d) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}

/**

**/

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


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

using ll = long long;

int main() {
    int N, x = 0, ans = 0;
    string S;
    cin >> N >> S;
    rep(i, N) {
        if (S[i] == 'I') x++;
        else x--;
        ans = max(ans, x);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       
      



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var x = Read();
            var a = x / 1000;
            x -= a * 1000;
            var b = x/100;
            x -= b * 100;
            var c = x / 10 ;
            x -= c * 10;
            var d = x;
            if (a+b+c+d==7) Console.WriteLine("{0}+{1}+{2}+{3}=7",a,b,c,d);
            else if (a+b+c-d==7) Console.WriteLine("{0}+{1}+{2}-{3}=7",a,b,c,d);
            else if (a+b-c+d==7) Console.WriteLine("{0}+{1}-{2}+{3}=7",a,b,c,d);
            else if (a-b+c+d==7) Console.WriteLine("{0}-{1}+{2}+{3}=7", a, b, c, d);
            else if (a+b-c-d==7) Console.WriteLine("{0}+{1}-{2}-{3}=7", a, b, c, d);
            else if (a-b+c-d==7) Console.WriteLine("{0}-{1}+{2}-{3}=7", a, b, c, d);
            else if (a-b-c+d==7) Console.WriteLine("{0}-{1}-{2}+{3}=7", a, b, c, d);
            else if (a-b-c-d==7) Console.WriteLine("{0}-{1}-{2}-{3}=7", a, b, c, d);

            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 55;

ll dp[N][N][N*N];
int A[N];

int main(){
	fio; cout<<fixed<<setprecision(25);	
	int n , a;
	cin >> n >> a;
	for(int i = 1 ;i <= n ; ++i)
		cin >> A[i];

	dp[0][0][0] = 1;
	for(int i =1 ;i <= n; ++i){
		for(int j = 0;j <= i ; ++j){
			for(int k = 0; k < N*N ; ++k){
				dp[i][j][k] += dp[i-1][j][k];
				if(j != 0 && k >= A[i])
				dp[i][j][k] += dp[i-1][j-1][k-A[i]];
			}
		}
	}
	ll cnt = 0;
	for(int i = 1;i <= n ; ++i){
		if(a*i < N*N)
		cnt += dp[n][i][a*i];
	}
	cout << cnt << endl;








	return 0;
}


Measured memory_bytes: 65792
#include <iostream>
#include <string>
#include <list>
#include <utility>
#include <map>

using namespace std;

int main()
{
  int N, M;
  multimap<int,int> X;

  cin >> N >> M;
  
  for (int n=0; n<N; ++n) {
    int A, B;
    cin >> A >> B;
    X.insert(pair<int,int>(A,B));
  }


  for (auto x: X) {
    cerr << x.first << ' ' << x.second << endl;
  }
  
  int64_t money = 0;
  auto it = X.begin();
  while(M>0) {
    cerr << M << endl;
    int64_t price = it->first;
    int count = it->second;
    money += price * min(count,M);
    M-=count;
    it++;
  }
  
  cout << money << endl;
  
  return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
int main() {
  int n,m;
  cin >> n >> m;
  long* x = new long[1000];
  long* y = new long[1000];
  long* z = new long[1000];
  for(int i=0;i<n;i++){
    cin >> x[i];
    cin >> y[i];
    cin >> z[i];
  }
  long score = 0;
  long* ord = new long[1000];
  for(int type=0;type<8;type++){
    for(int i=0;i<n;i++){
      ord[i] = x[i]*((type/4)*2-1) + y[i]*(((type%4)/2)*2-1) + z[i]*((type%2)*2-1);
    }
    sort(ord,ord+n);
    long cand = 0;
    for(int i=0;i<m;i++) cand += ord[n-1-i];
    score = max(score,cand);
  }
  cout << score << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
string s;
int a;

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

	cin>>a;
	cin.ignore();
	cin>>s;
	if(a>=3200) cout<<s;

	else cout<<"red\n";
}

Measured memory_bytes: 256
// aaaaaaaaaaaaa
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
long long n,t,q,a[100001],d[100001],x[1001],s[100001],k,f[1001],flg,i,j;
int main(void)
{
	scanf("%lld %lld %lld",&n,&t,&q);
	for(i=1;i<=n;i++){
		scanf("%lld %lld",&a[i],&d[i]);
	}
	for(i=1;i<=q;i++){
		scanf("%lld",&x[i]);
	}
	k=0;
	for(i=1;i<n;i++){
		if(d[i]==1&&d[i+1]==2&&a[i]+t*2>=a[i+1]){
			s[k]=a[i]-(a[i]-a[i+1])/2;
			k++;
		}
	}
	for(j=1;j<=q;j++){
		flg=0;
		for(i=0;i<k;i++){
			if(d[x[j]]==1&&s[i]>=a[x[j]]&&s[i]-t<=a[x[j]]){
				f[j]=s[i];
				flg=1;
//				printf("%lld %lld\n",f[j],s[i]);
				break;
			}
		}
		for(i=k-1;i>=0;i--)	{
			if(d[x[j]]==2&&s[i]<=a[x[j]]&&s[i]+t>=a[x[j]]){
				f[j]=s[i];
				flg=1;
//				printf("%lld %lld\n",f[j],s[i]);
				break;
			}
		}
		if(flg==0){
			if(d[x[j]]==1) f[j]=a[x[j]]+t;
			else f[j]=a[x[j]]-t;
//			printf("%lld\n",f[j]);
		}
	}
	for(i=1;i<=q;i++){
		printf("%lld\n",f[i]);
	}
	return 0;
}


Measured memory_bytes: 4456
#include<iostream>
#include<queue>
#include<vector>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> v(N+1);
    for(int i = 1; i <= N; i++) cin >> v[i];

    queue<int> que;
    que.push(v[1]);
    int ans = 0;
    bool ispossible = false;
    while(!que.empty()) {
        int now = que.front(); que.pop();
        ans++;
        if(ans > N) break;
        if(now == 2) {
            ispossible = true;
            break;
        }
        que.push(v[now]);
    }

    if(ispossible) cout << ans << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 640
N=int(input())
alist=list(map(int,input().split()))
blist=list(map(int,input().split()))
clist=list(map(int,input().split()))

answer=0
old_ryori=-100
for i in range(N):
  new_ryori=alist[i]-1
  answer+=blist[new_ryori]
  if old_ryori+1==new_ryori:
    answer+=clist[new_ryori-1]
  old_ryori=new_ryori
    
print(answer)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int n, a, b, c;
    cin >> n;
    while(n--){
        cin >> a >> b >> c;
        if(a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b)
            cout<<"YES\n";
        else
            cout<<"NO\n"; 
    }
    return 0;
}

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

int main()
{
	static char s[1200];
	cin.getline(s, sizeof(s));
	for (int i = 0; s[i] != 0; ++i) {
		char *c = s+i;
		if (isalpha(*c)) {
			if (islower(*c))
				s[i] = toupper(s[i]);
			else
				s[i] = tolower(s[i]);
		}
	}
	cout << s<<endl;
	return 0;
}



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

int main(){
    int a;
    cin >> a;
   switch(a){
    case 25: cout << "Christmas" ;
        break;
    case 24: cout << "Christmas Eve ";
       break;
    case 23: cout << "Christmas Eve Eve";
       break;
    case 22: cout << "Christmas Eve Eve Eve";
        break;
    }
}


Measured memory_bytes: 256
import collections
N=int(input())
A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
C=A+B
if (max(collections.Counter(C).values()))<=N:
  judge="Yes"
  B=B[::-1]
  fore=0
  back=-1
  for i in range(len(A)):
    if A[i]==B[i]:
      dup=A[i]
      if A[fore]!=dup and B[fore]!=dup:
        B[fore],B[i]=B[i],B[fore]
        fore+=1
      elif A[back]!=dup and B[back]!=dup:
        B[back],B[i]=B[i],B[back]
        back-=1
      else:
        judge="No"
else:
  judge="No"
if judge=="Yes":
  print(judge)
  print(' '.join(map(str, B)))
else:
  print(judge)

Measured memory_bytes: 149504
import sys
input = sys.stdin.readline

def chmin(a,b):
	if a<b:
		return a
	else:
		return b

N = int(input())
lst_P = list(map(int, input().split()))
mem = [float("Inf")]*N # mem[i]: i番目までで一番大きな値

ans = 1
for i in range(1,N):
	mem[i] = chmin(mem[i-1],lst_P[i-1])
	if mem[i] >= lst_P[i]:
		ans += 1

print(ans)

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;
const ll MOD = 1000000007;

ll solve(int N, const vector<int>& A) {
  vector<int> tmp(N);
  REP(i,N) tmp[i] = abs(i - (N - i - 1));
  sort(ALL(tmp));
  REP(i,N) if(tmp[i] != A[i]) return 0;

  ll res = 1;
  REP(i, N / 2) res = 2 * res % MOD;
  return res;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i,N) cin >> A[i];
  sort(ALL(A));

  cout << solve(N, A) << endl;
  return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	int pn = 1;
	if (ci - cn + 16 > cm) {
		if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); }
		A = ct - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
	else {
		if ((ct = *ci++) == '-') { pn = -1; ct = *ci++; }
		A = ct - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putintsp(int X) {
	if (X < 0) {
		*di++ = '-';
		X = -X;
	}
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}
inline void putint(int X) {
	if (X < 0) {
		*di++ = '-';
		X = -X;
	}
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint();
	int A[100000];
	int saidai = -1e9;
	int saishou = 1e9;
	int isaidai, isaishou;
	rep(i, N) {
		A[i] = getint();
		if (A[i] > saidai) {
			saidai = A[i];
			isaidai = i;
		}
		else if (A[i] < saishou) {
			saishou = A[i];
			isaishou = i;
		}
	}
	for (int i = 0; i < N; i++) {
		if (i != isaidai && i != isaishou) {
			if (A[i] < 0) {
				putintsp(saidai);
				putint(A[i]);
				saidai -= A[i];
			}
			else {
				putintsp(saishou);
				putint(A[i]);
				saishou -= A[i];
			}
		}
	}
	putintsp(saidai);
	putint(saishou);

	int X = saidai - saishou;

	if (X == 0) {
		putchar_unlocked('0');
		putchar_unlocked('\n');
	}
	else {
		if (X < 0) {
			putchar_unlocked('-');
			X = -X;
		}
		int keta = 0;
		char C[10];
		while (X) {
			*(C + keta) = '0' + X % 10;
			X /= 10;
			keta++;
		}
		for (int i = keta - 1; i >= 0; i--) putchar_unlocked(*(C + i));
		putchar_unlocked('\n');
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4096
import java.util.ArrayList;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		@SuppressWarnings("unchecked") ArrayList<Integer>[] jobs = new ArrayList[m + 1]; // 遅延日数ごとに仕事をグルーピングする
		for ( int i = 0; i <= m; i++ ) {
			ArrayList<Integer> a = new ArrayList<>();
			a.add(0); // ダミー要素
			jobs[i] = a;
		}

		for ( int i = 0; i < n; i++ ) {
			int d = in.nextInt();
			int f = in.nextInt();
			if ( d > m ) continue; // 遅延日数的に候補になりえない仕事は除外
			jobs[d].add(f);
		}

		long total = 0;
		PriorityQueue<Integer> pool = new PriorityQueue<Integer>(Collections.reverseOrder()); // job候補のプール
		pool.add(0); // ダミー

		// m日目をゼロとして考え後退していく days:残り日数
		for ( int today = 0; today <= m; today++ ) {
			pool.addAll(jobs[today]);
			total += pool.poll();
		}

		System.out.println(total);
		in.close();
	}
}


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

int main(){
  int N,M,C;
  cin>>N>>M>>C;
  vector <int> B(M);
  for(int i=0;i<M;i++){
    cin>>B[i];
  }
  vector <int>A(M);

  int count=0;

  for(int j=0;j<N;j++){
    int sum=0;
    for(int i=0;i<M;i++){
      cin>>A[i];
      sum+=A[i]*B[i];
    }
    if(sum+C>0)
      count++;
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(a) ((int)(a.size()))
#define PB push_back
#define LL long long
#define X first
#define Y second
#define debug(a) cout << #a << " = " << a << endl;

const int INF = 1000 * 1000 * 1000;
using namespace std;
vector<vector<int> > g(100005);
int c[100005];
int ptr = 0;
int res[100005];
LL ans = 0;
void dfs(int u , int p = -1)
{
	for(auto v : g[u])
	{
		if(v == p)
			continue;
		dfs(v , u);
	}
	if(p != -1)	
		ans += c[ptr];
	res[u] = c[ptr++];
}
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i < n; i++)
	{
		int u , v;
		cin >> u >> v;
		u--;v--;
		g[u].PB(v);
		g[v].PB(u);
	}
	for(int i = 0; i < n; i++)
		cin >> c[i];
	sort(c , c + n);
	for(int i = 0; i < n; i++)
	{
		if(SZ(g[i]) > 1)
		{
			dfs(i);
			cout << ans << endl;
			for(int i = 0; i < n; i++)
				cout << res[i] << " ";
			cout << endl;
			return 0;
		}
	}
	dfs(0);
	cout << ans << endl;
	for(int i = 0; i < n; i++)
		cout << res[i] << " ";
	cout << endl;
	
}




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



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
    
    string s;cin>>s;
    int n=s.size();

    n--;

    while(s.substr(0,n/2)!=s.substr(n/2,n/2)){
        n--;
    }
    // cout<<s.substr(0,n/2)<<endl;
    // cout<<s.substr(n/2,n/2)<<endl;
    cout<<n-1<<endl;
    
}


Measured memory_bytes: 3572
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    const MOD: usize = 1_000_000_007;

    let mut s: Vec<usize> = vec![0; n];
    s[n - 1] = a[n - 1];
    for i in (0..(n - 1)).rev() {
        s[i] = s[i + 1] + a[i];
        s[i] %= MOD;
    }

    let mut ans = 0;
    for i in 0..(n - 1) {
        ans = ans + (a[i] * s[i + 1]) % MOD;
        ans %= MOD;
    }
    ans.to_string()
}


Measured memory_bytes: 7280
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	getline(cin, s);
	bool foundC = false;
	bool foundF = false;
	for(int i = 0; i < s.length(); i++)
		if (foundC){
			if (s[i] == 'F'){
				foundF = true;
				break;
			}
		}else
			if (s[i] == 'C')
				foundC = true;
	if (foundF)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    int ai;
    int a = 0;
    int b = 0;
    int c = 0;

    for(int i=0; i<n; i++){
        scanf("%d", &ai);
        if(ai%4==0){
            a++;
        }else if(ai%4==2){
            b++;
        }else{
            c++;
        }
    }
    int d = b/2;
    if(a>=(float)(n-1)/2 || b==n || (b>0&&c-(a-1)<=1)){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define IOS   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test IOS long long t;cin >> t;while(t--)
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define MX 99999
const double pi=acos(-1.0);
vector<int>v;
map<int,int>mp;
int main()
{

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

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



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, m, a[12525];
  cin>>n>>m;
  int sum=0;
  REP(i, m){
    cin>>a[i];
    sum+=a[i];
  }
  cout<<(sum>n ? -1 : (n-sum))<<'\n';
  return 0;
}


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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;

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

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const long long MOD=1e9+7;
int h,w;
char m[100][100];
int dis[100][100];
void bfs(P b){
	rep(i,h){
		rep(j,w){
			dis[i][j]=INF;
		}
	}
	dis[b.first][b.second]=0;
	queue<P> task;
	task.push(b);
	while(!task.empty()){
		P p=task.front(); task.pop();
		if(p.first+1<h&&m[p.first+1][p.second]=='.'&&dis[p.first+1][p.second]==INF){
			dis[p.first+1][p.second]=dis[p.first][p.second]+1;
			task.push(P(p.first+1,p.second));
		}
		if(p.second+1<w&&m[p.first][p.second+1]=='.'&&dis[p.first][p.second+1]==INF){
			dis[p.first][p.second+1]=dis[p.first][p.second]+1;
			task.push(P(p.first,p.second+1));
		}
		if(p.first-1>=0&&m[p.first-1][p.second]=='.'&&dis[p.first-1][p.second]==INF){
			dis[p.first-1][p.second]=dis[p.first][p.second]+1;
			task.push(P(p.first-1,p.second));
		}	
		if(p.second-1>=0&&m[p.first][p.second-1]=='.'&&dis[p.first][p.second-1]==INF){
			dis[p.first][p.second-1]=dis[p.first][p.second]+1;
			task.push(P(p.first,p.second-1));
		}
	}
}
signed main(){
	cin>>h>>w;
	rep(i,h){
		rep(j,w){
			cin>>m[i][j];
		}
	}
	int ans=0;
	rep(i,h){
		rep(j,w){
			if(m[i][j]=='#')continue;
			bfs(P(i,j));
			rep(k,h){
				rep(l,w){
					if(m[k][l]=='#')continue;
					chmax(ans,dis[k][l]);
				}
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()

N = ini()
tasks = []
for i in range(N):
    a, b = inm()
    tasks.append((b, a))
tasks.sort()


def solve():
    t = 0
    for b, a in tasks:
        if t + a > b:
            return False
        t += a
    return True


print("Yes" if solve() else "No")


Measured memory_bytes: 29480
n = gets.to_s.to_i
a = gets.to_s.split.map{|t|t.to_i}

h = Array.new(n, 0)
ans = 0
a.each_with_index do |e, i|
  ans      += h[i - e] if i - e >= 0
  h[i + e] += 1        if i + e < n
end

puts ans

Measured memory_bytes: 29048
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next()) - 1;
		int y = Integer.parseInt(sc.next()) - 1;
		sc.close();
		long[] k = new long[n - 1];
		Arrays.fill(k , 0);
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < i ; j++){
				k[Math.min(i - j - 1 , Math.abs(j - x) + Math.abs(i - y))]++;
			}
		}
		for(int i = 0 ; i < n - 1 ; i++) ou.print(k[i] + "\n");
		ou.flush();
    }
}

Measured memory_bytes: 39092
N,M=map(int, input().split()) 
AB=[list(map(int, input().split())) for _ in range(N)]
ans = 0
AB.sort(key=lambda x:x[0],reverse=False)
for i in range(N):
    if M - AB[i][1] > 0:
        ans += AB[i][0]*AB[i][1]
        M -= AB[i][1]
    elif M > 0:
        ans += AB[i][0]*M
        M = 0
print(ans)

Measured memory_bytes: 29028
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  string N,a,b,c;
  cin >> N;
  a=N.at(0),b=N.at(1),c=N.at(2);
  if ("7"==a) {
    cout << "Yes";
  }
  else if ("7"==b) {
    cout << "Yes";
  }
  else if ("7"==c) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
  cout << endl;
}

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

int main() {
    map<string,int>map;
    int len;
    cin >> len;
    int mx = 0;
    while(len--){
        string s;
        cin >> s;
        map[s]++;
        mx = max(map[s],mx);
    }
    for(auto x : map){
        if(x.second == mx){
            cout << x.first << endl;
        }
    }
}

Measured memory_bytes: 19232
from math import sqrt,ceil
N,M=map(int,input().split())
yakusuu=[]
for i in range(ceil(sqrt(M))):
    if M%(i+1)==0:
        yakusuu.append(i+1)
        yakusuu.append(M//(i+1))
yakusuu.sort()
#print(yakusuu)
for i in range(len(yakusuu)):
    if yakusuu[i]>=N:
        print(M//yakusuu[i])
        break

Measured memory_bytes: 38640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;

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

  map<string, int> dic;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    dic[s]++;
  }

  long long ans = 0;
  for (auto& p : dic) {
    int s = p.second;
    ans += (long long)s*(s-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 11136