akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;
typedef complex<long double> C;

const int INF = 1e9 + 7, P = 200003, N = 1 << 19;
const long double TT = acosl(-1);

int e[P], cnt[P], b[P];

C a[N];

int pos[N];

void FFT(C* a, int k, int inv) {
	for(int i=1;i<(1<<k);i++) pos[i] = (pos[i >> 1] >> 1) | ((i & 1) << (k-1));
	for(int i=0;i<(1<<k);i++) if(i < pos[i]) swap(a[i], a[pos[i]]);
	for(int len=2;len<=(1<<k);len<<=1) {
		C w = C(cosl(2*TT/len), inv*sinl(2*TT/len));
		for(int i=0;i<(1<<k);i+=len) {
			C p = C(1, 0);
			for(int j=i;j<i+len/2;j++,p*=w) {
				C l = a[j], r = a[j+len/2];
				a[j] = l + p * r, a[j+len/2] = l - p * r;
			}
		}
	}
}

signed main()
{
	IO_OP;

	int n;
	cin >> n;
	int ans = 0;
	for(int i = 0, pw = 1; i < P - 1; i++, pw = pw * 2 % P) e[pw] = i;
	for(int i = 0, x; i < n; i++) {
		cin >> x;
		if(x == 0) continue;
		cnt[e[x]]++, ans -= x * x % P;
	}
	for(int i = 0; i < P; i++) {
		a[i] = cnt[i];
	}
	FFT(a, 19, 1);
	for(int i = 0; i < N; i++) a[i] = a[i] * a[i];
	FFT(a, 19, -1);
	for(int i = 0; i < N; i++)
		b[i % (P-1)] += int(a[i].real()/N + 0.5);
	for(int i = 0, pw = 1; i < P-1; i++) ans += pw * b[i], pw = pw * 2 % P;
	ans /= 2;
	cout << ans << endl;
}





Measured memory_bytes: 29128
import static java.lang.System.*;
import java.util.*;
 
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int a=sc.nextInt(), b=sc.nextInt(), c=sc.nextInt(), d=sc.nextInt();
		int difAB = (int)Math.abs(a-b);
		int difBC = (int)Math.abs(b-c);
		int difAC = (int)Math.abs(a-c);
		if (difAB<=d && difBC<=d) {
			out.println("Yes");
		}
		else if (difAC <= d) out.println("Yes");
		else out.println("No");
	}
}

Measured memory_bytes: 21844
program test
implicit none
character::S*4
read*,S
if(S(1:1)==S(2:2) .and. S(3:3)==S(4:4) .and. S(1:1)/=S(3:3)) then 
print*,'Yes'
else if (S(1:1)==S(3:3) .and. S(2:2)==S(4:4) .and. S(2:2)/=S(3:3)) then
print*,'Yes'
else if(S(1:1)==S(4:4) .and. S(3:3)==S(2:2) .and. S(1:1)/=S(3:3)) then
print*,'Yes'
else 
print*,'No'
end if
end program test

Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

// long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a;
// }

// int binary_search(int key) {
//     int ng = -1;
//     int ok = (int)a.size();
//     while(abs(ok - ng) > 1) {
//         int mid = (ok + ng) / 2;
//         if(isOK(mid, key))
//             ok = mid;
//         else
//             ng = mid;
//     }
//     return ok;
// }

// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W
// int MOD = 1000000007;

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

    map<long long, long long> nc2;
    auto nC2 = [&](long long n) {
        if(nc2.count(n) == 0) {
            nc2[n] = n * (n - 1) / 2;
        }
        return nc2[n];
    };

    map<long long, long long> M; // 出現カウント
    vector<long long> A(N);
    long long sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        M[A[i]]++;
    }
    for(auto m: M){
        sum += nC2(m.second);
    }

    for(size_t i = 0; i < N; i++) {
        long long count = M[A[i]];
        long long ans = sum - nC2(count) + nC2(count-1);
        cout << ans << endl;
    }
}

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

static const long double pi = 3.141592653589793;

int main(){
  double a,b,x;
  cin >> a >> b >> x;
  double len = x / a * a;
  if(2 * x > a * a * b){
    double ans = 180/pi * atan(2 * (a * a * b - x) / (a * a * a));
    cout << setprecision(12) <<  ans << endl;
  }else{
    double ans = 180/pi * atan(a * b * b / (2 * x));
    cout << setprecision(12) << ans << endl;
  }
}


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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0510

int main() {
	int a = 0, b = 0;
	for (int i = 0; i < 4; i++) {
		int in;
		cin >> in;
		a += in;
	}
	for (int i = 0; i < 4; i++) {
		int in;
		cin >> in;
		b += in;
	}
	cout << (a > b ? a : b) << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> plc(N + 3);
    plc[N + 1] = 0;
    plc[N + 2] = 0;
    for (int i = 1; i <= N; i++) {
        scanf("%d", &(plc[i]));
    }

    int ans = 0;
    int i = 1;
    while (i <= N) {
        if (plc[i] == i && plc[i + 1] == i + 1) {
            ans++;
            i += 2;
        } else if (plc[i + 1] == i + 1 && plc[i + 2] == i + 2) {
            ans++;
            i += 3;
        } else if (plc[i] == i || plc[i + 1] == i + 1) {
            ans++;
            i += 2;
        } else {
            i++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            City[] cities = new City[N];
            for (int i = 0; i < N; i++) {
                cities[i] = new City();
                cities[i].s = in.next();
                cities[i].p = in.nextInt();
                cities[i].i = i + 1;
            }
            Arrays.sort(cities, new Comparator<City>() {
                @Override
                public int compare(City o1, City o2) {
                    int c = o1.s.compareTo(o2.s);
                    if (c != 0) {
                        return c;
                    }
                    if (o1.p > o2.p) {
                        return -1;
                    }
                    if (o1.p < o2.p) {
                        return 1;
                    }
                    return 0;
                }
            });

            for (City city : cities) {
                System.out.println(city.i);
            }
        }
    }
}

