akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

static inline ll manhattan(ll x1, ll x2, ll y1, ll y2) {
  return abs(x1 - x2) + abs(y1 - y2);
}

int main() {
  ll N, M;
  cin >> N >> M;
  vec<pair<ll, ll>> students(N), checkpoints(M);
  REP(i, N) {
    ll a, b;
    cin >> a >> b;
    students[i] = make_pair(a, b);
  }
  REP(i, M) {
    ll c, d;
    cin >> c >> d;
    checkpoints[i] = make_pair(c, d);
  }
  REP(i, N) {
    ll near = numeric_limits<ll>::max(), res = 0;
    REP(j, M) {
      const ll d = manhattan(students[i].first, checkpoints[j].first,
                             students[i].second, checkpoints[j].second);
      if (d < near) {
        near = d;
        res = j + 1;
      }
    }
    cout << res << endl;
  }
  return 0;
}


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

int main() {
	
	vector<int> v1;
	int x = 3;
	
	while(x--){
		int s;
		cin >> s;
		v1.push_back(s);
	}
	// v1.reverse();
	x = 3;
	
	swap(v1[0], v1[1]);
	
	while(x--){
		cout << v1[x] << " ";
	}
	
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v),end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

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

    int m,nmin,nmax;
    while(cin>>m>>nmin>>nmax,m|nmin|nmax){
        int p[205];
        REP(i,m) cin>>p[i+1];
        int ma=0,ans;
        for(int i=nmin;i<=nmax;i++){
            if(p[i]-p[i+1]>=ma){
                ma=p[i]-p[i+1];
                ans=i;
            }
        }
        cout<<ans<<endl;
    }

}

Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;


// 68 11 55 - rank 3
// 69 12 19 - rank 3
// 70 12 34 - rank 100
// 71 12 58 - rank 4
// 72 13 24 - rank 20
// 73 13 39

ull gcd(ull a, ull b) {
    while (b != 0) {
        auto na = a % b;
        a = b;
        b = na;
    }
    return a;
}


void oneCase() {
    int n;
    cin >> n;
    int c = n;
    for (int i = 0; i < n; ++i ) {
        int a, b;
        cin >> a >> b;
        c += b - a;
    }
    cout << c << "\n";
}


int main() {
    int t = 1;
//    cin >> t;
    while (t--) {
       oneCase();
    }

    return 0;
}

ll fact(ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        res = (res * n) % mod;
        --n;
    }
    return res;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	x <- readInt
	print $ head $ filter isPrime [ x .. ]

