akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define eps 1e-10
struct Point 
{
    double x, y;
    Point ( double x = 0, double y = 0 ) : x ( x ) , y ( y ) {}
    Point operator + ( const Point & p ) const { return Point ( x + p.x, y + p.y) ;}
    Point operator - ( const Point & p ) const { return Point( x - p.x, y - p.y);}
    Point operator * ( const double & a ) const { return Point( a * x, a * y) ;}
    Point operator / ( const double & a ) const { return Point( x / a, y / a );}
    double norm(){return x * x + y * y;}
    double abs(){return sqrt( norm());}
    double dot ( const Point & p ) const 
    {
        return x * p.x + y * p.y;

    }
    double det( const Point & p ) const {return x * p.y - y * p.x;}
    bool operator < ( const Point & p ) const {
        return x != p.x ? x < p.x : y < p.y;
    }
    bool operator == ( const Point & p ) const
    {
        return fabs( x - p.x ) < eps && fabs( y - p.y ) < eps;
    }
};
typedef pair< Point, int > P;
P p[100], q[100];
vector<P> convex_hull(P *ps, int n)
{
    sort(ps, ps + n);
    int k = 0;
    vector<P> qs(n * 2);
    for( int i = 0; i < n; i++ )
    {
        while (k > 1 && (qs[k - 1].first - qs[k - 2].first).det(ps[i].first - qs[k - 1].first) <= 0)
            k--;
        qs[k++] = ps[i];
    }
    for (int i = n - 2, t = k; i >= 0; i--)
    {
        while (k > t && (qs[k - 1].first - qs[k - 2].first).det(ps[i].first - qs[k - 1].first) <= 0)
            k--;
        qs[k++] = ps[i];
    }
    qs.resize(k - 1);
    return qs;
}
int par[100];
int find( int x )
{
    if( x == par[x] )return x;
    return par[x] = find( par[x] );

}
void unite( int x, int y ) {par[find(x)] = find(y);
}
struct st{
    int a,b;
    double c;
};
main()
{
    int v, r;
    cin >> v >> r;
    for( int i = 0; i < v; i++ )scanf( "%lf%lf", &p[i].first.x, &p[i].first.y), p[i].second = i, q[i] = p[i];
    for( int i = 0; i < v; i++ )par[i] = i;
    vector< P > res = convex_hull( p, v );
    double ans = 0;
    for( int i = 0; i < res.size(); i++ )
    {
        ans += ( res[ ( i + 1 ) % res.size()].first - res[i].first).abs();
        unite( res[( i + 1 ) % res.size()].second, res[i].second );

    }
    vector< st > u;
    for( int i = 0; i < r; i++ )
    {
        int a, b;
        scanf("%d%d", &a, &b);
        a--;
        b--;
        u.push_back({a, b, (q[a].first - q[b].first).abs()});
    }
    sort(u.begin(), u.end(), [](st &a, st &b) { return a.c < b.c; });
    for( int i = 0; i < u.size(); i++ )
    {
        if( find( u[i].a ) == find( u[i].b ) )continue;
        ans += u[i].c;
        unite( u[i].a, u[i].b );
    }
    printf( "%.7lf\n", ans );
    return 0;
}


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

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

	int n;
	cin >> n;
	vector<int> xs(n);
	for (int& x : xs) {
		cin >> x;
	}
	reverse(xs.begin(), xs.end());

	int ans = 0;
	vector<int> s;
	for (int x : xs) {
		if (s.empty() || s.back() <= x) {
			s.push_back(x);
			ans = max(ans, (int) s.size());
		} else {
			int i = upper_bound(s.begin(), s.end(), x) - s.begin();
			s[i] = x;
		}
	}

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



Measured memory_bytes: 1276
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>

using int64 = long long;

