akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



int main() {


	int r;
	cin >> r;

	cout << 3 * r * r << endl;

	

	return 0;
}

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

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n,m;
cin>>n;
cin>>m;
vector<P>list(m);
rep(i,m)
{
P p;
  //ある要望で、左(西)側の島をsecondに
  cin>>p.second;
  //ある要望で、右(東)側の島をfirstに
  cin>>p.first;
  list.at(i)=p;
}
sort(list.begin(),list.end());

int nowx=-1e9;
int ans=0;
rep(i,m)
{P p=list.at(i);
  if(nowx<=p.second)//<=か<か見極めるのが大事
  {ans++; nowx=p.first;}
}

cout << ans << endl;



}
/*vector <int> a(3);
for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }*/

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


int i,j,k,n,t,ces;
int x,y,z;

int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    scanf("%d %d %d", &x, &y, &z);
    if(abs(x-y)>abs(x-z)){
        printf("B\n");
    }
    else printf("A\n");


    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
    //static List<string> str = new List<string>();
	static void Main(string[] args)
	{
		// 入力フェーズ
        string b = Console.ReadLine();

				if(b == "A")
					Console.WriteLine("T");
				else if(b == "T")
					Console.WriteLine("A");
			  else if(b == "G")
						Console.WriteLine("C");
				else if(b == "C")
								Console.WriteLine("G");		

    }

}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=unsigned long long;
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> p(n),q(n),num(n);
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];

    int cnt=0;
    int ans=0;
    int a,b;
    iota(num.begin(),num.end(),1);
    do{
        cnt++;
        bool flag1=true;
        bool flag2=true;
        rep(i,n){
            if(num[i]!=p[i]){
                flag1=false;
                break;
            }
        }
        rep(i,n){
            if(num[i]!=q[i]){
                flag2=false;
                break;
            }
        }
        if(flag1) a=cnt;
        if(flag2) b=cnt;
        ans=abs(a-b);
    }while(next_permutation(num.begin(),num.end()));

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

Measured memory_bytes: 3628
#include <iostream>
//#include <algorithm>
//#include <vector>
using namespace std;

