akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int ct_1(string s)
{
    int c = 0;
    rep(i, sz(s))
    {
        if (s[i] == '1') {
            c++;
        }
    }

    return c;
}

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

    int N;
    cin >> N;

    string X;
    cin >> X;

    int ct = 0;
    rep(i, N)
    {
        if (X[i] == '1') {
            ct++;
        }
    }

    int m = ct - 1;
    int M = ct + 1;

    vector<int> mod_m(N);
    vector<int> mod_M(N);


    if (m)
        mod_m[0] = 1 % m;
    mod_M[0] = 1 % M;


    REP(i, N - 1)
    {
        if (m)
            mod_m[i] = (2 * mod_m[i - 1]) % m;
        mod_M[i] = (2 * mod_M[i - 1]) % M;
    }


    int tmp_m = 0;
    int tmp_M = 0;

    for (int i = N - 1; i >= 0; i--) {
        if (X[i] == '1') {
            tmp_m += mod_m[N - i - 1];
            if (m)
                tmp_m %= m;
            tmp_M += mod_M[N - i - 1];
            tmp_M %= M;
        }
    }


    vector<int> f(N + 1);
    for (int i = 1; i <= N; i++) {
        auto bs = bitset<20>(i);
        int tmp = bs.count();

        f[i] = 1 + f[i % tmp];
    }

    rep(i, N)
    {
        if (X[i] == '1') {
            if (m == 0) {
                cout << 0 << endl;
            } else {

                int tmp = tmp_m;
                tmp += m;
                tmp -= mod_m[N - i - 1];

                cout << 1 + f[tmp % m] << endl;
            }
        } else {
            int tmp = tmp_M;
            //            cout << tmp << endl;
            tmp += mod_M[N - i - 1];
            //           cout << tmp << endl;
            cout << 1 + f[tmp % M] << endl;
        }
    }
}


Measured memory_bytes: 5912
#include <bits/stdc++.h>
using namespace std;
int x, y;

int main() {
    cin >> x >> y;
    if (x == 0) {
        if (y > 0) cout << y << endl;
        else cout << 1 - y << endl;
        return 0;
    }
    if (y == 0) {
        if (x < 0) cout << -x << endl;
        else cout << x + 1 << endl;
        return 0;
    }
    if (x > 0 && y > 0) {
        if (x > y) cout << x - y + 2;
        else cout << y - x;
        return 0;
    }
    if (x > 0 && y < 0) {
        if (x == -y) cout << 1 << endl;
        else if (x < -y) cout << -y - x + 1 << endl;
        else cout << x + y + 1 << endl;
        return 0;
    }
    if (x < 0 && y > 0) {
        if (-x == y) cout << 1 << endl;
        else if (-x < y) cout << x + y + 1 << endl;
        else cout << -x - y + 1 << endl;
        return 0;
    }
    if (x < y) cout << y - x;
    else cout << x - y + 2 << endl;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
As = list(map(int, input().split()))

ct = Counter(As)
ans = 0
for k, v in ct.items():
    ans += (v * (v-1)) // 2

for a in As:
    c = ct[a]
    if c >= 2:
        print(ans - ((c * (c-1)) // 2) + (((c-1) * (c-2)) // 2))
    else:
        print(ans)

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

int main() {
  int h,n;
  cin >> h >> n;
  for(int i=0; i<n; i++){
    int x;
    cin >> x;
    h -= x;
  }
  if(h <= 0)
    cout << "Yes";
  else
    cout << "No";
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> M;
  DV(G,lli,N,N,INF);
  rep(i,0,M){
    cin >> A >> B >> C;
    G[A][B]=C;
  }
  rep(i,0,N)G[i][i]=0;
  rep(i,0,N)rep(j,0,N)rep(k,0,N)if(G[i][k]!=INF&&G[j][i]!=INF)G[j][k]=min(G[j][k],G[j][i]+G[i][k]);
  rep(i,0,N)if(G[i][i]<0){
    flag=1;
    Out("NEGATIVE CYCLE");
    break;
  }
  if(!flag)rep(i,0,N){
    rep(j,0,N){
      if(j>0)NeOut(' ';)
      if(G[i][j]==INF)cout << "INF";
      else cout << G[i][j];
    }
    Out("");
  }
}





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

signed main(){
  int n;
  cin>>n;
  int A=0,B=0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if(x&1)A++;
    else B++;
  }
  if(!A || !B)cout<<0<<endl;
  else{
    if(A%2==1)cout<<(n-1)<<endl;
    else cout<<(n-2)<<endl;
  }
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);


int f (int v){
    int ret = 1;
    for(int i=2;i<=v;i++){
        if(v % i == 0 ) ret ++ ;
    }
    return ret ;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n, ans = 0;
    cin >> n;
    for(int i=1;i<=n;i++){
        if(i%2 == 1 && f(i) ==  8 )ans++;
    }
    cout << ans << endl;
}

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

// 無限大を表す値
const long long INF = 1LL<<60;

// 辺を表す型，ここでは重みを表す型を long long 型とします
struct Edge {
    int to; // 隣接頂点番号
    long long w; // 重み
    Edge(int to, long long w) : to(to), w(w) {}
};

// 重み付きグラフを表す型，各頂点の隣接リストを辺集合で表す
using Graph = vector<vector<Edge>>;

// 緩和処理 (更新が行われたときは true を返し，行われないときは false を返す)
template<class T> bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    else return false;
}

int main() {
    // 頂点数と辺数，始点
    int N, M, s;
    cin >> N >> M >> s;

    // グラフ
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b, w;
        cin >> a >> b >> w;
        G[a].push_back(Edge(b, w));
    }

    // Bellman-Ford 法
    bool exist_negative_cycle = false; // 負閉路をもつかどうか
    vector<long long> dist(N, INF); // 最終的に各頂点への最短路長が格納される
    dist[s] = 0;
    for (int iter = 0; iter < N; ++iter) {
        bool update = false; // 更新が発生したかどうかを表すフラグ
        for (int v = 0; v < N; ++v) {
            // dist[v] = INF のときは頂点 v からの緩和を行わない
            if (dist[v] == INF) continue;
            
            for (auto e : G[v]) {
                // 緩和処理を行い，更新されたら update を true にする
                if (chmin(dist[e.to], dist[v] + e.w)) {
                    update = true;
                }
            }
        }

        // 更新が行われなかったら，すでに最短路が求められている
        if (!update) break;

        // N 回目の反復で更新が行われたならば，負閉路をもつ
        if (iter == N-1 && update) exist_negative_cycle = true;
    }

    // 結果出力
    if (exist_negative_cycle) cout << "NEGATIVE CYCLE" << endl;
    else {
        for (int v = 0; v < N; ++v) {
            if (dist[v] < INF) cout << dist[v] << endl;
            else cout << "INF" << endl;
        }
    }
}