int countDivisors(int number) {
    int num = 0;
    for (int n = 1; n <= number; n++) {
        if (number % n == 0) num++;
    }
    return num;
}

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

    int N;
    std::cin >> N;

    int ans = 0;
    for (int n = 1; n <= N; n += 2) {
        if (countDivisors(n) == 8) ans++;
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test ll t;cin>>t;while(t--)
#define input1(n) ll n;cin>>n;
#define input2(a,b) ll a,b;cin>>a>>b;
#define mod 1000000007

int main()  
{  
    input2(n,m);
    char ar[n][m];
    ll dp[n][m];
    memset(dp,0,sizeof(dp));
    for(ll i=0;i<n;i++)
    for(ll j=0;j<m;j++)
    cin>>ar[i][j];
    // for(ll i=0;i<n;i++)
    // for(ll j=0;j<m;j++)
    // cout<<ar[i][j];
    if(ar[0][1]=='.')
    dp[0][1]=1;
    if(ar[1][0]=='.')
    dp[1][0]=1;
    for(ll i=2;i<n;i++)
    {
        if(ar[i][0]!='#')
        dp[i][0]=dp[i-1][0];
        else
        dp[i][0]=0;
        
        
    }
    for(ll i=2;i<m;i++)
    {
        if(ar[0][i]!='#')
        dp[0][i]=dp[0][i-1];
        else
        dp[0][i]=0;
    }
    for(ll i=1;i<n;i++)
    {
        for(ll j=1;j<m;j++)
        {
            if(ar[i][j]=='#')
            dp[i][j]=0;
            else
            dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
        }
    }
    // for(ll i=0;i<n;i++)
    // {
    //     for(ll j=0;j<m;j++)
    //     cout<<dp[i][j]<<" ";
    //     cout<<"\n";
    // }
    cout<<dp[n-1][m-1];
    return 0;
}


Measured memory_bytes: 12412
function Main(input) {
	input = input.split("\n");
	tmp = input[0].split(" ");

    var a = tmp[0].toString();

    if(a.match(/^[A-Z]+$/)) {
        console.log( 'A' );
    } else{
        console.log( 'a' );
    }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29624
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var x = int.Parse(line[2]);
        var ab = a + b;
        Console.WriteLine(ab >= x && a <= x ? "YES" : "NO");
    }
}


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

typedef long long ll;
ll mod = 1000000007;
const double PI = 3.141592653589793238460;
const int INF = 1e9+5;

ll power(ll x, ll y)
{
    ll res = 1;
    x = x%mod;
    while (y)
    {
        if (y&1) res = ((res%mod)*(x%mod))%mod;

        y>>=1;
        x = ((x%mod)*(x%mod))%mod;
    }
    return res;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, a, b, c;
    cin >> n;    

    vector<vector<int>> dp(n+1, vector<int> (3));
    cin >> a >> b >> c;
    dp[1][0] = a;
    dp[1][1] = b;
    dp[1][2] = c;

    for(int i=2; i<=n; i++){
        cin >> a >> b >> c;
        dp[i][0] = max(a+dp[i-1][1],a+dp[i-1][2]);
        dp[i][1] = max(b+dp[i-1][0],b+dp[i-1][2]);
        dp[i][2] = max(c+dp[i-1][0],c+dp[i-1][1]);
    }

    cout<<max(dp[n][0], max(dp[n][1],dp[n][2]));

    return 0;
}

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

#define mk(x, y) make_pair(x, y)
#define X first
#define Y second

using namespace std;

typedef pair<int, int> pii;

int main( void )
{
	int dx[] = { -1, 0, 1, 0 };
	int dy[] = { 0, 1, 0, -1 };

	pii T[200];
	int n;
	while(cin >> n, n) {
		int minx, miny, maxx, maxy;
		minx = miny = maxx = maxy = 0;
		T[0] = mk(0, 0);
		for(int i=1; i < n; ++i) {
			int no, d;
			cin >> no >> d;
			T[i] = mk(T[no].X + dx[d], T[no].Y + dy[d]);
			minx = min(minx, T[i].X);
			miny = min(miny, T[i].Y);
			maxx = max(maxx, T[i].X);
			maxy = max(maxy, T[i].Y);
		}
		cout << maxx - minx + 1 << ' ' << maxy - miny + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		//キーボード入力メソッド
		Scanner sc = new Scanner(System.in);

		//入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		//処理
		if(a < b) {
			System.out.println("a < b");
		}else if(a > b) {
			System.out.println("a > b");
		}else {
			// a = b のとき
			System.out.println("a == b");
		}

	}

}



Measured memory_bytes: 26048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		WriteLine(Char.IsUpper(GetChar()) ? "A" : "a");
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

int main(){
  ll h,n;
  cin>>h>>n;
  ll sum=0;
  vector<ll>a(n);
  for(int i=0;i<n;i++){

    cin>>a[i];
    sum=sum+a[i];
  }
  if(sum>=h)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;}
  


Measured memory_bytes: 4060
//
// Created by Tetsuya Shiota on 2019-04-13.
//

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(e, o) for (auto &&e : o)
#ifdef LOCAL
#define pp(x) cerr << __LINE__ << ' ' << #x << " = " << (x) << endl
#define dump(x)                                                                \
  cerr << __LINE__ << ' ' << #x << " : ";                                      \
  FOR(e, x) cerr << e << ' ';                                                  \
  cerr << endl;
#else
#define pp(x)
#define dump(x)
#endif

using namespace std;

using Int = long long;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int, Int>;

template <typename T> void reverse(vector<T> &v) {
  reverse(v.begin(), v.end());
}

template <typename T> void sort(vector<T> &v) { sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T> &v) { sort(v.rbegin(), v.rend()); }

template <typename T> T sum(const vector<T> &v) {
  return accumulate(v.begin(), v.end(), T(0));
}

template <class T> void update_max(T &a, const T &b) { a = max(a, b); }
template <class T> bool update_min(T &a, const T &b) { a = min(a, b); }