class City {
    int i;
    String s;
    int p;
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sd second
#define ft first
#define pr pair
#define vl vector<ll>
#define vs vector<string>
#define vmp vector<pair<ll,ll>>
#define en "\n"
#define lb lower_bound
#define ub upper_bound
#define vll vector<vector<ll>>
#define vmpl vector<vector<pair<ll,ll>>>
#define st size()
#define al(v) v.begin(),v.end()
#define cast static_cast<char>
#define ins insert
#define fata_fat ios_base::sync_with_stdio(false); cin.tie(NULL);
ll M=1e9+7,MAX=1e18,MIN=-1e18;
void bhaag()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
int main()
{   
     bhaag(); fata_fat;
     ll l,r,d,c=0; cin>>l>>r>>d;
     for(ll i=l;i<=r;i++)
     {
        if(i%d==0)c++;
     }
     cout<<c;
     
}

 

Measured memory_bytes: 3648
def printing(a_start, a_2, n):

    a_3 = []
    mod_list = []
    for i in range(len(a_2)):
        if a_2[i][1] % a_start[1] not in mod_list and a_2[i][1] % a_start[1] != 0:
            a_3.append(a_2[i])
            mod_list.append(a_2[i][1] % a_start[1])
    a_3.sort(key=lambda x: x[1], reverse=True)


    if len(a_3) >= 2:
        if a_start[0] + a_3[-1][0] < n and a_3[0][0] < a_3[1][0] and a_3[1][0] > a_start[0]:
            a_3.pop(0)


    ans = ""
    while n % a_start[1] != 0:
        for i in range(len(a_3)):
            if n % a_start[1] >= a_3[i][1] % a_start[1]:
                n -= a_3[i][1]
                ans += str(a_3[i][0])
                break
            elif n % a_start[1] == 0:
                break
        else:
            n -= a_3[0][1]
            ans += str(a_3[0][0])