isPrime x = all ( ( /= 0 ) . ( x `mod` ) ) ps
	where
		ps = takeWhile ( \i -> i * i <= x ) [ 2 .. ]

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define pb push_back
#define ld long double
#define fi first
#define se second
#define ll long long
#define mp make_pair
using namespace std;
int n;
char s[1000005];
const int mod = 1e9 + 7;
int last[30];
int main()
{	
	scanf("%d", &n);
	scanf("%s", s + 1);
	for(int i = 1; n >= i; ++i)
		last[s[i] - 'a']++;
	ll ans = 1;
	for(int i = 0; 26 > i; ++i)
		ans = ((ll)ans * (last[i] + 1)) % mod;
	cout << ans - 1;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
long long check(int i,long long a,long long b,string &s)
{
	if(i==s.size())
		return b;
	int t=s[i]-'0';
	long long res=0;
	if(i+1!=s.size())
		res+=check(i+1,a*10+t,b,s);
	res+=check(i+1,0,a*10+b+t,s);
	return res;
}
int main()
{
	string s;
	cin>>s;
	cout<<check(0,0,0,s);

	return 0;
}

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

using namespace std;

int main()
{
	int n;
	int sum_taro = 0, sum_hana = 0;
	string str1, str2;
	cin >> n;

	for(int i = 0; i < n; i++)
	{
		cin >> str1 >> str2;
		if(str1 == str2){
			sum_taro++;
			sum_hana++;
		}
		else if (str1 > str2)
		{
			sum_taro += 3;
		}
		else
		{
			sum_hana += 3;
		}
	}

	cout << sum_taro << " " << sum_hana << endl;
	return 0;
}


Measured memory_bytes: 3220
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(){
    double num;
    char a[201], b[101];
    scanf("%s %s", a, b);
    strcat(a, b);
    num = atoi(a);
    puts(num==pow((int)pow(num, 0.5), 2) ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <stdio.h>
//#include <cstdio>
//#include <stdio.h>
using namespace std;
const int t_max = 1270;

int main(){
    int N, M;
    while( cin >> N >> M && N && M ){
        vector< vector<int> > data( N+1, vector<int>(t_max));
        int r;
        cin >> r;
        while( r-- ){
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            if( s == 1 ){
                data[n][t] = -m;
            }else{
                for( int i = 0; i < t_max; i++ ){
                    if( data[n][i] == -m ){
                        for( ; i < t; i++ ){
                            data[n][i] = m;
                        }
                        break;
                    }
                }
            }
        }
        int q;
        cin >> q;
        while( q-- ){
            int ts, te, m, sum = 0;
            vector<int> student(t_max);
            //memset( student, 0, sizeof(student));
            cin >> ts >> te >> m;
            for( int i = 0; i <= N; i++ ){
                //int a = 0;
                for( int j = ts; j < te; j++ ){
                    if( data[i][j] == m && student[j] != 1 ){
                        /*
                        if( data[i][j-1] != m || j == ts ){
                            a++;
                        }
                        if( data[i][j+1] != m || j == te ){
                            a++;
                        }
                        */
                        sum++;
                        student[j] = 1;
                    }
                }
                //sum -= a / 2;
            }
            cout << sum << endl;
        }
    }
}

Measured memory_bytes: 6084
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    int k = s.size();
    int cnt = 0;
    for(int i = 0; i < k; i++){
        if(s[i] == 'o') cnt++;
    }
    if(15-k+cnt >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#!/user/bin/python
# coding: UTF-8
import sys

x = str(raw_input())
x_list = list(x)
x_int = []

for i in range(len(x_list)):
    x_int.append(int(x_list[i]))

if x_int[0] + x_int[1] + x_int[2] + x_int[3] == 7:
    op = ['+', '+', '+']
elif x_int[0] + x_int[1] + x_int[2] - x_int[3] == 7:
    op = ['+', '+', '-']
elif x_int[0] + x_int[1] - x_int[2] + x_int[3] == 7:
    op = ['+', '-', '+']
elif x_int[0] + x_int[1] - x_int[2] - x_int[3] == 7:
    op = ['+', '-', '-']
elif x_int[0] - x_int[1] + x_int[2] + x_int[3] == 7:
    op = ['-', '+', '+']
elif x_int[0] - x_int[1] + x_int[2] - x_int[3] == 7:
    op = ['-', '+', '-']
elif x_int[0] - x_int[1] - x_int[2] + x_int[3] == 7:
    op = ['-', '-', '+']
elif x_int[0] - x_int[1] - x_int[2] - x_int[3] == 7:
    op = ['-', '-', '-']

sys.stdout.write(x_list[0])
sys.stdout.write(op[0])
sys.stdout.write(x_list[1])
sys.stdout.write(op[1])
sys.stdout.write(x_list[2])
sys.stdout.write(op[2])
sys.stdout.write(x_list[3])
sys.stdout.write('=7')


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

int main()
{
    int N, ans = 0;
    cin >> N;
    vector<int>V(N);
    int Visited[2000009];

    for (int j = 0; j < N ; j++)
    {
        cin >> V[j];
    }
    int K = 1;
    for (int j = 0; j < N ; j++)
    {
       
        if (Visited[K] == 0 && V[j]== K)
        {
            Visited[K++] = 1;
        }
        else
        {
            ans++;
        }
    }
    if (ans < N) { cout << ans << endl; }
    else { cout << -1 << endl; }

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fori(n) for ( int i = 0; i < (n);i++)
#define forj(n) for ( int j = 0; j < (n);j++)
#define fork(n) for ( int k = 0; k < (n);k++)
#define forghj(n) for ( int ghj = 0; ghj < (n);ghj++)
#define fori1(n) for ( int i = (n)-1; i >= 0;i--)
#define all(vector) (vector).begin(),(vector).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define INF 1e9+7
/*
────────▄──────────────▄
────────▌▒█───────────▄▀▒▌
────────▌▒▒▀▄───────▄▀▒▒▒▐
───────▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐
─────▄▄▀▒▒▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐
───▄▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀██▀▒▌
──▐▒▒▒▄▄▄▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄▒▒▌
──▌▒▒▐▄█▀▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐
─▐▒▒▒▒▒▒▒▒▒▒▒▌██▀▒▒▒▒▒▒▒▒▀▄▌
─▌▒▀▄██▄▒▒▒▒▒▒▒▒▒▒▒░░░░▒▒▒▒▌
_▌▀▐▄█▄█▌▄▒▀▒▒▒▒▒▒░░░░░░▒▒▒▐
▐▒▀▐▀▐▀▒▒▄▄▒▄▒▒▒▒▒░░░░░░▒▒▒▒▌
▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒░░░░░░▒▒▒▐
─▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒▒▒░░░░▒▒▒▒▌
─▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▐
──▀▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▄▒▒▒▒▌
────▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀
───▐▀▒▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀
──▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀▀
*/
int k(int x) {
    int ans = 0;
    for (int i = 1; i <= x; i++) {
        if (x % i == 0) ans++;
    }
    return ans;
}
int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (k(i) == 8 && i % 2 == 1) ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static void Main() {
        int n = cin.Int();
        int a = cin.Int();
        int b = cin.Int();
        if (a + b <= n) Console.WriteLine(Math.Min(a, b) + " " + 0);
        else Console.WriteLine(Math.Min(a, b) + " " + (a + b - n));
        Console.ReadLine();
    }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;


int main()
{
	int h,w,x;
	cin >> h >> w >> x;
	cout << min(ceil(x *1.0 / h),ceil(x * 1.0 / w)) << endl; 
	return 0;
}


Measured memory_bytes: 256
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
//const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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


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

int bfs(const vector<string> &v, int x, int y) {
	int H = v.size(), W = v[0].size();
	vector<vector<int>> dist(H, vector<int>(W, -1));
	queue<pair<int, int>> que;

	int res = 0;
	que.push({ x, y });
	dist[x][y] = 0;
	while (!que.empty()) {
		int x = que.front().first, y = que.front().second;
		res = max(res, dist[x][y]);
		que.pop();
		for (int dir = 0; dir < 4; ++dir) {
			int nx = x + dx[dir], ny = y + dy[dir];
			if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
			if (v[nx][ny] == '#') continue;
			if (dist[nx][ny] == -1) {
				dist[nx][ny] = dist[x][y] + 1;
				que.push({ nx, ny });
			}
		}
	}
	return res;
}

int main() {
	
	int h, w;
	cin >> h >> w;
	vector<string> maze(h);
	rep(i, h) cin >> maze[i];

	int res = 0;
	rep(i, h) {
		rep(j, w) {
			if (maze[i][j] == '#') continue;
			res = max(res, bfs(maze, i, j));
		}
	}
	cout << res << endl;
	return 0;
}


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

typedef long long ll;

int main()
{
    string S, T;
    cin >> S >> T;

    for (int i = 0; i < S.size(); i++)
    {
      if (S[i] != T[i]) {
          cout << "No" << endl;
          return 0;
      }
    }

    if (S.size() + 1 == T.size())
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 3624
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      double r = Double.parseDouble(sc.nextLine());
      DecimalFormat dot6 = new DecimalFormat("0.000000");
      double pi = Math.PI;
      
      double area = pi * r * r;
      double circumference = 2.0 * pi * r;
      
      System.out.println(dot6.format(area) + " " + dot6.format(circumference));  
      
   }//main
}//class

Measured memory_bytes: 26248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9;
const int INF = 0x3f3f3f3f;
const int N = 200000 + 5;
int a[N];
 
int main(){
	ll x;
	cin >> x;
	for(ll a = -1000; a < 1000; a++){
		for(ll b = -1000; b < a; b++){
			if(a*a*a*a*a - b*b*b*b*b == x){
        		cout << a << ' ' << b << endl;
        		return 0;
			}
		}
	}
	return 0;
}

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

using namespace std;

int main() {

	string s;
	getline(cin,s);

	string t;
	int counter = 0;
	while (1) {
		getline(cin, t);
		if (t == "END_OF_TEXT") { break; }
		for (int i = 0; i < t.size(); i++) {
			for (int j = 0; j < s.size(); j++) {
				if (s[j] >= 'a' && s[j] <= 'z') {
					if (t[i + j] != s[j] && t[i + j] != s[j]+'A'-'a') { break; }
				}
				if (s[j] >= 'A' && s[j] <= 'Z') {
					if (t[i + j] != s[j] && t[i + j] != s[j] - 'A' + 'a') { break; }
				}
				if (j == s.size() - 1 && i!=0 && i+j!=t.size()-1) {
					if (t[i - 1] == ' ' && t[i + j + 1] == ' ') {
						counter++;
					}
				}
				else if (j == s.size() - 1 && i == 0 && i+j != t.size() - 1) {
					if (t[i + j + 1] == ' ') {
						counter++;
					}
				}
				else if (j == s.size() - 1 && i!=0 && i+j == t.size()-1) {
					if (t[i- 1] == ' ') {
						counter++;
					}
				}
				else if (s == t) {
					counter++;
				}
			}
		}
	}

	cout << counter << endl;
}


Measured memory_bytes: 3156
import sys
input=sys.stdin.readline
#N = int(input())
#S = input()[:-1]
N,M = map(int,input().split())
#S,T = map(str,input().split())
A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
A.sort(reverse = True)
s = 0
for i in A:
    s += i
a = A[M-1]
if a >= (s/4)/M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


bool check(vint a) {
    int sz = a.size();
    int p = a[0];
    srep(i, 1, sz) {
        if (abs(p-a[i]) > 1) return false;
        p = a[i];
    }
    return true;
}

void update(vint& a) {
    int sz = a.size();
    int id = 0;
    while (1) {
        while (1) {
            if (a[id] < 9) {
                a[id]++;
                break;
            }
            else {
                id++;
                if (id >= sz) {
                    a = {};
                    rep(i, sz) a.push_back(0);
                    a.push_back(1);
                    return;
                }
            }
            
        }
        rrep(i, id) {
                a[i] = max(a[id]-(id-i), 0);
        }
        if (check(a)) return;
    }
}

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

    int count = 1;
    vint a = {1};
    while (count < k) {
        if (check(a)) count++;
        // if (check(a)) show_ary(a);
        update(a);
    }

    // show_ary(a);
    ll ans = 0;
    ll d = 1;
    for (int ai : a) {
        ans += ai*d;
        d *= 10;
    }

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

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

using namespace std;
using ll = long long;
using vec = vector<int>;

#define rep(i, n)  for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
#define pout(n, a) cout << fixed << setprecision(n) << (a)
#define Cast(dig, n) static_cast<std::bitset<(dig)>>(n)

const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    int s, w;
    cin >> s >> w;

    cout << ((s <= w)?"unsafe":"safe");
}

Measured memory_bytes: 3612
N,x=map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
a.sort()
for i in a:
    if x >= i:
        x -= i
        cnt +=1
    else:
        print(cnt)
        exit()
if x ==0:
    print(cnt)
else:
    print(cnt-1)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    cout << (N+999)/1000*1000-N << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int main() {
	int t,sum=0,m,s;
	for(int i=1; i<=4; i++){
		cin>>t;
		sum+=t;
	}
	m=sum/60;
	s=sum-60*m;

	cout<<m<<endl<<s<<endl;	
		
	return 0;
}

Measured memory_bytes: 1160
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main() {
	int n, m, a;

	while(cin >> n >> m >> a, n) {
		vvi data(m, vi(3));

		REP(i, m) {
			cin >> data[i][0] >> data[i][1] >> data[i][2];
		}

		sort(RALL(data));

		REP(i, m) {
			if(data[i][1] == a) {
				a = data[i][2];
			} else if(data[i][2] == a) {
				a = data[i][1];
			}
		}

		cout << a << endl;
	}

	return 0;
}

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

int main()
{
  string a;
  cin >> a;

  bool isRight = true;
  bool isCrossover = false;
  
  for (int i = 0; i < a.length(); i ++) {
    if (isRight && a[i] == 'L') { isCrossover = true; break; }
    if (!isRight && a[i] == 'R') { isCrossover = true; break; }

    isRight = !isRight;
  }

  cout << ( isCrossover ? "No" : "Yes" ) << endl;
}

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

int main(void)
{
	int n, x;
	cin >> n >> x;

	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];

	sort(a.begin(), a.end());
	int i;
	for (i = 0; i < n; i++) {
		x -= a[i];
		if (x < 0) {
			cout << i << endl;
			return 0;
		}
	}

	if (x > 0)
		cout << n-1 << endl;
	else
		cout << n << endl;
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int  W,H,N; cin >> W >> H >> N;

    int l=0,r=W,d=0,u=H;
    REP(i,N){
        int x,y,a; cin >> x >> y >> a;
        switch (a){
            case 1:
                l = max(l,x);
                break;
            
            case 2:
                r = min(r,x);
                break;
            
            case 3:
                d = max(d,y);
                break;
            
            case 4:
                u = min(u,y);
                break;
        }
    }
    if(l<r && d<u) cout << (r-l)*(u-d) << endl;
    else cout << 0 << endl;
        

    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
//const u32 P=;
//inline u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
//inline u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
//inline u32 sum(u32 a, u32 b) {return (a+=b)<P?a:a-P;}
//inline u32 dif(u32 a, u32 b) {return (a-=b)&0x80000000?a+P:a;}
//u64 power(u64 a, int b) {
//	u64 ans=1;
//	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
//	return ans;
//}

const int N=2e5;
int tot=3, up[60], aa[30], bb[30], cc[60];
int alloc() {
	return tot++;
}
void add(int a, int b, int c) {
	printf("+ %d %d %d\n", a, b, c);
}
void less(int a, int b, int c) {
	printf("< %d %d %d\n", a, b, c);
}
void lsh(int a, int k) {
	while(k--) add(a, a, a);
}
int main() {
	puts("5761");
	int a=0, b=1, res=2, zero=alloc(), one=alloc();
	add(a, b, one);
	less(zero, one, one);
	up[0]=one;
	for(int i=1; i<60; ++i) up[i]=alloc();
	for(int i=0; i<30; ++i) aa[i]=alloc();
	for(int i=0; i<30; ++i) bb[i]=alloc();
	for(int i=0; i<60; ++i) cc[i]=alloc();
	for(int i=0; i<30; ++i) meow("%d ", aa[i]); meow("\n");
	for(int i=0; i<30; ++i) meow("%d ", bb[i]); meow("\n");
	for(int i=0; i<60; ++i) meow("%d ", cc[i]); meow("\n");
	int t=alloc(), tmp=alloc();
	for(int i=1; i<60; ++i) add(up[i-1], up[i-1], up[i]);
	for(int i=30; i--; ) {
		add(t, up[i], tmp);
		less(a, tmp, aa[i]);
		less(aa[i], one, aa[i]);
		add(zero, aa[i], tmp);
		lsh(tmp, i);
		add(t, tmp, t);
	}
	t=alloc();
	for(int i=30; i--; ) {
		add(t, up[i], tmp);
		less(b, tmp, bb[i]);
		less(bb[i], one, bb[i]);
		add(zero, bb[i], tmp);
		lsh(tmp, i);
		add(t, tmp, t);
	}
	for(int i=0; i<30; ++i) {
		for(int j=0; j<30; ++j) {
			add(aa[i], bb[j], tmp);
			less(one, tmp, tmp);
			add(cc[i+j], tmp, cc[i+j]);
		}
	}
	for(int i=0; i<60; ++i) {
		lsh(cc[i], i);
		add(res, cc[i], res);
	}
	return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define MAX 1000
#define MOD 1000000007
using namespace std;
long long ep[MAX+1];
void fact(int x)
{
	for(int i=2;i*1LL*i<=x;++i)
		while(x%i==0)
			++ep[i], ep[i] %= MOD,x /= i;
	if(x^1)
		++ep[x],ep[x] %= MOD;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	for(int i=2;i<=n;++i)
		fact(i);
	long long ans = 1;
	for(int i=2;i<=n;++i)
		ans *= (++ep[i])%MOD, ans %= MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3512
#include "bits/stdc++.h"
using namespace std;
#define shandom_ruffle random_shuffle
#define pb push_back
#define nl puts("")
using ll = long long;
using pii = pair<ll,ll>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vlll = vector<vll>;
using mpll = map<ll,ll>;
using stch = stack<char>;
using stvll = stack<vll>;
const ll nax = 1000*1007;
const ll mno = 1007;
const ll mod = 1e9 + 7;
const ll mxN = 1e5;
const ll rc = 64;
const ll MOD = 998244353; 
int main() {
  string n; 
  cin >> n;
  if(n[0] == '7' || n[1] == '7' || n[2] == '7') puts("Yes");
  else puts("No");
}

Measured memory_bytes: 3628
import sys
n = int(input())
a = list(map(int, input().split()))

t = [sys.maxsize]*n
t[0] = 0

for i in range(n):
    for j in range(i+1,i+3):
        if j<n:
            t[j] = min(t[j],t[i] + abs(a[i] - a[j]))
print(t[n-1])

Measured memory_bytes: 13980
fun main(args : Array<String>) {
    val (q, h, s, d) = readLine()!!.split(" ").map { it.toInt() }
    val n = readLine()!!.toInt()

    val q2 = 8*q
    val h2 = 4*h
    val s2 = 2*s
    val d2 = d

    val q1 = 4*q
    val h1 = 2*h
    val s1 = s

    val min1 = Math.min(Math.min(q1, h1), s1)
    val min2 = Math.min(Math.min(q2, h2), Math.min(s2, d2))

    println((n / 2) * min2.toLong() + (n % 2) * min1.toLong())
}

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

struct data {
  int x[2], y[2];
};

int h, w;
int d[4] = {0, 1, 0, -1};
string s[2][55];
bool ch[55][55][55][55] = {0};
queue<data> qu;

void chset();
bool solve();
bool chover(data now);

int main() {
  while(1) {
    cin >> w >> h;
    if(w + h == 0) break;
    for(int i = 0; i < h; ++i)
      for(int j = 0; j < 2; ++j) cin >> s[j][i];
    for(int i = 0; i < 2; ++i) chset();
    if(solve())
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
    while(qu.size() > 0) qu.pop();
  }
  return 0;
}

void chset() {
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      for(int k = 0; k < h; ++k)
        for(int l = 0; l < w; ++l) ch[i][j][k][l] = 0;
}
bool solve() {
  data fi;
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      for(int k = 0; k < 2; ++k)
        if(s[k][i][j] == 'L' || s[k][i][j] == 'R') {
          fi.x[k] = i;
          fi.y[k] = j;
          s[k][i][j] = '.';
        }
  qu.push(fi);
  ch[fi.x[0]][fi.y[0]][fi.x[1]][fi.y[1]] = 1;
  while(qu.size() > 0) {
    data now = qu.front();
    qu.pop();
    for(int i = 0; i < 4; ++i) {
      data nextp = now;
      int cnt = 0;
      for(int j = 0; j < 2; ++j) {
        nextp.x[j] += d[i];
        nextp.y[j] += d[1 ^ i] * (1 - 2 * j);
      }
      for(int j = 0; j < 2; ++j)
        if(nextp.x[j] < 0 || nextp.y[j] < 0 ||
           nextp.x[j] >= h || nextp.y[j] >= w ||
           s[j][nextp.x[j]][nextp.y[j]] == '#') {
          nextp.x[j] -= d[i];
          nextp.y[j] -= d[1 ^ i] * (1 - 2 * j);
        }
        else if(s[j][nextp.x[j]][nextp.y[j]] == '%')
          ++cnt;
      if(cnt == 2)
        return 1;
      else if(cnt != 0)
        continue;
      if(!ch[nextp.x[0]][nextp.y[0]][nextp.x[1]]
            [nextp.y[1]]) {
        ch[nextp.x[0]][nextp.y[0]][nextp.x[1]][nextp.y[1]] =
            1;
        qu.push(nextp);
      }
    }
  }

  return 0;
}

bool chover(data now) {
  for(int i = 0; i < 2; ++i)
    if(now.x[i] < 0 || now.x[i] >= h || now.y[i] < 0 ||
       now.y[i] >= w)
      return 0;
  return 1;
}


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

int main(){
  int i, j;
  string s, t;
  cin >> s >> t;
  
  for( i = 0; i < s.size() - 1; i++ ){
    for( j = s.size() - 1; j > i; j-- ){
      if ( s[j] < s[j - 1] ){
        char x = s[j];
        s[j] = s[j - 1];
        s[j - 1] = x;
      }
    }
  }
  for( i = 0; i < t.size() - 1; i++ ){
    for( j = t.size() - 1; j > i; j-- ){
      if ( t[j] > t[j - 1] ){
        char x = t[j];
        t[j] = t[j - 1];
        t[j - 1] = x;
      }
    }
  }
  
  
  if( s.size() < t.size() ){
    for ( i = 0; i < s.size(); i++ ){
      if ( s[i] < t[i] ){
        cout << "Yes" << endl;
        return 0;
      }
      if(i == s.size() - 1 && s[i] == t[i] ){
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No"  << endl;
  }else{
    for ( i = 0; i < t.size(); i++ ){
      if ( s[i] < t[i] ){
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int l,r;cin >> l >> r;
    if(r-l>3000)cout << 0 << endl;
    else{
        ll ans = INF;
        for(ll i=l;i<r;i++){
            for(ll j=i+1;j<=r;j++){
                chmin<ll>(ans,(i*j)%2019);
            }
        }
    cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define endl '\n'
using namespace std;

int main()
{
    int a, l, tmp1, tmp2, rem;
    cin >> a >> l;
    rem=l%2;
    tmp1=a*2;
    tmp2=a*4;
    if (rem) cout << "No" << endl;
    else if (l<tmp1 || l>tmp2) cout << "No" << endl;
    else cout << "Yes" << endl;

}


Measured memory_bytes: 3632
R,G,B,N=map(int,input().split())

ans=0
for r in range(3001):
	if R*r > N:
		break
	for g in range(3001):
		z = N - R*r - G*g
		if z < 0:
			break
		if z % B == 0:
			ans += 1
print(ans)


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

int main()
{
  int N; cin >> N;
  vector<int> v;
  for (int i=0; i<N; i++) {
    int p;cin>>p;
    v.push_back(p);
  }

  vector<int> copy(v);
  sort(copy.begin(), copy.end());
  int diffCount = 0;
  for (int i=0; i<N; i++) {
    if (v.at(i) == copy.at(i)) continue;
    diffCount++;
  }

  if (diffCount > 2) cout << "NO" << endl;
  else cout << "YES" << endl;
  
  
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

char C[2];
int main(){
	string s;cin>>s;
	deque<char>v;
	for(char&c:s)v.push_back(c);
	int q;cin>>q;
	int cnt=0;
	rep(i,q){
		int ty;scanf("%d",&ty);
		if(ty==1){
			cnt^=1;
		}
		else{
			int f;scanf("%d%s",&f,C);f--;
			int e=(f^cnt);
			if(e==0)v.push_front(C[0]);
			else v.push_back(C[0]);
		}
	}
	if(cnt){
		reverse(v.begin(),v.end());
	}
	for(char c:v){
		cout<<c;
	}
	cout<<endl;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
using namespace std;


int main(){

  int a, b;
  char op;
  while(cin >> a >> op >> b){
    if( op == '?' ) break;
    else if( op == '+' ) cout << a + b << endl;
    else if( op == '-' ) cout << a - b << endl;
    else if( op == '*' ) cout << a * b << endl;
    else if( op == '/' ) cout << a / b << endl;
  }

  return 0;
}








// EOF

Measured memory_bytes: 3088
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    static final int INF = Integer.MAX_VALUE / 2;
    static int V = 10;
    static int[][] c = new int[V][];

    public static void main(String[] args) {
        int H = in.i();
        int W = in.i();
        Arrays.setAll(c, i -> in.ii(V));

        int[] cnt = new int[V];
        for (int i = 0, N = H * W; i < N; i++) {
            int a = in.i();
            if (a > -1) {
                cnt[a]++;
            }
        }

        int[][] d = WarshallFloyd();

        int ans = 0;
        for (int i = 0; i < V; i++) {
            ans += d[i][1] * cnt[i];
        }

        out.println(ans);
    }

    static int[][] WarshallFloyd() {
        int[][] d = c;

        for (int k = 0; k < V; k++) {
            for (int i = 0; i < V; i++) {
                for (int j = 0; j < V; j++) {
                    int t = d[i][k] + d[k][j];
                    if (t < d[i][j]) {
                        d[i][j] = t;
                    }
                }
            }

        }
        return d;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 36396
n, m = [int(_) for _ in input().split()]
l = []
for i in range(m):
    l.append([int(_) for _ in input().split()])
p_l = [int(_) for _ in input().split()]
# print(l)
# print(p_l)
ans = 0
for i in range(2**n):
    i_bin = format(i, '0' + str(n) + 'b')
    flag = True

    # print('i_bin', i_bin)

    for i in range(m):

        # print('i', i)

        k = l[i][0]

        # print('k', k)

        c = 0
        for j in range(k):
            c += int(i_bin[l[i][j + 1] - 1])

            # print('j', j)
            # print('i_bin[l[i][j] - 1]', i_bin[l[i][j + 1] - 1])

        # print('c', c)

        if c % 2 != p_l[i]:
            flag = False
            break

        # print('flag', flag)

    if flag:
        ans += 1

    # print('ans', ans)
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(void) {

    string S,T;

    cin >> S;
    cin >> T;

    int num = 0;
    for( int ii = 0; ii < S.length(); ii++ ) {

        if( S[ii] != T[ii] ) {
            num++;
        }
    }

    cout << num;

    return 0;
}

Measured memory_bytes: 3912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
 
public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int	sc = parseNum();

		if (sc > 0) {
			int			ec = 0;
			Suspect[]	sp = new Suspect[sc];
			Cmp			cp = new Cmp();

			for (int i = 0; i < sc; i++) {
				sp[i] = new Suspect(i+1, sc);
			}

			ec = parseNum();
			while (ec-- > 0) {
				int[]	od = parseOrder();

				sp[od[1]].p.add(od[0]);
			}

			for (int i = 0; i < sp.length; i++) {
				calcWeight(i, sp);
			}

			Arrays.sort(sp, cp);

			for (int i = 0; i < sp.length; i++) {
				System.out.println(sp[i].n);
			}
		}
	}

	private static void calcWeight(int i, Suspect[] sp) {
		int	sz = sp[i].p.size();

		for (int j = 0; j < sz; j++) {
			int	p = sp[i].p.get(j);

			if (!sp[p].f) {
				calcWeight(p, sp);
			}

			int	ln = sp[p].p.size();
			for (int k = 0; k < ln; k++) {
				int	q = sp[p].p.get(k);
				if (!sp[i].p.contains((Integer)q)) {
					sp[i].p.add(q);
				}
			}
		}

		sp[i].f = true;
	}

	private static int[] parseOrder() {
		int[]	params = null;
		String	stdin  = null;

		if ((stdin = parseStdin()) != null) {
			if (!stdin.equals("0 0")) {
				String[]	lines = stdin.split(" ");

				params    = new int[2]; 
				params[0] = Integer.parseInt(lines[0])-1;
				params[1] = Integer.parseInt(lines[1])-1;
			}
		}

		return params;
	}

	private static int parseNum() {
		int		num = 0;
		String	str = null;

		if ((str = parseStdin()) != null) {
			num = Integer.parseInt(str);
		}

		return num;
	}

	private static String parseStdin() {
		String  stdin = null;

		try {
			String  tmp = br.readLine();
			if (!tmp.isEmpty()) stdin = tmp;
		}
		catch (IOException e) {}

		return stdin;
	}
}

class Suspect {
	boolean				f = false;
	int					n = 0;
	ArrayList<Integer>	p = null;

	Suspect (int num, int cnt) {
		n = num;
		p = new ArrayList<Integer>();
	}
}

class Cmp implements Comparator<Suspect> {
	public int compare(Suspect sus1, Suspect sus2) {
		int	res = sus1.p.size() - sus2.p.size();

		return (res == 0) ? sus1.n - sus2.n : res;
	}
}

Measured memory_bytes: 16960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

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

	int ans = 0;
	
	vector<int> vec(n);

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

	for (int i = 1; i < n-1; i++) {
		if ((vec[i - 1] < vec[i] && vec[i] < vec[i + 1])
			|| (vec[i - 1] > vec[i] && vec[i] > vec[i + 1])) {
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1000000000000000;


#define MAX 9223372036854775807
/*********************** */
int n;
int h[100010][3];
int dp[100010][3];
int main(void){
	cin >> n;
	for(int i=0;i<n;i++){
		for(int j =0;j<3;j++) cin >> h[i][j];
	}
	
	for(int i =0;i < 3;i++) dp[0][i] = h[0][i];
	for(int i = 1;i < n;i++){
		dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + h[i][0];
		dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + h[i][1];
		dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + h[i][2];
	}
	cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << endl;
	return 0;
}


Measured memory_bytes: 2560