akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long int X, year;
   cin >> X;
    double rate=1.01;
    long int money=100;
    for(year=0;money< X;year++){
      money=money*rate;
    }
      
      cout << year << endl;
    
    }



Measured memory_bytes: 3596
// AOJ CGL_7_D Cross Points of a Circle and a Line
// 2018.5.3 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef struct { double x, y; } PP;
typedef struct { PP s, e; } SEG, LINE;
typedef struct { double x, y, r; } C;

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define INF 1e8
#define EPS 1e-8
#define EQ(a,b)		(fabs((a)-(b))<EPS)

int dcmp(double x) { if (fabs(x) < EPS) return 0; return x <= 0 ? -1 : 1; }
PP vset(double x, double y) { PP r; r.x = x, r.y = y; return r; }
PP vadd(PP p1, PP p2) { PP r; r.x = p1.x + p2.x, r.y = p1.y + p2.y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
PP vsmul(PP p, double k) { PP r; r.x = p.x * k, r.y = p.y * k; return r; }
double vabs(PP a) { return hypot(a.x, a.y); }
double dist(PP p1, PP p2) {	return vabs(vsub(p1, p2)); }
double cross(PP a, PP b) { return a.x * b.y - a.y * b.x; }
double dot(PP a, PP b) { return a.x * b.x + a.y * b.y; }
double norm(PP a) { return a.x * a.x + a.y * a.y; }

double distancePL(PP p, LINE ln)
{
	PP a = vsub(ln.e, ln.s);
	return fabs(cross(vsub(p, ln.s), a)) / vabs(a);
}

PP projection(PP p1, PP p2, PP p)
{
	PP p2p1 = vsub(p2, p1);
	PP pp1 = vsub(p, p1);
	return vadd(p1, vsmul(p2p1, dot(pp1, p2p1)/norm(p2p1)));
}

int cmp(PP *a, PP *b)
{
	if (EQ(a->x, b->x)) return dcmp(a->y - b->y);
	return dcmp(a->x - b->x);
}

void crossPointCL(PP *p, C c, LINE line)
{
	PP c0 = vset(c.x, c.y);
	PP p0;
	double a, b;

	a = distancePL(c0, line), b = sqrt(c.r*c.r - a*a);
	p0 = projection(line.s, line.e, c0);
	p[0] = vadd(p0, vsmul(vsub(line.s, line.e), b/dist(line.s, line.e)));
	p[1] = vadd(p0, vsmul(vsub(line.e, line.s), b/dist(line.s, line.e)));
}
		
int main()
{
	int q, i;
	C c;
	PP p[2];
	LINE line;

	c.x = in(), c.y = in(), c.r = in();
	q = in();
	while (q--) {
		line.s.x = in(), line.s.y = in(), line.e.x = in(), line.e.y = in();

		crossPointCL(p, c, line);

		qsort(p, 2, sizeof(PP), cmp);
		for (i = 0; i < 2; i++) {
			printf("%.10lf %.10lf", p[i].x, p[i].y);
			putchar(' ');
		}
		putchar('\n');
	}
	return 0;
}


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

int main() {
  int n;
  int ans = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if ((i+1)%2!=0 && a[i]%2!=0) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

void replace_all(std::string& str, const std::string& from, const std::string& to) {
    std::size_t start_pos = 0;
    while( (start_pos = str.find(from, start_pos)) != std::string::npos ) {
        str.replace(start_pos, from.length(), to);
        start_pos += to.length();
    }
}

int main(void) {
    u_int n;
    std::string str;
    const std::string from  = "Hoshino";
    const std::string to    = "Hoshina";

    std::cin >> n; std::cin.ignore(); // ignore next newline character
    for (u_int i = 0; i < n; ++i) {
        std::getline(std::cin, str);
        replace_all(str, from, to);
        std::cout << str << std::endl;
    }

    return 0;
}

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


int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    for (auto &&x : v)
    {
        cin >> x;
    }

    int min = v[0],ans=-1000000000;
    for (int i = 1; i < N; i++)
    {
        if(v[i]-min>ans){
            ans = v[i] - min;
        }
        if(min>v[i]){
            min = v[i];
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 3612
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n=int(input())
a=sorted(list(map(int,input().split())))
b=a[n-1]
a.pop(n-1)
ans=0
for i in range(n-1):
    if abs(b/2-a[ans])>abs(b/2-a[i]):
        ans=i
print(str(b)+" "+str(a[ans]))


Measured memory_bytes: 14180
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int i,n,k,a[200020]={};
    scanf("%d %d",&n,&k);
    for(i=1; i<=n; i++){
        scanf("%d",&a[i]);
    }
    for(i=k+1; i<=n; i++){
        if(a[i-k]<a[i])printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 2444
#create date: 2020-04-12 21:11

import sys
stdin = sys.stdin
from math import gcd

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    k = ni()
    ans = 0
    for a in range(1,k+1):
        for b in range(1, k+1):
            for c in range(1, k+1):
                g = gcd(a, b)
                ans += gcd(c, g)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9200
n = int(input())
h = list(map(int, input().split()))
def chmin(a, b):
    if a > b:
        return b
    else:
        return a

dp = [float('inf')] * n
dp[0] = 0
for i in range(0, n - 1):
    dp[i + 1] = chmin(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
    if i < n - 2:
        dp[i + 2] = chmin(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))

print(dp[n - 1])

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

#define INF (INT64_MAX)
#define MOD (1000000000+7)
#define MAX 100000

int N;
vector<int> g[MAX + 1];

long long memo[MAX + 1][2];

long long dfs( int i, int f, int p )
{
	if( memo[i][f] >= 0 ) {
		return memo[i][f];
	}
	long long res1 = 1;
	if( f == 0 ) {
		res1 = 0;
	}
	long long res2 = 1;
	for( int j = 0; j < g[i].size(); j++ ) {
		int y = g[i][j];
		if( y == p ) {
			continue;
		}
		if( f ) {
			res1 = ( res1 * dfs( y, 0, i ) ) % MOD;
		}
		res2 = ( res2 * dfs( y, 1, i ) ) % MOD;
	}
	return memo[i][f] = (res1 + res2) % MOD;
}

int main() {
	cin >> N;
	for( int i = 0; i < N - 1; i++ ) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		g[x].push_back( y );
		g[y].push_back( x );
	}

	memset( memo, -1, sizeof( memo ) );
	long long ans = dfs( 0, 1, -1 );

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 15616
import java.util.*;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
      int [] a = new int [5];
      int x=0 ;
      Scanner sc = new Scanner(System.in);
      for(int i=0;i<5;i++){
        a[i] = sc.nextInt();
        
      }
      for(int i =0;i<5;i++){
        if(a[i]==0){
          x = i+1;
        }
      }
      System.out.println(x);

      
     
    }
   
    
       
    
}

Measured memory_bytes: 27080
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  // 入力
  ll D;
  cin >> D;
  vll C(26);
  rep(i, 26) cin >> C[i];
  vvll S(D, vll(26));
  rep(i, D) rep(j, 26) cin >> S[i][j];

  vll T(D);  // その日に行うコンテスト
  rep(i, D) {
    T[i] = (ll)(rand() % 26) + 1;
  }

  // auto calc = [&]() -> ll {
  //   vll la(26, 0);
  //   ll res = 0;
  //   rep(i, D + 1) {
  //     if (i == 0) continue;
  //     ll t = T[i - 1];
  //     res += S[i - 1][t];
  //     la[t] = i;
  //     rep(j, 26) {
  //       res -= C[j] * (i - la[j]);
  //     }
  //   }
  //   return res;
  // };

  // rep(i, 5) {
  //   ll original = calc();
  //   ll index = rand() % D;
  //   ll before_contest = T[index];
  //   ll after_contest = rand() % 26 + 1;
  //   T[index] = after_contest;
  //   ll after = calc();
  //   if (original < after) {
  //     continue;
  //   } else {
  //     T[index] = before_contest;
  //   }
  // }

  rep(i, D) {
    COUT(T[i]);
  }

  return 0;
}

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

using namespace std;

int n, cap, w[110], v[110];
long long dp[1000001][110];

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

    w[0] = 0;
    v[0] = 0;
    for(int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];
    
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i <= cap; i++) dp[i][0] = 0;
    for(int j = 0; j <= n; j++) dp[0][j] = 0;

    for(long long i = 1; i <= cap; i++){
        for(int j = 1; j <= n; j++){
            if(w[j] > i) dp[i][j] = dp[i][j - 1];
            else dp[i][j] = max(v[j] + dp[i - w[j]][j - 1], dp[i][j - 1]);
        }
    }
    cout << dp[cap][n] << endl;

    return 0;
}