int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int left = a+b, right=c+d;
    
    if(left<right){
        cout << "Right" << endl;
    } else if(left>right){
        cout << "Left" << endl;
    } else {
        cout << "Balanced" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;
using System.Xml;

namespace hello_world
{
	class Program
	{

		static void Main(string[] args)
		{
			string[] a = Console.ReadLine().Split(" ");
			int h1 = int.Parse(a[0]);
			int m1 = int.Parse(a[1]);
			int h2 = int.Parse(a[2]);
			int m2 = int.Parse(a[3]);
			int k =  int.Parse(a[4]);
			int h3 = h1 * 60;
			int h4 = h2 * 60;
			int sum = h4 + m2 - h3 - m1-k;
			Console.WriteLine(sum);


		}
	}

}


Measured memory_bytes: 27548
#include <stdio.h>

int main(){
   int x1,y1,x2,y2,a,b;

   scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
   a=x2-x1;b=y2-y1;
   printf("%d %d %d %d\n",x2-b,y2+a,x1-b,y1+a);
   return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <assert.h>
#include <chrono>
#include <bitset>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <random>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;

typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<pll> vpll;

#ifdef OLBOEB
mt19937 rnd(228 + 1488 + 239 + 24111997 % 322 + std::hash<std::string>()("Tsypkokokokoko is gay"));
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

void print_time() {
#ifdef OLBOEB
  cout.flush();
  cerr << "\ntime: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
}


#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(x) ((ll)(x).size())
#define popcnt(x) (__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

template <typename T>
void update_max(T& x, T y) { x = max(x, y); }
template <typename T>
void update_min(T& x, T y) { x = min(x, y); }
template <typename T>
T min(T x, T y, T z) { return min(x, min(y, z)); }
template <typename T>
T max(T x, T y, T z) { return max(x, max(y, z)); }

ll get_bit(ll m, ll i) {
  return (m >> i) & 1;
}

void set_bit(ll& m, ll i) {
  m |= (1LL << i);
}

template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class T> ostream& operator<<(ostream& out, set<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }
template<class L, class R> ostream& operator<<(ostream& out, map<L, R> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }




int main() {
  cout << fixed << setprecision(20);
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

  ll n;
  cin >> n;
  ll ans = 0;
  ll minx = 1e6;
  for (ll i = 0; i < n; ++i) {
    ll x;
    cin >> x;
    ans += (x < minx);
    update_min(minx, x);
  }
  cout << ans;

  print_time();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

    int k;
    cin >> k;
    long long sum = 0;

    for (int i = 1; i <= k; i++) {
        for (int j = 1; j <= k; j++) {
            for (int l = 1; l <= k; l++) {
                // cout << i << " + " << j << " + " << l << " = " << gcd(gcd(i, j), l) << "\n";
                sum += gcd(gcd(i, j), l);
            }
        }
    }
    cout << sum;
    return 0;
}

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

int main()
{
   int N,c=0;
  double X, Y, D;
  cin>>N>>D;
  for(int i=0; i<N; ++i)
  {
  	cin>>X>>Y;
  	double d=X*X +Y*Y;
    if(d<=D*D)
      c++;
  }
  cout<<c;

   
   return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

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

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

using namespace std;


int main ()
{
    int n;
    cin>>n;
    int a;
    vector<int>b;
    while(n--)
    {
        cin>>a;
        a*=-1;
        int it=upper_bound(b.begin(),b.end(),a)-b.begin();
        if(it==b.size())
        {
            b.push_back(a);
        }
        else
            b[it]=a;

    }
    cout<<b.size()<<endl;
    return 0;
}


Measured memory_bytes: 892
import numpy as np
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z
        
def lcm(m, n):
    return int(m*n/gcd(m,n))

A, B = list(map(int,input().split()))
ans = lcm(A, B)
print(ans)

Measured memory_bytes: 12388
import heapq
n, m = map(int, input().split())
INF = float('inf')


def dijkstra(s, n, edges):
    d = [INF] * n
    d[s] = 0
    pq = [(0, s)]
    while len(pq) != 0:
        c, v = heapq.heappop(pq)
        if d[v] < c:
            continue
        for v2nvc, nv in edges[v]:
            if c + v2nvc < d[nv]:
                d[nv] = c + v2nvc
                heapq.heappush(pq, (d[nv], nv))
    return d


edges = [[] for _ in range(n)]
for _ in range(m):
    l, r, c = map(int, input().split())
    l -= 1
    r -= 1
    edges[l].append((c, r))
for i in range(n - 1):
    edges[i + 1].append((0, i))
d = dijkstra(0, n, edges)
if d[-1] == INF:
    print(-1)
else:
    print(d[-1])


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

int main(void)

{
	int i;
	char s[50];
	scanf("%s",s);
	
	for(i=0;i<=4;i++){
		printf("%c",s[i]);
	}
	printf(" ");
	for(i=6;i<=12;i++){
		printf("%c",s[i]);
	}
	printf(" ");
	for(i=14;i<=18;i++){
		printf("%c",s[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define pi pair<ll,ll>
#define pii pair<pi,ll>
#define fr freopen("in.txt","r",stdin)
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define frep(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define f first
#define s second

int main() {
    ll R,G;
    cin >> R >> G;
    cout << 2*G-R;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long Int;
int main() {
    Int n;
    cin >> n;
    auto ans = 0LL;
    for (auto i = 1LL; i * i <= n; i++) {
        if (n % i == 0) {
            ans = i + n / i - 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define loop(i, sta, end, inc) for(int i = sta; i <= end; i += inc)
#define itr(it, l)             for(auto it = l.begin(); it != l.end(); it ++)
#define in(a, b, c)            assert( b <= a && a <= c)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define what_is(x) cerr<<#x<<" ="<<x<<" ";
#define error(args...)  { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define LINT_MAX  9223372036854775807
#define LINT_MIN -9223372036854775808
#define EPS 1e-9
#define MOD 1000000007
#define DEBUG 0

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
void err(istream_iterator<string> it) { cerr<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    if(DEBUG == 0)return;
	cerr << *it << " = " << a <<" ";
	err(++it, args...);
}

int A[100];
bool dp[100001];
int main(){
    //freopen("test.txt", "r", stdin);
    int n,k;cin>>n>>k;
    forn(i,n)cin>>A[i];
    forn(i,100001)dp[i]=false;
    for(int i=1;i<=k;i++){
    	for(int j=0;j<n;j++){
    		if(A[j]==i){dp[i]=true;break;}
    		else if(A[j]<i){
    			if(dp[i-A[j]]==false){
    				//cout<<i<<" "<<A[j]<<endl;
    				dp[i]=true;
    				break;
    			}
    			dp[i]=false;
    		}
    	}
    }
    
    if(dp[k]==false)cout<<"Second"<<endl;
    else cout<<"First"<<endl;

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <iomanip>


using namespace std;

/*2点[(x1,y1),(x2,y2)]を入力し二点を通る直線ax+by+cの(a,b,c)を返す,  */
/*x1==x2ならfalseを返す*/
/*falseならばx=cの形の直線*/
void straight_line_passing_through_the_two_points(double x1, double y1, double x2, double y2, double *a, double *b, double *c){
    *a=(y2-y1);
    *b=-(x2-x1);
    *c=y2*(x2-x1)-x2*(y2-y1);
}


/*(x,y)を通るa1x+b1y+c1=0に垂直な直線a2x+b2y+c2=0を返す*/
void vertical_straight_line(double x, double y, double a1, double b1, double c1, double *a2, double *b2, double *c2){
    *a2 = -b1;
    *b2 = a1;
    *c2 = b1*x - a1*y;
}

/*2直線 a1x+b1y+c1=0 a2x+b2y+c2=0 の交点 (x,y)を返す*/
/*2直線が平行であるならばfalseを返す*/

bool intersection_and_parallel(double a1, double b1, double c1, double a2, double b2, double c2, double *x, double *y){
    if(a1*b2==a2*b1)return false;//平行の判定
    
    *x = (b1*c2-b2*c1)/(a1*b2-a2*b1);
    *y = (a2*c1-a1*c2)/(a1*b2-a2*b1);
    
    return true;
}

/*2点(x1,y1), (x2,y2) の距離*/
bool distance_between_the_two_pointss(double x1,double y1, double x2, double y2){
    return  sqrt(fabs((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}





int main(int argc, const char * argv[])
{
    double x1,x2,y1,y2,a,b,c;
    cin>>x1>>y1>>x2>>y2;
    
    straight_line_passing_through_the_two_points(x1, y1, x2, y2, &a, &b, &c);
    
    int q;
    cin>>q;
    for(int i=0; i<q; i++){
        double x,y,a2,b2,c2;
        cin>>x>>y;
        vertical_straight_line(x, y, a, b, c, &a2, &b2, &c2);
        //cout<<a<<b<<c<<endl;
        //cout<<a2<<b2<<c2<<endl;
        double ans_x, ans_y;
        intersection_and_parallel(a, b, c, a2, b2, c2, &ans_x, &ans_y);
        cout<< fixed << setprecision( 10 ) <<ans_x<<" "<<ans_y<<endl;
    }
    
}

Measured memory_bytes: 1296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i = a; i < b; i++)

int main(){
    ll M, N; cin >> M >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];

    int pre = -1, cnt = 1, ans = 0;
    if(M == 2){
        int cnt1 = 0, cnt2 = 0;
        rep(i, 0, N){
            if(A[i] != (i%2 + 1)) cnt1++;
            else cnt2++;
        }
        ans = min(cnt1, cnt2);
    }else{
        rep(i, 0, N){
            if(pre == A[i]) cnt++;
            else{
                pre = A[i];
                ans += cnt / 2;
                cnt = 1;
            }
        }
        ans += cnt / 2;
    }
    cout << ans << endl;
}


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


 
double EPS = 1e-10;
const double PI = acos(-1);
 
double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}
 
struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}
 
  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }
 
  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }
 
  point operator * (double d){
    return point(x*d,y*d);
  }
 
  point operator / (double d){
    return point(x/d,y/d);
  }
};
 
double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}
 
double norm(point a){
  return sqrt(dot(a,a));
}
 
typedef point Vector;
typedef pair<point,point> Line;
 
point projection(Vector p,Vector b){
  return b*dot(p,b)/dot(b,b);
}
 
point projection(Line l,Vector p){
  point a=l.second-l.first;
  point b=p-l.first;
  return l.first+projection(b,a);
}
 
int main(void){
 
  Line l;
  point c;
  int q;
  cin >> l.first.x >> l.first.y >> l.second.x >> l.second.y;
  cin >> q;
  while(q--){
    cin >> c.x >> c.y;
    point res=projection(l,c);
    printf("%.10f %.10f\n",res.x,res.y);
  }
 
  return 0;
}

Measured memory_bytes: 3244
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	vector<int>v(4); int a, b;
	rep(i, 0, 4)cin >> v[i];
	cin >> a >> b;
	sort(all(v));
	cout << v[3] + v[2] + v[1] + max(a, b) << endl;
	return 0;
}

Measured memory_bytes: 3112
N = input()
N = int(N)

flag = False
q = N // 4
for i in range(q):
    if (N % 7) == 0:
        print("Yes")
        flag = True
        break
    elif (N - (4 * (i + 1))) % 7 == 0:
        print("Yes")
        flag = True
        break

if not flag:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define i64 long long
#define maxn (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
using namespace std;
bool valid(char c){
	return (c=='A' or c=='C' or c=='G' or c=='T');
}

int main(){
	string s;
	cin>>s;
	int n = s.length();
	int cnt =0, maxCnt = 0;
	for(int i=0;i<n;i++){
		if(valid(s[i])) cnt++;
		else{
			maxCnt = max(maxCnt,cnt);
			cnt =0;
		}
	}
	maxCnt = max(maxCnt,cnt);
	printf("%d\n",maxCnt);
	return 0;
}

Measured memory_bytes: 256
def solve():
    
    A, B, C, D, E, F = map(int, input().split())
    memo = {}
    
    for a in range(31):
        for b in range(31):
            for c in range(101):
                for d in range(101):
                    w = (100*A)*a + (100*B)*b
                    s = C*c + D*d
                    if w ==0:
                        break
                    if w+s > F:
                        break
                    else:
                        if w/100 * E >= s:
                            density = 100* s/(w+s)
                            memo[a,b,c,d] = density
    
    max_v = max(memo.values())
    
    for k, v in memo.items():
        if v == max_v:
            print((100*A)*k[0] + (100*B)*k[1] + C*k[2] + D*k[3], C*k[2] + D*k[3] )
            break
 
if __name__ == '__main__':
    solve()

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

// サイズの大きい配列はローカルではなくグローバルで宣言する
char field[1010][1010];
int J[1010][1010];
int O[1010][1010];
int I[1010][1010];

int main() {
  // 入力
  int M, N, K;
  cin >> M >> N >> K;
  for (int y = 1; y <= M; y++) {
    for (int x = 1; x <= N; x++) {
      cin >> field[y][x];
    }
  }

  // ジャングル、海、氷ごとに累積和をとり、与えられる区間に含まれる数の計算の高速化をする
  // 累積和をとるための前処理
  for (int y = 1; y <= M; y++) {
    for (int x = 1; x <= N; x++) {
      if (field[y][x] == 'J') J[y][x] = 1;
      else if (field[y][x] == 'O') O[y][x] = 1;
      else I[y][x] = 1;
    }
  }
  // 横方向の累積和をとる
  for (int y = 1; y <= M; y++) {
    for (int x = 2; x <= N; x++) {
      J[y][x] += J[y][x-1];
      O[y][x] += O[y][x-1];
      I[y][x] += I[y][x-1];
    }
  }
  // 縦方向の累積和をとる
  for (int x = 1; x <= N; x++) {
    for (int y = 2; y <= M; y++) {
      J[y][x] += J[y-1][x];
      O[y][x] += O[y-1][x];
      I[y][x] += I[y-1][x];
    }
  }

  // 区間の入力を受け取りつつ、累積和を利用して定数時間で解答する
  int a, b, c, d;
  for (int i = 0; i < K; i++) {
    cin >> a >> b >> c >> d;
    cout << J[c][d] - J[a-1][d] - J[c][b-1] + J[a-1][b-1] << " ";
    cout << O[c][d] - O[a-1][d] - O[c][b-1] + O[a-1][b-1] << " ";
    cout << I[c][d] - I[a-1][d] - I[c][b-1] + I[a-1][b-1] << endl;
  }
  return 0;
}



Measured memory_bytes: 15816
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b)* b; }
 
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
 
inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}
 
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int k,s; cin>>k>>s;
  int ans=0;
  rep(i,k+1){
    rep(j,k+1){
      int z=s-i-j;
      if(z>=0&&z<=k) ans++;
    }
  }
  cout<<ans<<endl;
}

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

char getPair( char a );
int pow( int a );
int max( int a, int b );

int main()
{
    string a, s, t;

    cin >> a;

    for( int i = 0; i < a.size(); i++ )
        if( a[i] == 'i' )
        {
            s = a.substr( 0, i );
            t = a.substr( i + 3, a.size() );
            break;
        }

    bitset<12> b;
    bitset<12> c;

    int ss = pow( s.size() ), ts = pow( t.size() ), ma = 0, cnt = 0;
    for( int i = 0; i < ss; i++ )
    {
        b = i;
        for( int j = 0; j < ts; j++ )
        {
            c = j;
            if( b.count() == c.count() )
            {
                string x = "", y = "";
                for( int k = 0; k < s.size(); k++ )
                    if( b[k] )
                        x += s[k];
                for( int k = 0; k < t.size(); k++ )
                    if( c[k] )
                        y += t[k];
                for( int k = 0; k < x.size(); k++ )
                    if( getPair(x[k]) == y[x.size()-1-k] )
                        cnt += 2;

                ma = max( ma, cnt );
            }
            cnt = 0;
        }
    }
    cout << ma + 3 << endl;
    return 0;
}

char getPair( char a )
{
    if( a == '(' )
        return ')';
    else if( a == ')' )
        return '(';
    else if( a == ']' )
        return '[';
    else if( a == '[' )
        return ']';
    else if( a == '}' )
        return '{';
    else if( a == '{' )
        return '}';
    else;
}

int pow( int a )
{
    int b = 1;
    for( int i = 0; i < a; i++ )
        b *= 2;
    return b;
}

int max( int a, int b )
{
    return a > b ? a : b;
}


Measured memory_bytes: 3220
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AHEX {
public:
	void solve(istream& in, ostream& out) {
        char x, y; in >> x >> y;
        map<char,int> mp; //={('A',1),('B',2),('C',3),('D',4),('E',5),('F',6)};
        mp.insert(make_pair('A',1));
        mp.insert(make_pair('B',2));
        mp.insert(make_pair('C',3));
        mp.insert(make_pair('D',4));
        mp.insert(make_pair('E',5));
        mp.insert(make_pair('F',6));
        if(mp.at(x) > mp.at(y)) out << '>' << endl;
        else if(mp.at(x) < mp.at(y)) out << '<' << endl;
        else out << '=' << endl;
	}
};

int main() {
	AHEX solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
struct node{
	int x,idx;
}A[1000010]; 
int n,Ji[1000100];
inline bool cmp(node p,node q){return p.x<q.x;}
int main()
{
	n=read();
	for(rint i=1;i<=n;++i) A[i].x=read(),A[i].idx=i,Ji[i]=i&1;
	sort(A+1,A+n+1,cmp);int ans=0;
	for(rint i=1;i<=n;++i) if((Ji[A[i].idx])!=(i&1)) ans++;cout<<ans/2;
	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a[10];
  for(int i=0;i<10;i++){
    cin >> a[i];    
  }
  sort(a,a+10);
  reverse(a,a+10);
  for(int i=0;i<3;i++){
    cout << a[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3124
N = int(input())
T, A = map(int, input().split())
H = [int(i) for i in input().split()]
for n,i in enumerate(H):
    H[n]=T-i*0.006
for n,i in enumerate(H):
    H[n]=abs(A-i)
print(H.index(min(H))+1)

Measured memory_bytes: 3060
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def resolve():
    N, M = list(map(int, input().split()))
    uf = UnionFind(N)
    for i in range(M):
        a, b = list(map(int, input().split()))
        uf.union(a-1, b-1)
    maxnum = 0
    for v in uf.parents:
        if v < 0:
            maxnum = max(maxnum, -v)
    print(maxnum)

if '__main__' == __name__:
    resolve()



Measured memory_bytes: 74860
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    int divide = 1;
    if (n % 2 == 0) divide = 2;
    
    cout << n * 2 / divide << endl;
    
    return 0;
}

Measured memory_bytes: 256
//////////////////////////
//      _        ____   //
//  U  /"\  u U /"___|  //
//   \/ _ \/  \| | u    //
//   / ___ \   | |/__   //
//  /_/   \_\   \____|  //
//   \\    >>  _// \\   //
//  (__)  (__)(__)(__)  //
//  Compro by NULL_CT©  //
//////////////////////////
// STL libs
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

// Boost
#include <boost/algorithm/minmax.hpp>
#include <boost/algorithm/minmax_element.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>

#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;
using boost::irange;
using boost::multiprecision::cpp_int;

constexpr int64_t MOD = 1000000007;

class UnionFind {
public:
  vector<int> par;

  UnionFind(int N) : par(N) {
    for (int i = 0; i < N; i++)
      par[i] = i;
  }
  int root(int x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry)
      return;
    par[rx] = ry;
  }
  bool isSame(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

vector<int64_t> divisor(const int64_t &_n) {
  vector<int64_t> head, tail;
  for (int64_t i = 1; i * i <= _n; i++) {
    if (_n % i == 0) {
      head.push_back(i);
      if (i * i != _n)
        tail.push_back(_n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return head;
}

int64_t kadanes(const vector<int64_t> &_ls) {
  int64_t highestMax = 0, currentMax = 0, length = _ls.size();
  for (int64_t i = 0; i < length; i++) {
    currentMax = max(_ls[i], currentMax + _ls[i]);
    highestMax = max(highestMax, currentMax);
  }
  return highestMax;
}

void execution();

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  // cout<<fixed<<setprecision(20);

  execution();
  return 0;
}

//--------------------------------------------------------------
void execution() {
  int n,m;
  cin>>n>>m;
  vector<int> a(m),b(m);
  UnionFind uni(n);
  for(int i:irange(m)){
    cin>>a[i]>>b[i];
    uni.unite(a[i]-1,b[i]-1);
  }

  int ans=0;
  for(int i:irange(n-1)){
    if(!uni.isSame(i,i+1)){
      uni.unite(i,i+1);
      ans++;
    }
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 3944
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
//#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};

int N, Z, W;
int a[2020];

signed main()
{
  cin >> N >> Z >> W;
  REP(i,N) cin >> a[i];

  if (N == 1) {
    cout << abs(a[0] - W) << endl;
  } else {
    cout << max(abs(a[N-1] - W), abs(a[N-2] - a[N-1])) << endl;
  }
}

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

int main() {
    int H, W;
    cin >> H >> W;
    while (true) {
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
        if (H == 0 && W == 0) {
            break;
        }
    }
}


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

lli q, h, s, d, n;

int main(void){
	cin >> q >> h >> s >> d >> n;
	lli x = min({4*q, 2*h, s});
	lli y = d;
	lli ans = 0;
	if(2*x > y){
		ans = n/2*y+n%2*x;
	}else{
		ans = n*x;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    int A,B,C,K,result;
    scanf("%d %d %d",&A,&B,&C);
    scanf("%d",&K);

    if(A>=B&&A>=C){
        result=B+C+A*pow(2,K);      
    }else if(B>=A&&B>=C){
        result=A+C+B*pow(2,K); 
    }else{
        result=A+B+C*pow(2,K); 
    }

    printf("%d", result);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 int n,i,w=0,r=0,ans=0;
    cin>>n;
    string s;
    cin>>s;
    for(i=0;i<n;i++)
    {
    	if(s[i]=='R')
    	r++;
    	else
    	w++;
	}
    for(int i=0;i<r;i++)
    if(s[i]=='W')
    ans++;
    cout<<ans<<endl;
    
	return 0;
}


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

bool all_even(vector<int> &A,int N);

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

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

    int count=0;
    while(all_even(A,N)){
        for(int i=0;i<N;i++){
            A[i] = A[i]/2;
        }
        count++;
    }

    cout << count << endl;

    return 0;
}

bool all_even(vector<int> &A,int N){
    int div_count=0;
    for(int i=0;i<N;i++){
        if(A[i]%2==0){
            div_count++;
        }
    }
    if(div_count==N){
        return true;
    }

    return false;
}

Measured memory_bytes: 256
sentence = list(input())
q = int(input())

for i in range(q):
    x = input().split()
    
    if len(x) == 3:
        order = x[0]
        first = int(x[1])
        second = int(x[2])
        
    else:
        order = x[0]
        first = int(x[1])
        second = int(x[2])
        change = x[3]
        
    
    if order == "print":
        print("".join(sentence[first : (second + 1)]))
        
    elif order == "reverse":
        if len(sentence[first : second + 1]) % 2 == 0:
            for i in range(int(len(sentence[first : second + 1]) / 2)):
                tmp = sentence[first + i]
                sentence[first + i] = sentence[second - i] 
                sentence[second - i] = tmp
                
        else:
            for i in range(len(sentence[first : second + 1] )// 2):
                tmp = sentence[first + i]
                sentence[first + i] = sentence[second - i] 
                sentence[second - i] = tmp
            
    else:
        sentence[first : second + 1] = change


Measured memory_bytes: 5632
#include "bits/stdc++.h"
using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    vector< int> v(n + 1, 0);

    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> v[i];
        sum += v[i];
    }

    int q;
    scanf("%d", &q);
    while (q--) {
        int a, b;
        cin >> a >> b;
        cout << sum - v[a] + b << endl;
    }
}

Measured memory_bytes: 256
import itertools as it

N,M,X=map(int,input().split())
book = [[int(_) for _ in input().split()] for i in range(N)]

combs = it.product([0, 1], repeat=N)
prices = []
for comb in combs:
	bag = [0] * (M+1)
	for i in range(N):
		if comb[i] == 0:
			continue
		else:
			for j in range(M+1):
				bag[j]+=book[i][j]
	if min(bag[1:]) < X:
		continue
	else:
		prices.append(bag[0])

if len(prices) == 0:
	print(-1)
else:
	print(min(prices))

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

int main() {
  int N;
  cin >> N;
  vector<string> vecblue(N);
  
  for (int i = 0; i < N; i++) {
   cin >> vecblue.at(i);
  }
  
  int M;
  cin >> M;
  vector<string> vecred(M);
  
  for (int i = 0; i < M; i++) {
   cin >> vecred.at(i);
  }
  
  vector<int> veccount(N);
  
  int c;
  
  for (int i = 0; i < N; i++) {
    c = 0;
    for (int j = 0; j < N; j++) {
      if (vecblue.at(i) == vecblue.at(j)) {
        c++;
      }
    }
    for (int k = 0; k < M; k++) {
      if (vecblue.at(i) == vecred.at(k)) {
        c--;
      }
    }
    veccount.at(i) = c;
  }
  
  int a = 0;
  
  for (int i = 0; i < N; i++) {
    if (a < veccount.at(i)) {
      a = veccount.at(i);
    }
  }
  
  cout << a << endl;
}
        

    
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
        ll n,k,q;
        cin>>n>>k>>q;
        ll arr[q],ar[n];
        for(ll i=0;i<n;i++){
            ar[i]=k-q;
        }
        for(ll i=0;i<q;i++){
            cin>>arr[i];
            ar[arr[i]-1]+=1;



        }
        for(ll i=0;i<n;i++){
               // cout<<ar[i]<<endl;
            if(ar[i]>=1){
                cout<<"Yes"<<endl;
            }
            else{
                cout<<"No"<<endl;
            }
        }
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

const int maxn = TEN(6) + 10;
V<int> g[maxn];
int in[maxn];
int N;

int getid(int p, int q) {
    if (p > q) swap(p, q);
    return p * N + q;
}

int main() {
    cin >> N;
    rep(i, N) {
        int la = -1;
        rep(j, N-1) {
            int x; cin >> x;
            --x;
            if (la != -1) {
                int a = getid(la, i);
                int b = getid(x, i);
                g[a].pb(b);
                ++in[b];
            }
            la = x;
        }
    }
    queue<int> que;
    V<int> dp(N * N, -1);
    rep(i, N * N) {
        if (in[i] == 0) {
            que.push(i);
            dp[i] = 1;
        }
    }
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int to : g[v]) {
            if (--in[to] == 0) {
                que.push(to);
            }
            chmax(dp[to], dp[v] + 1);
        }
    }
    bool ok = 1;
    rep(i, N * N) if (in[i] != 0) ok = 0;
    if (ok) {
        cout << *max_element(ALL(dp)) << endl;
    } else {
        puts("-1");
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll h1, h2, m1, m2, k, ans = 0;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  ans = (h2 - h1) * 60 + (m2 - m1) - k;

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


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



typedef long long ll;
//ll gcd(ll a, ll b) { while (b) a %= b, swap(a, b); return a; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int N;
int A[101010];
//-----------------------------------------------------------------
bool sol() {
	if (N == 1) return A[0] % 2 == 0;

	int even = 0;
	rep(i, 0, N) if (A[i] % 2 == 0) even++;

	if (even % 2 == 1) return true;
	if (2 <= N - even) return false;

	int sit;
	rep(i, 0, N) if (A[i] % 2 == 1) sit = i;
	if (A[sit] == 1) return false;
	A[sit]--;

	ll g = A[0];
	rep(i, 0, N) g = gcd(g, A[i]);
	rep(i, 0, N) A[i] = A[i] / g;

	return !sol();
}
//-----------------------------------------------------------------
int main() {
	cin >> N;
	rep(i, 0, N) scanf("%d", &A[i]);

	if (sol())
		printf("First\n");
	else
		printf("Second\n");
}

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

#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define loop(i,x,n) for(int i=x;i<n;i++)
#define arr 1000005
#define F first
#define S second
#define pii pair<int,int>

const int modu=1e9+7;
ll mod(ll n){
    return (n%modu);
}

bool cmp(ll a,ll b){
    return a>b;
}

int main() {
    FIO
    ll n,m,x=0;
    cin>>n>>m;
    while(m--){
        ll a;
        cin>>a;
        x+=a;
    }
    n=n-x;
    if(n>=0){
        cout<<n;
    }
    else
    cout<<-1;
	return 0;
}


Measured memory_bytes: 3160
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,k]=i2()
if k%2==1:
 print(int(n/k)**3)
else:
 print(int(n/k)**3+(int(n/(k/2))-int(n/k))**3)

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

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b:
        a, b = b, a%b
    return a

def lcm(a: int, b: int):
    return a * b // gcd(a, b)


def main():
	#N,M = map(int, input().split())
	S = input().rstrip()
	#vA = list(map(int, input().split()))
	#vX = [input().rstrip() for _ in [0,]*N]
	
	res = "No" if (S=="AAA" or S=="BBB") else "Yes"
	#res = -(-N//M)
	#res = gcd(N,M)
	print(res)
	
if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int N = 2e5 + 50;
int n; vector<int> G[N];
int sz[N], rt[N], fa[N];
int mx[N], se[N], dn[N];
namespace SGT{
	#define mid ((l+r)>>1)
	cs int N = ::N * 100;
	int lc[N], rc[N], A[N], B[N], nd;
	void ins(int &x, int l, int r, int p, bool typ){
		if(!x) x=++nd; if(l==r) return typ ? ++B[x] : ++A[x], void();
		(p<=mid)?ins(lc[x],l,mid,p,typ):ins(rc[x],mid+1,r,p,typ);
	}
	int mrg(int x, int y, int l, int r){
		if(!x||!y) return x|y;
		if(l==r){ int nx=++nd; A[nx]=A[x]+A[y]; B[nx]=B[x]+B[y]; return nx; }
		int nx=++nd; lc[nx]=mrg(lc[x],lc[y],l,mid);
		rc[nx]=mrg(rc[x],rc[y],mid+1,r); return nx;
	}
	int qry(int x, int l, int r, int p, int typ){
		if(!x) return 0; if(l==r) return typ ? B[x] : A[x];
		if(p<=mid) return qry(lc[x],l,mid,p,typ);
		return qry(rc[x],mid+1,r,p,typ);
	}
}
void dfs(int u, int f){
	mx[u]=mx[f]; se[u]=se[f];
	if(u>mx[u]) se[u]=mx[u], mx[u]=u;
	else if(u>se[u]) se[u]=u;
	sz[u]=1; SGT::ins(rt[u],1,n,mx[u],0);
	SGT::ins(rt[u],1,n,se[u],1);
	if(mx[u]==mx[f]){
		if(mx[f]==f) dn[u]=u;
		else dn[u]=dn[f];
	} 
	
	for(int e=0,v;e<G[u].size();e++)
	if((v=G[u][e])!=f){
		fa[v]=u; dfs(v,u); sz[u]+=sz[v];
		rt[u]=SGT::mrg(rt[u],rt[v],1,n);
	}
} int as[N];
void cope(int u, int f){
	if(f){
		if(u==mx[u]) as[u]=as[f]+SGT::qry(rt[u],1,n,se[u],1);
		else{
			as[u]=as[fa[mx[u]]];
			as[u]+=SGT::qry(rt[dn[u]],1,n,mx[u],0);
			as[u]+=SGT::qry(rt[mx[u]],1,n,se[mx[u]],1);
			as[u]-=SGT::qry(rt[dn[u]],1,n,se[mx[u]],1);
		}
	} for(int e=0,v;e<G[u].size();e++)
	if((v=G[u][e])!=f) cope(v,u);
}
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d",&n);
	for(int i=1,u,v; i<n; i++)
	scanf("%d%d",&u,&v), G[u].pb(v), G[v].pb(u);
	dfs(1,0); cope(1,0);
	for(int i=2; i<=n; i++) cout<<as[i]<<" ";
	return 0;
} 

Measured memory_bytes: 244340
#include <stdio.h>

void print_number(int a) {
  int i;
  if (a == 0)
    printf("-\n");
  else {
    for (i = 0; i < a; i++)
      printf("*");
    putchar('\n');
  }
}

int main(void) {
  int n, c[10], i, t;

  while (1) {
    scanf("%d", &n);
    if (n == 0) break;

    for (i = 0; i < 10; i++)
      c[i] = 0;

    for (i = 0; i < n; i++) {
      scanf("%d", &t);
      c[t]++;
    }

    for (i = 0; i < 10; i++)
      print_number(c[i]);
  }

  return 0;
}

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

int main(void){
  int N, T, H, L;
  cin >> N >> T >> H  >> L;
  int t[101], h[101];
  for(int i=0; i<N; i++) {
    cin >> t[i] >> h[i];
  }

  int i;
  int sum = 0;
  while( 1 ) {
    for(i=0; i<N; i++) {
      if( t[i] > 0 ) {
	t[i]--;
	T++;
	sum += 10;
      } else if( h[i] > 0 ) {
	h[i]--;
	H++;
	sum += 100;
      } else {
	cout << i+1 << endl;
	return 0;
      }

      if( T > L ) {
	cout << i+1 << endl;
	return 0;
      }
      if( sum == 90 ) {
	sum = 0;
      }
      if( sum > 90 ) {
	if( T * 10 >= sum - 90 ) {
	  t[i] += (sum - 90) / 10;
	  T -= (sum - 90) / 10;
	  sum = 0;
	} else {
	  cout << i+1 << endl;
	  return 0;
	}
      }
      
    }
  }
 
}

Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <climits>

typedef long long ll;

using namespace std;

bool isPrime(int x){
    if(x == 2){
        return true;
    }

    if(x < 2 || x%2 == 0){
        return false;
    }

    for(int i = 3; i <= sqrt(x); i+=2){
        if(x%i == 0){
            return false;
        }
    }
    return true;
}

void solve() {
    int n, count=0;
    cin >> n;
    for(int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        if(isPrime(temp)){
            count++;
        }
    }
    cout << count << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int A, B, C; cin>>A>>B>>C;
  int ans = A+B+C - max(A,(max(B,C)));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
a, b, c, d = map(int,input().split())
dp = [[0 for j in range(d+1)] for i in range(c+1)]
for i in range(a, c+1):
  for j in range(b, d+1):
    if i == a and j == b:
      dp[i][j] = 1
      continue
    dp[i][j] = (dp[i-1][j] * j + dp[i][j-1] * i - dp[i-1][j-1] * (i-1) * (j-1) ) % 998244353
    dp[i][j] += 998244353
    dp[i][j] %= 998244353
print(dp[c][d])

Measured memory_bytes: 147168