Measured memory_bytes: 3184
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder02
{
    class ABC113_A
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int x = int.Parse(str[0]);
            int y = int.Parse(str[1]);
            Console.WriteLine(x + y / 2);
        }
    }
}

Measured memory_bytes: 11092
from queue import Queue

k = int(input())

q = Queue()

for i in range(1, 10):
    q.put(i)

for i in range(k):
    num = q.get()
    
    if i == k - 1:
        print(num)
    
    if num % 10 != 0:
        q.put(10 * num + (num % 10 - 1))
    
    q.put(10 * num + (num % 10))
    
    if num % 10 != 9:
        q.put(10 * num + (num % 10 + 1))

Measured memory_bytes: 13016
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <limits.h>
#include <float.h>
#include <numeric>
#include <queue>

using namespace std;

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

#define fs first
#define sc second

vector<int> prime_list;
vector<int> counter;

bool is_prime(int n){
    bool res = true;
    for(int i = 2; i < n; i++){
        if(n % i == 0){
            res = false;
            break;
        }
    }
    return res;
}


int main(){
    int N;  cin >> N;
    for(int i = 2; i <= N; i++){
        if (is_prime(i)){
            prime_list.push_back(i);
            counter.push_back(1);
        }
        else{
            int ii = i;
            for(int j = 0; j < prime_list.size(); j++){
                while(ii % prime_list[j] == 0){
                    counter[j]++;
                    ii /= prime_list[j];
                }
            }
        }
    }


    ll res = 0;
    for(int i = 0; i < prime_list.size(); i++){
        for(int j = i+1; j < prime_list.size(); j++){
            for(int k = j+1; k < prime_list.size(); k++){
                if(counter[i] >= 2 && counter[j] >= 4 && counter[k] >= 4){
                    res++;
                }
                if(counter[i] >= 4 && counter[j] >= 2 && counter[k] >= 4){
                    res++;
                }
                if(counter[i] >= 4 && counter[j] >= 4 && counter[k] >= 2){
                    res++;
                }
            }
        }
    }

    for(int i = 0; i < prime_list.size(); i++){
        for(int j = i+1; j < prime_list.size(); j++){
            if(counter[i] >= 24 && counter[j] >= 2){
                res++;
            }
            if(counter[i] >= 2 && counter[j] >= 24){
                res++;
            }
            if(counter[i] >= 14 && counter[j] >= 4){
                res++;
            }
            if(counter[i] >= 4 && counter[j] >= 14){
                res++;
            }
        }
    }

    for(int i = 0; i < prime_list.size(); i++){
        if(counter[i] >= 74){
            res++;
        }
    }

    cout << res << endl;

    return 0;
}

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

