akhauriyash/Code-Regression huggingface dataset:
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[]$) {
        int x = scanner.nextInt(), y = scanner.nextInt(), z = scanner.nextInt(), k = scanner.nextInt();
        long[] a = java.util.stream.IntStream.range(0, x).mapToObj(i -> scanner.nextLong()).sorted(java.util.Comparator.reverseOrder()).mapToLong(Long::longValue).toArray();
        long[] b = java.util.stream.IntStream.range(0, y).mapToObj(i -> scanner.nextLong()).sorted(java.util.Comparator.reverseOrder()).mapToLong(Long::longValue).toArray();
        long[] c = java.util.stream.IntStream.range(0, z).mapToObj(i -> scanner.nextLong()).sorted(java.util.Comparator.reverseOrder()).mapToLong(Long::longValue).toArray();
        java.util.stream.IntStream.rangeClosed(1, x).boxed().flatMap(i -> java.util.stream.IntStream.rangeClosed(1, y).boxed().flatMap(j -> {
            java.util.List<Long> list = new java.util.ArrayList<>();
            int l = 1;
            while (i * j * l <= k && l <= z) list.add(a[i - 1] + b[j - 1] + c[l++ - 1]);
            return list.stream();
        })).sorted(java.util.Comparator.reverseOrder()).limit(k).forEach(System.out::println);
    }
}

Measured memory_bytes: 75156
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int main() {
  int y, s, i;
  int c[] = {10, 50, 100, 500};
  int N[4];
  bool key = false;
  while (cin >> y, y) {
    s = -y;
    if (key)
      cout << endl;
    for (i = 0; i < 4; i++) {
      cin >> N[i];
      s += c[i] * N[i];
    }
    for (i = 3; i >= 0; i--) {
      while (s >= c[i]) {
        s -= c[i];
        N[i]--;
      }
    }
    for (i = 0; i < 4; i++) {
      if (N[i] > 0) {
        cout << c[i] << " " << N[i] << endl;
      }
    }
    key = true;
  }
  return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>

#define ull unsigned long long
#define ul unsigned long
#define ll long long
#define size_t unsigned long long

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >> a >> b >> c;

  std::cout << a*b/2 << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());

int a[]={0,1,2};
int main(){
	int n;
	cin>>n;
	rep(u,n){
		vector<vint> vv;
		vector<vint> ans;
		initvv(ans,9,9);
		initvv(vv,9,9);
		rep(i,9){
			rep(j,9){
				cin>>vv[i][j];
				ans[i][j]=0;
			}
		}
		rep(i,9){
			vint t(10,0);
			rep(j,9){
				t[vv[i][j]]++;
			}
			rep(j,9){
				if(t[vv[i][j]]>1){
					ans[i][j]=1;
				}
			}
		}
		rep(i,9){
			vint t(10,0);
			rep(j,9){
				t[vv[j][i]]++;
			}
			rep(j,9){
				if(t[vv[j][i]]>1){
					ans[j][i]=1;
				}
			}
		}
		rep(i,3){
			rep(j,3){
				int x=i*3,y=j*3;
				vint t(10,0);
				rep(k,3){
					rep(l,3){
						t[vv[k+x][l+y]]++;
					}
				}
				rep(k,3){
					rep(l,3){
						if(t[vv[k+x][l+y]]>1){
							ans[k+x][l+y]=1;
						}
					}
				}
			}

		}
		rep(i,9){
			rep(j,9){
				if(ans[i][j]==1){
					cout<<"*";
				}
				else cout<<" ";
				cout<<vv[i][j];
			}
			cout<<endl;
		}
		if(u!=n-1) cout<<endl;

	}
}

Measured memory_bytes: 1216
using System;

class Program{
  static void Main(){
    while(true){
      var input = Console.ReadLine();
      string[] inputint = input.Split(' ');
      int size = int.Parse(inputint[0]);
      int nummax = int.Parse(inputint[1]);
      if(size == 0 && nummax == 0)break;
      int[] array = new int[size];
      int answer = 0,subanswer = 0;
      for(int n = 0;n<size;n++){
        array[n] = int.Parse(Console.ReadLine());
      }
      for(int m = 0;m<size-nummax+1;m++){
        subanswer = 0;
        for(int i = 0;i<nummax;i++){
          subanswer += array[i+m];
        }
        if(subanswer > answer)answer = subanswer;
      }
      Console.WriteLine(answer);
    }
  }
}