    ans = ans + str(a_start[0]) * (n // a_start[1])
    ans_list = sorted([ans[i] for i in range(len(ans))], reverse=True)
    print("".join(ans_list))

def main():
    n, m = [int(i) for i in input().split()]
    a = sorted([int(i) for i in input().split()], reverse=True)
    number = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    a_list = []
    a_2 = []

    for i in range(m):
        if number[a[i]] not in a_list:
            a_2.append([a[i], number[a[i]]])
            a_list.append(number[a[i]])
    a_2.sort(key=lambda x: x[1])
    a_start = a_2.pop(0)
    printing(a_start, a_2, n)

main()


Measured memory_bytes: 3192
from collections import deque

def bfs(table, visited, sy, sx):
    queue=deque([[sy, sx]])
    visited[sy][sx]=0
    md=0
    while queue:
        y, x=queue.popleft()
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if 0 <= new_y < R and 0 <= new_x < C:
              if table[new_y][new_x]=="." and visited[new_y][new_x]==-1:
                visited[new_y][new_x]=visited[y][x] + 1
                queue.append([new_y, new_x])
                md=max(visited[new_y][new_x],md)
    return md

R, C=map(int, input().split())
table = [input() for i in range(R)]
ans=0
for yi in range(R):
  for xi in range(C):
    visited=[[-1]*C for j in range(R)]
    if table[yi][xi]!='#':
      a=bfs(table,visited,yi,xi)
      ans=max(a,ans)
print(ans)

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

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

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

const int MOD = 1e9 + 7;

int pow_2(int x) {
  if (x == 0) {
    return 1;
  } else {
    return ((pow_2(x-1) % MOD) * 2) % MOD;
  }
}

int main() {
  int i;
  int N;
  int a[100010];
  int num[100010] = {};
  bool odd = false;
  bool even = false;
  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    scanf("%d", &a[i]);
    num[a[i]] += 1;
    if (a[i] % 2 == 0) {
      even = true;
    } else {
      odd = true;
    }
  }
  bool impossible = false;
  int num_2 = 0;
  if (num[0] > 1) {
    impossible = true;
  }
  if (even && odd) {
    impossible = true;
  }
  if (even) {
    for (i = 2; i < N; i += 2) {
      if (num[i] == 2) {
	num_2 += 1;
      } else {
	impossible = true;
	break;
      }
    }
  } else {
    for (i = 1; i < N; i += 2) {
      if (num[i] == 2) {
	num_2 += 1;
      } else {
	impossible = true;
	break;
      }
    }
  }
  if (impossible) {
    printf("0");
  } else {
    printf("%d", pow_2(N/2));
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){	
	string N;
	cin>>N;
	
	REP(i,(int)N.length()+1){
		if(i==(int)N.length()) puts("No");
		else if(N[i]=='9'){
			puts("Yes");
			break;
		}
	}
	return 0;
}



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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

int main() {
    int r, c;
    cin >> r >> c;
    vector<vector<int>> table(r, vector<int>(c, 0));
    int                 sum = 0;
    //入力
    rep(i, r) {
        rep(j, c) { cin >> table[i][j]; }
    }

    //出力
    rep(i, r) {
        sum = 0;
        rep(j, c) {
            cout << table[i][j] << " ";
            sum += table[i][j];
        }
        cout << sum << "\n";
    }

    // // 出力 最下行
    int sum_row = 0;
    int total   = 0;
    rep(j, c) {
        sum_row = 0;
        rep(i, r) { sum_row += table[i][j]; }
        cout << sum_row << " ";
        total += sum_row;
    }
    cout << total << "\n";
    return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

int n,k;

int main(){
	cin>>n>>k;
	vl dp(k+1);
	for(int i=k;i>0;i--){
		dp[i]=Pow(k/i,n);
		for(int j=2*i;j<=k;j+=i) dp[i]=(dp[i]-dp[j]+mod)%mod;
	}
	ll res=0;
	for(int i=1;i<=k;i++) (res+=dp[i]*i)%=mod;
	cout<<res<<endl;
}

Measured memory_bytes: 3980
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	ios::sync_with_stdio(false);
	int a, b,c,d,e;
	cin >> a >> b;
	c = max(a, b);
	d = min(a, b);
	e = max(c - 1, d);
	cout << c + e;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int w = 0, r = 0;
int main() {
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') {
			w++;
		}
		else {
			r++;
		}
	}
	int ans = 1000000007;
	if (ans > n - w) {
		ans = n - w;
	}
	if (ans > n - r) {
		ans = n - r;
	}
	int co = 0;
	for (int i = r; i < n; i++) {
		if (s[i] == 'R') {
			co++;
		}
	}
	if (ans > co) {
		ans = co;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
int n;
vi a, b;
bitset<100> make;
bool can(int mask){
    for(int i = 0; i < n; i++){
       //check all that can be made
        make.reset();
        make[a[i]] = 1;
        for(int bit = 50; bit >= 1; bit--){
           if(mask & (1LL << bit)){
               for(int j = bit; j <= 50; j++){
                  if(make[j]){
                    make[(j%bit)] = 1;
                  } 
               }
           } 
        }
       if(!make[b[i]])return false;
    }
    return true;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    cin >> n;
    a.resize(n);
    b.resize(n);
    FOR(i, n)cin >> a[i];
    FOR(i, n)cin >> b[i];
    int mask = (1LL << 51) - 1;
    int ans = 0;
    //cout<< can(1) << endl;
    if(!can(mask)){
        cout << -1;
        return 0;
    }
    for(int i = 50; i >= 1; i--){
        mask ^= (1LL << i); 
        if(!can(mask)){
            mask ^= (1LL << i);
            ans += (1LL << i);
        }
    }
    cout << ans;

}




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

int main() {
  string S;
  cin >> S;
  vector<int> v(4);
  for(int i = 0; i < 4; i++){
    v.at(i) = (int)S.at(i) - (int)'0';
  }
  
  bool finish = false;
  
  for (int tmp = 0; tmp < (1 << 3); tmp++){
    if(finish) break;
    bitset<3> s(tmp);
    int test = v.at(0);
    int sign = 1;
    string op = "+++";
    for(int i = 0; i < 3; i++){
      if(s.test(i)){
        sign = -1;
        op.at(i)='-';
      }else{
        sign = 1;
      }
      test += sign * v.at(i+1);
    }
    if(test == 7){
      for(int i=0; i<3;i++){
        cout << v.at(i) << op.at(i);
      }
      cout << v.at(3) << "=7" << endl;
      finish = true;
    }
  }
  
}


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

int main() {
    int n, m;
    cin >> n >> m;
    int p[m][2];
    int right_min = n;
    int left_max = 0;
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < 2; j++) {
            cin >> p[i][j];
        }
        if (p[i][0] >= left_max) {
            left_max = p[i][0];
        }
        if (p[i][1] <= right_min) {
            right_min = p[i][1];
        }
    }
    bool check = right_min - left_max + 1 > 0;

    if(check) {
        cout << right_min - left_max + 1 << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 1024
#include <stdio.h>
#define N 305

typedef long long ll;
typedef long double ld;

int n, cnt[4];
ld dp[N][N][N];

int main()
{
	scanf("%d", &n);
	for(int a=1; a<=n; a++)
	{
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
	for(int a=0; a<N; a++)
		for(int b=0; b<N; b++)
			for(int c=0; c<N; c++)
			{
				if(a==0 && b==0 && c==0)
					continue;
				if(a+b+c>N)
					continue;
				dp[c][b][a]=((ld)n)/((ld)(a+b+c));
				if(c)
				{
					ld coeff=((ld)c)/((ld)(a+b+c));
					dp[c][b][a]+=coeff*dp[c-1][b][a];
				}
				if(b)
				{
					ld coeff=((ld)b)/((ld)(a+b+c));
					dp[c][b][a]+=coeff*dp[c+1][b-1][a];
				}
				if(a)
				{
					ld coeff=((ld)a)/((ld)(a+b+c));
					dp[c][b][a]+=coeff*dp[c][b+1][a-1];
				}
			}
	printf("%0.10Lf\n", dp[cnt[1]][cnt[2]][cnt[3]]);
    return 0;
}

Measured memory_bytes: 442624
#include <stdio.h>
#include <stdlib.h>

int ord(const void * x, const void * y){

	const int a = (*(int*)x), b = (*(int*)y);
	
	if (a < b)
		return -1;
	if (a > b)
		return 1;
		
	return 0;
}


int main(){
	
	int n;
	
	scanf("%d", &n);
	
	int dificul[n];
	
	for (int i = 0; i < n; ++i){
		scanf("%d", &dificul[i]);
	}
	
	
	qsort(dificul, n, sizeof(dificul[0]), ord);

	int meio = (n/2);
	
	int total = dificul[meio] - dificul[meio-1];
	
	printf("%d\n", total);
	
	return 0;
	
}


Measured memory_bytes: 892
#include <stdio.h>
#include <string.h>
int main(){
  int k=1;
  long long N;
  char a[5000];
  scanf("%s",a);
  N=strlen(a);
  for(int i = 1; i<N;i++){
	if (a[i] != '9'){
	    k=0;
		break;
		}
	}
  if(k==1){printf("%d",(N-1)*9+a[0]-48);}
  else{
  printf("%lld",(N-1)*9+a[0]-48-1);
    }
  return 0;
  }

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

using i64 = long long;
using u64 = unsigned long long;

const int mod = (int) 1e9+7;

void __print() {cerr << "]\n";}

template<typename T, typename... V>
void __print(T t, V... v)
{ cerr << t; if(sizeof...(v)) cerr << ", "; __print(v...);}

#define dbg(x...) cerr << "[" << #x << "] = [", __print(x)
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(NULL)

int main()
{
    i64 a[4];
    i64 mx = -1000000000000000000;
    cin >> a[0] >> a[1] >> a[2] >> a[3];
    for(int i = 0; i < 2; i++) {
        for(int j = 2; j < 4; j++ ) {
            mx = max(mx, a[i] * a[j]);
        }
    }
    cout << mx << "\n";
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace AtCoder
{
	public class QuestionA
	{
		public static void Main(string[] args)
		{
			// 文字列の入力
			string s = Console.ReadLine();

			long result = 0;

			if (s.Length == 1) {
				Console.WriteLine(s);
				return;
			}

			result += (s[0] - '0') - 1;
			result += 9 * (s.Length - 1);

			var simple = digit_sum(long.Parse(s));
			Console.WriteLine(Math.Max(result, simple));
		}

		private static long  digit_sum(long n)
		{
			if (n < 10) return n;
			return digit_sum(n / 10) + n % 10;
		}
	}
}


Measured memory_bytes: 27472
#include <stdio.h>
#include <string.h>

int main (void)
{
    char s[200010];
    int len;
    int sum=0;
    int ans;
    int i;

    scanf("%s",s);
    len = strlen(s);
    // printf("%d\n",len);
    for(i=0;i<len;i++){
        sum = sum + s[i] - '0';
        // printf("%d\n",sum);
    }
    ans = sum % 9;
    if(ans == 0){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 1896
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>

#define Int long long
#define rep(i, n) for(Int i = 0; i < n; i++)
#define in(params) cin >> params;
#define p(params) cout << params << endl;
#define mod 1000000007LL

using namespace std;

int main()
{
    Int A, B, C;
    in(A >> B >> C);


    p(min(B / A, C));

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int n;
        int m;
        cin >> n >> m;
        if (n == 0 && m == 0) {
            break;
        }

        unordered_map<int, int> wip;
        using Range = tuple<int, int, int>;
        vector<Range> v;
        int r;
        cin >> r;
        for (int i = 0; i < r; ++i) {
            int t;
            int n_;
            int m_;
            int s;
            cin >> t >> n_ >> m_ >> s;
            if (s == 1) {
                wip[n_] = t;
            }
            else {
                v.push_back(make_tuple(m_, wip[n_], t));
                wip.erase(n_);
            }
        }
        int q;
        cin >> q;
        for (int i = 0; i < q; ++i) {
            int t_s;
            int t_e;
            int m_;
            cin >> t_s >> t_e >> m_;
            auto merge = [](const Range& a, const Range& b) -> vector<Range> {
                int am, as, ae;
                int bm, bs, be;
                tie(am, as, ae) = a;
                tie(bm, bs, be) = b;
                int max_ = max(as, bs);
                int min_ = min(ae, be);
                if (max_ <= min_) {
                    return {make_tuple(am, min(as, bs), max(ae, be))};
                }
                return {};
            };
            vector<Range> cv;
            copy_if(begin(v), end(v), back_inserter(cv),
                    [m_](const Range& a) { return get<0>(a) == m_; });
            vector<Range> curr = cv;
            vector<Range> prev = cv;
            while (true) {
                prev = curr;
                curr = {};
                bool merged{false};
                for (int j = 0; j < static_cast<int>(prev.size()) - 1; ++j) {
                    auto a = merge(prev[j], prev[j + 1]);
                    if (a.empty()) {
                        curr.push_back(prev[j]);
                    }
                    else {
                        curr.push_back(a[0]);
                        curr.insert(end(curr), begin(prev) + j + 2, end(prev));
                        merged = true;
                        break;
                    }
                }
                if (!merged) {
                    break;
                }
            }
            cv = prev;
            cv.erase(unique(begin(cv), end(cv)), end(cv));
            int c{0};
            for (auto&& j : cv) {
                int beg = max(t_s, get<1>(j));
                int en = min(t_e, get<2>(j));
                if (en - beg > 0) {
                    c += en - beg;
                }
            }
            cout << c << endl;
        }
    }
}

Measured memory_bytes: 3000
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int N=20,S=(1<<16)+5,Mo=1e9+7;

int pwr(int x,int y) {
	int z=1;
	for(;y;y>>=1,x=(ll)x*x%Mo)
		if (y&1) z=(ll)z*x%Mo;
	return z;
}

int n,m,a[N],f[N][S],fac[S],inv[S];

void pre(int N) {
	fac[0]=1;fo(i,1,N) fac[i]=(ll)fac[i-1]*i%Mo;
	inv[N]=pwr(fac[N],Mo-2);fd(i,N-1,0) inv[i]=(ll)inv[i+1]*(i+1)%Mo;
}

int C(int m,int n) {
	if (m<n||m<0||n<0) return 0;
	return (ll)fac[m]*inv[n]%Mo*inv[m-n]%Mo;
}

void inc(int &x,int y) {x=x+y>=Mo?x+y-Mo:x+y;}
void dec(int &x,int y) {x=x-y<0?x-y+Mo:x-y;}

int main() {
	scanf("%d%d",&n,&m);pre(1<<n);
	fo(i,1,m) scanf("%d",&a[i]);
	sort(a+1,a+m+1);
	f[m][0]=1;
	fd(i,m,1)
		fo(s,0,(1<<n)-1) {
			inc(f[i-1][s],f[i][s]);
			int cnt=(1<<n)-a[i]+1;
			fo(j,0,n-1) if ((s>>j)&1) cnt-=1<<j;
			fo(j,0,n-1) if (!((s>>j)&1)) dec(f[i-1][s|(1<<j)],(ll)f[i][s]*C(cnt-1,(1<<j)-1)%Mo*fac[1<<j]%Mo);
		}
	int ans=0;
	fo(s,0,(1<<n)-1) {
		int cnt=0;
		fo(j,0,n-1) if (!((s>>j)&1)) cnt+=1<<j;
		inc(ans,(ll)f[0][s]*fac[cnt]%Mo);
	}
	ans=(ll)ans*(1<<n)%Mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>

int main()
{
    int k, s;
    std::cin >> k >> s;

    int count = 0;
    for (int x = 0; x <= std::min(s, k); ++x)
    {
        const int tmp = s - x;
        if (tmp > 2 * k)
        {
            continue;
        }
        if (tmp <= k)
        {
            count += tmp + 1;
        }
        else
        {
            count += k - (tmp - k) + 1;
        }
    }

    std::cout << count << std::endl;
    return 0;
}


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

using namespace std;

struct Node {
    long long x, y;
    long long sz, pl;
    Node* L;
    Node* R;

    Node(long long x) : x(x), y(rand()), sz(1), L(NULL), R(NULL), pl(0) {}
};

const int MAX_N = 2e5 + 10;

int n;
long long k;
long long a[MAX_N];

void rec(Node* v) {
    if (v == NULL) {
        return;
    }
    v->sz = 1 + v->pl;
    if (v->L != NULL) {
        v->sz += v->L->sz;
    }
    if (v->R != NULL) {
        v->sz += v->R->sz;
    }
}

pair<Node*, Node*> split(Node* v, long long k) {
    if (v == NULL) {
        return {NULL, NULL};
    }
    if (k > v->x) {
        auto p = split(v->R, k);
        v->R = p.first;
        rec(v);
        return {v, p.second};
    }
    auto p = split(v->L, k);
    v->L = p.second;
    rec(v);
    return {p.first, v};
}

Node* merge(Node* v, Node* u) {
    if (u == NULL) {
        return v;
    }
    if (v == NULL) {
        return u;
    }
    if (v->y > u->y) {
        v->R = merge(v->R, u);
        rec(v);
        return v;
    }
    u->L = merge(v, u->L);
    rec(u);
    return u;
}

Node* insert(Node* v, long long x) {
    auto p = split(v, x);
    Node* ans = merge(p.first, new Node(x));
    rec(ans);
    ans = merge(ans, p.second);
    rec(ans);
    return ans;
}

bool inc(Node* v, long long x) {
    if (v == NULL) {
        return 0;
    }
    if (x == v->x) {
        v->pl++;
        rec(v);
        return 1;
    }
    if (x < v->x) {
        bool ans = inc(v->L, x);
        rec(v);
        return ans;
    }
    bool ans = inc(v->R, x);
    rec(v);
    return ans;
}

int main() {
    srand(239566);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] -= k;
    }
    Node* root = new Node(0);
    long long pref = 0;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        pref += a[i];
        auto ok = split(root, -pref);
        if (ok.second != NULL) {
            ans += ok.second->sz;
        }
        root = merge(ok.first, ok.second);
        if (!inc(root, -pref)) {
            root = insert(root, -pref);
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 14336
C, n = map(int, input().split())
mp = [input() for _ in range(n)]
diff_dic = {}
def change(x, y):
  global diff_dic
  if (x, y) in diff_dic:
    diff_dic.pop((x, y))
  else:
    diff_dic[(x, y)] = True
for y in range(n // 2):
  for x in range(n // 2):
    base = mp[y][x]
    if mp[y][n - 1 - x] != base:
      change(n - 1 - x, y)
    if mp[n - 1 - y][x] != base:
      change(x, n - 1 - y)
    if mp[n - 1 - y][n - 1 - x] != base:
      change(n - 1 - x, n - 1 - y)
if n % 2:
  for x in range(n // 2):
    if mp[n // 2][x] != mp[n // 2][n - 1 - x]:
      chenge(n - 1 - x, n // 2)
  for y in range(n // 2):
    if mp[y][n // 2] != mp[n - 1 - y][n // 2]:
      change(n // 2, n - 1 - y)

ans = 0
if not diff_dic:
  ans += 1

for _ in range(C - 1):
  d = int(input())
  for _ in range(d):
    r, c = map(int, input().split())
    r -= 1
    c -= 1
    if r < n // 2 and c < n // 2:
      change(c, n - 1 - r)
      change(n - 1 - c, r)
      change(n - 1 - c, n - 1 - r)
    elif n % 2 and r == n // 2 and c != n // 2:
      change(max(c, n - 1 - c), r)
    elif n % 2 and r != n // 2 and c == n // 2:
      change(c, max(r, n - 1 - r))
    else:
      change(c, r)
  if not diff_dic:
      ans += 1
print(ans)



Measured memory_bytes: 68828
//{{{
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL = unsigned long long;
using MAT = array<array<LL, 2>, 2>;

template<class T> constexpr inline T begin(const T&) {return 0;}
template<class T> constexpr inline T end(const T& x) {return max(T(0), x);}

#define SZ(x) int((x).size())
#define PB push_back
#define EB emplace_back
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define CHECK(a,b) static_assert(std::is_same<decltype(a), decltype(b)>::value, "REP diff types");

#define REPPP(i,s,c,t) for(i; ((s) and (c)) or (putchar("\n "[c]) and (c)); (t))
#define REPP2(i,n) REPPP(auto i=begin(n),i==begin(n),i!=end(n),++i)
#define REPP3(i,m,n) CHECK(m,n) REPPP(auto i=(m),i==(m),i<(n),++i)
#define REPP4(i,m,n,s) CHECK(m,n) REPPP(auto i=(m),i==(m),((s)>0 and i<(n)) or ((s)<0 and i>(n)),i+=(s))
#define REPP(...) GET_MACRO(__VA_ARGS__, REPP4, REPP3, REPP2)(__VA_ARGS__)

#define REP2(i,n) for(auto i=begin(n);i!=end(n);++i)
#define REP3(i,m,n) CHECK(m,n) for(auto i=(m);i<(n);++i)
#define REP4(i,m,n,s) CHECK(m,n) for(auto i=(m);((s)>0 and i<(n)) or ((s)<0 and i>(n));i+=(s))
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)

template<class T> void _read(T &x) {cin >> x;}
void _read(size_t &x) {scanf("%zu", &x);}
void _read(int &x) {scanf("%d", &x);}
void _read(LL &x) {scanf("%lld", &x);}
void _read(ULL &x) {scanf("%llu", &x);}
void _read(double &x) {scanf("%lf", &x);}
void _read(char &x) {scanf(" %c", &x);}
void _read(char *x) {scanf("%s", x);}
void read() {}
template<class T, class... U>
void read(T& head, U&... tail) {
    _read(head);
    read(tail...);
}

template<class T> void _print(const T &x) {cout << x;}
void _print(const size_t &x) {printf("%zu", x);}
void _print(const int &x) {printf("%d", x);}
void _print(const LL &x) {printf("%lld", x);}
void _print(const ULL &x) {printf("%llu", x);}
void _print(const double &x) {printf("%.16lf", x);}
void _print(const char &x) {putchar(x);}
void _print(const char *x) {printf("%s", x);}
void _print(const string &x) {printf("%s", x.c_str());}
template<class T> void _print(const vector<T> &x) {
    for(auto i = x.begin(); i != x.end(); _print(*i++)) {
        if (i != x.cbegin()) putchar(' ');
    }
}
void print() {putchar('\n');}
template<class T, class... U> void print(const T& head, const U&... tail) {
    _print(head);
    if(sizeof...(tail)) putchar(' ');
    print(tail...);
}

//}}}
const int MOD = 1000000007;

#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

#define MAX_N 300005

int main()
{
    int M1, D1, M2, D2;
    read(M1, D1, M2, D2);
    if(D2 == 1) {
        print(1);
    } else {
        print(0);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    ll n;
	cin >> n;
    
      cout << (n-1)*n/2<< endl;
}


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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  ll a[n];
  rep(i, n) cin >> a[i];

  rep(i, n) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll x = 1;
  ll lim = 1e18;
  rep(i, n) {
    if (a[i] > lim / x) {
      cout << -1 << endl;
      return 0;
    }
    x *= a[i];
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 4380
#include<stdio.h>
#include<math.h>

int main(){
	int a,b,g;
	int i;
	scanf("%d %d",&a,&b);
	if(a>b){
		a=a%b;
		b=b%a;
		for(i=1;i<=b;i++){
			if(a%i==0&&b%i==0){
				g=i;
			}
		}
	}
	else if(a<b){
		b=b%a;
		a=a%b;
		for(i=1;i<=a;i++){
			if(a%i==0&&b%i==0){
				g=i;
			}
		}
	}
	else if(a==b){
		g=a;

	}
	
	
	printf("%d\n",g);
	return 0;
}

Measured memory_bytes: 592
def solve():
  n, m = map(int, input().split())
  if m//2 <= n:
    print(m//2)
  else:
    ans = 0
    ans += n
    m = m-n*2
    ans += m//4
    print(ans)
  return 0
 
if __name__ == "__main__":
  solve()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,ans=0;
  string a,b,c;
  cin >> n;
  cin >> a >> b >> c;
  for (int i = 0; i < n; i++){
    if (a[i] == b[i]){
      if (b[i] != c[i]){
        ans++;
      }
    }else if (b[i] == c[i]){
      ans++;
    }else if (a[i] == c[i]){
      ans++;
    }else{
      ans += 2;
    }
  }
  cout << ans << "\n";
}

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

int main()
{
	int n,x[100005];
	memset(x,0,sizeof(x));
	cin >> n;
	int a[n],max = 0;
	
	for(int i = 0;i < n;i++){
		cin >> a[i];
		if(a[i] > max) max = a[i];
		if(!a[i]){
			x[a[i]]++;
			x[a[i] + 1]++;
		}
		else{
			x[a[i] - 1]++;
			x[a[i]]++;
			x[a[i] + 1]++;
		}
	}
	
	int max2 = 0;
	for(int i = 0;i <= max + 1;i++){
		if(x[i] > max2) max2 = x[i];
	}
	cout << max2;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm> 
#define ull unsigned long long
using namespace std;
int main()
{
  int n;
  cin>>n;
  ull ans=1;
  ull a[n];
  for(int i=0;i<n;i++)
  {
  	cin>>a[i];
  }
  sort(a,a+n);
  
  if(a[0]==0)
    {
    	cout<<0;
    	return 0;
    }
  
    for(int i=0;i<n;i++)
  {
    if(a[i]<=(1000000000000000000/ans))
  	{
  		         ans*=a[i];
  	}
         else
         {
         		cout<<-1;
  		return 0;
         }
  }
  cout<<ans;	
  return 0;
}

Measured memory_bytes: 4400
#include <stdio.h>

double getBMI(double w, double h){
	return w / (h * h);
}

int main(void){
	int id;
	double weight, height;
	
	while(scanf("%d,%lf,%lf", &id, &weight, &height) != EOF){
		if(getBMI(weight, height) >= 25){
			printf("%d\n", id);
		}
	}
	return 0;
}

Measured memory_bytes: 628
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

int a[55],dp[55];
int ncr(int n,int r)
{
    int lob=1;
    f(i,1,n)lob=lob*i;
    int hor=1;
    f(i,1,r)hor=hor*i;
    f(i,1,n-r)hor=hor*i;
    return lob/hor;
}
int chk(int x)
{
    int ret=0;
    for(int i=0;i<=x;i+=2)
    {
        ret+=ncr(x,i);
    }
    return ret;
}
 main()

{
    fast
    int n,p;
    cin>>n>>p;
    int od=0;
    int ses=1;
    int total=1;
    f(i,1,n)
    {
        cin>>a[i];
        total=total*2;
        if(a[i]%2==0)
        {
            ses=ses*2;
        }
        else
        {
            od++;
        }
    }
    if(od==0)
    {
        if(p==1)
        {
            cout<<"0"<<endl;
        }
        else cout<<ses<<endl;
        return 0;
    }
    dp[0]=1;
    for(int i=1;i<=od;i++)
    {
        dp[i]=dp[i-1]*2;
    }
    ses=ses*dp[od-1];
    if(p==1)
    {
        ses=total-ses;
    }
    cout<<ses<<endl;
    return 0;

}





































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

#define sz(x) (int)x.size() 
#define pb push_back 
#define mp make_pair 
#define fi(a, b) for(int i=a; i<=b; i++) 
#define fj(a, b) for(int j=a; j<=b; j++) 
#define fo(a, b) for(int o=a; o<=b; o++) 
#define fdi(a, b) for(int i=a; i>=b; i--) 
#define fdj(a, b) for(int j=a; j>=b; j--) 
#define fdo(a, b) for(int o=a; o>=b; o--) 

#ifdef LOCAL
#define err(...) fprintf(stderr, __VA_ARGS__)
#else
#define err(...) while(false) {}
#endif

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef vector<int> vi; 
typedef vector<ll> vll;
typedef vector<pii> vpii; 
typedef vector<pll> vpll; 
typedef long double ld;
typedef unsigned long long ull;

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

int const MAX = 1e5 + 41;

int n, m, s, t;

vpii e1[MAX];
vpii e2[MAX];

ll d1[MAX];
ll d2[MAX];
ll ans[MAX];

ll const INF = 1e18;
ll const M = 1e15;

int u[MAX];

void dijk(int s, ll d[MAX], vpii e[MAX]) {
	fi(0, MAX - 1) {
		d[i] = INF;
	}
	memset(u, 0, sizeof(u));

	d[s] = 0;
	set<pair<ll, int>> t;
	t.insert(mp(d[s], s));

	while (sz(t)) {
		pair<ll, int> cur = (*t.begin());
		t.erase(t.begin());
		ll dist = cur.first;
		int x = cur.second;
		if (u[x]) continue;

		for (pii z : e[x]) {
			int y = z.first;
			int w = z.second;
			if (dist + w < d[y]) {
				d[y] = dist + w;
				t.insert(mp(d[y], y));
			}
		}

		u[x] = 1;
	}
}



void solve() {
	dijk(s, d1, e1);
	dijk(t, d2, e2);
	fdi(n - 1, 0) {
		ans[i] = ans[i + 1];
		ll pans = M - d1[i + 1] - d2[i + 1];
		ans[i] = max(ans[i], pans);
	}
		
	fi(0, n - 1) {
		printf("%lld\n", ans[i]);
	}
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

  scanf("%d %d %d %d", &n, &m, &s, &t);
  fi(1, m) {
  	int x, y, a, b;
  	scanf("%d %d %d %d", &x, &y, &a, &b);
  	
  	e1[x].pb(mp(y, a));
  	e1[y].pb(mp(x, a));

		e2[x].pb(mp(y, b));
  	e2[y].pb(mp(x, b));  	
  }
	solve();		

	
#ifdef LOCAL
	err("ELAPSED TIME: %.3Lf\n", (ld) clock() / CLOCKS_PER_SEC);
#endif	
	
	return 0;
}

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

int main() {

int n,m;
cin>>n>>m;
vector<int> high(n);
for(int i=0;i<n;i++){
    cin>>high[i];
}
vector<int> vec(n,0);
for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    int x,y;
    x=high[a-1];
    y=high[b-1];
    if(x<y){
        vec[a-1]++;
    }
    else if(x==y){
        vec[a-1]++;
        vec[b-1]++;
    }
    else{
        vec[b-1]++;
    }
}
int count=0;
for(int i=0;i<n;i++){
   if(vec[i]==0){
       count++;
   }
}
cout<<count<<endl;

}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
inline ll in() { ll x; cin >> x; return x; }

#define INIT (-1)
#define move(a,b) ((a == INIT && b != INIT) ? a = b : a = a)
int main() {
  int h = in(), w = in(), k = in(), c = 0;
  vvi ans(h, vi(w, INIT));
  rep(i,h) {
    string s;
    cin >> s;
    rep(j,w) if (s[j] == '#') c++, ans[i][j] = c;
  }
 
  rep(i,h-1)rep(j,w) move(ans[i+1][j], ans[i][j]); // 下へ
  drep(i,h-1)rep(j,w) move(ans[i][j], ans[i+1][j]); // 上へ
  rep(i,h)rep(j,w-1) move(ans[i][j+1], ans[i][j]); // 右へ
  rep(i,h)drep(j,w-1) move(ans[i][j], ans[i][j+1]); // left

  rep(i,h)rep(j,w) cout << ans[i][j] << (j==w-1 ? "\n" : " ");
}


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

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define llrep(i,m,n) for(ll i=m;i<n;++i)
#define inf 1000000000
#define llinf 1000000000000000000
#define mod 1000000007
#define mmod 998244353
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define all(v) v.begin(),v.end()



int main() {
	ll x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	if ((x - (x % d)) / d >= k) {
		cout << x - k * d << endl;
	}
	else {
		k -= x / d;
		x %= d;
		k %= 2;
		if (k == 0) {
			cout << x << endl;
		}
		else {
			cout << d - x << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll long long int
#define v vector
#define MP make_pair
#define F first
#define S second
#define M 1000000007
#define endl "\n"
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

template<typename T>
inline void print(v<T >&a){
	for(int i=0;i<a.size();i++)
		cout<<a[i]<<" ";
	cout<<endl;
}

template<typename T>
inline void inp(v<T >&a){
	for(int i=0;i<a.size();i++){
		cin>>a[i];
	}
}

template <typename T>inline void out(T t){cout << t << " " ;}
template<typename T, typename... A>
inline void out(T t, A... args){
	cout << t <<" " ;out(args...);
}

inline bool check(int x,int y,int z){
	int a=max(x,max(y,z)),b=min(x,min(y,z));
	int c=x+y+z-a-b;
	if(a<b+c && a!=b && b!=c && a!=c)return 1;
	return 0;
}

int main(){
	fastio();
	int n;cin>>n;
	v<ll>l(n);inp(l);
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(check(l[i],l[j],l[k])){
					// cout<<i<<j<<k<<endl;
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
		
return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string s;
  cin >> s;
  int n = s.size();
  REP(i, n) cout << s[n - 1 - i];
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <string>

using namespace std;

typedef long long ll;

string s;

int main(){
    cin >> s;
    if(s[0] == s[1]){
        cout << "1 2" << endl;
        return 0; 
    }
    for(int i=2;i<s.size();i++){
        if(s[i] == s[i-1]){
            cout << i << " " << i+1 << endl;
            return 0;
        }
        if(s[i] == s[i-2]){
            cout << i-1 << " " << i+1 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
  	int n;
  cin >> n;
  if(n==25)cout<<"Christmas"<<endl;
  else if(n==24)cout<<"Christmas Eve"<<endl;
  else if(n==23)cout<<"Christmas Eve Eve"<<endl;
  else cout<<"Christmas Eve Eve Eve"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;

#define ll long long
#define pal pair<ll,ll>
#define pad pair<double,double>
#define PB push_back
#define MP make_pair
#define F first
#define S second

const ll MOD = 1e9+7;
const ll INF = 1e18;
const double EPS = 1e-8;

long long lpow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return ret;
}

template<typename T,typename U>
bool chmax(T& max, const U& x){
	if(max<x){
		max = x;
		return true;
	}
	return false;
}

template<typename T,typename U>
bool chmin(T& min, const U& x){
	if(min>x){
		min = x;
		return true;
	}
	return false;
}

const ll MAX = 2000001;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	ll k,ans=0;
	string s;
	cin >> k >> s;
	ll n=k+s.size();
	COMinit();
	
	for(ll i=s.size();i<=n;i++){
		ans = (ans+((COM(i-1,s.size()-1)*lpow(25,i-s.size()))%MOD*lpow(26,n-i))%MOD)%MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 51240
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
vector<int> input(int N) {
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  return vec;
}

int main() {
  string s;
  cin >> s;
  int count=0;
  rep(i,s.size()){
    if(s[i]!=s[s.size()-i-1]){
      count++;
    }
  }
  cout << count/2 << endl;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
ans=False
aa=a[0]

s1=0
s2=0
check=True
for i in range(n):
    if a[i]==aa:
        s1+=1
    elif a[i]==aa+1:
        s2+=1
    else:
        check=False
        break
if check:
    if s2==0:
        if aa==n-1:
            ans=True
    else:
        if 2<=(aa+1-s1)*2<=s2:
            ans=True
s1=0
s2=0
check=True
for i in range(n):
    if a[i]==aa-1:
        s1+=1
    elif a[i]==aa:
        s2+=1
    else:
        check=False
        break
if check:
    if s2==0:
        pass
    else:
        if 2<=(aa-s1)*2<=s2:
            ans=True

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 83220