Measured memory_bytes: 859648
using static System.Math;
using static System.Console;
class Z
{
	const int 無限 = 1000000007;
	static void Main() => WriteLine(F(ReadLine()));
	static int F(string S)
	{
		var N = S.Length;
		var bit = new int[N + 1];
		for (var i = 0; i < N; i++) bit[i + 1] = bit[i] ^ (1 << (S[i] - 'a'));
		var s = 0;
		for (var i = 0; i < 26; i++) if ((bit[N] & (1 << i)) != 0) s++;
		if (s <= 1) return 1;
		var dp = new int[N + 1];
		var tb = new int[1 << 26];
		for (var i = 1; i <= N; i++) dp[i] = 無限;
		for (var i = 1; i < (1 << 26); i++) tb[i] = 無限;
		for (var i = 1; i <= N; i++)
		{
			for (var j = 0; j < 26; j++) dp[i] = Min(dp[i], tb[bit[i] ^ (1 << j)] + 1);
			tb[bit[i]] = Min(tb[bit[i]], dp[i]);
		}
		return dp[N];
	}
}


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

int main(){

string N;
cin >> N;

int S = 0;

for(int i = 0; i < N.size(); i++){ 
     S += N.at(i) - '0';
}

if(stoi(N) % S == 0) cout << "Yes" << endl;
else cout << "No" << endl;

}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    long double l;
    cin >> l;
    long double d = l / 3;
    printf("%.10Lf\n", d * d * d);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n, ans, c = INF;
