akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    int now = 0;
    
    int N;
    cin >> N;
    int A;
    cin >> A;
    now = A;
    REP (i, N-1) {
        cin >> A;
        if (now >= A) {
            ans += now - A;
        }
        else {
            now = A;
        }
    }
    cout << ans << endl;
    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc176/abc176_c && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc176/abc176_c && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc176/abc176_c && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3688
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;
const ll MAX = 1e6 + 10;

long long fac[MAX], finv[MAX], inv[MAX];

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

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

int main() {
	ll i, j;
	ll x, y;
	cin >> x >> y;
	if ((x + y) % 3 != 0) {
		cout << 0 << endl;
		return 0;
	}
	ll c = (x + y) / 3;
	if (c > min(x, y)) {
		cout << 0 << endl;
		return 0;
	}
	ll d = min(x, y) - c;
	COMinit();
	cout << COM(c, d) << endl;

	return 0;
}


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

#define NMAX 200100
#define INF 2000000000

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)

typedef unsigned long long ull;
typedef long long int lli;

using namespace std;

// std::ifstream cin("f.in");
// std::ofstream cout("f.out");

int n;
int lowest = INF;
ull sum;

int main()
{
    cin >> n;
    int lows = 0;
    for(int i = 0; i < n; i++)
    {
        int aux;
        cin >> aux;
        if(aux < 0)
            lows++;
        lowest = MIN(lowest, abs(aux));
        sum += abs(aux);
    }

    if(lows % 2 == 1)
        sum -= 2 * lowest;
    cout << sum << '\n';

    return 0;
}   

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

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

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        if (i&1) {
            ans += x&1;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		int a, b, solution;
		String op;
		
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			
			a = scan.nextInt();
			op = scan.next();
			b = scan.nextInt();
			
			if(op.equals("?")) break;
			
			if(op.equals("+")) {
				solution = a + b;
			} else if(op.equals("-")) {
				solution = a - b;
			} else if(op.equals("*")) {
				solution = a * b;
			} else if(op.equals("/")) {
				solution = a / b;
			} else return;
			
			System.out.println(solution);
			
		}
		
	}

}


Measured memory_bytes: 26300
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXA = 200000;
const int MAXB = 200000;

int na; int a[MAXA];
int nb; int b[MAXB];

void run() {
	scanf("%d", &na); REP(i, na) scanf("%d", &a[i]); sort(a, a + na);
	scanf("%d", &nb); REP(i, nb) scanf("%d", &b[i]); sort(b, b + nb);
	int at = 0;
	REP(i, nb) {
		while (at < na&&a[at] != b[i]) ++at;
		if (at >= na) { printf("NO\n"); return; }
		++at;
	}
	printf("YES\n");
}

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int d[k];
  bool x[n];
  int c;
  for(int i=0;i<n;i++){
    x[i]=false;
  }
  for(int i=0;i<k;i++){
    cin >> d[i];
    for(int j=0;j<d[i];j++){
      cin >> c;
      x[c-1]=true;
    }
  }
  int m=0;
  for(int i=0;i<n;i++){
    if(!x[i])m++;
  }
  cout << m;
}


Measured memory_bytes: 3528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <fstream>
#include <cmath>

using namespace std;

int main(void){
    int x, a, b;
    cin >>x >> a >> b;
    cout << (x-a)%b << endl;
    return 0;
}


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



using namespace std;

const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;


#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
#else
#define PRINT(A)
#endif

typedef pair<int, int> P;

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll N, M, K;
ll A[201];