struct BoolName : numpunct<char> {
  string t, f;
  BoolName(string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const { return t; }
  string do_falsename() const { return f; }
};

class Solver {
public:
  Solver() {}
  Int N, K, ans = 0;
  string S;
  void input() {
    cin >> N >> K;
    cin >> S;
  }
  void solve() {
    char last = '*';
    vector<pii> cntV;
    FOR(c, S){
      if(last == c){
        cntV.back().second++;
      }else{
        cntV.push_back(make_pair(c - '0', 1));
        last = c;
      }
    }

    deque<pii> Q;
    Int need = 0, score = 0;

    FOR(cnt, cntV){
      Q.push_back(cnt);
      score += cnt.second;
      if(cnt.first == 0){
        need++;
      }
      while(need > K){
        pii f = Q.front();
        Q.pop_front();
        if(f.first == 0)need--;
        score -= f.second;
      }
      update_max(ans, score);
    }
  }
  void output(){
    cout << ans <<endl;
  };
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(15) << boolalpha;
  cout.imbue(locale(cout.getloc(), new BoolName));
#ifdef LOCAL
  while (1) {
    Solver s;
    s.input();
    if (cin.eof())
      break;
    s.solve();
    s.output();
  }
#else
  Solver s;
  s.input();
  s.solve();
  s.output();
#endif
}

Measured memory_bytes: 2736
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdlib>
#include<stack>
#include<queue>
#define ll long long
using namespace std;
const int maxn=5e5+7;
const int mod=1e9+7;
ll fac[maxn],inv_fac[maxn];
ll quick(ll a,ll n){
    ll res=1,t=a;
    while(n){
        if(n&1) res=(res*t)%mod;
        t=(t*t)%mod;
        n/=2;
    }
    return res;
}
void init(){
    fac[0]=1;
    for(int i=1;i<=maxn;i++) fac[i]=(fac[i-1]*i)%mod;
    //inv_fac[maxn]=quick(fac[maxn],mod-2);
    //for(int i=maxn-1;i>=0;i--) inv_fac[i]=(inv_fac[i+1]*(i+1))%mod;
    for(int i=0;i<=maxn;i++){
        inv_fac[i]=quick(fac[i],mod-2);
    }
}
ll C(int n,int m){
    if(n<0||m<0||m>n) return 0;
    if(m==0||m==n) return 1;
    return fac[n]*inv_fac[n-m]%mod*inv_fac[m]%mod;
}
int main(){
    init();
    //cout<<C(5,2)<<endl;
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    ll ans=0;
    for(int i=b+1;i<=m;i++) ans=(ans+(C(n-a-1+i-1,i-1)*C(a-1+m-i,m-i))%mod)%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>

int main(void){
        int a,b,c,i;

        scanf("%d%d%d",&a,&b,&c);

        if(a<1||c>100){
        return 1;
        }
        else if (a>b){
        printf("0\n");
        return 0;
        }

        for(i=0;i<c;i++){
        b=b-a;
                if(b<0){
                break;
                }
        }

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

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;


int main() {
    
    int n;
    cin>>n;
    map<string,int> m;
    rep(i,n){
        int q;
        cin>>q;
        if(q==0){
            int x;
            string k;
            cin>>k>>x;
            m[k]=x;
        } else {
            string k;
            cin>>k;
            fin(m[k]);
        }
    }
}


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

int main(){
    vector <int> A(3);
    for (int i=0; i<3; i++) cin >> A[i];
    sort(A.begin(),A.end(),greater<int>());
    
    int ans=10*A[0]+A[1]+A[2];
    cout << ans;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def solve():
    H, W, M = map(int, input().split())
    numRs = [0] * H
    numCs = [0] * W
    hws = []
    for _ in range(M):
        h, w = map(int, input().split())
        h, w = h-1, w-1
        numRs[h] += 1
        numCs[w] += 1
        hws.append((h, w))

    maxR = max(numRs)
    maxC = max(numCs)

    hs = set()
    ws = set()
    for h in range(H):
        if numRs[h] == maxR:
            hs.add(h)
    for w in range(W):
        if numCs[w] == maxC:
            ws.add(w)
    numH = len(hs)
    numW = len(ws)

    num = 0
    for hb, wb in hws:
        if hb in hs and wb in ws:
            num += 1

    ans = maxR+maxC
    if num == numH*numW:
        ans -= 1

    print(ans)


solve()


Measured memory_bytes: 167512
a = input()

flag=True
a = a[0:len(a)-2]
while(flag):
    #print(a[0:len(a)//2],a[len(a)//2:])
    if a[0:len(a)//2]==a[len(a)//2:]:
        print(len(a))
        flag=False
    else:
        a = a[0:len(a)-2]


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define ind(a) scanf("%d", &a)
#define inlld(a) scanf("%lld", &a)
#define ind2(a, b) scanf("%d%d", &a, &b)
#define inlld2(a, b) scanf("%lld%lld", &a, &b)
#define ind3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define inlld3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

using namespace std;

const int N=305;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

string s;
int k, n, dp[N][N][N];

int solve(int i, int j, int left)
{
    if(left<0)
        return -1e9;
    if(i==j)
        return 1;
    if(i>j)
        return 0;
    if(dp[i][j][left]!=-1)
        return dp[i][j][left];
    int ret=0;
    if(s[i]==s[j])
        ret=solve(i+1, j-1, left)+2;
    else
        ret=solve(i+1, j-1, left-1)+2;
    ret=max(ret, solve(i+1, j, left));
    ret=max(ret, solve(i, j-1, left));
    // printf("%d %d %d %d\n", i, j, left, ret);
    return dp[i][j][left]=ret;
}

int main() 
{
    cin>>s>>k;
    n=s.length();
    memset(dp, -1, sizeof(dp));
    printf("%d\n", solve(0,n-1,k));
    return 0;
}



Measured memory_bytes: 111104
#include<stdio.h>

int main(void){
  int A,B,m;
  int a[100001],b[100001];
  int x[100001],y[100001],c[100001];
  int i,ma,mb,mp;
  int d[100001];
  
  scanf("%d %d %d\n",&A,&B,&m);
  for(i=1;i<=A;i++){
    scanf("%d ",&a[i]);
  }
  for(i=1;i<=B;i++){
    scanf("%d ",&b[i]);
  }
  for(i=1;i<=m;i++){
    scanf("%d %d %d\n",&x[i],&y[i],&c[i]);
  }
  
  ma=a[1];
  for(i=2;i<=A;i++){
    if(a[i]<ma){
      ma=a[i];
    }
  }
  mb=b[1];
  for(i=2;i<=B;i++){
    if(b[i]<mb){
      mb=b[i];
    }
  }
  mp=ma+mb;
  
  for(i=1;i<=m;i++){
    if(a[x[i]]+b[y[i]]-c[i]<mp){
      mp=a[x[i]]+b[y[i]]-c[i];
    }
  }
  
  printf("%d",mp);
  
  return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>	
 
#define f first
#define s second
#define pb push_back
                         	
#define ll long long
 
#define int ll
 
#define ull unsigned long long
 
#define mp make_pair
                          
  
using namespace std;
                       
 
const int inf = 1e9 + 7;
 
const ll ll_inf = 1e18;
const int K = 2e6 + 50;
const int N = 3e5 + 200;
 
const int bl = 320;
 
const int ep = 1e-7;
 
const int pro = 31;
 
const double pi = 3.141592653589793238462643;
                                         
ll binpow (ll a, ll n)
{
	if(n == 0)
		return 1ll;           
    ll res = 1;
    while (n) {
        if (n & 1)                                          
        {
            res *= a;
            res %= inf;
        }      	
        a *= a;
        n >>= 1;
        a %= inf;
    }                          
    return res;
}   
          
  
 
void boost()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);                                        
}
 
void fr()
{
    freopen("road-to-work.in","r",stdin);
    freopen("road-to-work.out","w",stdout);
}

 
void solve() 
{
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	while (b <= a)
	{
		b *= 2;
		k--;
	}
	if (k < 0)
	{
		cout << "No";
		return;
	}
	for (int i = 1;i <= k;++i)
		c *= 2;
   	if (c > b && b > a)
   		cout << "Yes";
   	else
   		cout << "No";
}   	                        	
 
main()
{
	//boost();
	int q = 1;
	//cin >> q;
	while(q--)
	{
		solve();
	}
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<pair<int,int> > h[100000];
  int flag[100000]={0};
  int ans[100000]={0};
  int an=0;
  rep(i,n-1){
    int c,b;
    cin>>c>>b;
    c--;b--;
    h[c].push_back(make_pair(i,b));
    h[b].push_back(make_pair(i,c));
    an=max(an,max((int)h[c].size(),(int)h[b].size() ));
  }
  queue<pair<int,int> >q;
  q.push(make_pair(0,0));
  flag[0]=1;
  while(!q.empty() ){
    pair<int,int> pp=q.front();
    q.pop();
    int color=1;
    rep(i,h[pp.scd].size() ){
      if(color == pp.fst) color++;
      if(flag[h[pp.scd][i].scd]==0){
	ans[h[pp.scd][i].fst]=color;
	q.push(make_pair(color,h[pp.scd][i].scd));
	flag[h[pp.scd][i].scd]=1;
	color++;
      }
    }
  }
  cout<<an<<endl;
  rep(i,n-1){
    cout<<ans[i]<<endl;
  }
			   
  
  return 0;
}


Measured memory_bytes: 9728
n = int(input())
T = [[] for i in range(n)]
for i in range(n - 1):
    u, v, w = map(int, input().split())
    T[u - 1].append([v - 1, w])
    T[v - 1].append([u - 1, w])
D = [-1] * n
D[0] = 0
Q = [0]
while Q:
    q = Q.pop()
    for adj, w in T[q]: ##BFS
        if D[adj] < 0: #uncertain is = -1
            D[adj] = D[q] + w
            Q.append(adj)
for d in D:
    print(d % 2)



Measured memory_bytes: 48976
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b / a, c) << endl;
	return 0;
}
 

Measured memory_bytes: 256
K, A, B = map(int, input().split())

ans = 1
yen = 0
if A+1 >= B:
    print(K+1)
    quit()
cycle = max(0, (K-(A-1))//2)
res = (K-(A-1)) % 2
ans = cycle * (B-A) + A + res
print(ans)

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

using namespace std; 

#define NOT_FOUND -1
#define rep(i,n) for(int i=0;i<(int)(n); i++)
/*for文のマクロ定義
rep(i,回数){
    処理
}
*/

void swap(int *a, int *b){
	*b=*a-*b;
	*a-=*b;
	*b+=*a;
}

int sosu_judge(int N){
	/*素数ならば1
	  素数でなければ0を返す
	*/
	int i,j;

	if(N==2)   return 1;
	if(N%2==0) return 0;

	for(i=3;i<N && N%i!=0;i+=2);

	if(i>=N) return 1;
	
	return 0;
}

int factorial(int N){  //Nの階乗を求める関数
	int ans=1;

	while(N--) ans*=(N+1);
	return ans;
}

//クイックソートをする関数
void q_sort(int a[], int first, int last){
    int i,j;
    int x,t;

    x = a[(first + last) / 2];
    i = first; j=last;

    while(1){
        while( a[i] < x) i++;
        while( x < a[j]) j--;
        
        if( i >= j) break;
        
        swap(&a[i],&a[j]);
        i++; j--;
    }
    if(first < i-1) q_sort(a, first,i-1 );
    if(last > j+1)  q_sort(a, j+1,  last);
}

int b_search(int target, int array[],int right, int left){
    /*二分探索を行う関数である。
      戻り値は探索したい値の格納されている位置である。
      もし値が存在しない場合、NOT_FOUND(-1)を返す
    */
    int mid;
    while(left<right){
        mid=(right+left)/2;
        if(array[mid]<target) left =mid+1;
        else                  right=mid;
    }
    if(array[mid]==target) return mid;
    return NOT_FOUND;
}

unsigned long combination(int n, int r){
    /*nCrの値を求める関数である。
      値が巨大になる可能性があるため、戻り地はunsigned longである
    */
    int i,j;
    unsigned long a[17];

    if(n-r<r) r=n-r;
    if(r==0 ) return 1;
    if(r==1 ) return n;
    if(r>17 ) return 0;
    for(i=1;i<r;i++) a[i]=i+2;
    for(i=3;i<=n-r+1;i++){
        a[0]=i;
        for(j=1;j<r;j++)a[j]+=a[j-1];
    }
    return a[r-1];
}
   
int main(){
    int  N,Q,count[100000]={};
    int sum=0;
    long K;
    cin>>N>>K>>Q;
    vector<int> A(Q);
    vector<int> point(N,K);

    rep(i,Q) cin>>A[i];

    rep(i,Q){
        count[A[i]-1]++;
        point[A[i]-1]++;
    }
    rep(i,N) sum+=count[i];
    rep(i,N){
       point[i]-=sum;
       if(point[i]<=0) cout<<"No"<<endl;
       if(point[i]>0)  cout<<"Yes"<<endl;
    }
    return 0;
}





Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n;
	cin>>n;
	long long int ans=n+1;
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0){
			long long int sum=i+n/i;
			if(ans>sum) ans=sum;
		}
	}
	cout<<ans-2<<endl;
	return 0;
}