bool ok = true;
int main() {
	cin >> n;
	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		if (a != b)ok = false;
		ans += b;
		if (a > b)c = min(c, b);
	}
	if (ok)cout << 0 << endl;
	else {
		if (c != INF)ans -= c;
		cout << ans << endl;
	}
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
map<string,ll>mp[3];
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n;
 	cin>>n;
 	string s;
 	cin>>s;
 	for(ll i=0;i<n;i++)
 	{
 		for(char j='0';j<='9';j++)
 		{
 			for(char k='0';k<='9';k++)
 			{
 				string token="";
 				token+=j;
 				token+=k;
 				if(mp[1].find(token)!=mp[1].end())
 				{
 					string app="";
 					app+=j;
 					app+=k;
 					app+=s[i];
 					mp[2][app]++;	
 				}
 			}
 		}
 		for(char j='0';j<='9';j++)
 		{
 			string token="";
 			token+=j;
 			if(mp[0].find(token)!=mp[0].end())
 			{
 				string app="";
 				app+=j;
 				app+=+s[i];
 				mp[1][app]++;
 			}
 		}
 		string temp="";
 		temp+=s[i];	
 		mp[0][temp]++;
 	}
 	cout<<mp[2].size()<<endl;
    return 0;
}

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

int main(){
    int A,B;
    
    cin >> A >> B;
    for(int i = 1;i <= max((A/0.08) + 1,(B/0.1) + 1);i++){
        if(int(i * 0.08 ) == A && int(i * 0.1) == B){
            cout << i << endl;
            return 0;
        }

    }
    cout << "-1" << endl;
    return 0;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = Integer.parseInt(in.nextLine());
        final long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextLong();
        }
        Arrays.sort(arr);
        int idx = n - 1;
        int count = n - 2;
        long res = arr[idx];
        while (count >= 2) {
            res += 2 * arr[--idx];
            count -= 2;
        }
        if (count == 1) {
            res += arr[idx - 1];
        }
        System.out.println(res);
    }
}


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

int main() {
    int N;
    std::cin >> N;

    uint64_t L[N+1];
    L[0] = 2;
    L[1] = 1;
    for (int i = 2; i <= N; ++i) {
        L[i] = L[i-1] + L[i-2];
    }

    std::cout << L[N] << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int N, i;
    cin >> N;
    string arr[N];
    for (i = 0; i < N; i++)
    {
        cin >> arr[i];
    }
    int arrCount[4];
    for (i = 0; i < 4; i++)
    {
        arrCount[i] = 0;
    }
    
    for (i = 0; i < N; i++)
    {
        if (arr[i].compare("AC") == 0)
        {
            arrCount[0]++;
        }
        else if (arr[i].compare("WA") == 0)
        {
            arrCount[1]++;
        }
        else if (arr[i].compare("TLE") == 0)
        {
            arrCount[2]++;
        }
        else if (arr[i].compare("RE") == 0)
        {
            arrCount[3]++;
        }
    }
    cout << "AC x " << arrCount[0] << endl;
    cout << "WA x " << arrCount[1] << endl;
    cout << "TLE x " << arrCount[2] << endl;
    cout << "RE x " << arrCount[3] << endl;

    return 0;
}