Measured memory_bytes: 10004
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }

    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

double dp[3010][3010];
int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    int N; cin >> N;
    vector<double> v(N);
    rep(i, N){
        cin >> v[i];
    }

     // ura no kosuu
    memset(dp, 0, sizeof(dp));
    dp[1][0] = v[0];
    dp[1][1] = 1 - v[0];

    rep2(i, 2, N+1){
        rep(j, i+1){
            double a = dp[i-1][j] * v[i-1];
            dp[i][j] = a;
            if(j > 0){
                double b = dp[i-1][j-1] * (1 - v[i-1]);
                dp[i][j] += b;
            }
        }
    }

    double ans = 0;
    rep2(i, 0, N/2+1){
        ans += dp[N][i];
    }  

    print(ans);
    
    
    return 0;
}


Measured memory_bytes: 71040
import Data.Array (Array, listArray, (!))

dp f s e = result ! e where
  result = listArray (s,e) $ map nth [s..]
  nth i = f result i

minjumpcost :: Int -> Int -> Array Int Int -> Int
minjumpcost n k hs = dp f 1 n where
  f _ 1 = 0
  f t i =
    let costs = [(t!j) + abs ((hs!i)-(hs!j)) | j <- [i-1,i-2..i-k], j>0]
    in
      minimum costs

main = do
  [n,k] <- map read . words <$> getLine
  hs <- listArray (1,n) . map read . words <$> getLine
  print $ minjumpcost n k hs


Measured memory_bytes: 141692
# import numpy as np
import sys
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
# map(int, input().split())
# list(map(int, input().split()))
 
N, M = map(int, input().split())
 
cond = [-1] * N
 
for i in range(M):
    s, c = map(int, input().split())
    if cond[s - 1] > -1 and cond[s - 1] != c:
        print(-1)
        exit()
    cond[s - 1] = c

cond = list(map(str, cond))
for i in range(10 ** N):
    si = str(i)
    if N != len(si):
        continue
    ok = True
    for j in range(N):
        if cond[j] == '-1':
            continue
        if si[j] != cond[j]:
            # print(si, si[j], cond[j])
            ok = False
            break
    if ok:
        print(si)
        exit()
print(-1)

Measured memory_bytes: 9488
n=int(input())
a = input()

c = 0
for i in range(1,n//2 +1):
  for j in range(n-2*i):
    if a[j] != a[j+i] and a[j+i] != a[j+2*i] and a[j] != a[j+2*i]:
      c+=1

ans = a.count("R") * a.count("G") * a.count("B") - c
print(ans)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
constexpr auto MOD = 1000000007;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VLL;

string s;
long long n, m;
int h, w, k;

int main()
{
  cin >> h >> w >> k;
  vector<vector<char>> s(h, vector<char>(w));
  vector<int> num[310];
  int ans[310][310];
  VI itigo;
  char in;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cin >> in;
      if(in=='#'){
        num[i].push_back(j);
      }
    }
  }
  for (int i = 0; i < h; i++)
  {
    if(num[i].size()){
      itigo.push_back(i);
    }
  }
  vector<pair<PII,PII>> mp;
  int cnt = 1; //いちごのナンバー
  bool flg = 0;//まだいちご現れていない
  int beforeadd = 0;
  int itigoidx = 0;
  for (int i = 0; i < h; i++)
  {
    if (i != itigo[itigoidx]){
      continue;
    }
  int bgn=beforeadd;
  int ed;
  if (itigoidx < itigo.size() - 1)
  {
    ed = itigo[itigoidx+1] - 1;
    }else{
      ed = h - 1;
  }
  int bfridx = 0;
  int ead = 0;
  for (int j = 0; j < num[i].size(); j++)
  {
    if(j<num[i].size()-1){
      ead = num[i][j + 1] - 1;
    }else{
      ead = w - 1;
    }
    mp.push_back(make_pair(make_pair(bgn, bfridx), make_pair(ed, ead)));
    bfridx = ead+1;
  }
  beforeadd = ed+1;
  itigoidx++;
  if(itigoidx==itigo.size())
    {itigoidx = 0;
    break;
    }
  }


  for (int i = 0; i < mp.size(); i++)
  {
    for (int j = mp[i].first.first; j <= mp[i].second.first; j++)
    {
      for (int l = mp[i].first.second; l <= mp[i].second.second; l++)
      {
        ans[j][l] = cnt;
      }
    }
    cnt++;
  }
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cout << ans[i][j] << ' ';
    }
    cout << endl;
  }
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