signed main() {

    cin >> N;

    for(int i=1;i<=N;i++){
        if(true){
            int j = 1;
            while(i * j <= N){
                A[i*j] += 1;
                j++;
            }
        }
    }
    int res = 0;
    for(int i=1; i <= N; i+=2){
        PRINT(i)
        PRINT(A[i])
        if(A[i] == 8){
            res += 1;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.Map.Strict               as M
import           Data.Char
import Data.Bits


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las



main = do
    (n, a, b) <- readTuple3
    let grp = n `div` (a + b)
    let rmd = n `mod` (a + b)
    print $ grp * a + min a rmd






Measured memory_bytes: 380
import java.io.*;
import java.util.*;
/**
 * Main
 */
public class Main {
       static int mod  = 1000000007;
        static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] args) {
       MyScanner ms  = new MyScanner();
        long n= ms.nextInt();
        int [] yen = {500,5};
        long sum=0;
        for(int i=0;i<yen.length;i++){
                while(yen[i]<=n){
                  if(yen[i]==500)
                  sum+=1000;
                  else if(yen[i]==5)
                    sum+=5;
                  n-=yen[i];
                }
        }
        pw.println(sum);
    pw.flush();

    }public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
}

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

int main(){
  int A, B;
  string S, T, U;
  
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if (U == S){
    cout << A-1 << " " << B << endl;
  }
  else {
    cout << A << " " << B-1 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){

    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    cout<<s<<endl;




return 0;
}



Measured memory_bytes: 3148
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
    int n;scanf("%d",&n);
    vector<ll> a(n);for(int i = 0;i < n;i++)scanf("%lld",&a[i]);
    vector<ll> cum(n+1,0);
    // a[l]+a[l+1]+...+a[r] = cum[r+1]-cum[l]
    for(int i = 0;i < n;i++){
        cum[i+1] = cum[i] + a[i];
    }
    map<ll,ll> m;
    const ll M = 1e9+1;
    for (int i = 0; i < n+1; ++i)
    {
        m[cum[i]+M]++;
    }
    ll ans = 0;
    for(auto i : m){
        ans += (i.second - 1)*(i.second)/2;
    }
    cout << ans << endl;
}

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

using namespace std;

long double dist(long double x1, long double y1, long double x2, long double y2) {
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

int main() {
    int x1, y1, x2, y2, x3, y3;
    scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3);
    while (x1 != 0 || y1 != 0 || x2 != 0 || y2 != 0 || x3 != 0 || y3 != 0) {
        long double a = dist(x1, y1, x2, y2);
        long double b = dist(x1, y1, x3, y3);
        long double c = dist(x2, y2, x3, y3);
        long double p = (a + b + c);
        long double s = p/2;
        long double area = sqrt(s * (s-a) * (s-b) * (s-c));
        long double r = area/s;
        long double ox = (x1*c + x2*b + x3*a)/p;
        long double oy = (y1*c + y2*b + y3*a)/p;
        // printf("a=%Lf, b=%Lf, c=%Lf\n", a, b, c);
        // printf("area=%Lf, r=%Lf\n", area, r);
        // printf("ox,oy = %Lf, %Lf\n", ox, oy);
        long double d = dist(x3, y3, ox, oy);
        long double e = dist(x2, y2, ox, oy);
        long double f = dist(x1, y1, ox, oy);
        // printf("d,e,f = %Lf, %Lf, %Lf\n", d, e, f);
        long double r3 = r*(s+d-r-e-f)/(2*(s-a));
        long double r2 = r*(s+e-r-d-f)/(2*(s-b));
        long double r1 = r*(s+f-r-d-e)/(2*(s-c));
        printf("%Lf %Lf %Lf\n", r1, r2, r3);
        scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3);
    }
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<cd> vcd;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 10, K = 26;
const double pi = acos(-1);
int n, m;

void solve(){
	int i, j, k, l, r;
	char s; cin >> s;
	if(s >= 'A' && s <= 'Z'){
		cout << "A";
	}
	else{
		cout << "a";
	}
}

signed main() {
    //freopen(".INP", "r", stdin);
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}


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

using namespace std;

// Header files, namespaces,
// macros as defined above
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


#define f first
#define s second
#define db long double
#define pb push_back
#define sz(c) (int)(c).size()
#define all(c) (c).begin(),(c).end()

typedef long long ll;
typedef pair <int , int> ii;
typedef pair <ii , ll> iii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <iii> viii;
typedef vector <vi> vvi;
typedef vector <vii> vvii;


const int mod = 998244353;
//const db eps = 1e-13;
const ll oo = 1e18;
const int MAX = 1e6+6;
// basic operations
int mul( int a , int b ) {
    return (1ll*a*b)%mod;
}
int add( int a , int b ) {
    return (a+b)%mod;
}
int sub( int a , int b ) {
    return (a-b+mod)%mod;
}
void addSelf( int& a, int b, int m ) {
    a += b;
    b %= m;
}

int exp( int a, int b ) {

    int res = 1;
    while( b ) {

        if ( b % 2 ) {
            res = mul( res, a );
        }
        a = mul(a, a);
        b >>= 1;

    }
    return res;
}

//ll gcd[500005][20], A[500005], N, Q, a, b, r;
//void process2() {
//        int i, j;
//        for (i = 0; i < N; i++)
//                gcd[i][0] = i;
//        for (j = 1; 1 << j <= N; j++)
//                for (i = 0; i + (1 << j) - 1 < N; i++)
//                        gcd[i][j] = __gcd(gcd[i][j - 1], gcd[i + (1 << (j - 1))][j - 1]);
//}
//int RMQ(int a, int b) {
//        int k = (int) log2(b - a + 1);
//        return __gcd(gcd[a][k], gcd[b - (1 << k) + 1][k]);
//}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout<<setprecision(10)<<fixed;
    int n;
    cin>>n;

    cout<<1.0 * (n/2 + (n%2)) / n<<"\n";
}