Measured memory_bytes: 6720
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

typedef long long ll;
using namespace std;
#define mod 1000000007

int main(){
    int n;
    cin >> n;
    
    cout << 3*n*n << endl;
    return 0;
}







Measured memory_bytes: 256
void main() {
  problem();
}

void problem() {
  auto N = scan!ulong;

  ulong solve() {
    // Sum_{k=1..n} k/2 * floor(n/k) * floor(1 + n/k)
    ulong ans;
    foreach(k; 1..N+1) {
      ulong x = N / k;
      ans += x * (2*k + (x - 1) * k) / 2;
    }
    return ans;
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Queue = Tuple!(long, "from", long, "to");

// -----------------------------------------------


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int n; cin >> n;
    vi a(n);
    vll s(n);
    rep(i, n) {
        cin >> a[i];
        s[i] = a[i] + (i==0?0:s[i-1]);
    }

    ll ans[2] = {0, 0};
    ll change[2] = {0, 0};
    rep(i, n) {
        rep(j, 2) {
            ll a = ((i+j)%2==1) ? -1 : 1;
            ll sum = s[i]+change[j];
            if (sum == 0) {
                change[j] += a;
                ans[j] += 1;
            } else if ((sum < 0 && (i+j)%2==0) || (sum > 0 && (i+j)%2==1)){
                change[j] += a - sum;
                ans[j] += abs(a - sum);
            }
        }
    }
    
    cout << min(ans[0], ans[1]) << endl;
}


Measured memory_bytes: 1408
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,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)]
#import itertools
#import heapq
#import numpy as np
#INF = float("inf")
def primes(n):#nまでの素数を列挙0は入れちゃダメ
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,int(n**(0.5)+1)):
        if not is_prime[i]:
            continue
        for j in range(i*2,n+1,i):
            is_prime[j] = False
    return is_prime
prime = primes(10**5)
li = [0]*(10**5)
for i in range(3,10**5,2):
    n = int((i-1)/2)
    if prime[i] and prime[int((i+1)/2)]:
        li[n] = li[n-1]+1
    else:
        li[n] = li[n-1]
Q = int(input())
for _ in range(Q):
    l,r = map(int,input().split())
    ln = int((l-1)/2)
    rn = int((r-1)/2)
    if ln == 0:
        print(li[rn])
    else:
        print(li[rn]-li[ln-1])

Measured memory_bytes: 51416
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n, a;
  cin >> n >> a;
  n %= 500;
  if (n <= a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ninnzuu = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int N = ninnzuu[0];
            int K = ninnzuu[1];
            int[] line = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int cnt = 0;
            for(int i = 0; i < N; i++)
            {
                if(line[i] >= K)
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 19168
S = gets.chomp
s_dup = S
T = gets.chomp
dist = T.size - 1
# p S[0..(T.size - 1)]
# p S[0..(0 + T.size - 1)]

# (S.size - dist).times do |i|
# binding.pry
(S.size - T.size).downto(0) do |i|
  # p S[i, T.size]

  check = true
  i.upto(i + dist).each do |j|
    if S[j] != "?" && S[j] != T[j - i]
      check = false
    end
  end
  if check
    s_dup[i, T.size] = T
    # puts s_dup.gsub!(/\?/, "a") # 間違い
    s_dup.each_char.with_index do |c,i|
      s_dup[i] = "a" if s_dup[i] == "?"
    end
    puts s_dup
    exit
  end
end
puts "UNRESTORABLE"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef vector<vector<ll> > matrix;
const int mod = 1e9+7;
ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){ans = ans*base;ans = ans%mod;}
        base *= base;base%=mod;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}

double pi = 3.141592653589793238462643;
double error = 0.0000001;
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/* -------Template ends here-------- */