Measured memory_bytes: 256
import itertools


n, m, q = map(int, input().split())
queries = []
for _ in range(q):
    a, b, c, d = map(int, input().split())
    queries.append((a-1, b-1, c, d))

patterns = itertools.combinations_with_replacement(range(1, m+1), n)

candidates = []
for pattern in patterns:
    res = 0
    for a, b, c, d in queries:
        if int(pattern[b]) - int(pattern[a]) == c:
            res += d

    candidates.append(res)

print(max(candidates))


Measured memory_bytes: 12760
S = input()

for i in range(len(S)):
    if i % 2 == 0:
        if not (S[i] in ['R', 'U', 'D']):
            print('No')
            exit()
    else:
        if not (S[i] in ['L', 'U', 'D']):
            print('No')
            exit()

print('Yes')

Measured memory_bytes: 3060
from math import sqrt, floor
 
N, M = map(int,input().split())
 
rootM = floor(sqrt(M))
l = []
for i in range(1, rootM +1):
    if M % i == 0:
        l.append(i)
        l.append(M//i)
        
ans = 1
for li in l:
    ans = max(ans, li) if li <= M // N else ans
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

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



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

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



int main() {
	string S;
	int i, j, k;
	//ll N, M, K;
	int N, M, K;
	ll X;
	cin >> X;
	const int I = 121;
	ll A[I];
	rep(i, 0, I) {
		A[i] = pow(i, 5);
	}
	
	rep(i, 1, I) {
		rep(j, 0, i) {
			if (A[i] - A[j] == X) {
				cout << i << " "<< j;
				return 0;
			}
			if (A[i]+ A[j]== X) {
				cout << i << " "<< -j;
				return 0;
			}
						

		}

	}


	return 0;

}

Measured memory_bytes: 4108
// Author: Jinhai Chen
#include <vector>
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long ll;
const int maxn = 1e5 + 10;
struct node {
	int y,id;
	bool operator<(const node& rhs) const { return y<rhs.y; }
}nd;

vector<node> p[maxn];
int n,m;
int ans1[maxn],ans2[maxn];
int main() {
#ifndef ONLINE_JUDGE
	//freopen("data.in","r",stdin);
#endif
	// ios::sync_with_stdio(false);
	scanf("%d%d",&m,&n);
	int u,v;
	for(int i=1;i<=n;i++) { scanf("%d%d",&u,&v); nd.id=i; nd.y=v; p[u].push_back(nd); }
	for(int i=1;i<=m;i++) sort(p[i].begin(),p[i].end());
	for(int i=0;i<=m;i++) {
		for(int j=0;j<p[i].size();j++) {
			int id=p[i][j].id,a2=j+1;
			ans1[id]=i; ans2[id]=a2;
		}
	}
	for(int i=1;i<=n;i++) {
		printf("%06d%06d\n",ans1[i],ans2[i]);
	}
	return 0;
}














Measured memory_bytes: 7808
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>


int ordena(const void *a, const void *b){
    int x = *((int*) a);
    int y = *((int*) b);

    if(x < y){
        return 1;
    }
    else if(x > y){
        return -1;
    }
    return 0;
}

int main(){
    int soma = 0;
    int n, k;
    scanf("%d %d", &n, &k);
    int v[n];

    for(int i = 0; i < n; ++i)
        scanf("%d", &v[i]);

    qsort(v, n, sizeof(v[0]), ordena);

    for(int i = 0; i < k; ++i){
        soma = soma + v[i];
    }

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


Measured memory_bytes: 128
// https://atcoder.jp/contests/arc091/tasks/arc091_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll ans = 0;
    int n, m;
    cin >> n >> m;
    for (int i = m + 1; i <= n; i++) {
        ll mok = n / i;
        ans += mok * (i - m);
        if ((n % i) >= m) {
            ans += (n % i) - m + 1;
        }
    }
    if (m == 0)
        ans -= n;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  C - Exception Handling
//
//  Created by Hashizo on 2019/07/20.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#undef INT_MAX
#undef INT_MIN

#define INT_MAX	2147483647
#define INT_MIN	(-INT_MAX  -1)

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REPLACE(s, f, t) regex_replace(s, regex(f), t)

int main(int argc, const char * argv[]) {
	int n;
	cin >> n;

	vector<int> a(n);

	REP(i, n) {
		cin >> a[i];
	}

	vector<int> work(n);
	work = a;
	
	SORT(work);

	REP(i, n) {
		if (work[n-1] == a[i]) {
			cout << work[n-2] << endl;
		}
		else {
			cout << work[n-1] << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
typedef long long ll;

using namespace std;

int main(){
  ll n;cin>>n;
    string a,b,c;cin>>a>>b>>c;
    ll ans=0;
    for(ll i=0;i<n;i++){
      set<char> st;
      st.insert(a[i]);
      st.insert(b[i]);
      st.insert(c[i]);
      ans+=st.size()-1;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	ll n,m;
	cin >> n >> m;
	ll ans = min(n,m/2);
	ll ANS = ans;
	n -= ans;
	m -= ans*2;
	ANS += m/4;
	cout<<ANS<<endl;
}


Measured memory_bytes: 3540
while 0 < n = gets.chomp.to_i
	change = {}
	n.times{a, b = gets.chomp.split(' '); change[a] = b}
	result = []
	gets.chomp.to_i.times do
		input = gets.chomp
		if change[input] == nil
			result << input
		else
			result << change[input]
		end
	end
	puts result.join
end

Measured memory_bytes: 8644
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define pi              acos(-1)
#define ordered_set     tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MAX             100005

typedef long long ll;


int main()
{
    FastRead

    long double r,ans;

    cin>>r;

    ans = 2.0*pi*r;

    cout<<fixed<<setprecision(15)<<ans;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 2*1e13;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,x,y;
struct edge{/*重み付き,有向*/
    int to , cost;/*toは接続先*/
    edge(ll to_ ,ll cost_ = 1){ to=to_; cost=cost_; };/*全てのcost=1 <=> 無向グラフ*/
};
bool operator<(edge e1 ,edge e2){return e1.cost < e2.cost; }
bool operator>(edge e1 ,edge e2){return e1.cost > e2.cost; }
using graph =  vector< vector<edge> >;
graph g;
bool ck[5010];
ll dist[5010];
vector<PLL> ans;

void bfs(ll x,ll num){
    queue<PLL> q;
    rep(i,5010)ck[i]=false;
    rep(i,5010)dist[i]=0;
    q.push(mp(x,num));
    ck[x]=true;
    dist[x]=0;
    while(!q.empty()){
        ll now = q.front().first;
        ll cs = q.front().second;
        q.pop();
        dist[now] = cs;
        if(false){
            ans.pb(mp(x,now));
            continue;
        }
        if(true){
            rep(i,g[now].size()){
                if(!ck[g[now][i].to])q.push(mp(g[now][i].to,cs+1));
                ck[g[now][i].to]=true;
            }
        }
    }
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>x>>y;
    g.resize(n+1);
    rep(i,n){
        if(i==0)continue;
        g[i+1].pb(edge(i));
        g[i].pb(edge(i+1));
    }
    g[x].pb(edge(y));
    g[y].pb(edge(x));
    bool ck = false;
    // rep(i,n){
    //     if(i==0)continue;
    //     if(!ck)rep(j,n){
    //         bfs(j+1,i);
    //     }
    //     print(ans.size()/2);
    //     if(ans.size()==0)ck = true;
    //     ans.clear();
    // }
    Vi tp(n+1);
    rep(i,n){
        bfs(i+1,0);
        rep(i,n){
            tp[dist[i+1]]++;
        }
    }
    rep(i,n){
        if(i==0)continue;
        print(tp[i]/2);
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll N = 1e6 + 5, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    ll n, c = 1;
    string s;
    cin >> n >> s;
    for (ll i = 1; i < n; i++)
        if (s[i] != s[i - 1])
            c++;
    cout << c;
}

Measured memory_bytes: 512
#!/usr/bin/env python3

import sys
import heapq
import copy
import itertools

inf = float('inf')
a = '.'
b = '#'

def solve(H, W, s):
    white_count = sum([line.count(a) for line in s])
    
    field = [[b for w in range(W+2)] for h in range(H+2)]
    for h in range(H):
        field[1+h][1:W+1] = s[h]

    D = {(h, w): inf for h, w in itertools.product(range(H+2), range(W+2))}
    start = (1, 1)
    D[start] = 1
    Q = [(D[start], start)]
    direction = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    
    while len(Q) > 0:
        Du, u = heapq.heappop(Q)
        for d in direction:
            v = (u[0]+d[0], u[1]+d[1])
            if field[u[0]+d[0]][u[1]+d[1]] == b:
                continue
            if Du + 1 < D[v]:
                D[v] = Du + 1
                heapq.heappush(Q, (D[v], v))

    path_length = D[(H, W)]
    if path_length == inf:
        print(-1)
        return
    print(white_count - path_length)
    return

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [[c for c in next(tokens)] for _ in range(H)]  # type: "List[str]"
    solve(H, W, s)
    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
// 
// 
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define is_in(i, s) (s.find(i) != s.end())
#define all(x) (x).begin(),(x).end()
#define outl(x) cout<<x<<endl
#define outsp(x) cout<<x<<" "
typedef long long ll;
typedef pair<int,int> P;


#define MAX_N 1000000005


int main() {
	int h1,m1,h2,m2,k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int t1 = 60*h1+m1;
	int t2 = 60*h2+m2;
	outl(t2-t1-k);
    return 0;
}



Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Stack {
	String[] stack;
	int index;
	public Stack(int size) {
		index = 0;
		stack = new String[size];
	}

	public void put(String target) {
		stack[index++] = target;
	}

	public void put(int target) {
		stack[index++] = String.valueOf(target);
	}

	public String get() {
		return stack[--index];
	}

	public int getNum() {
		return Integer.parseInt(get());

	}
}
public class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Stack stack = new Stack(200);
		String[] strs = br.readLine().split(" ");
		for (String target : strs) {
			if ("*".equals(target)) {
			stack.put(stack.getNum() * stack.getNum());
			} else if ("+".equals(target)) {
				stack.put(stack.getNum() + stack.getNum());
			} else if ("-".equals(target)) {
				int b = stack.getNum();
				int a = stack.getNum();
				stack.put(a - b);
			} else {
				stack.put(target);
			}
		}
		System.out.println(stack.get());
	}
}

Measured memory_bytes: 24352
import string
import collections
S = input()
T = input()
s_cnt =collections.Counter(list(S))
n_cnt = collections.Counter(list(T))
#print(s_cnt, n_cnt)

for i in range(len(s_cnt)):
  if(s_cnt.most_common()[i][1] != n_cnt.most_common()[i][1]):
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 5804
#include<stdio.h>
#define N 100000
#define M 50000

int binarySearch(int *, int, int);

int main(){
  int S[N],n1,n2,T[M],key,count=0,c;
  int i,j,k;
  int left, right, mid;
  
  scanf("%d",&n1);
  for(i = 0; i < n1; i++){
    scanf("%d",&S[i]);
  }

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

  for(i=0; i<n2; i++){
    key = T[i];
    c = binarySearch(S,key,n1);
    if( c != -1 ) count++;
  }
       
  printf("%d\n",count);

  return 0;
}

int binarySearch(int S[], int key, int n){
  int left, right, mid;

  left = 0;
  right = n;

  while( left < right ){
    mid = ( left + right ) / 2;
    if(S[mid] == key) return mid;
    else if (key < S[mid]) right = mid;
    else left = mid + 1;
  }
  return -1;
}


Measured memory_bytes: 2368
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayLong();
            var N = input[0];
            var X = input[1];
            var sum = Psum(N) + Bsum(N);
            var chk = sum / 2 + 1;
            var ans = 0L;
            if (chk == X)
            {
                ans = Psum(N - 1) + 1;
                Console.WriteLine(ans);
                Console.ReadLine();
                return;
            }
            while (true)
            {
                if (N == 1)
                {
                    if (X == 2) ans += 1;
                    else if (X == 3) ans += 2;
                    else if (X >= 4) ans += 3;
                    break;
                }
                var P = Psum(N - 1);
                var B = Bsum(N - 1);                
                if (chk > X)
                {
                    X -= 1;
                    chk = P;
                    N--;
                }
                else if (chk < X)
                {
                    ans += P + 1;
                    X = X - (P + B + 2);
                    chk = P;
                    N--;
                }
                else
                {
                    ans += P + 1;
                    break;
                }
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static long Psum(long num)
        {
            var ret = 1L;
            for (int i = 0; i < num; i++) ret = 2 * ret + 1;
            return ret;
        }

        static long Bsum(long num)
        {
            var ret = 0L;
            for (int i = 0; i < num; i++) ret = 2 * ret + 2;
            return ret;
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    scanf("%d",&N);
    if(N <= 111) printf("111\n");
    else if(N <= 222) printf("222\n");
    else if(N <= 333) printf("333\n");
    else if(N <= 444) printf("444\n");
    else if(N <= 555) printf("555\n");
    else if(N <= 666) printf("666\n");
    else if(N <= 777) printf("777\n");
    else if(N <= 888) printf("888\n");
    else              printf("999\n");
}


Measured memory_bytes: 128
"""
author : halo2halo
date : 8, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

word = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
N = int(readline())
S = readline().decode('utf8').rstrip()

ans = [None] * len(S)
for i in range(len(S)):
    ans[i] = word[(word.index(S[i]) + N) % len(word)]

ans=''.join(ans)
print(ans)


Measured memory_bytes: 3064
def f():
    s = input()
    for i in range(len(s)):
        if i%2 == 1:
            if s[i] == "L" or s[i] == "U" or s[i] == "D":
                continue
            else:
                return "No"
        else:
            if s[i] == "R" or s[i] == "U" or s[i] == "D":
                continue
            else:
                return "No"
    return "Yes"
print(f())

Measured memory_bytes: 9080
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double w = sc.nextLong();
        double h = sc.nextLong();
        double x = sc.nextLong();
        double y = sc.nextLong();
        if(w / 2 == x && h / 2 == y) {
            System.out.print(w * h / 2);
            System.out.println(" 1");
        }else {
            System.out.print(w * h / 2);
            System.out.println(" 0");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll l,r,d;
    cin>>l>>r>>d;
    ll x=r/d;
    ll y=(l-1)/d;
    cout<<x-y<<endl;
}
return 0;
}

Measured memory_bytes: 3604
#

import sys
input=sys.stdin.readline

def main():
    N,A,B=map(int,input().split())
    
    if N<=A:
        print(N)
    else:
        print(A*(N//(A+B))+min(N%(A+B),A))
    
    
if __name__=="__main__":
    main()


Measured memory_bytes: 61664
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
#define ll long long 
int n;
int a[100010];
int ans=0;
map<int,int> mp;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(mp[a[i]]){
			mp[a[i]]=0;
			ans--;
		}
		else{
			ans++;
			mp[a[i]]=1;
		}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long ll;

ll n, a, mn=4e18, s[200005];
int main() {
	cin >> n;
	for(ll i=1; i<=n; i++) {
		scanf("%lld", &a);
		s[i] = s[i-1] + a;
	}
	for(ll i=1; i<=n; i++) {
		mn = min(mn, (ll)abs(2*s[i] - s[n]));
	}
	cout << mn;
	return 0;
}


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

int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  bool yes = true;
  if(abs(a - c) > d){
    if(abs(a-b) > d || abs(b-c) > d){
      yes = false;
    }
  }
  
  if(yes){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256