class Combination{
public:
    int N;
    ll mod;
    vector<ll> fact;

    Combination(int n, ll m) : N(n), mod(m), fact(n+1){
        fact[0] = 1;
        for(ll i=1; i<=N; i++){
            fact[i] = i * fact[i-1] % mod;
        }
    }

    ll POW(ll a, ll b){
        ll res = 1;
        while(b > 0){
            if(b & 1){
                res = res * a % mod;
            }
            a = a * a % mod;
            b >>= 1;
        }
        return res;
    }

    ll combin(int n, int k){
        if(n < 0 || k < 0 || n < k){
            return 1;
        }
        return fact[n] * POW(fact[k] * fact[n-k] % mod, mod - 2) % mod;
    }
};

signed main(){
    int h, w , a, b;
    cin >> h >> w >> a >> b;

    Combination C(h + w, MOD);
    ll ans = C.combin(h + w - 2, h - 1);

    REP(i, b){
        ll sub = C.combin(h - a + i - 1, i) * C.combin(a + w - i - 2, a - 1) % MOD;
        ans = (ans - sub + MOD) % MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
$a=[0]
$a.clear
n=gets.to_i
 
n.times{
        $a=gets.split
        $a.sort
        3.times{|i|
        $a[i]=$a[i].to_i
        }
        $a=$a.sort
        if $a[0]*$a[0]+$a[1]*$a[1]==$a[2]*$a[2]
        puts "YES"
        else
        puts "NO"
        end
}

Measured memory_bytes: 2804
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define SANKOU(n, a, b) cout << ((n) ? (#a) : (#b)) << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>

struct vertex {
    vector<vertex*> edge;
    int cost = 0;
    int n = 0;
};
vertex G[10010];
int N;
int c[10100];
int C[10100];

void solve()
{
    int tc = 0;
    sort(c, c + N);
    queue<int> que;
    int a = N - 1;
    FOR(i, 1, N + 1)
    {
        if ((int)G[i].edge.size() == 1) {
            que.push(G[i].n);
            G[i].cost = c[a];
            a--;
            break;
        }
    }
    while (que.size()) {
        int t;
        t = que.front();
        que.pop();
        int l;
        l = G[t].edge.size();
        FOR(i, 0, l)
        {
            if (G[t].edge[i]->cost == 0) {
                que.push(G[t].edge[i]->n);
                G[t].edge[i]->cost = c[a];
                a--;
            }
        }
    }
    queue<int> q;
    FOR(i, 1, N + 1)
    {
        if ((int)G[i].edge.size() == 1) {
            q.push(i);
            C[i] = 1;
            break;
        }
    }
    while (q.size()) {
        int t;
        t = q.front();
        q.pop();
        int l;
        l = G[t].edge.size();
        for (int i = 0; i < l; i++) {
            if (!C[G[t].edge[i]->n]) {
                tc += min(G[t].cost, G[t].edge[i]->cost);
                C[G[t].edge[i]->n] = 1;
                q.push(G[t].edge[i]->n);
            }
        }
    }
    cout << tc << endl;
    FOR(i, 1, N + 1)
    {
        cout << G[i].cost << endl;
    }
}


signed main()
{
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        int s, t;
        cin >> s >> t;
        G[s].edge.push_back(&G[t]);
        G[t].edge.push_back(&G[s]);
    }
    FOR(i, 0, N)
    {
        cin >> c[i];
    }
    FOR(i, 1, N + 1)
    {
        G[i].n = i;
    }
    solve();
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    int arr[n];
    vector <int> v;
    for (int i=0;i<n;i++){
        cin>>arr[i];
    }
    int count=1;
    for (int i=0;i<n;i++){
        if (arr[i]==count){
            v.push_back(count);
            count++;
        }
    }
    if (!v.empty()){
        cout<<n-count+1;
    }
    else{
        cout<<"-1";
    }
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	ll a,x;
	cin>>x>>a;
	if(x<a)
		cout<<0;
	else
		cout<<10;
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, ans;
	cin >> n;
	if (n % 2 == 0) ans = n;
	else ans = n * 2;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define INF 10000000

int n,m,x1,x2,y1,y2;
int fee[21][21];
int ans[21][21];

int main(){
  scanf("%d %d",&n,&m);

  for(int i=1; i<=n; i++){
    for(int j=1; j<=n; j++){
      fee[i][j] = i==j?0:INF;
    }
  }

  for(int i=0; i<m; i++){
    int a,b,c,d;
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    fee[a][b] = c;
    fee[b][a] = d;
  }

  scanf("%d,%d,%d,%d",&x1,&x2,&y1,&y2);

  for(int k=1; k<=n; k++){
    for(int i=1; i<=n; i++){
      for(int j=1; j<=n; j++){
	if(fee[i][j] > fee[i][k]+fee[k][j]){
	  fee[i][j] = fee[i][k]+fee[k][j];
	}
      }
    }
  }

  printf("%d\n", y1-y2-fee[x1][x2]-fee[x2][x1]);
}

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

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

  int a[N], b[N];
  int c[M], d[M];
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> c[i] >> d[i];
  }

  for (int i = 0; i < N; i++) {
    // Integer.MaxValue 的な定数ないのかな
    int minD = 1000000000;
    int minPoint = 0;
    for (int j = 0; j < M; j++) {
      int tmp = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if (tmp < minD) {
        minPoint = j + 1;
        minD = tmp;
      }
    }

    cout << minPoint << endl;;
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;

class A
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ms = new int[n].Select(_ => Console.ReadLine().Split()).ToArray();
		var x = Console.ReadLine();
		Console.WriteLine(ms.SkipWhile(m => m[0] != x).Skip(1).Sum(m => int.Parse(m[1])));
	}
}


Measured memory_bytes: 28424
#include<stdio.h>
#define MAX_i 50002

typedef struct process{
    char name[11];
    int time;
}pr;
void enqueue(pr x);
pr dequeue();
pr p[MAX_i];
int head,tail;

int main(void){
    int n,q,i,sum=0;
    pr x;
    
    scanf("%d %d",&n,&q);
    for(i=0;i<n;i++){
        scanf("%s %d",p[i].name,&p[i].time);
    }
    head=0;
    tail=n;
    while(head!=tail){
        x=dequeue();
        if(x.time<=q){
            sum+=x.time;
            printf("%s %d\n",x.name,sum);
        }else{
            sum+=q;
            x.time-=q;
            enqueue(x);
        }
    }
    return 0;
}

void enqueue(pr x){
    p[tail]=x;
    if(tail+1==MAX_i){
        tail=0;
    }else{
        tail++;
    }
}

pr dequeue(){
    if(head+1==MAX_i){
        head=0;
        return p[MAX_i-1];
    }else{
        head++;
        return p[head-1];
    }
}



Measured memory_bytes: 2628
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

double Length(double x1, double y1, double x2, double y2) {

    double X;

    X = sqrt(pow((x2-x1), 2) + pow((y2-y1), 2));

    return X;
}

int main () {

    double x1, y1;
    double x2, y2;

    cin >> x1 >> y1 >> x2 >> y2;

    double answer = Length(x1, y1, x2, y2);

    cout << fixed;
    cout << setprecision(5) << answer << endl; 

    return 0;

}


Measured memory_bytes: 3284
//ITP1-11-B: Dice 2
//2019.05.22

#include <stdio.h>

void throwdice(char, int*);

typedef struct dice_ {
  int d[6];
} dice;

int main(void){
  int q;
  int top, south, ans_east;
  dice dice1;

  for (int i = 0; i < 6; i++) scanf("%d", &dice1.d[i]);

  scanf("%d\n", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d %d\n", &top, &south);
    for (int j = 0; j < 6; j++) {
      if (dice1.d[j] == top) {
        switch (j) {
          case 0:
            break;
          case 1:
            throwdice('N', &dice1.d[0]);
            break;
          case 2:
            throwdice('W', &dice1.d[0]);
            break;
          case 3:
            throwdice('E', &dice1.d[0]);
            break;
          case 4:
            throwdice('S', &dice1.d[0]);
            break;
          case 5:
            throwdice('N', &dice1.d[0]);
            throwdice('N', &dice1.d[0]);
            break;
        }
      }
    }
    for (int j=0; j < 4; j++) {
      if (dice1.d[1] == south) {
        ans_east = dice1.d[2];
        break;
      }else{
        throwdice('R', &dice1.d[0]);
      }
    }
    printf("%d\n", ans_east);
  }

  /*d[0] = top
    d[1] = south
    d[2] = east
    d[3] = west
    d[4] = north
    d[5] = bottom */

  return 0;
}

void throwdice(char c, int *d){
  int tmp[6];
  for (int i = 0; i < 6; i++) {
    tmp[i] = d[i];
  }

  if (c == 'N') {
    d[0] = tmp[1]; //top
    d[1] = tmp[5]; //south
    d[2] = tmp[2]; //east
    d[3] = tmp[3]; //west
    d[4] = tmp[0]; //north
    d[5] = tmp[4]; //bottom
  }else if (c == 'E') {
    d[0] = tmp[3]; //top
    d[1] = tmp[1]; //south
    d[2] = tmp[0]; //east
    d[3] = tmp[5]; //west
    d[4] = tmp[4]; //north
    d[5] = tmp[2]; //bottom
  }else if (c == 'W') {
    d[0] = tmp[2]; //top
    d[1] = tmp[1]; //south
    d[2] = tmp[5]; //east
    d[3] = tmp[0]; //west
    d[4] = tmp[4]; //north
    d[5] = tmp[3]; //bottom
  }else if (c == 'S') {
    d[0] = tmp[4]; //top
    d[1] = tmp[0]; //south
    d[2] = tmp[2]; //east
    d[3] = tmp[3]; //west
    d[4] = tmp[5]; //north
    d[5] = tmp[1]; //bottom
  }else if (c == 'R'){
    d[0] = tmp[0]; //top
    d[1] = tmp[3]; //south
    d[2] = tmp[1]; //east
    d[3] = tmp[4]; //west
    d[4] = tmp[2]; //north
    d[5] = tmp[5]; //bottom
  }
}



Measured memory_bytes: 2032
n=input().split(" ")

A=int(n[0])
B=int(n[1])
C=int(n[2])

if A < B:
    if C<A or B<C:
        print("No")
    else:
        print("Yes")
else:
    if B<C<A:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
import std.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;

void main() {
    int N; readf("%d\n", &N);
    int[] d = new int[100003];
    int[] r = new int[100003];
    foreach (i; 0 .. N) {
        int a, b; readf("%d %d\n", &a, &b);
        d[a]++;
        d[b + 1]--;
    }
    int c = 0;
    foreach (i; 2 .. 100003) {
        c += d[i];
        r[i] = c;
    }
    int ans = 0;
    foreach (i; 2 .. 100003) {
        if (r[i] >= i - 1) {
            ans = max(ans, i - 1);
        }
    }
    ans.writeln;
}

Measured memory_bytes: 1764
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
using namespace std;


int main(){
    std::list<char> s;
    bool rb = false;
    string s1;
    int q;
    cin >> s1 >> q;
    rep(i,s1.size()){
        s.push_back(s1[i]);
    }


    rep(i,q){
        int t,f;
        char c;
        cin >> t;
        if(t == 1){
            rb = 1-rb;
        }
        if(t== 2){
            cin >> f >>c;
            if(rb){
                f = 3-f;
            }
            if(f==1){
                s.push_front(c);
            }else{
                s.push_back(c);
            }
        }
    }
    if(rb){
        reverse(s.begin(),s.end());
    }
    std::list<char>::iterator itr;
    for (itr = s.begin(); itr != s.end(); itr++) {
        std::cout << *itr ;
    }
    cout <<endl;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> L(N);
	for(int i = 0;i < N;i++){
		cin >> L[i];
	}
	puts(*max_element(L.begin(), L.end()) * 2 < accumulate(L.begin(), L.end(), 0) ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine().Split(' ');
			int R = int.Parse(input[0]);
			int G = int.Parse(input[1]);
			int B = int.Parse(input[2]);
			int N = int.Parse(input[3]);

			// R * r + G * g + B * b = N
			int count = 0;
			int rMax = N / R;
			for (int r = 0; r <= rMax; r++)
			{
				int gMax = (N - R * r) / G;
				for (int g = 0; g <= gMax; g++)
				{
					if ((N - R * r - G * g) % B == 0)
					{
						count++;
					}
				}
			}
			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	 int n ; cin >> n; 
	 cout << (n+1)/2 << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3604
n = int(input())
alp = [chr(ord("a") + x) for x in range(26)]

def dfs(S):
    if len(S) == n:
        print(S)
    else:
        max_s = ord(max(S)) - 96
        #print(max_s)
        for i in range(max_s + 1):
            dfs(S + alp[i])

dfs("a")

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


int main(){
  int n;
  long long d;
  cin>>n>>d;
  int ans=0;
  for(int i=0;i<n;i++){
  long long x,y;
    cin>>x>>y;
    if(x*x+y*y<=d*d)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3156
#include<iostream>

using namespace std;

int main(void) {
    int a, b;
    while(cin >> a >> b) {
        int sum = a + b;

        int c = 1;
        while (9 < sum) {
            sum = sum / 10;
            c++;
        }

        cout << c << endl;
    }
}

Measured memory_bytes: 3052
// AtCoder My Practice
// author: Leonardone @ NEETSDKASU

fn modpow(x: i64, p: i64, m: i64) -> i64 {
	if p == 0 { return 1; }
    if p % 2 == 0 {
    	modpow((x * x) % m, p / 2, m)
    } else {
    	(x * modpow(x, p - 1, m)) % m 
    }
}
struct ModBinomial {
	m: i64,
	f: Vec<i64>,
    p: Vec<i64>,
}
impl ModBinomial {
	fn new(n: i64, m: i64) -> ModBinomial {
    	let mut f = vec![1; n as usize + 1];
        let mut p = vec![1; f.len()];
        for i in 2..f.len() {
        	f[i] = (i as i64 * f[i - 1]) % m;
            p[i] = modpow(f[i], m - 2, m);
        }
        ModBinomial { m: m, f: f, p: p }
    }
    fn bin(&self, n: i64, k: i64) -> i64 {
    	(((self.f[n as usize] * self.p[k as usize])
        	% self.m) * self.p[(n - k) as usize]) % self.m
    }
}


fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let m = 998244353_i64;
    let n = get!();
    let a = get!();
    let b = get!();
    let k = get!();
    let mb = ModBinomial::new(300_000, m);
    let mut ans = 0;
    for ac in 0..n+1 {
    	let rem = k - ac * a;
        if rem < 0 { continue; }
        let bc = rem / b;
        if bc * b != rem { continue; }
        if bc > n { continue; }
        if ac + bc > n + n { continue; }
        ans += (mb.bin(n, ac)
           	     * mb.bin(n, bc)
                 ) % m;
        ans %= m;
    }
    if k == 0 { ans = 1; }
    println!("{}", ans);
}

Measured memory_bytes: 12668
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
#define SIZE 1005
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
int n, m, k;
string s;
int main() {
	io(); cin >> n >> m;
	vector<double> a(n);
	double sum = 0;
	for (auto& i : a) cin >> i, sum += i;
	sum /= (4.0 * m);
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	rep(i, 0, (m - 1)) {
		if (a[i] < sum) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  s.erase(n-2,2);
  while(s.size()>0) {
    int m = s.size();
    if(s.substr(0,m/2)==s.substr(m/2)) {
      cout << m << endl;
      return 0;
    }
    s.erase(m-2,2);
  } 
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    ll n = 0,b;
    cin>>n>>b;
    ll a = 6;
    pr(a-n-b);
}


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

const int INF = numeric_limits<int>::max();

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> arr(n);
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    if (arr[i] < 0) ++cnt;
  }
  int min_time = INF;
  for (int i = 0; i <= cnt; ++i) {
    if (cnt + k - i > n) continue;
    int minus_time = 0;
    if (i > 0) minus_time = abs(arr[cnt - i]);
    int plus_time = 0;
    if (k - i > 0) plus_time = arr[cnt + k - i - 1];
    int total_time = plus_time + minus_time + min(plus_time, minus_time);
    min_time = min(min_time, total_time);
  }
  cout << min_time << endl;
}


Measured memory_bytes: 640
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i];
    if (i != vec.size() - 1) os << ',';
  }
  os << '}';
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
// constant
constexpr int INF = std::numeric_limits<int>::max() / 2;  // 1.073741823e9
constexpr int64 INF64 = std::numeric_limits<int64>::max() / 2;  // 4.611686018427387903e18
constexpr int MOD = 1000000007;
constexpr double pi = 3.141592653589793238;

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

  double a, b, x; cin >> a >> b >> x;
  if (x * 2 >= a * a * b) {
    cout << setprecision(15) << 90 - atan2(a, (2 * a * a * b - 2 * x) / (a * a)) * 180 / pi << endl;
  } else {
    cout << setprecision(15) << (atan2(b,(2 * x) / (a * b)) * 180 / pi) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
N,M=list(map(int,input().split()))
requests=[]
for i in range(M):
    requests.append(list(map(int,input().split())))

requests.sort(key=lambda x:x[1])
answer=1
pulldown=(requests[0][1]-1)-1
for i in range(1,M):
    if requests[i][0]-1 <= pulldown:
        pass
    else:
        pulldown=(requests[i][1]-1)-1
        answer+=1
print(answer)

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

int main() {
  int n,k;
  string s;
  cin >> n >> s >> k;
  char c=s[k-1];
  for (int i; i<n; i++){
    if (s[i]!=c){
      s[i]='*';
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

const int64_t kMod = 1000000007LL;
// const int64_t kMod = 998244353LL;
struct Mint {
  int64_t value;
  Mint(int64_t value = 0LL) : value((value % kMod + kMod) % kMod) {}
  Mint operator-() const {
    return Mint(-value);
  }
  Mint &operator+=(const Mint rhs) {
    if ((value += rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator-=(const Mint rhs) {
    if ((value += kMod - rhs.value) >= kMod) {
      value -= kMod;
    }
    return *this;
  }
  Mint &operator*=(const Mint rhs) {
    (value *= rhs.value) %= kMod;
    return *this;
  }
  Mint operator+(const Mint rhs) const {
    return Mint(*this) += rhs;
  }
  Mint operator-(const Mint rhs) const {
    return Mint(*this) -= rhs;
  }
  Mint operator*(const Mint rhs) const {
    return Mint(*this) *= rhs;
  }
  Mint Pow(int64_t p) const {
    if (p == 0LL) {
      return 1LL;
    } else if (p < 0LL) {
      return Pow(-p).Pow(kMod - 2LL);
    }
    Mint temp = Pow(p >> 1LL);
    temp *= temp;
    if (p & 1LL) {
      temp *= (*this);
    }
    return temp;
  }
  Mint Inv() const {
    return Pow(kMod - 2LL);
  }
  Mint &operator/=(const Mint a) {
    return *this *= a.Inv();
  }
  Mint operator/(const Mint a) const {
    return Mint(*this) /= a;
  }
};

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

  int64_t N;
  string S1, S2;
  cin >> N >> S1 >> S2;
  pair<Mint, Mint> current;
  if (S1[0] == S2[0]) {
    current.first = 3;
    current.second = 0;
  } else {
    current.first = 0;
    current.second = 6;
  }
  for (int64_t i = 1; i < N; ++i) {
    pair<Mint, Mint> previous;
    swap(current, previous);
    if (S1[i] == S2[i]) {
      current.first = previous.first * 2 + previous.second;
      current.second = 0;
    } else {
      if (S1[i] != S1[i - 1]) {
        current.first = 0;
        current.second = previous.first * 2 + previous.second * 3;
      } else {
        current = previous;
        // DO NOTHING
      }
    }
    // cerr << "i=" << i << ": " << current.first.value << ", " << current.second.value << endl;
  }
  cout << (current.first + current.second).value << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define Abs(x) ((x) > 0 ? (x) : -(x))
#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
typedef long long ll;

int sort(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

int
main(int argc, char *argv[])
{
  int n, p[100], a[100];
  scanf("%d", &n);
  REP(i, n){
    scanf("%d", &p[i]);
    a[i] = p[i];
  }

  qsort(p, n, sizeof(int), sort);
  int flag = 0;

  for(int i = 0; i < n; i++){
    if(a[i] != p[i]) flag++;
  }

  if(flag == 2 || flag == 0) printf("YES\n");
  else printf("NO\n");

  return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var n int
	var vArr []int
	var cArr []int
	vTotal := 0
	cTotal := 0

	fmt.Scanf("%d", &n)
	vArr = make([]int, n)
	cArr = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &vArr[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &cArr[i])
	}

	for i := 0; i < n; i++ {
		if vArr[i] > cArr[i] {
			vTotal += vArr[i]
			cTotal += cArr[i]
		}
	}

	fmt.Println(vTotal - cTotal)

}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
int GCD(int a, int b) {
	return b ? GCD(b, a%b) : a;
}
//sort(a, a + N, greater<int>())   // descend
//sort(a, a+N)                    //  ascend

using ll = long long;
using namespace std;

int l[110000];
int r[110000];
int ans[110000];
int pp = 0;
int tmp1 = 1100000;
int tmp2 = 0;
int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++) cin >> l[i] >> r[i];

	for (int i = 1; i <= m; i++) {
		tmp2 = max(tmp2, l[i]);
	}
	for (int i = 1; i <= m; i++) {
		tmp1 = min(tmp1, r[i]);
	}
	if(tmp1-tmp2+1>=0) cout << tmp1 - tmp2 + 1;
	else cout << 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

#define N 10000

int main(){
  int n1,n2,num1[N],num2[N],i,j,count=0;

  scanf("%d",&n1);

  for(i=0;i<n1;i++){
    scanf("%d",&num1[i]);
  }

  scanf("%d",&n2);

  for(i=0;i<n2;i++){
    scanf("%d",&num2[i]);
  }

  for(i=0;i<n2;i++){
    for(j=0;j<n1;j++){
      if(num2[i]==num1[j]){
	count++;
break;
      }
    }
  }

  printf("%d\n",count);
  
  return 0;
}

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

const int mod = 998244353;
long long pow_mod(long long base,long long exp,long long mod){
    long long res = 1;
    while(exp>0){
        if(exp & 1)res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

int main(){

    
    long long n;
    long long ans = 1;
    std::map<long long,long long> um;
    std::cin>>n;
    for(long long i=0;i<n;i++){
        long long tmp;
        std::cin>>tmp;
        um[tmp]++;
        if(i && !tmp)ans = 0;//頂点2~で1との距離が0の場合
        if(!i && tmp)ans = 0;//頂点1が0で無い場合
    }

    for(long long i=1;i<n;i++){
        ans *= pow_mod(um[i-1],um[i],mod);
        ans %= mod;
    }

    std::cout<<ans<<std::endl;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,k;
int a[N],ans=999999999;
inline int Mx(int x,int y){return x>y?x:y;}
inline int Mi(int x,int y){return x<y?x:y;}
int read()
{
	int x=0,w=1;char ch=getchar();
	while(ch>'9'||ch<'0') {if(ch=='-') w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*w;
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;++i) a[i]=read();
	for(int i=1;i<=n-k+1;++i)
	{
		if(a[i]<=0&&a[i+k-1]<=0) ans=Mi(ans,0-a[i]);
		if(a[i]<=0&&a[i+k-1]>=0) ans=Mi(ans,Mi(((0-a[i])<<1)+a[i+k-1],(a[i+k-1]<<1)+0-a[i]));
		if(a[i]>=0&&a[i+k-1]>=0) ans=Mi(ans,a[i+k-1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    string s[h];
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
    }
    int ans = 0;
    for (int i = 0; i < (1 << h); i++)
    {
        for (int j = 0; j < (1 << w); j++)
        {
            int count = 0;
            for (int k = 0; k < h; k++)
            {
                for (int l = 0; l < w; l++)
                {
                    if (i & (1 << k)) // to check if kth bit is set or not
                    {
                        continue;
                    }
                    if (j & (1 << l)) // to check if lth bit is set or not
                    {
                        continue;
                    }
                    if (s[k][l] == '#')
                    {
                        count++;
                    }
                }
            }
            if (count == k)
            {
                ans++;
            }
        }
    }
    cout << ans;
}

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

int main(int argc, const char * argv[]) {
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        string st; cin >> st;
        if (st == "Y") {
            cout << "Four" << endl;
            return 0;
            break;
        }
    }
    cout << "Three" << endl;
    return 0;
}


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

#define vi vector<int>
#define pb push_back

typedef long long ll;
using namespace std;



int main(){
    int n;
    cin >> n;
    int cnt;
    string str;
    rep(i,n){
        cin >> str;
        if(str == "A") cnt++;
        else cnt--;
        if(cnt < 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    if(cnt == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define FOR(I,A,B) for(int I=int(A);I<int(B);++I)
#define FORR(I,A,B) for(int I=int(B-1);I>=int(A);--I)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int r,c;
	cin >> r >> c;
	int sum[c]={};
	FOR(i,0,r){
		int s,a;
		cin >> a;
		cout << a;
		s = a;
		sum[0] += a;
		FOR(j,1,c){
			cin >> a;
			cout << " " << a;
			s += a;
			sum[j] += a;
		}
		cout << " " << s << '\n';
	}
	r = sum[0];
	cout << sum[0];
	FOR(i,1,c){
		cout<<' '<<sum[i];
		r += sum[i];
	}
	cout << " " << r << '\n';
}



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

int main()
{
	int n;
	bool result = false;
	int cnt = 0;
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		int first, second;
		cin >> first >> second;
		if (first == second) {
			cnt++;
			if (cnt >= 3) {
				result = true;
			}
		}
		else {
			cnt = 0;
		}
	}

	if (result) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		String a = "";
		Integer count = 0;
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8))) {
			a = br.readLine();
		}
		for(char x:a.toCharArray()) {
			if(x == '2') {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 22612