const int M = 100001;
const int N = 1234567;

int a[12345], b[N], c[N];


int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
    //cin.sync_with_stdio(false);
    //cin.tie(0); cout.tie(0);

    int h, w, n;
    cin >> h >> w >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    vector <vector <int> > vec(h);
    for(int i = 0; i < h; i++) vec[i].resize(w);
    int i1 = 0, ni = 0;
    int t = h*w;
    while(t){
            //cout << i1 << endl;
          for(int j = 0; j < w; j++){
              t--;
              if(!a[ni]) ni++;
              vec[i1][j] = ni+1;
              a[ni]--;
              //cout << ni << " " << a[ni] << endl;
          }

          i1++;
          if(t == 0) break;
          for(int j = w-1; j >= 0; j--){
              t--;
              if(!a[ni]) ni++;
              vec[i1][j] = ni+1;
              a[ni]--;
          }
           i1++;
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << vec[i][j] << " ";
        }
        cout << endl;
    }
}



Measured memory_bytes: 384
a=int(input())

if 400<=a<=599:
	print(8)
elif 600<=a<=799:
	print(7)
elif 800<=a<=999:
	print(6)
elif 1000<=a<=1199:
	print(5)
elif 1200<=a<=1399:
	print(4)
elif 1400<=a<=1599:
	print(3)
elif 1600<=a<=1799:
	print(2)
elif 1800<=a<=1999:
	print(1)

Measured memory_bytes: 9128
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	long long n, k;
	cin >> n >> k;

	long long ans = 0;
	for (int i = k + 1; i <= n; i++) {
		ans += n / i * max(0LL, i - k);
		ans += max(0LL, n % i + 1 - k);
	}
	ans -= k == 0 ? n : 0;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <fstream>
#include <set>
#include <stack>
#include <queue>
#include <list>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    int a;
    int b;
    cin >> a >> b;
    ctn(a*b);
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    } 
    int sum = 0;
    rep(i, 0, n){
        if(i % 2 == 0) sum += a[i];
        else sum -= a[i];
    }
    vector<int> ans(n);
    ans[0] = sum;
    rep(i, 1, n){
        ans[i] = 2 * (a[i - 1] - ans[i - 1] / 2);
    }
    for(int ii = 0; ii < ans.size(); ii++){
        if(ii) cout << ' ';
        cout << ans[ii];
    }
    cout << endl;
}

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

int main() {
    string S;
    cin >> S;
    int N = S.size();
    rep(i, N) cout << 'x';
    cout << endl;
}

Measured memory_bytes: 3556
#include<stdio.h>

int main(){
  int k;
  int count;
  scanf("%d", &k);

  if((k&0x00000001)==0){
    count = (k/2) * (k/2);
  }else{
    count = ((k+1)/2) * ((k-1)/2);
  }

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

  return 0;
}


Measured memory_bytes: 128
import sys 
sys.setrecursionlimit(10**6)
import sys
def input():
    return sys.stdin.readline()[:-1]
n, q = map(int, input().split())
G = [[] for _ in range(n)]
point = [0]*n
for _ in range(n-1):
    a,b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
for i in range(q):
    p, x = map(int, input().split())
    p = p-1
    point[p] += x

def dfs(now, prev = -1):
    for next in G[now]:
        if next == prev:
            continue
        point[next] += point[now]
        dfs(next, now)

dfs(0)
print(*point)    
 

Measured memory_bytes: 268464
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 666666;
int a[N],b[N],n,A[N],B[N];Pii c[N],d[N];
int qz1[N],qz2[N],p[N],vis[N];
int main() {
	read(n);rep(i,1,n)read(a[i]),c[i]=Pii(a[i],i),A[i]=a[i];
	rep(i,1,n)read(b[i]),d[i]=Pii(b[i],i),B[i]=b[i];
	sort(c+1,c+n+1);sort(d+1,d+n+1);
	rep(i,1,n)if(c[i].fi>d[i].fi){puts("No");return 0;}
	rep(i,2,n)if(c[i].fi<=d[i-1].fi){puts("Yes");return 0;}
	rep(i,1,n)p[c[i].se]=d[i].se;
//	rep(i,1,n)cerr<<p[i]<<' ';cerr<<endl;
	int cnt=0;
	for(int i=1;!vis[i];i=p[i])vis[i]=1,cnt++;
	if(cnt==n)puts("No");else puts("Yes");
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << ((a + b == 15) ? '+' : (a * b == 15) ? '*' : 'x') << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	ll h,w; cin >> h >> w;
	ll ans = h*w;
	if(h==1||w==1) cout << 1 << endl;
	else if(ans%2) cout << (ans+1)/2 << endl;
	else cout << ans/2 << endl;
}




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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