int main()
{
    int m,r,g,b;
    while(scanf("%d%d%d",&r,&g,&b)!=EOF)
    {
        m=r*100+g*10+b;
        if (m%4==0) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 384
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

struct UnionFind{
    vector<int> data;
    UnionFind(int size){
        data=vector<int>(size,-1);
    }
    bool union_set(int x,int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];
            data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI3(A,B,K);
    FOR(i,K/2){
        if(A%2==1)A--;
        A/=2;
        B+=A;
        if(B%2==1)B--;
        B/=2;
        A+=B;
    }
    if(K%2){
        if(A%2==1)A--;
        A/=2;
        B+=A;
    }
    cout<<A<<" "<<B<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		double a = scanner.nextDouble();
		double b = scanner.nextDouble();
		double degree = scanner.nextDouble();

		double S = 0.5*a*b*Math.sin(Math.PI*degree/180.0);
		double c = Math.sqrt(a*a+b*b-2*a*b*Math.cos(Math.PI*degree/180.0));

		System.out.printf("%.10f\n",S);
		System.out.printf("%.10f\n", a+b+c);
		System.out.printf("%.10f\n", 2*S/a);
	}
}




Measured memory_bytes: 28292
n, q = map(int, input().split())
s = input()
hp = [0] * (n+1)
for i in range(len(s)):
  hp[i+1] = hp[i] + (1 if s[i:i+2] == 'AC' else 0)
for _ in range(q):
  l, r = map(int, input().split())
  print(hp[r-1] - hp[l-1])

Measured memory_bytes: 7748
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <iomanip>
using namespace std;

typedef pair <long long, long long> pii;

const long long MAX_N = 3e3 + 3, inf = 1000000LL * 1000000LL * 1000000LL, MOD = 1e9 + 7;
long long n;
double p[MAX_N];
double dp[MAX_N][MAX_N], ans;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> p[i];
	
	dp[0][0] = 1;

	for (int i = 1; i <= n; i++) {
		dp[i][0] = (1.0 - p[i]) * dp[i - 1][0];
		for (int j = 1; j <= i; j++)
			dp[i][j] = p[i] * dp[i - 1][j - 1] + (1.0 - p[i]) * dp[i - 1][j];
	}

	for (int i = (n + 1) >> 1; i <= n; i++)
		ans += dp[n][i];

	cout << fixed << setprecision(10) << ans;
	return 0;
}

Measured memory_bytes: 68992
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    int m1,d1;cin>>m1>>d1;
    int m2,d2;cin>>m2>>d2;
    if(m1!=m2) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
    int n,m;
    cin >> n >> m;

    while(n!=0){
        vector<int> sub(n,0);
        for(int j = 0;j<m;j++){
            for(int i = 0;i<n;i++){
                int a;
                cin >> a;
                sub.at(i) += a;
            }
        }

        sort(sub.begin(),sub.end());

        cout << sub.at(n-1) << endl;

        cin >> n >> m;
    }
    
}


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

int main()
{    
    
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(), v.end());
    double ans = v[0];
    rep2(i,1,n) ans = (ans+v[i])/2;
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

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

int main() {
	long int a,b,c,d;
	cin>>a>>b>>c>>d;
	
	long long int l,m,n,p;
	l=a*c;
m=a*d;
n=b*c;
p=b*d;

if(l>m && l>n &&l>p)
cout<<l;
else if(m>l &&m>n&&m>p)
cout<<m;
else if(n>l&&n>m&&n>p)
cout<<n;
else
cout<<p;
	
	return 0;
}


Measured memory_bytes: 3616
def main():
    N = int(raw_input())

    n = N
    sN = 0
    i = 1000000000
    while i > 0:
        sN += n/i
        n -= n/i * i
        i = i/10
    if N % sN == 0:
        print 'Yes'
    else:
        print 'No'

