akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int AA[SIZE];
int main(){
    int N; R(N);
    REP(i,N)R(AA[i]);
    if(count(AA,AA+N,0)==N){
        W("Yes");
        return 0;
    }
    if(N%3)W("No");
    else{
        map<int,int>d;
        REP(i,N){
            d[AA[i]]++;
        }
        if(SZ(d)==2){
            if(d.begin()->F==0&&d.begin()->S*2==d.rbegin()->S)W("Yes");
            else W("No");
        }
        else if(SZ(d)==3){
            VPII gg(ALL(d));
            if((gg[0].F^gg[1].F^gg[2].F)==0&&gg[0].S==gg[1].S&&gg[0].S==gg[2].S){
                W("Yes");
            }
            else{
                W("No");
            }
        }
        else{
            W("No");
        }
    }
    return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
#include<math.h>
long long gcm(long long a, long long b)
{
    long long r = a%b;
    while (r > 0)
    {
        a = b;
        b = r;
        r = a%b;
    }
    return b;
}
int main()
{
    int t;
    scanf("%d", &t);
    int i;
    long long a, b, c, d;
    for (i = 0; i < t; i++)
    {
        scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
        if (a < b)
            printf("No\n");
        else if (b > d)
            printf("No\n");
        else
        {
            if (a >= b && a >= c)
            {
                a = (a-c)%b;
                if (a == b)
                    a -= b;
                a += c;
            }
            if (a - b < 0 && a>c)
                printf("No\n");
            else if (c < b - gcm(b, d))
                printf("No\n");
            else
                printf("Yes\n");
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <typeinfo>
#include <list>
#include <queue>
#include <stack>
#include <limits.h>
#include <unordered_set>
#include <map>
#include <cstring>

using namespace std;

long long Solve(vector<pair<long long, long long> > A, long long M, int N) {
    sort(A.begin(), A.end());
    long long res = 0;
    for (int i = 0; i < N && M > 0; i++) {
        res += min(A[i].second, M) * A[i].first;
        M -= A[i].second;
    }
    return res;
}


int main() {
    ios::sync_with_stdio(false);
    int N;
    long long M;
    cin >> N >> M;
    vector<pair<long long, long long> > A(N);
    for (int i = 0; i < N; i++) {
        long long f, s;
        cin >> f >> s;
        A[i] = {f, s};
    }
    cout << Solve(A, M, N);
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ans;
    if (n & 1) {
        for(int l = 1, r = n-1; l < r; l++, r--) {
            ans.emplace_back(l, r);
        }
    } else {
        bool flag = false;
        for(int l = 1, r = n-1; l < r; l++, r--) {
            if(!flag && r-l <= n/2) {
                flag = true;
                r--;
            }
            ans.emplace_back(l, r);
        }
    }
    rep(i, m) {
        printf("%d %d\n", ans[i].first, ans[i].second);
    }
}

Measured memory_bytes: 4324
from sys import stdin


def input():
    return stdin.readline()[:-1]


def intput():
    return int(input())


def sinput():
    return input().split()


def intsput():
    return map(int, sinput())


# Code

n = intput()
s = input()

cnt = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            targets = list(map(str, [a, b, c]))
            i = 0
            target = targets[i]
            for digit in s:
                if digit == target:
                    i += 1
                    if i == 3:
                        break
                    target = targets[i]
            if i == 3:
                cnt += 1

print(cnt)


Measured memory_bytes: 42844
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    if (S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22868
#include <iostream>
#include <vector>
using namespace std;
 
long long GCD(long long a, long long b) {
    if(b == 0) return a;
    else return GCD(b, a % b);
}
 
int main() {
    long long a, b;
    cin >> a >> b;
    long long G = GCD(a, b);
    long long res = 1;
    for (long long p = 2; p * p <= G; ++p) {
        if (G % p != 0) continue;
        while (G % p == 0) {
            G /= p;
        }
        ++res;
    }
    if(G != 1) ++res;
    
    cout << res << endl;
}


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

int main() {
	int l, r; cin >> l >> r;

	if (r - l >= 2019) { cout << 0; return 0; }

	int ans = 2019;
	int rr = r % 2019, ll = l % 2019;
	if (rr > ll) {
		for (int i = ll; i <= rr; i++) {
			for (int j = i + 1; j <= rr; j++) {
				ans = min(ans, i * j % 2019);
			}
		}
	}
	else {
		for (int i = ll; i <= rr + 2019; i++) {
			for (int j = i + 1; j <= rr + 2019; j++) {
				ans = min(ans, i * j % 2019);
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start; i < end; i++)
#define newline std::cout<<'\n';
#define newlinedx(num) for(int i=0;i<num;i++)std::cout<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ui = uint64_t;

//----------------library in this time--------------------------------
template <class T>
T gcd(const T a,const T b) {
    return (b == 0) ? a : gcd (b, a % b);
}
template <class T>
T lcm(const T a, const T b) {
    return a * b / gcd(a,b);
}
template <class T>
inline T ave(const T a, const T b) {
    return (a + b) / 2.0f;
}

long long squareTwo(const long long a,const long long b) {
    return (b == 1) ? a : squareTwo(a * 2, b - 1);
}

template <class T>
inline T Max(const T a,const T b) {
    return (a >= b) ? a : b;
}

template <class T>
inline T Min(const T a,const T b) {
    return (a <= b) ? a : b;
}


//------------------------main function-------------------------------
void Main(){
    int n, x, sum = 0, ans = 1; cin >> n  >> x;
    rep(i, n){
        int a; cin >> a;
        sum += a;
        if(sum <= x) ans++;
    }
    cout << ans << endl;
}

//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
     
    Main();
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
fn main() {
    input!(N: usize, M: usize);
    input!(A: [usize; M]);
    let tot: usize = A.iter().sum();
    if tot <= N {
        println!("{}", N - tot);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2248
<?php
  list($W, $H, $x, $y, $r) = explode(" ", trim(fgets(STDIN)));
  if (($x > $W-$r) || ($x < $r) || ($y > $H-$r) || ($y < $r)) {
    print "No";
  } else {
    print "Yes";
  }
?>

Measured memory_bytes: 6564
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a /g* b ;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
int  GetDigit(T num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};

int main()
{
    int N;
    cin >> N;
    int W;
    cin >> W;
    int w[N];
    ll v[N];
    REP(i,0,N){
        cin >> w[i] >> v[i];
    }
    ll dp[N + 1][W + 1];
    memset(dp, 0, sizeof(dp));

    REP(i,0,N){
        REP(j,0,W+1){
            if(j>=w[i]){
                dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]]+v[i]);
            }else{
                dp[i + 1][j] = dp[i][j];
            }
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}

Measured memory_bytes: 79104
import java.util.*;
import java.io.*;

public class Main {


    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        if (n%1000==0) {
            System.out.println(0);
        } else {
            System.out.println(1000-n%1000);
        }
    }

    private static boolean ok(int k) {
        while (k>0) {
            int c = k%10;
            if (c!=4&&c!=7) return false;
            k/=10;
        }
        return true;
    }

    // 1 2 3 4 5 6
    // x * 2 == 10



    private static boolean preSum(int[] nums, int target) {
        int cur = 0;
        Set<Integer> set = new HashSet<>();
        set.add(0);
        for (int i = 0; i < nums.length; i++) {
            cur += nums[i];
            if (set.contains(cur-target)) {
                System.out.println(cur-target);
                return true;
            }
            set.add(cur);
        }
        return false;
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            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: 32928
#include <stdio.h>
#include <math.h>

int prime[1230],s;

int isPrime(int x){
  int i;
  for(i=0;i<s && prime[i]<=sqrt(x);i++){
    if(x % prime[i] == 0) return 0;
  }
  return 1;
}

void mkprime(void){
  int i;

  prime[0] = 2;
  s = 1;
  for(i=3;i<10008;i++){
    if(isPrime(i)) prime[s++] = i;
  }
}

int main(void){
  int i,x;

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

    for(i=0;prime[i]<=x;i++);
    for(i--;prime[i]!=prime[i-1]+2;i--);
    printf("%d %d\n",prime[i-1],prime[i]);
  }

  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	string str;
	cin >> str;
	bool flag = true;
	for(int i = 0;i < str.size();i++){
		if(i + 1 < str.size() && str[i] == str[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			flag = false;
			break;
		}else if(i + 2 < str.size() && str[i] == str[i + 2]){
			cout << i + 1 << " " << i + 3 << endl;
			flag = false;
			break;
		}
	}
	if(flag) cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	long long A, B;
	cin >> A >> B;

	auto temp = A + B;
	if (temp % 2 == 0)
	{
		cout << temp / 2 << endl;
	}
	else
	{
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import Data.Bits
import Data.List
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import qualified Data.ByteString.Char8 as B
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.Function
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.Vector as VB
import qualified Data.Vector.Mutable as VBM
-- import Data.Vector.Unboxed ((!))
import Data.Tuple
import Data.Ord (Down(..))
import Data.Coerce
import GHC.Exts (build)



code :: Int -> Int -> Int
code p k = 10^12 + 10^6 * p + k

{-
query' :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int
query' n m vec = VB.create $ do
  dictmut <- VBM.replicate n $ IntMap.empty
  V.imapM_ (\i (p,y) -> do entry <- VBM.read dictmut (p-1)
                           VBM.write dictmut (p-1)
                             $! IntMap.insert y i entry) vec
-}  

query :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int
query n m vec
  = V.replicate m 0 V.// codes
  where
    vec' :: VB.Vector (Int, (Int, Int))
    vec' = VB.convert $ V.imap (\i (p,y) -> (p-1,(y,i))) vec
    dict :: VB.Vector (IntMap Int)
    dict = VB.accumulate (\entry (y,i) -> IntMap.insert y i entry)
            (VB.replicate n IntMap.empty) vec'
    codes :: [(Int,Int)]
    codes = concat $ VB.toList $
      VB.imap (\pm1 -> zipWith (\k i -> (i,code (pm1+1) k)) [1..]
                                 . IntMap.elems) dict 

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  rest <- B.getContents
  let vec = V.unfoldrN m (\b -> let (l,r) = B.span (/= '\n') b in
                             Just (decode l, B.tail r)) rest
      decode l = (p,y)
        where Just (p, l1) = B.readInt l
              Just (y, _ ) = B.readInt $ B.dropWhile (== ' ') l1
  V.mapM_ (putStrLn . tail . show) $ query n m vec


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

typedef struct UnionFind{
    vector<lli> par; //par[i]:iの親番号 par[3] = 2 : 3の親が2
    vector<lli> size;//size[i]:iの大きさ 自分のみのときは1,根っこにsizeを持たせる*/

    UnionFind(int N){/*最初はすべてが根であると初期化*/
        REP(i,0,N){
            par.push_back(i);
            size.push_back(1);
        }
    }

    lli root(lli x){/*データxが属する木の根を再起で得る root(x) = {xの木の根}}*/
        if(par[x] == x)return x;
        return par[x] = root(par[x]);
    }

    void unite(lli x,lli y){/*xとyの併合*/
        lli rx = root(x);
        lli ry = root(y);
        if(rx == ry)return;
        par[rx] = ry; /*xとyの根が同じじゃない: xの根をrxをyの根ryに変更する */
        lli resize = size[rx] + size[ry];
        size[rx] = resize;
        size[ry] = resize;
    }

    bool same(lli x,lli y){
        lli rx = root(x);
        lli ry = root(y);
        return rx == ry;
    }

    lli getSize(lli x){
        lli rx = root(x);
        return size[rx];
    }
};

void func(long long N, long long M, std::vector<long long> X, std::vector<long long> Y, std::vector<long long> Z){

    UnionFind uf(N);
    REP(i,0,M){
        uf.unite(X[i],Y[i]);
    }

    set<lli> s;
    REP(i,0,N)s.insert(uf.root(i));

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

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> X(M);
    std::vector<long long> Y(M);
    std::vector<long long> Z(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&X[i]);
        scanf("%lld",&Y[i]);
        scanf("%lld",&Z[i]);
        X[i]--,Y[i]--;
    }
    func(N, M, std::move(X), std::move(Y), std::move(Z));
    return 0;
}


Measured memory_bytes: 8812
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int cnt=0,cnt2=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0')cnt++;
    if(s[i]=='1')cnt2++;
  }
  cout << 2*min(cnt,cnt2) << endl;
}

Measured memory_bytes: 3760
def solve():
    N, M = map(int, input().split())
    A = []
    B = []
 
    for i in range(N):
        A.append(input())
    for i in range(M):
        B.append(input())
 
    for i in range(N - M + 1):
        for j in range(N - M + 1):
            for k in range(M):
                s1 = A[i + k][j:j + M]
                s2 = B[k]
                if s1 != s2:
                    break
            else:
                print('Yes')
                return None
 
    print('No')
 
if __name__ == '__main__':
    solve()

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	vector<ll> cnt(n);
	REP(i, n){ cnt[i] = 0; }
	ll tmp;
	REP(i, 2*m){
		cin >> tmp;
		cnt[tmp-1]++;
	}
	REP(i, n){
		cout << cnt[i] << endl;
	}
}


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

using namespace std;

inline int read();

#define LL long long

LL n, ans;
string s;
map<string, int> ma;

int main() {
	n = read();
	for(int i = 1; i <= n; ++i) {
		cin >> s;
		sort(s.begin(), s.end());
		ans += ma[s];
		ma[s]++;
	}
	printf("%lld\n", ans);
	return 0;
}

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



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

int main(){
	int N;
	double T, A;
	cin >> N >> T >> A;
	double tem[N];
	for(int i = 0; i < N; i++){
		cin >> tem[i];
		tem[i] = T - tem[i]*0.006;
		tem[i] = abs(A-tem[i]);
	}
	double min = tem[0];
	int ans = 1;
	for(int i = 0; i < N; i++){
		if(min > tem[i]){
			min = tem[i];
			ans = i+1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
using namespace std;


int main(){
    int n;
    int p[9] = {111,222,333,444,555,666,777,888,999};
    cin >> n;
    for(int i=0;i<9;i++){
        if(n <= p[i]){
            cout << p[i] << endl;
            return 0;
        }
    }
	return 0;
}


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

int keta(long long n) {
  int cnt = 0;
  while (n > 0) {
    n /= 10;
    cnt++;
  }
  return cnt;
}

int f(long long a, long long b) { return max(keta(a), keta(b)); }

int main() {
  long long n, a, b;
  int fmax, kmin = INT_MAX;
  cin >> n;
  a = 1;
  while (a <= sqrt(n)) {
    if (n % a == 0) {
      b = n / a;
      fmax = f(a, b);
      kmin = min(kmin, fmax);
    }
    a++;
  }
  cout << kmin << endl;
}

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

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 N, K;
  cin >> N >> K;
  vector<i64> A(N);
  for (auto& x : A) cin >> x;

  const i64 M = 1LL << 42;

  vector<i64> lower_sum(45), eq_sum(45);
  int k = 1;
  for (i64 d = M; d > 0; d >>= 1, ++k) {
    i64 cnt = 0;
    REP(i, N) {
      if (A[i] & d) cnt++;
    }
    i64 lsm = lower_sum[k - 1] + max(cnt, N - cnt) * d;
    lower_sum[k] = (lower_sum[k - 1] == 0) ? 0 : lsm;
    if (K & d) {
      eq_sum[k] = eq_sum[k - 1] + (N - cnt) * d;
      lower_sum[k] = max(lower_sum[k], eq_sum[k - 1] + cnt * d);
    } else {
      eq_sum[k] = eq_sum[k - 1] + cnt * d;
    }
  }
  i64 ans = max(lower_sum[k - 1], eq_sum[k - 1]);
  cout << ans << endl;
}

Measured memory_bytes: 3980
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;

int main()
{
	int n;
	cin >> n;
	int mmax = 0;
	vector<string> as(n);
	map<string, int> mp;
	vector<string> ans(n);
	rep(i, n) {
		cin >> as[i];
		mp[as[i]]++;
		mmax = max(mmax, mp[as[i]]);
		
	}
	int aa = 0;
	rep(i, n) {
		if (mmax == mp[as[i]]) {
			ans[aa] = as[i];
			aa++;
			mp[as[i]] = 0;
		}
	}
	sort(ans.begin(), ans.begin()+aa);
	rep(i, aa) {
		cout << ans[i] << endl;
	}
}


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

using ll = long long;

// Z algorithm O(|S|)
vector<int> Z_algorithm(vector<int> &s) {
  vector<int> Z(s.size());
  Z[0] = s.size();
  
  int i = 1, j = 0;
  while (i < s.size()) {
    while (i + j < s.size() && s[j] == s[i + j]) j++;
    Z[i] = j;
    if (j == 0) {
      i++;
      continue;
    }
    int k = 1;
    while (k < j && k + Z[k] < j) {
      Z[i + k] = Z[k];
      k++;
    }
    i += k;
    j -= k;
  }
  return Z;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  for (int i = 0; i < n; i++) cin >> b.at(i);
  
  vector<int> keep(n);
  for (int i = 0; i < 30; i++) {
    vector<int> x, y;
    for (int j = 0; j < n; j++) {
      if (b.at(j) & (1 << i)) {
        x.emplace_back(1);
        y.emplace_back(1);
      }
      else {
        x.emplace_back(0);
        y.emplace_back(0);
      }
    }
    for (int j = 0; j < n; j++) {
      if (a.at(j) & (1 << i)) {
        x.emplace_back(1);
        y.emplace_back(0);
      }
      else {
        x.emplace_back(0);
        y.emplace_back(1);
      }
    }
    for (int j = 0; j < n; j++) {
      if (a.at(j) & (1 << i)) {
        x.emplace_back(1);
        y.emplace_back(0);
      }
      else {
        x.emplace_back(0);
        y.emplace_back(1);
      }
    }
    vector<int> xret = Z_algorithm(x), yret = Z_algorithm(y);
    for (int j = n; j < 2 * n; j++) {
      if (xret.at(j) >= n || yret.at(j) >= n) keep.at(j - n)++;
    }
  }
  
  for (int i = 0; i < n; i++) {
    if (keep.at(i) == 30) {
      cout << i << " " << (a.at(i) ^ b.at(0)) << '\n';
    }
  }
}

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

struct Graph
{
    int N;
    struct Edge { int source, target, weight; };
    vector<vector<Edge>> adjacency_list;

    Graph(int N) : N(N), adjacency_list(N) {}

    void add_edge(int a, int b, int w) { adjacency_list[a].push_back({a, b, w}); }

    int distance(int start, int finish)
    {
        auto seen = vector<bool>(N);
        auto distances = vector<int>(N, -1);

        struct State { int v, distance; };
        auto deque = std::deque<State>({{start, 0}});

        while (!deque.empty())
        {
            auto s = deque.front(); deque.pop_front();
            if (seen[s.v]) continue;
            seen[s.v] = true;
            distances[s.v] = s.distance;

            for (const auto e : adjacency_list[s.v])
            {
                const auto next = State{e.target, s.distance + e.weight};
                if (e.weight == 0) deque.push_front(next);
                else deque.push_back(next);
            }
        }

        return distances[finish];
    }
};

struct Subway { int source, target, company; };

int solve(const int N, const vector<Subway>& subways)
{
    auto companies_at = vector<unordered_set<int>>(N);
    for (const auto s : subways)
    {
        companies_at[s.source].insert(s.company);
        companies_at[s.target].insert(s.company);
    }

    auto V = 0;

    auto in_vertices = vector<int>(N), out_vertices = vector<int>(N);
    for (auto i = 0; i < N; i++)
    {
        in_vertices[i] = V++;
        out_vertices[i] = V++;
    }

    auto company_in_vertices = vector<unordered_map<int, int>>(N);
    auto company_out_vertices = vector<unordered_map<int, int>>(N);
    for (auto i = 0; i < N; i++)
    {
        for (const auto c : companies_at[i])
        {
            company_in_vertices[i][c] = V++;
            company_out_vertices[i][c] = V++;
        }
    }

    auto graph = Graph(V);
    for (auto i = 0; i < N; i++)
        graph.add_edge(in_vertices[i], out_vertices[i], 1);

    for (auto i = 0; i < N; i++)
    {
        for (const auto c : companies_at[i])
        {
            graph.add_edge(company_in_vertices[i][c], in_vertices[i], 0);
            graph.add_edge(out_vertices[i], company_out_vertices[i][c], 0);
            graph.add_edge(company_in_vertices[i][c], company_out_vertices[i][c], 0);
        }
    }

    for (const auto s : subways)
    {
        graph.add_edge(company_out_vertices[s.source][s.company], company_in_vertices[s.target][s.company], 0);
        graph.add_edge(company_out_vertices[s.target][s.company], company_in_vertices[s.source][s.company], 0);
    }

    return graph.distance(in_vertices[0], in_vertices[N-1]);
}

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

    auto subways = vector<Subway>();
    for (auto i = 0; i < M; i++)
    {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        subways.push_back({a, b, c});
    }

    cout << solve(N, subways) << endl;
}


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

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

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007

#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p )
{
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v )
{
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename T >
ostream &operator << ( ostream & os, const multiset< T > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v )
{
    os << "[";
    for(auto it = v.begin(); it != v.end(); ++it)
    {
        if( it != v.begin() )
            os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

void faltu ()
{
    cerr << endl;
}

template <typename T>
void faltu( T a[], int n )
{
    for(int i = 0; i < n; ++i)
        cerr << a[i] << ' ';
    cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}


int gcd(int a,int b)
{
    return b ? gcd(b,a%b) : a;
}
int lcm(int a,int b)
{
    return (a*( b/ gcd(a,b)));
}

void f()
{
    int s,i=1;
    cin>>s;
    map<int,int>m;

    while(true)
    {
        m[s]++;
        if(m[s]==2)
        {
            cout<<i<<nl;
            return;
        }
        if(s%2==0)
        {
            s=s/2;
        }
        else
        {
            s=3*s+1;
        }
        i++;
    }
}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3628
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

res = 0
for i in range(n):
    index1 = bisect.bisect_left(a, b[i])
    index2 = bisect.bisect_right(c, b[i])
    res += index1 * (n - index2)

print(res)


Measured memory_bytes: 23092
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#define itn int
#define reaD read
#define N 200001
using namespace std;

int n, Q, f[N], cnt, fa[N]; 
struct edge { int from, to, cost; bool operator < (const edge &p) const { return cost < p.cost; } } e[N << 2]; 

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

inline void adde(int u, int v, int w) { e[++cnt] = (edge) { u, v, w }; }

int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }

long long Kruscal()
{
	sort(e + 1, e + cnt + 1); 
	long long ans = 0; 
	for(int i = 1; i <= cnt; i++)
	{
		int u = find(e[i].from), v = find(e[i].to), w = e[i].cost; 
		if(u == v) continue; 
		fa[u] = v; ans += w; 
	}
	return ans; 
}

int main()
{
	n = read(); Q = read();
	for(int i = 1; i <= n; i++) fa[i] = i; 
	memset(f, 0x3f, sizeof(f)); 
	while(Q--)
	{
		int u = read() + 1, v = read() + 1, w = reaD();
		adde(u, v, w); 
		f[u] = min(f[u], w + 1); f[v] = min(f[v], w + 2); 
	}
	int pos = 1; 
	for(int i = 2; i <= n; i++) if(f[i] < f[pos]) pos = i; 
	for(int i = pos; i <= pos + n - 1; i++) f[i % n + 1] = min(f[i % n + 1], f[(i - 1) % n + 1] + 2); 
	for(int i = 1; i <= n; i++) adde(i, i % n + 1, f[i]);
	printf("%lld\n", Kruscal()); 
	return 0;
}

Measured memory_bytes: 12288
/**
*    author:  y_takano
*    created: 18.06.2020 15:19:40
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int i, j;
  cin >> i >> j;

  if(i < j) {
      cout << "a < b\n";
  }
  else if (i > j){
      cout << "a > b\n";
  }
  else
  {
      cout << "a == b\n";
  }
      
  return 0;
}


Measured memory_bytes: 3120
#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++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll n;
    cin >> n;
    VL a(n, 0), cnt(100010, 0);
    ll sum = 0;
    rep(i, 0, n){
        cin >> a[i];
        cnt[a[i]]++;
        sum += a[i];
    }
    ll q;
    cin >> q;
    rep(hoge, 0, q){
        ll b, c;
        cin >> b >> c;
        sum -= b * cnt[b];
        sum += c * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define Sim template<class n
Sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
Sim> auto operator << (ostream &p, n y) -> 
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
Sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
Sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
Sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "
const int M = 1024;

int n, m, res = 0;
int dist[M][M];
char C[M];

int x[] = {1, 0, -1, 0};
int y[] = {0, 1, 0, -1};

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(NULL);
	scanf("%d%d", &n, &m);
	queue<PII> Q;
	FOR(i, 1, n)
	{
		FOR(j, 1, m)
		{
			dist[i][j] = M * M;
		}
		scanf("%s", C);
		FOR(j, 0, m - 1)
		{
			if (C[j] == '#')
			{
				dist[i][j + 1] = 0;
				Q.push(MP(i, j + 1));
			}
		}
	}
	while (!Q.empty())
	{
		PII v = Q.front();
		Q.pop();
		maxi(res, dist[v.f][v.s]);
		FOR(i, 0, 3)
		{
			if (dist[v.f + x[i]][v.s + y[i]] == M * M)
			{
				dist[v.f + x[i]][v.s + y[i]] = dist[v.f][v.s] + 1;
				Q.push(MP(v.f + x[i], v.s + y[i]));
			}
		}
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 12560
;;; Utils

(defmacro read-numbers-to-list ()
  `(read-from-string
    (concatenate 'string "(" (read-line) ")")))


(defmacro read-line-to-array (dimension)
  (if (< dimension 0)
      (error "invalid arguments for dimension.")
      `(make-array ,dimension :initial-contents (read-numbers-to-list))))

(defmacro read-line-to--char-list ()
  `(concatenate 'list (read-line)))

(defmethod make-cumlative-sum ((sequence list))
  (labels ((inner (sequence &optional (acc '(0)))
             (if (null sequence)
                 (reverse acc)
                 (inner (rest sequence) (cons (+ (first sequence)
                                                 (first acc))
                                              acc)))))
    (inner sequence)))





(defmethod princ-for-each-line ((sequence list))
  (labels ((inner (sequence)
             (if (null sequence)
                 nil
                 (progn
                   (fresh-line)
                   (princ (first sequence))
                   (inner (rest sequence))))))
    (inner sequence)))

(defmethod princ-for-each-line ((sequence array))
  (dotimes (i (length sequence))
    (fresh-line)
    (princ (aref sequence i))))




;;; Write code here

(defun solve (s)
  (+ 700
     (* (count #\o s :test #'char-equal)
        100)))


(defun main ()
  (let ((s (read-line)))
    (format t "~a~%" (solve s))))

(main)


Measured memory_bytes: 25080
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>N(4);
  for(int &n:N)cin>>n;
  sort(N.begin(),N.end());
  if(N==vector<int>({1,4,7,9}))
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
//package solution;

import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
    
    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }
    
    void run() throws Exception {
        String s = " " + nt(), t = " " + nt();
        int n = s.length(), m = t.length();
        
        int[][] dp = new int[n][m];
        for(int i=1; i<n; i++)
            for(int j=1; j<m; j++)
                if(s.charAt(i) == t.charAt(j))
                    dp[i][j] = dp[i-1][j-1] + 1;
                else
                    dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
        
        int rptr = n-1, cptr = m-1;
        char[] ans = new char[dp[rptr][cptr]];
        int ans_i = ans.length - 1;
        while(rptr > 0 && cptr > 0) {
            if(s.charAt(rptr) == t.charAt(cptr)) {
                ans[ans_i--] = s.charAt(rptr);
                rptr--; cptr--;
            } else {
                if(dp[rptr-1][cptr] > dp[rptr][cptr-1])
                    rptr--;
                else
                    cptr--;
            }
        }
        
        pl(new String(ans));
    }
    
    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

    int ni() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
    
    void selector() {
        Random rd = new Random();
        String[] s = new String[] {"Strings", "Sorting", "Search"
                , "Graph theory", "Greedy", "Dynamic programming"
                , "Constructive algos", "Bit manipulation", "Recursion"};
        pl(s[rd.nextInt(s.length)] + " " + (rd.nextInt(5)+1));
    }
}

Measured memory_bytes: 82648
#include <iostream>

int main()
{
	int N, M;

	std::cin >> N >> M;

	char* A = new char[N*N];
	char* B = new char[M*M];

	for (int i = 0; i < N; i++)
		for (int j = 0; j < N; j++)
		{
			std::cin >> A[j*N + i];
		}

	for (int i = 0; i < M; i++)
		for (int j = 0; j < M; j++)
		{
			std::cin >> B[j*M + i];
		}

	int movi = N - M + 1;
	int movj = movi;

	for (int offi = 0; offi < movi; offi++)
		for (int offj = 0; offj < movj; offj++)
		{
			for (int i = offi; i < offi + M; i++)
				for (int j = offj; j < offj + M; j++)
				{
					if (A[j*N + i] != B[(j-offj)*M + (i-offi)])
					{
						goto NO_MATCH;
					}

				}
		
			std::cout << "Yes" << std::endl;
			return 0;
		NO_MATCH:
			;
		}

	std::cout << "No" << std::endl;
	return 0;
}

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

int n;
vector<int> dp;
vector<string> label;
map<string, int> to;

void dfs(int s, int c){
	if(dp[s] <= c) return;
	dp[s] = c;
	if(s == label.size()) return;
	dfs(to[label[s]], c);
	dfs(s+1, c+1);
}

main(){
	int i,j;
	while(cin >> n){
		label.clear();
		while(n--){
			string s;
			cin >> s;
			if(s == "goto"){
				cin >> s;
				s[s.size()-1] = ':';
				label.push_back(s);
			}else{
				to[s] = label.size();
			}
		}
		dp = vector<int>(label.size()+1, 100);
		dfs(0, 0);
		cout << dp[label.size()] << endl;
	}
	return 0;
}

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

int main()
{
  vector<int> ans;
  for(int i=0;i<12;i++)
    ans.push_back(i);
  ans.push_back(0);
  int n;
  for(;cin>>n,n!=-1;)
    {
      vector<int> p;
      p.push_back(n);
      for(int i=0;i<12;i++)
	{
	  int tmp;
	  cin>>tmp;
	  p.push_back(tmp);
	}
      set<vector<int> >hash;
      queue<pair<vector<int>,int> >qu;
      qu.push(make_pair(p,0));
      int anscnt=-1;
      int dx[]={0,1,1,2,2,3,4,5,5,6,6 ,7,7 ,9 ,10,10};
      int dy[]={2,2,5,3,6,7,5,6,9,7,10,8,11,10,11,12};
      set< vector<int> >t1;
      while(!qu.empty())
	{
	  vector<int > data=qu.front().first;
	  int cnt=qu.front().second;
	  qu.pop();
	  // cout<<"qu: "<<cnt<<endl;
	  if(data==ans)
	    {
	      anscnt=cnt;
	      break;
	    }
	  if(hash.find(data)!=hash.end())
	    continue;
	  hash.insert(data);
	  if(cnt>=10)
	    {
	      t1.insert(data);
	      continue;
	    }
	  for(int i=0;i<16;i++)
	    {
	      int x=dx[i];
	      int y=dy[i];
	      if(data[x]==0 || data[y]==0)
		{
		  swap(data[x],data[y]);
		  if(hash.find(data)==hash.end())
		    qu.push(make_pair(data,cnt+1));
		  swap(data[x],data[y]);
		}
	    }
	}
      if(anscnt==-1)
	{
	  set<vector<int> >hash;
	  queue<pair<vector<int>,int> >qu;
	  qu.push(make_pair(ans,0));
	  while(!qu.empty())
	    {
	      vector<int > data=qu.front().first;
	      int cnt=qu.front().second;
	      qu.pop();
	      // cout<<"qu: "<<cnt<<endl;
	      if(t1.find(data)!=t1.end())
		{
		  anscnt=10+cnt;
		  break;
		}
	      if(hash.find(data)!=hash.end())
		continue;
	      hash.insert(data);
	      if(cnt>=10)
		continue;
	      for(int i=0;i<16;i++)
		{
		  int x=dx[i];
		  int y=dy[i];
		  if(data[x]==0 || data[y]==0)
		    {
		      swap(data[x],data[y]);
		      if(hash.find(data)==hash.end())
			qu.push(make_pair(data,cnt+1));
		      swap(data[x],data[y]);
		    }
		}
	    }
	}

      if(anscnt==-1)
	cout<<"NA"<<endl;
      else
	cout<<anscnt<<endl;
    }
}

Measured memory_bytes: 6856