using P = pair<double, double>;
map<string, P> mp;

void init() {
  mp["AAA"] = {35.5, 71.0};
  mp["AA"] = {37.5, 77.0};
  mp["A"] = {40.0, 83.0};
  mp["B"] = {43.0, 89.0};
  mp["C"] = {50.0, 105.0};
  mp["D"] = {55.0, 116.0};
  mp["E"] = {70.0, 148.0};
}

bool operator < (const P& a, const P& b) {
  return (a.first - b.first < -1e-10) && (a.second - b.second < -1e-10);
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  init();
  vector<string> s = {"AAA", "AA", "A", "B", "C", "D", "E"};
  P a;
  while (cin >> a.first >> a.second) {
    string ans = "NA";
    for (int i = 0; i < 7; i++) {
      if (a < mp[s[i]]) {
        ans = s[i];
        break;
      }
    }
    cout << ans << endl;
  }

  return 0;
}


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

flag = [False]*(10**5 + 10)
A = [X]
for i in range(N):
    X = X**2 % M
    if flag[X]:
        break
    
    flag[X] = True
    A.append(X)

# return index when a appears for the first time
index = A.index(X)

# A's before loop begins
loop_bef = A[0:index]

# A's where loop exists
loop = A[index:]

# number of loops
num_loop = (N - len(loop_bef)) // len(loop)
num_aft_loop = (N - len(loop_bef)) % len(loop)

ans = sum(loop_bef) + sum(loop)*num_loop + sum(loop[:num_aft_loop])

print(ans)

Measured memory_bytes: 12308
# B. Exponential
# https://atcoder.jp/contests/abc097/tasks/abc097_b

x = int(input())

ans = 1
for b in range(2, int(x ** .5) + 2):
  p = 2
  while b ** p <= x:
    ans = max(ans, b ** p)
    p += 1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,a[200005],n,maxx=0,cnt=0,b[200005];
    cin>>k>>n;

    int i;
    cin>>a[0];
    for(i=1;i<n;i++){
        cin>>a[i];
        b[i]=a[i]-a[i-1];
        if(maxx<b[i]) maxx=b[i];
        cnt+=b[i];
    }
    b[0]=k-a[n-1]+a[0];
    if(b[0]>maxx) maxx=b[0];
    cnt+=b[0];
  cnt-=maxx;
  cout<<cnt<<endl;

}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

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




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}

template<typename T>
ll com(T n, T m, T mod){
  ll a = 1, b = 1, ans;
  if(n == m || m == 0){
    ans = 1;
  }else{
    for(ll i = 0;i < m; i++){
      a *= n-i;
      a %= mod;
      b *= i+1;
      b %= mod;
    }
    ans = (a * powmod(b, mod-2, mod)) % mod;
  }
  
  return ans;
}



int main() {
  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
  
  // cout << setprecision(8) << ans << endl;  // For double
}



Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <cstdint>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 1000000007;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    SORT(a);
    ll ans = a[N-1];
    int cnt = 1;
    int i = N - 2;
    while (cnt != N-1) {
        
        cnt++;
        ans += a[i];
        if (cnt % 2 == 1)i--;
        
    }
    cout << ans << endl;
    return 0;

}


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