main()

Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
const int twx=+100;
const int inf=0x7fffffff;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
int m1,d1,m2,d2;
void init()
{
	m1=read();
    d1=read();
    m2=read();
    d2=read();
    if(m1!=m2)
    {
        puts("1");
    }
    else
    {
        puts("0");
    }
}
void work()
{
	
}
void print()
{
	
}
int main()
{
    init();
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
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-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vi a;

int main(){
	cin>>n>>m;
	a=vi(m);
	for(int i=0;i<n;i++){
		int k;
		cin>>k;
		for(int j=0;j<k;j++){
			int x;
			cin>>x;
			a[x-1]++;
		}
	}
	int res=0;
	for(auto i:a) if(i==n) res++;
	cout<<res<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

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

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 
const long double eps = 1e-5; 
const long double root2 = 1.4142135623730950488016887242096;
string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(11);
	
	long double d;
	
	cin>>d;

	
	if(d >= 1 && sqrt((int)(d)*(int)(d) - 1) <= d)cout<<max(sqrt(2)*d, (long double)((int)d + 1))<<endl;
	else  cout<<root2*d<<endl;
	
	return 0;
}


Measured memory_bytes: 3336
x, n = map(int, input().split())
a = list(map(int, input().split()))
o = [0] * 102
for i in a:
    o[i] = 1

ans = 1000
dis = 1000
for i in range(0, len(o)):
    if o[i] == 0:
        if dis > abs(x - i):
            ans = i
            dis = abs(x-i)

print(ans)


Measured memory_bytes: 9204
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int read()
{
	int a = 0,x = 1;
	char ch = getchar();
	while(ch > '9' || ch < '0'){
		if(ch == '-') x = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		a = a*10 + ch-'0';
		ch = getchar();
	}
	return a*x;
}

int n,ans = 0;
void check(int s)
{
	int ret = 0;
	for(int i = 1;i*i <= s;i ++){
		if(s%i==0) ret += 2;
		if(i*i == s) ret --;
	}
	ans += ret;
}

int main()
{
	n = read();
	for(int i = 1;i < n;i ++) {
		check(n-i);
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;

 
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
const int N = 300011;
int n, k, arr[N], tree[N<<2], dp[N];
void update(int node, int l, int r, int i, int v) {
  if (r < i || l > i) return;
  if (i <= l && r <= i) {
    tree[node] = v; 
    return;
  } int mid = (l + r) >> 1;
  update(node << 1, l, mid, i, v);
  update(node << 1|1, mid + 1, r, i, v);
  tree[node] = max(tree[node << 1], tree[node << 1|1]);
}
int query(int node, int l, int r, int i, int j) {
  if (r < i || l > j) return 0;
  if (i <= l && r <= j) {
    return tree[node]; 
  } int mid = (l + r) >> 1;
  return max(query(node << 1, l, mid, i, j), 
       query(node << 1|1, mid+1, r, i, j));
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> arr[i], arr[i]++;
  for (int i = 1; i <= n; ++i) {
    dp[i] = query(1, 1, N - 10, max(1, arr[i] - k), min(N - 10, arr[i] + k)) + 1;
    // debug(i, arr[i], dp[i]);
    update(1, 1, N - 10, arr[i], dp[i]);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) ans = max(ans, dp[i]);
  cout << ans << '\n';
}

Measured memory_bytes: 10108
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,k;
  string s;
  cin>>n>>k;
  cin>>s;
  if(s[k-1]=='A'){
    s[k-1]='a';
  }
  else if(s[k-1]=='B'){
    s[k-1]='b';
  }
  else if(s[k-1]=='C'){
    s[k-1]='c';
  }
  cout<<s<<endl;
  return 0;
}

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

int main(){
  string S; cin >> S;
  if(S=="SUN"){
    cout << 7 << endl;
  }
  if(S=="MON"){
    cout << 6 << endl;
  }
  if(S=="TUE"){
    cout << 5 << endl;
  }
  if(S=="WED"){
    cout << 4 << endl;
  }
  if(S=="THU"){
    cout << 3 << endl;
  }
  if(S=="FRI"){
    cout << 2 << endl;
  }
  if(S=="SAT"){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int selectionSort(int A[],int N){
int i,j,t,sw=0,minj;
for(i=0;i<N-1;i++){
minj=i;
for(j=i;j<N;j++){
if(A[j]<A[minj]) minj=j;
}
t=A[i];A[i]=A[minj];A[minj]=t;
if(i!=minj) sw++;
}
return sw;
}
int main(){
int A[100],N,i,sw;
scanf("%d",&N);
for(i=0;i<N;i++) scanf("%d",&A[i]);
sw=selectionSort(A,N);
for(i=0;i<N;i++){
if(i>0) printf(" ");
printf("%d",A[i]);
}
printf("\n");
printf("%d\n",sw);
return 0;
}

Measured memory_bytes: 604
def resolve():
    N, M = [int(i) for i in input().split()]
    llrr = [list(map(int, input().split())) for _ in range(M)]
    maxL = 1
    minR = N
    for l, r in llrr:
        maxL = max(maxL, l)
        minR = min(minR, r)
    ans = minR - maxL + 1
    if ans < 0:
        print(0)
    else:
        print(ans)


resolve()

Measured memory_bytes: 27348
n = gets.chomp.to_i
s = []
n.times do
  s.push gets.chomp
end
count_a = 0
count_b = 0
count_ab = 0
count_ba = 0
s.each do |e|
  count_a += 1 if e[-1] == 'A'
  count_b += 1 if e[0] == 'B'
  count_ba += 1 if e[0] == 'B' && e[-1] == 'A'
  1.upto(e.size - 1) do |i|
    count_ab += 1 if e[i - 1] == 'A' && e[i] == 'B'
  end
end
count_a -= [count_ba, count_a].min
count_b -= [count_ba, count_b].min
count = 0
if count_ba >= 1
  count = count_ab + count_ba - 1 + [count_a, 1].min + [count_b, 1].min
  count_a -= [1, count_a].min
  count_b -= [1, count_b].min
  count += [count_a, count_b].min
else
  count = count_ab + [count_a, count_b].min
end
puts count


Measured memory_bytes: 2684
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int x[3];
    int tmp;
    int i, j;
    
    for (i=0; i<3; i++) {
        scanf("%d", &x[i]);
    }
    for (i=0; i<3; i++) {
        for (j=0; j<2; j++) {
            if (x[j] > x[j+1]) {
                tmp = x[j];
                x[j] = x[j+1];
                x[j+1] = tmp;
            }
        }
    }
    
    printf("%d %d %d\n", x[0], x[1], x[2]);
    
    
    return 0;
}

Measured memory_bytes: 596
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum
import sys

readline = sys.stdin.buffer.readline

#iimr = lambda: map(int, sys.stdin.buffer.readline().rstrip().split())
# il ne y a pas plus le buffer sur atcoder
iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
#sys.setrecursionlimit(10 ** 8)

def debug(*x):
    print(*x, file=sys.stderr)


class atcoder():
    def __init__(self):
        pass

    def çözmek(self):
        N = int(input())
        A = list(map(int, sys.stdin.readline().split()))
        res = []
        res.append(self.関数(N, A))
        print(*res, "")	
    
    def 関数(self, n, Aliste):
        res = 0
        for i in range(1, n):
            if Aliste[i - 1] > Aliste[i]:
                res += Aliste[i - 1] - Aliste[i]
                Aliste[i] = Aliste[i - 1]

        return res

if __name__ == "__main__":
    ima = atcoder()
    ima.çözmek()



Measured memory_bytes: 32800
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define YN(y, n, b) (b? y : n)
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 H, W, K;
    cin >> H >> W >> K;
    Vec<Vec<bool>> c(H, Vec<bool>(W, false));
    for (i32 i = 0; i < H; i++) {
        for (i32 j = 0; j < W; j++) {
            char q;
            cin >> q;
            c[i][j] = (q == '#');
        }
    }
    i32 l = 0;
    for (i32 bit1 = 0; bit1 < (1 << H); bit1++) {
        Vec<i32> v1;
        for (i32 i = 0; i < H; i++) {
            if (bit1 & (1 << i)) v1.push_back(i);
        }
        for (i32 bit2 = 0; bit2 < (1 << W); bit2++) {
            Vec<i32> v2;
            for (i32 j = 0; j < W; j++) {
                if (bit2 & (1 << j)) v2.push_back(j);
            }
            i32 sum = 0;
            for (i32 s = 0; s < H; s++) {
                if (find(ALL(v1), s) != v1.end()) continue;
                for (i32 t = 0; t < W; t++) {
                    if (find(ALL(v2), t) != v2.end()) continue;
                    if (c[s][t]) sum++;
                }
            }
            if (sum == K) l += 1;
        }
    }
    cout << l << endl;
}


Measured memory_bytes: 3660
#include <iostream>
#include <stdio.h>

int max(int a, int b);

int main()
{
    int a, b;
    int add, sub, mul;
    int max_val;
    
    std::cin >> a >> b;
    
    add = a + b;
    sub = a - b;
    mul = a * b;
        
    max_val = max(mul, max(add, sub));
    
    std:: cout << max_val << std::endl; 
    
    return 0;
}

int max(int a, int b) {
    if (a > b) return a;
    else return b;    
}

Measured memory_bytes: 256
a,b,k = map(int,input().split())
if a <= b:
    buf = a
    a = b
    b = buf
count = 0
for i in range(b):
    if a%(b - i) == 0 and b%(b-i) == 0:
        count += 1
    if count == k:
        print(b - i)
        break


Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    for(int i = 0; i < n; i++){
        if(i == 0){
            cin >> a[0];
            sum += a[0];
        }else{
            int x;
            cin >> x;
            a[i] = a[i - 1] + x;
            sum += x;
        }
    }
    
    int ans[n];
    for(int i = 0; i < n; i++){
        ans[i] = abs((sum - a[i]) - a[i]);
    }
    sort(ans, ans+n);
    cout << ans[0];
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
string s1,s2;
int main()
{
	cin>>s1>>s2;
	for(int i=0;i<min(s1.size(),s2.size());i++)
	{
		cout<<s1[i]<<s2[i];
	}
	if(s1.size()!=s2.size()) cout<<s1[s1.size()-1];
	cout<<endl;
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int n; scanf("%d", &n);
	int ans = 0;
	while (n) {
		n >>= 1;
		++ans;
	}
	printf("%d", 1<<--ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int x[5];
  int ans;

  for(int i=0;i<5;i++)
  {
    scanf("%d",&x[i]);
    if(x[i]==0) ans=i+1;
  }

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

  return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
const int N=3e5;
  int n;
  char s[N],t[N];
  int a[N],b[N];
  int x[N],y[N];
  string A[2]={"Yes","No"};

int che()
{
  for (int i=0;++i<=n;)
    if (x[i]^y[i]) return 1;
  return 0;
}

int main()
{
  scanf("%s%s",s+1,t+1);
  n=strlen(s+1);
  for (int i=0,k=0;++i<=n;)
    {    
      if (!a[s[i]]) a[s[i]]=++k;
      x[i]=a[s[i]];
    }
  for (int i=0,k=0;++i<=n;)
    {    
      if (!b[t[i]]) b[t[i]]=++k;
      y[i]=b[t[i]];
    }
  cout<<A[che()];
  exit(0);
}


Measured memory_bytes: 4224
awk 'function sort(a,n){qsort(a,1,n)}\
function qsort(a,p,r){if(p<r){q=ptn(a,p,r);qsort(a,p,q-1);qsort(a,q+1,r)}}\
function ptn(a,p,r){x=a[r];i=p-1;for(j=p;j<r;j++){if(a[j]<=x){i++;t=a[i];a[i]=a[j];a[j]=t}}t=a[i+1];a[i+1]=a[r];a[r]=t;return i+1}\
BEGIN{\
	getline n;\
	getline;\
	for(i=1;i<=n;i++)a[i]=$i;\
	sort(a,n);\
	for(i=2;i<=n;i++)a[1]=(a[1]+a[i])/2;\
	print(a[1]);\
}'

Measured memory_bytes: 1444
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s; i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;


int main(){
    string s; cin >> s;
    int ans = 0;
    if(s[0] == 'S'){
        if(s[1] == 'A') ans = 1;
        else ans = 7;
    }
    else if(s[0] == 'F') ans = 2;
    else if(s[0] == 'T'){
        if(s[1] == 'H') ans = 3;
        else ans = 5;
    }
    else if(s[0] == 'W') ans = 4;
    else ans = 6;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>  // min, max
#include <fstream>  // ifstream
#include <iomanip>  // setprecision
using namespace std;
typedef long long ll;

bool string_order(std::pair<string, int> first_entry,
                  std::pair<string, int> second_entry)
{
    int foo = (first_entry.second & 0xFF);
    int bar = (second_entry.second & 0xFF);
    return (foo > bar);
}

int main(void)
{
    ifstream inputFile("data/input.txt");
    if (getenv("SSH_CONNECTION") != nullptr) {
        cin.rdbuf(inputFile.rdbuf());
    }

    int N;
    cin >> N;
    vector<pair<string, int>> data(N);
    for (int i = 0; (i < N); ++i) {
        cin >> data[i].first >> data[i].second;
        data[i].second += (i * 256);
    }
    sort(data.begin(), data.end());
    data.emplace_back("", 0);
    int i = 0;
    while (i < N) {
        int j = i;
        while (data[i].first == data[j+1].first) {
            ++j;
        }
        sort(data.begin() + i, data.begin() + j + 1, string_order);
        int k;
        for (k = i; (k <= j); ++k) {
            cout << ((data[k].second & 0xFF00) / 256) + 1 << endl;
        }
        i = j + 1;
    }
    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int n, k;
	char s[51];
	scanf("%d%d%s", &n, &k, s);
	for (int i = 0; i < n; i++) {
		if (i == k - 1)
			printf("%c", s[i] + 'a' - 'A');
		else
			printf("%c", s[i]);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 128
n=int(input())
a=sorted(list(map(int,input().split())))
flag=0
if n%2==1 and a.pop(0)!=0:flag=1
for i in range(n//2):
    if a[i*2]==a[i*2+1]==(i+1)*2-1+n%2:pass
    else:flag=1
print(0 if flag else 2**(n//2)%(10**9+7))

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

 int main() {

 int N,A;
 cin>>N>>A;

 int L=A;
 int R=A+N-1;

 int eat;
 if(R<=0)eat=R;
 else if(L>=0)eat=L;
 else eat=0;

 int answer=(R+L)*(R-L+1)/2-eat;

 cout<<answer<<endl;

 return 0;

 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int N, ans = 0,P;
    double max = 0, min = 100;
    cin >> N;
    int X[N];

//入力
    for (int i = 0; i < N; i++)
    {
        cin >> X[i];
    }
    for (int i = 0; i < N; i++)
    {
        max += X[i];
    }   
//中間計測
    P = round(max / N);
    //演算
    for (int i = 0; i < N ; i++)
    {
        ans += ((P - X[i]) * (P - X[i]));
        //cout << "count-" <<P-X[i]<<"-"<< P << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	x := nextInt64()
	x = abs(x)
	k := nextInt64()
	d := nextInt64()
	k1 := x / d
	if k1 > k {
		fmt.Println(abs(x - k*d))
		return
	}
	//fmt.Println("k1 ", k1)
	if (k-k1)%2 == 0 {
		fmt.Println(abs(x % d))
	} else {
		fmt.Println(abs((x % d) - d))
	}

}
func abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}


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

int main() {
  string s;
  cin >> s;
  
  int n = 0;
  
  for(int i = 0;i < 3;i++){
    if(s.at(i) == 'o'){
      n++;
    }
  }
  
  cout << 700 + (n * 100) << endl;
    
      
}


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

int main()
{
  char s[11];
  int i,j,k;

  scanf("%s",s);

  if(s[0]!='A'){
    printf("WA\n");

    return 0;
  }

  j=0;
  k=0;
  for(i=2;i<strlen(s)-1;i++){
    if(s[i]=='C'){
      j=i;
      k++;
    }
  }
  if(k>2||k==0){
    printf("WA\n");
    
    return 0;
  }

  for(i=1;i<strlen(s);i++){
    if(s[i]<=90&&s[i]>=65&&i!=j){
      printf("WA\n");

      return 0;

    }
  }

  printf("AC\n");

  return 0;
}


Measured memory_bytes: 128
#include <map>
#include <list>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;

LL prep[2005][2005] = {0};
LL prer[2005][2005] = {0};
LL prec[2005][2005] = {0};
char bl[2005][2005] = {0};
char sidr[2005][2005] = {0};
char sidc[2005][2005] = {0};

LL n,m,q,a1,b1,a2,b2;

int main(){
	cin >> n >> m >> q;
	for(int i = 1;i <= n;i ++){
		for(int j = 1;j <= m;j ++){
			cin >> bl[i][j]; bl[i][j] -= '0';
			prep[i][j] = prep[i - 1][j] + prep[i][j - 1] - prep[i - 1][j - 1] + bl[i][j];
			if(bl[i][j] && bl[i - 1][j]) sidr[i][j] = 1;
			if(bl[i][j] && bl[i][j - 1]) sidc[i][j] = 1;
			prer[i][j] = prer[i - 1][j] + prer[i][j - 1] - prer[i - 1][j - 1] + sidr[i][j];
			prec[i][j] = prec[i - 1][j] + prec[i][j - 1] - prec[i - 1][j - 1] + sidc[i][j];
		}
	}
	while(q --){
		scanf("%lld %lld %lld %lld",&a1,&b1,&a2,&b2);
		printf("%lld\n",(prep[a2][b2] - prep[a1 - 1][b2] - prep[a2][b1 - 1] + prep[a1 - 1][b1 - 1])  - (prec[a2][b2] - prec[a1 - 1][b2] - prec[a2][b1] + prec[a1 - 1][b1]) - (prer[a2][b2] - prer[a1][b2] - prer[a2][b1 - 1] + prer[a1][b1 - 1]) );
	}
	return 0;
}

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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<string> A(N);
	vector<string> B(M);

	for(int i = 0; i < N; i++) cin >> A[i];
	for(int i = 0; i < M; i++) cin >> B[i];

	int offset = N - M;
	bool found = false;
	for(int i = 0; i <= offset; i++){
		for(int j = 0; j <= offset; j++){
			bool same = true;
			int bx = 0;
			for(int x = i; x < i + M; x++, bx++){
				int by = 0;
				for(int y = j; y < j + M; y++, by++){
					// cout << A[y][x] << " " << B[by][bx] << endl;
					if(A[y][x] != B[by][bx]){
						same = false;
						break;
					}
				}
				if(!same) break;
			}
			if(same){
				found = true;
				break;
			}
		}
		if(found) break;
	}
	if(found) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ar array

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

    for (int i = 0, x; i < 5; i++) {
        cin >> x;
        if (x == 0) {
            cout << i + 1 << '\n';
            return 0;
        }
    }
}

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

List=list(map(int,input().split()))
ans = [0 for i in range(N)]


for i in range(M):
  A,B = map(int,input().split())
  HA = List[A-1]
  HB = List[B-1]
  if HA > HB:
    ans[B-1] = -1
  elif HB > HA:
    ans[A-1] = -1
  else:
    ans[A-1] = -1
    ans[B-1] = -1

cnt = 0    
for i in ans:
  if i == 0:
    cnt+= 1

print(int(cnt))
    


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

int main()
{
    int n,m,r;
    scanf("%d %d",&m,&r);
    if (m<10){
        n=r+100*(10-m);
    }
    else{
        n=r;
    }
    printf("%d",n);
    return 0;
}


Measured memory_bytes: 2032
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int mondai = sc.nextInt();
        int[] jikan = new int[mondai];
        for (int i = 0; i < mondai; i++) {
            jikan[i] = sc.nextInt();
        }
        int nomimono = sc.nextInt();
        int[] ans = new int[nomimono];
        for (int i = 0; i < nomimono; i++) {
            int koukamondai = sc.nextInt() - 1;
            int koukajikan = sc.nextInt();
            for (int j = 0; j < mondai; j++) {
                if (j == koukamondai) {
                    ans[i] += koukajikan;
                } else {
                    ans[i] += jikan[j];
                }
            }
        }
        for (int i = 0; i < nomimono; i++) {
            System.out.println(ans[i]);
        }
    }

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int g(int a,int b){
    if(b == 0){
        return a;
    }

    return g(b , a % b);
}

int main() {

    int x,y;
    cin >> x >> y;
    cout << g(x,y) << endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++) 

int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> a(n+1);
    for(int i = 1; i < n+1; i++) {
        cin >> a[i];
    }
    map<int, int> mp;
    vector<int> count(n+1, 0);
    int sum = 0;
    mp[1] = 1;
    vector<int> val;
    int i = a[1];
    int tmp = 1;
    while(1) {
        //cout << "i: " << i  << " tmp: " << tmp << endl;
        if(k-tmp == 0) {
            cout << i << endl;
            return 0;
        }
        if(mp[i] == 0) {
            mp[i] = 1;
            tmp++;
            //k--;
        }
        else if(mp[i] == 1) {
            val.push_back(i);
            mp[i] = 2;
        }
        else {
            break;
        }
        i = a[i];
    }
    //cout << "k: " << k << endl;
    k -= tmp;
    k %= (val.size());
    //rep(i, val.size()) cout << val[i] << endl;
    cout << val[k] << endl;
    return 0;
}

Measured memory_bytes: 12132
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact

N,M=acinput()

digit=[-1]*N
for i in range(M):
    s=acinput()
    if digit[s[0]-1] >= 0 and digit[s[0]-1]!=s[1]:
        print(-1)
        sys.exit()

    digit[s[0]-1]=s[1]

#print(digit)

if N==1:
    if digit[0] == 0 or digit[0] == -1:
        print(0)
        sys.exit()



        
if digit[0]==0:
    print(-1)
    sys.exit()

if digit[0]==-1:
    digit[0]=1

for i in range(1,N):
    if digit[i]<0:
        digit[i]=0


print(int("".join(map(str,digit))))


Measured memory_bytes: 12512
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>

#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <random>
#include <complex>
#include <utility>
#include <tuple>
#include <memory>

#include <array>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <csignal>
#include <cstdint>
#include <cstddef>

#ifdef ONLINE_JUDGE
#define NDEBUG
#endif
#include <cassert>
#include <stdexcept>
#include <exception>

// << pair
template <typename T1, typename T2>
std::ostream&operator<<(std::ostream&os,const std::pair<T1,T2>&p){return os<<"("<<p.first<<", "<<p.second<<")";}
// << container
template <typename C>
std::ostream&_debug_go(std::ostream&os,const C&v) {bool first=true;os<<"[";for(auto i:v){if(!first)os<<", ";os<<i;first=false;}return os<<"]";}
// << {vector, set, map} delegating to _debug_go
template<typename T> std::ostream&operator<<(std::ostream&os,const std::vector<T>&v){return _debug_go(os, v);}
template<typename T> std::ostream&operator<<(std::ostream&os,const std::set<T>&v){return _debug_go(os, v);}
template<typename T1, typename T2> std::ostream&operator<<(std::ostream&os,const std::map<T1,T2>&v){return _debug_go(os, v);}
struct Debugger{template<typename T>Debugger&operator,(const T&v){std::cerr<<v<<" "; return *this;}} dbg;
#ifndef NDEBUG
#define debug(args...) do {dbg,args; cerr << "\n";} while(0)
#else
#define debug(args...)
#endif

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ITER(i, s, e) for (auto i((s)); i != (e); ++i)
#define IT(i, c) ITER(i, (c).begin(), (c).end())

using namespace std;

using ui = uint32_t;
using ll = int64_t;
using ull = uint64_t;
template <typename T = int> using Pt = complex<T>;

template <typename T>
T cross(const Pt<T>& a, const Pt<T>& b) { return a.real() * b.imag() - a.imag() * b.real(); }

template <typename T>
bool cmpPt(const Pt<T>& a, const Pt<T>& b) {
    return a.real() < b.real() || (a.real() == b.real() && a.imag() < b.imag());
}
// END TEMPLATE


constexpr int X1 = 1e6;

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

    int K, X; cin >> K >> X;
    for (int x = max(X - K + 1, -X1); x <= min(X + K - 1, X1); ++x) {
        cout << x << " ";
    }
    cout << '\n';

    return 0;
}


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

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

    def connect(self, x, y):
        x = self.root(x)
        y = self.root(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 isConnect(self, x):
        return self.root(x) == self.root(y)

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

N, M = map(int, input().split())
uf = Unionfind(N)
for i in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    uf.connect(a, b)
ans = 0
for i in range(N):
    ans = max(ans, uf.size(i))
print(ans)


Measured memory_bytes: 14552
#include <iostream>
#include <string.h>
using namespace std;

int main(void){
    int num;
    cin >> num;
    int a = num / 100;
    int b = num % 100;
    
    if(1 <= a && a <= 12){
        if(1 <= b && b <= 12){
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if(1 <= b && b <= 12){
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256