Measured memory_bytes: 256
from collections import defaultdict

def read_input():
    n = int(input())
    alist = list(map(int, input().split()))

    return n, alist


def submit():
    n, alist = read_input()

    occurs = defaultdict(int)
    for a in alist:
        occurs[a] += 1

    el = 0
    for k in occurs.keys():
        if occurs[k] < k:
            el += occurs[k]
        elif k < occurs[k]:
            el += occurs[k] - k

    print(el)

if __name__ == '__main__':
    submit()

Measured memory_bytes: 18676
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e9+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }

int main()
{
	int ans = 0;
	int a, b;
	cin >> a >> b;

	if (b == 1)
	{

	}
	else
	{
		int ana = a;
		ans = 1;
		while (1)
		{
			if (ana >= b) break;
			++ans;
			ana += (a - 1);
		}
	}

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

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

int main()
{
	vector<string> weekStr = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	
	
	// 入力
	string S;
	cin >> S;
	
	int today = 0;
	for (int i = 0; i < weekStr.size(); i++)
	{
		// 入力曜日の値を取得する
		if (S == weekStr[i])
		{
			today = i;
			break;
		}
	}
	
	// 答えの計算
	int answer = weekStr.size() - today;
	
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
def diameter(N, E):#diamete of a tree
    V = [-1]*N
    V[0] = 0
    q = deque([0])
    # s = 0
    while q:
        v = q.popleft()
        for w in E[v]:
            if V[w] == -1:
                # s = w
                V[w] = V[v] + 1
                q.append(w)
    s = V.index( max(V))
    p = deque([s])
    W = [-1]*N
    W[s] = 0
    while p:
        v = p.popleft()
        for w in E[v]:
            if W[w] == -1:
                W[w] = W[v] + 1
                p.append(w)
    return max(W)

N = int( input())
E = [ [] for _ in range(N)]
for _ in range(N-1):
    a, b = map( int, input().split())
    a, b = a-1, b-1
    E[a].append(b)
    E[b].append(a)
ans = "First"
if diameter(N, E)%3 == 1:
    ans = "Second"
print( ans)

Measured memory_bytes: 94668
void main() {
	auto ip = readAs!(int[]), P = ip[0], Q = ip[1], R = ip[2];
	ip.sort();
	writeln(ip[1] + ip[0]);
}

// =======================111=1===========

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.ascii : toLower;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}

T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef vector<int>V;
void I(V&v)
{
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
}
int main()
{
	int n,m,i,j,r;
	V v,w;
	v.reserve(1001);
	w.reserve(501501);
	while(scanf("%d%d",&n,&m),n)
	{
		v.clear();
		w.clear();
		for(i=0;i<n;++i)
		{
			scanf("%d",&r);
			v.push_back(r);
		}
		v.push_back(0);
		I(v);
		for(r=i=0;i<v.size();++i)for(j=i;j<v.size();++j)w.push_back(v[i]+v[j]);
		I(w);
		for(i=j=upper_bound(w.begin(),w.end(),m/2)-w.begin()-1;0<=i&&j<w.size();)
		{
			if(w[i]+w[j]>m)--i;
			else r=max(r,w[i]+w[j]),++j;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 2772
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

int n, m, q;
int a[100000];

int cnt[100001];
int pos[100000];
bool s[100000];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	vector<int> ord;
	cin >> n >> m >> q;
	rep(i, q) cin >> a[i], a[i]--;

	for (int i = q - 1; i >= 0; i--) {
		if (s[a[i]])continue;
		ord.push_back(a[i]);
		s[a[i]] = true;
	}
	rep(i, m) {
		if (!s[i])ord.push_back(i);
	}

	rep(i, m)pos[ord[i]] = i;
	cnt[0] = n;

	for (int i = q - 1; i >= 0;i--){
		int p = pos[a[i]];
		if (cnt[p] > 0) {
			cnt[p]--;
			cnt[p + 1]++;
		}
	}
	rep(i,m) {
		int p = pos[i];
		cnt[p + 1] += cnt[p];
		cnt[p] = 0;
	}
	cout << (cnt[m] == n ? "Yes" : "No") << endl;


	return 0;
}

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

int main()
{
    int n;
    scanf("%d",&n);
     long int t[n+1],i,sum=0;
  for(i=1;i<=n;++i)
  {
    scanf("%ld",&t[i]);
    sum+=t[i];
  }
  
  long int m;
  long int x,y;
  scanf("%ld",&m);
  while(m--)
  {
    scanf("%ld%ld",&x,&y);
    printf("%ld\n",sum-t[x]+y);
  }
  
    
  
  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int s[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int h[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int c[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int d[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int n, cnt, l;
    char m;

    cin >> n;
    
    for( cnt = 0; cnt < n; cnt++ ){
        cin >> m >> l;
        switch( m ){
            case 'S':
                s[l] = 1;
                break;
            case 'H':
                h[l] = 1;
                break;
            case 'C':
                c[l] = 1;
                break;
            case 'D':
                d[l] = 1;
                break;
        }
    }
    for( cnt = 1; cnt < 14; cnt++ ){
        if( s[cnt] != 1 ){
            cout << "S " << cnt << endl;
        }
    }
    for( cnt = 1; cnt < 14; cnt++ ){
        if( h[cnt] != 1 ){
            cout << "H " << cnt << endl;
        }
    }
    for( cnt = 1; cnt < 14; cnt++ ){
        if( c[cnt] != 1 ){
            cout << "C " << cnt << endl;
        }
    }
    for( cnt = 1; cnt < 14; cnt++ ){
        if( d[cnt] != 1 ){
            cout << "D " << cnt << endl;
        }
    }
}


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

int main(){
    ll N, M;
    cin >> N >> M;
    string S;
    cin >> S;

    ll i = N;
    vector<ll> ans;
    while(true){
        bool f = true;
        for(ll j = M; j >= 1; j--){
            if(i-j < 0) continue;
            if(S[i-j] == '0'){
                i = i-j;
                ans.push_back(j);
                f = false;
                break;
            }
        }
        if(f){
            cout << -1 << endl;
            return 0;
        }
        if(i == 0) break;
    }

    reverse(ans.begin(), ans.end());
    rep(i, 0, ans.size()) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c,d,f,g;
  cin>>a;
  if(a==3||a==5||a==7)cout<<"YES";
  else cout<<"NO";
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	map<string,int> S;
	REP(i,N){
		S[in<string>()]++;
	}
	int M=in();
	map<string,int> T;
	REP(i,M){
		T[in<string>()]++;
	}
	int maxV = 0;
	for(auto& x:S){
		maxV = max(maxV,x.second-T[x.first]);
	}
	out(maxV);

	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 200001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

int main(){
  ll n; cin >> n; ll ans = 0;
  vvl bitsum(n+1,vl(22));
 
  
  for(ll i=1; i <= n; i++){
    ll x; cin >> x;
    
    rep(j,22){
      bitsum[i][j] = bitsum[i-1][j];
      
      if(x % 2 == 1){
        if(i == 0) bitsum[i][j] = 1;
        else bitsum[i][j]++;
    }
      
      x /= 2;
    }
  
  }
  
          
 
  ll left = 0; ll right = 1; bool flag = true;
  
  while(!(right == n+1)){
    flag = true;
    
    rep(i,22){
      if(bitsum[right][i] - bitsum[left][i] > 1) flag = false;
    }
    
    if(flag){
      ans += right-left;
      right++;
      
    }
    else{
      left++;
    }
    if(left == right - 1){
      right++; ans++;
    }
  }
  
  cout << ans << endl;
  
}
  
  

Measured memory_bytes: 51860
#include <iostream>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)

vector<int> sieve_of_eratosthenes() {
	int n = 1000000;
	vector<int> primes(n);
	for (int i = 2; i < n; i++)primes[i] = i;
	for (int i = 2; i*i < n; i++) {
		if (primes[i]) {
			for (int j = i * i; j < n; j += i) primes[j] = 0;
		}
	}
	return primes;
}

int main() {
	auto p = sieve_of_eratosthenes();

	vector<int> q(1000000);
	//擬素数の条件を加えて、該当する数をｑ配列で管理
	rep(i, 3, p.size()) {
		if (p[i] && p[(p[i] + 1) / 2]) {
			q[i] = 1;
		}
	}
	//擬素数の累積和を求める
	rep(i, 1, q.size())	q[i] += q[i - 1];

	//クエリ実行
	ll Q; cin >> Q;
	rep(i, 0, Q) {
		ll l, r; cin >> l >> r;
		//範囲内の擬素数の数を求める
		cout << q[r] - q[l - 1] << endl;
	}

	return 0;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, 0, N) cin >> A[i];
    sort(A.begin(), A.end());
    rep(i, 0, N-1){
        if(A[i] == A[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1792
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int n;
  cin >> n;
  ll count = 0;
  vector<ll>a(n);
  rep(i,n) cin >> a.at(i);
  rep(i,n) if(a.at(i)%2!=0) count++;
  if(count%2==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

vector<vector<double>> X(10,vector<double>(10,0));

int main(){
    int N,D;
    cin >> N >> D;
    int ans = 0;
    while (N > 0) {
        N -= 2*D + 1;
        ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#include <unordered_map>
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m;
ll A[222222];
unordered_map<ll, int> M;
int main() {
	scanf("%d", &n);
	multiset<ll> S;
	REP(i, n) {
		scanf("%lld", A+i);
		M[A[i]]++;
	}
	sort(A, A+n);
	int ans = 0;
	for(int j = n-1; j >= 0; j--) {
		if(M[A[j]] == 0)
			continue;
		for(ll tgt = 1LL<<31; tgt > 0; tgt >>= 1) {
          if(tgt < A[j])
            break;
			ll need = tgt-A[j];
			int cnt = M[need];
			if(A[j] == need) {
				if(cnt >= 2) {
					M[need]--;
					M[need]--;
					ans++;
					break;
				}
			} else if(cnt >= 1) {
				M[need]--;
				M[A[j]]--;
				ans++;
				break;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 35472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
const ll mod = 1e9 + 7;

int main()
{
    int d;
    cin >> d;
    if (d == 25)
        cout << "Christmas" << endl;
    if (d == 24)
        cout << "Christmas Eve" << endl;
    if (d == 23)
        cout << "Christmas Eve Eve" << endl;
    if (d == 22)
        cout << "Christmas Eve Eve Eve" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;//ABC138-B,再度復習
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    double x = 0;
    double y = 0;

    for(int i=0 ; i<n ; i++){
      a[i] = sc.nextInt();
    }
    for(int i=0 ; i<n ; i++){
      x += 1/(double)a[i];
    }
    y = 1/(double)x;
    System.out.println(y);
  }
}


Measured memory_bytes: 21716
// ------------------------------------
// Date:2018/ 2/28
// Problem:ABC 063 Bugged c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;

static const int MOD = 1000000007;

int main()
{
  int N, s, diff, sum, ans;
  cin >> N;
  sum = 0;
  diff = 1e9;
  REP(i, N) {
    cin >> s;
    sum += s;
    // debug(s);
    // 必要のない数字1つをdiffにストック
    if (s % 10 != 0 && s < diff) diff = s;
  }
  ans = sum - (sum % 10 == 0 ? diff : 0);
  cout << (ans < 0 ? 0 : ans) << endl;
  return 0;
}



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

#define PI 3.14159265358979323846264338327950L

int main()
{
  int A,B,H,M;
  long double c,d,x,y;
  scanf("%d",&A);
  scanf("%d",&B);
  scanf("%d",&H);
  scanf("%d",&M);
  c=(60*H+M)*PI/360;
  d=(60*H+M)*PI/30;
  y=(long double)(A*A+B*B)-(long double)(2*A*B*cos(c-d));
  x=sqrtl(y);
  printf("%20.20Lf\n",x);
  return 0;
}


Measured memory_bytes: 2516
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

const double eps = 1e-10;
const double inf = 1e+10;
const double pi = acos(-1.0);
int sgn(double a) { return a < -eps ? -1 : a > eps; }
using P = complex<double>;
namespace std {
  istream& operator>>(istream& i, P& p) { double x, y; i >> x >> y; p = P(x, y); return i; }
  ostream& operator<<(ostream& o, const P& p) { o << real(p) << ' ' << imag(p); return o; }
  bool operator<(const P& p, const P& q) { return sgn(real(p) - real(q)) ? sgn(real(p) - real(q)) < 0 : sgn(imag(p) - imag(q)) < 0; }
  bool operator>(const P& p, const P& q) { return q < p; }
  bool operator<=(const P& p, const P& q) { return !(p > q); }
  bool operator>=(const P& p, const P& q) { return !(p < q); }
}
bool eq(const P& p, const P& q) { return !(p < q) and !(p > q); }
double dot(const P& p, const P& q) { return real(conj(p) * q); }
double cross(const P& p, const P& q) { return imag(conj(p) * q); }

int intCC(const P& o1, double r1, const P& o2, double r2) {
  double d = abs(o1 - o2);
  if (sgn(d - (r1 + r2)) > 0) return 4;
  if (sgn(d - (r1 + r2)) == 0) return 3;
  if (sgn(d - abs(r1 - r2)) > 0) return 2;
  if (sgn(d - abs(r1 - r2)) == 0) return 1;
  return 0;
}

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  P o1, o2; double r1, r2; cin >> o1 >> r1 >> o2 >> r2;
  cout << intCC(o1, r1, o2, r2) << '\n';
}


Measured memory_bytes: 3352
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n, k;
vector<string> ans_str = {"POSSIBLE", "IMPOSSIBLE"};
int a[100005];
/**********************************************/

LL euclidean(LL a, LL b){
    if(a < b) swap(a, b);
    LL r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

LL gcd(LL a, LL b){
    return euclidean(a, b);
}

LL lcm(LL a, LL b){
    return a * b / gcd(a, b);
}

int main(){
    cin >> n >> k;
    REP(i, n) cin >> a[i];
    
    int max_num = 0;
    REP(i, n){
        if(a[i] > max_num) max_num = a[i];
    }
    
    if(max_num < k){
        cout << ans_str[1] << endl;
        return 0;
    }

    int num = a[0];
    FOR(i, 1, n){
        num = gcd(a[i], num);
    }
    if(k % num == 0){
        cout << ans_str[0] << endl;
    }else{
        cout << ans_str[1] << endl;
    }
    
}


Measured memory_bytes: 640
def main():
    S = input()
    T = input()
    min = len(T)
    for i in range(len(S) - len(T) + 1):
        temp = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                temp += 1
        if temp < min:
            min = temp
    print(min)
main()

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

const int limit = 50;

int n,m;
int a[limit],b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
    visited[v]=true;
    for (int v2=0;v2<n;v2++){
        if (graph[v][v2]==true & visited[v2]==false){
            dfs(v2);
        }
    }
}

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

    for (int i=0;i<m;++i){
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for (int i = 0; i < m; ++i) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
        for (int j = 0; j < n; ++j) visited[j] = false;
        dfs(0);
        
        bool bridge = false;
        for (int j = 0; j<n;++j) if (visited[j]==false)bridge = true;
        if(bridge)ans+=1;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }
    cout << ans << endl;

    return 0;

        }


    //sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});


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

using namespace std;

#define int long long
#define dotimes(i, n) for (int i = 0, i##max__ = (n); i < i##max__; i++)
#define whole(f, x, ...) ([&](decltype((x)) c) { return (f)(begin(c), end(c), ## __VA_ARGS__); })(x)

int rint() {
  int x;
  scanf("%lld", &x);
  return x;
}

void wint(int x) {
  printf("%lld\n", x);
}

template<typename T> int size(T const& c) { return static_cast<int>(c.size()); }
template <typename T> bool maxs(T& a, T const& b) { return a < b ? a = b, true : false; }
template <typename T> bool mins(T& a, T const& b) { return a > b ? a = b, true : false; }
inline int lg(int x) { return 63 - __builtin_clzll(static_cast<unsigned int>(x)); }

class segment_tree {
  vector<int> xs;
public:
  segment_tree(int n) : xs(1 << (lg(2 * n - 1) + 1), (((1LL << 31) - 1) << 1) | 1) {}
  void update(int i, int j, int x) {
    x <<= 1;
    function<void(int, int, int)> rec;
    rec =
      [&](int k, int a, int b) {
        if (i <= a && b <= j)
          xs[k] = x | 1;
        else {
          if (xs[k] & 1)
            xs[2*k] = xs[2*k+1] = xs[k];
          int c = a + (b - a) / 2;
          if (j <= c)
            rec(2*k, a, c);
          else if (c <= i)
            rec(2*k+1, c, b);
          else {
            rec(2*k, a, c);
            rec(2*k+1, c, b);
          }
          xs[k] = (~1LL) & min(xs[2*k], xs[2*k+1]);
        }
      };
    rec(1, 0, ::size(xs)/2);
  }
  int query(const int i, const int j) {
    function<int(int, int, int)> rec;
    rec =
      [&](int k, int a, int b) {
        if ((i <= a && b <= j) || (xs[k] & 1))
          return xs[k];
        int c = a + (b - a) / 2;
        return j <= c ? rec(2*k, a, c) : c <= i ? rec(2*k+1, c, b) : min(rec(2*k, a, c), rec(2*k+1, c, b));
      };
    return rec(1, 0, ::size(xs)/2) >> 1;
  }
};

signed main() {
  const int n = rint();
  const int q = rint();
  segment_tree st(n);
  dotimes(i, q)
    if (rint()) {
      int s = rint();
      int t = rint();
      wint(st.query(s, t+1));
    } else {
      int s = rint();
      int t = rint();
      int x = rint();
      st.update(s, t+1, x);
    }
  return 0;
}



Measured memory_bytes: 4512
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define N 200005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    ll f[n+1]={0};
    for(int i=0;i<n;i++){
        cin>>a[i];
        f[a[i]]++;
    }
    ll sum = 0;
    for(int i=1;i<=n;i++){
        sum += f[i]*(f[i]-1)/2;
    }
    for(int i=0;i<n;i++){
        cout<<sum-(f[a[i]]-1)<<'\n';
    }
	return 0;
}


Measured memory_bytes: 4992
using System;

class Program {
    static void Main(string[] args) {
        //入力
        string s = Console.ReadLine();

        int A = int.Parse(s.Split(' ')[0]);
        int B = int.Parse(s.Split(' ')[1]);


        //検証
        if (B % A == 0) {
            Console.WriteLine(A + B);
        } else {
            Console.WriteLine(B - A);
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e6+5;
int a[N];
int main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=2*n;i++)scanf("%d",&a[i]);
    sort(a+1,a+2*n+1);
    ll ans=0;
    for(int i=1;i<=2*n;i+=2)ans+=a[i];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define db double
#define ld long double
#define IOS  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#pragma GCC optimize(2)
#define ull unsigned long long
#define maxn 110
void dfs(){}
int dp[maxn][maxn];
signed main()
{
    IOS
    int num;
    cin>>num;
    memset(dp,0, sizeof(dp));
    for (int k = 0; k <=9 ; ++k) {
        dp[1][k]=1;
    }
    for (int i = 2; i <=10 ; ++i) {
        for (int j = 0; j <=9 ; ++j) {
            dp[i][j]=dp[i-1][j]+dp[i-1][j-1]+dp[i-1][j+1];
        }
    }
    queue<int> ans;
    int l=0, r = 0,fl=0;
    for (int j = 1; j <=10 ; ++j) {
        for (int i = 1; i <=9 ; ++i) {
            if(num<=dp[j][i]){
                l=j;
                r=i;
                fl=1;
                break;
            }
            num-=dp[j][i];
        }
        if(fl==1)break;
    }
    l--;
    ans.push(r);
    while(l!=0){
        if(num<=dp[l][r-1]){
            r--;
            ans.push(r);
        }else{
            num-=dp[l][r-1];
            if(num<=dp[l][r]){
                ans.push(r);
            }else{
                num-=dp[l][r];
                r++;
                ans.push(r);
            }
        }
        l--;
    }
    while(!ans.empty()){
        int now=ans.front();
        cout<<now;
        ans.pop();
    }
    return 0 ;
}

Measured memory_bytes: 256
fun main(args:Array<String>) {
     val n = readLine()!!.toInt()
    val list = (1..n).map { readLine()!! }
    val map = list.groupBy { it }.map { it.key to it.value.size }
    val max = map.maxBy { it.second }!!.second
    val answer = map.filter { it.second == max }.map { it.first }.sorted()
        .joinToString(System.lineSeparator())
    println(answer)
}


Measured memory_bytes: 111892
a,b,c,d=map(int,input().split())
from fractions import gcd # ~3.4
import math # 3.5~
# lcm(a, b) = a * b / gcd(a, b)
cd=int(c*d/gcd(c,d))
e=(b-a+1)
f=(b//c-a//c)
if c*(a//c)==a:
  f+=1
g=(b//d-a//d)
if d*(a//d)==a:
  g+=1
h=(b//cd-a//cd)
if cd*(a//cd)==a:
  h+=1
#print(e,f,g,h)
print(e-f-g+h)

Measured memory_bytes: 5048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	private StringTokenizer st;
	private BufferedReader bf;
	private int w;
	
	Main() {
		readData();
		

	}	

	private void readData() {
		try {
			bf = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(bf.readLine());
			
			
			String s = next();
			for (int i=s.length()-1;i>=0;i--) {
				System.out.print(s.charAt(i));
			}
			System.out.println("");
			
		} catch (Exception e) {
			System.out.println("dacat");
			e.printStackTrace();
		}
	}
	
	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	
	private String next() throws IOException {
		try {
		if (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(bf.readLine());
		} catch (Exception e) {
			System.out.println("dacat");
		}
		return st.nextToken();
	}
	
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main m = new Main();
	}

}

Measured memory_bytes: 17064
"""
YESの条件

NOの条件
    数字が3個以上含まれる数列
    1,2,3,4のいずれがか含まれない数列

"""

n = 3
p = [list(map(int, input().split(" "))) for _ in range(n)]
p = p[0]+p[1]+p[2]


result = "YES"
for i in range(1,5):
    if 0 < p.count(i) < 3:
        pass
    else:
        result = "NO"
        break

print(result)


Measured memory_bytes: 3060