int main(){
  int n;
  cin >> n;
  for(int i = 0; i <= 25; i++){
    for(int j = 0; j <= 25; j++){
      if(i * 4 + j * 7 == n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

const ll MOD = 1e9 + 7;
constexpr ll bs = 1ll << 16;
vector<ll> pv(41, 1);
ll dp[41][bs];
ll N, X, Y, Z, ans;

vector<ll> bit2vec(ll b){
    vector<ll> S;
    while(b){
        for(ll k = 1; k <= 10; k++){
            if(b & 1){
                S.push_back(k);
                break;
            }
            b /= 2;
        }
        b /= 2;
    }
    return S;
}

ll vec2bit(const vector<ll> &v){
    ll up = X + Y + Z;
    ll sum = 0;
    bitset<16> ret(0);
    ll dig = 0;
    for(ll e : v){
        sum += e;
        if(sum > up) return ret.to_ullong();
        ret |= bitset<16>(1ll << (dig + e - 1));
        dig += e;
    }
    return ret.to_ullong();
}

bool check(const vector<ll> &v){
    ll idx = 0;
    vector<ll> xyz = { Z, Y, X };
    ll sum = 0;
    for(ll e : v){
        if(idx == 3) break;
        sum += e;
        if(xyz[idx] == sum){
            sum = 0;
            idx++;
        }
    }
    return idx == 3;
}

int main(){
    for(ll i = 0; i < 40; i++) pv[i + 1] = pv[i] * 10 % MOD;
    cin >> N >> X >> Y >> Z;
    dp[0][0] = 1;
    for(ll i = 0; i < N; i++){
        for(ll S = 0; S < bs; S++){
            if(!dp[i][S]) continue;
            vector<ll> NS = {0};
            {
                const auto tmp = move(bit2vec(S));
                for(ll t : tmp) NS.push_back(t);
            }
            for(ll nxt = 1; nxt <= 10; nxt++){
                NS[0] = nxt;
                ll val = dp[i][S];
                if(check(NS)){
                    ll rest = N - (i + 1);
                    (val *= pv[rest]) %= MOD;
                    (ans += val) %= MOD;
                }else{
                    (dp[i + 1][vec2bit(NS)] += val) %= MOD;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 19456
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int n; cin >> n;
  cout << (n + 1) / 2 << '\n';
  return 0;
}


Measured memory_bytes: 256
s=input()
l=len(s)
flag=0
for i in range(l):
    if i%2==0:
        if not(s[i]=='R' or s[i]=='U' or s[i]=='D'):
            flag=1
    else:
        if not(s[i]=='L' or s[i]=='U' or s[i]=='D'):
            flag=1
print('Yes' if flag==0 else 'No')

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
int main() {
	double v;
	while (cin >> v) {
		int N = 0;
		double V = 0;
		do{
			N++;
			double h = 5 * N - 5;
			V = 9.8*pow(h / 4.9, 0.5);
		} while (V < v);
		cout << N << endl;
	}
}

Measured memory_bytes: 3240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] S = new long[n];

		for(int i = 0; i < n; i++) {
			S[i] = sc.nextLong();
		}

		int q = sc.nextInt();
		int count = 0;

		for(int j = 0; j < q; j++) {
			long T = sc.nextLong();
			for(int i = 0; i < n; i++) {
				if(T == S[i]) {
					count++;
					break;
				}
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 40244
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T&a,T b){ if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T&a,T b){ if(a>b){a=b; return 1;} return 0;}
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main() {
    int n;
  cin>>n;
  vector<ll> h(n);
   rep(i,n) cin>>h[i];
  vector<ll> dp(n);
  rep(i,n) dp[i]=INF;
    dp[0]=0;
  rep(i,n){
        chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1) chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1792
// E.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e5 + 200;

int n, k;
char S[MAX_N], T[MAX_N], ans[MAX_N], minc = 'z', maxc = 'a';

void check(char *str, int idx)
{
	int ptr = n, len = 0;
	while (ptr >= 1 && str[ptr] == minc)
		ptr--, len++;
	while (idx != 0 && len < n)
		len <<= 1, idx--;
	if (len >= n)
	{
		fill(ans + 1, ans + 1 + n, minc);
		printf("%s\n", ans + 1), exit(0);
	}
	for (int i = 1; i <= len; i++)
		T[i] = minc;
	for (int i = len + 1; i <= n; i++)
		T[i] = str[ptr--];
	// compare;
	for (int i = 1; i <= n; i++)
		if (ans[i] < T[i])
			break;
		else if (ans[i] > T[i])
		{
			for (int j = 1; j <= n; j++)
				ans[j] = T[j];
			break;
		}
}		

int main()
{
	scanf("%d%d%s", &n, &k, S + 1);
	for (int i = 1; i <= n; i++)
	{
		minc = min(minc, S[i]), maxc = max(maxc, S[i]);
		ans[i] = 'z', S[(n << 1) - i + 1] = S[i];
	}
	if (minc == maxc)
		return printf("%s\n", ans + 1), 0;
	if (S[n] == minc)
		check(S, k);
	for (int i = n; i <= (n << 1); i++)
		if (S[i] == minc)
			check(S + i - n, k - 1);
	printf("%s\n", ans + 1);
	return 0;
}

Measured memory_bytes: 3768
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//                       _oo0oo_                         //
//                      o8888888o                        //
//                      88" . "88      ------ hzt1       //
//                      (| -_- |)                        //
//                      0\  =  /0                        //
//                    ___/`---'\___                      //
//                  .' \|     |// '.                     //
//                 / \|||  :  |||// \                    //
//                / _||||| -:- |||||- \                  //
//               |   | \  -  /// |     |                 //
//               | \_|  ''\---/''  |_/ |                 //
//               \  .-\__  '-'  ___/-. /                 //
//             ___'. .'  /--.--\  `. .'___               //
//          ."" '<  `.___\_<|>_/___.' >' "".             //
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |           //
//         \  \ `_.   \_ __\ /__ _/   .-` /  /           //
//     =====`-.____`.___ \_____/___.-`___.-'=====        //
//                       `=---='                         //
//                                                       //
//                                                       //
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       //
//                                                       //
//                 God-He Bless All.                     //
//           This Code Will Never Explode.               //
//                                                       //
//                                                       //
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
const int maxn=100010;
int n,A[maxn];
int gcd(int a,int b) {return !b?a:gcd(b,a%b);}
int solve() {
	int a=0,b=0,is=0,sum=0;
	rep(i,1,n) {
		if(A[i]&1) a++; else b++;
		(sum+=A[i]-1)%=2;
		if(A[i]==1) is=1;
	}
//	rep(i,1,n) printf("%d%c",A[i],i==n?'\n':' ');
	if(is) return sum;
	if(b%2==1) return 1;
	else if(a!=1) return 0;
	else {
		rep(i,1,n) if(A[i]%2==1) A[i]--;
		int k=0;
		rep(i,1,n) k=gcd(k,A[i]);
		rep(i,1,n) A[i]/=k;
		return !solve();
	}
}
int main() {
	n=read();
	rep(i,1,n) A[i]=read();
	puts(solve()?"First":"Second");
	return 0;
}


Measured memory_bytes: 768
#include <iostream>

using namespace std;

int koyakusu(int x, int y) {
  if(y == 0) {
    return x;
  }
  
  return koyakusu(y, x % y);
}

int main() {
  long long int x, y;
  cin >> x >> y;

  if(x >= y) {
    cout << koyakusu(x, y) << endl;
  }else {
    cout << koyakusu(y, x) << endl;
  }
}



Measured memory_bytes: 3088
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int W = in.nextInt();
		int[] w = new int[n];
		long[] p = new long[n];
		for (int i = 0; i < n; i++) {
			w[i] = in.nextInt();
			p[i] = in.nextLong();
		}
		long[][]dp = new long[n][W+1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= W; j++) {
				if(i == 0){
					if(j >= w[i]) dp[i][j] = p[i];
				}else{
					dp[i][j] = dp[i-1][j];
					if(j >= w[i]) dp[i][j] = Math.max(dp[i][j], dp[i-1][j-w[i]] + p[i]);
				}
			}
		}
		System.out.println(dp[n - 1][W]);
	}
}

Measured memory_bytes: 126412
s = list(input())

a = 10*int(s[0])+int(s[1])
b = 10*int(s[2])+int(s[3])

if 0<a<13 and 0<b<13:
    print("AMBIGUOUS")
elif 0<a<13:
    print("MMYY")
elif 0<b<13:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 9100
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int ans = 0;

	int  N;
	vector<int> h;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int j;
		cin >> j;
		h.push_back(j);
	}
	int th =0;

	for (int i = 0; i < N; i++) {
		if (h[i] >= th) {
			th = h[i];
			ans++;
		}
	}
	
	cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
 
main()
{
    int d,e;
 
    scanf("%d",&d); //??\?????????????????????????????°
 
    for(e=0;e<d;e++){
        int a=0,b=0,c=0;
 
        scanf("%d %d %d",&a,&b,&c);
        
        if( (a*a) + (b*b) == (c*c) ||
            (b*b) + (c*c) == (a*a) ||
            (c*c) + (a*a) == (b*b))
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 580