akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  map<int, int> F, S;
  for (int i = 0; i < n; i += 2) {
    F[a[i]]++;
    if (i < n) {
      S[a[i + 1]]++;
    }
  }
  int ans = 100010001;
  int mf = 0, c;

  for (auto it : F) {
    if (mf < it.se) {
      mf = it.se;
      c = it.fi;
    }
  }

  int ms = 0;
  for (auto it : S) {
    if (it.fi != c) maxs(ms, it.se);
  }
  int h = n / 2;
  mins(ans, h - mf + h - ms);

  mf = 0;
  for (auto it : S) {
    if (mf < it.se) {
      mf = it.se;
      c = it.fi;
    }
  }

  ms = 0;
  for (auto it : F) {
    if (it.fi != c) maxs(ms, it.se);
  }
  mins(ans, h - mf + h - ms);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5376
#include <iostream>
using namespace std;
 
int main() 
{
  int n,time;
  cin >> n >> time;
  int c[n],t[n];
  int i;
  for(i= 0;i < n;i++){
    cin >> c[i] >> t[i];
  }
  for(i = 0;i < n;i++){
    if(t[i] <=  time){
      break;
    }
  }
  if(i == n){
    cout << "TLE" << endl;
    return 0;
  }
  int a = c[0];
  for(i = 0;i < n;i++){
    if(t[i] <= time && c[i] < a){
      a = c[i];
    }
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i;
   char a[101];
  scanf("%s\n",a);
   for(i=0;i<=3;i++)
   {
       printf("%c",a[i]);
   }
   printf(" ");
   for(i=4;i<strlen(a);i++)
   {
       printf("%c",a[i]);
   }
   printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int ch(int *w,int p,int n,int k)
{
	int i,t=0,c=1;
	for(i=0;i<n;i++){
		if(w[i]>p) return 0;
		if(w[i]+t>p){
			c+=1;
			t=0;
		}
		t+=w[i];
	}
	return c<=k;
}
int main(void)
{
	int m,n,k,i,w[100000];
	int l=0,r=1000000000;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){scanf("%d",&w[i]);}
	while(l<r){
		m=(l+r)/2;
		if(ch(w,m,n,k))
			r=m;
		else
			l=m+1;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 988
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = Array.fill(3)(sc.nextInt())
  val five = s.count(_ == 5) == 2
  val seven = s.count(_ == 7) == 1
  if (five && seven) {
    println("YES")
  } else {
    println("NO")
  }
}


Measured memory_bytes: 55360
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

char t[200010];
char d[200010];
char s[200010];
int main(){ _;
  int n,q;cin>>n>>q;
  REP(i,n) cin>>s[i+1];
  REP(i,q) cin>>t[i]>>d[i];
  s[0]=s[n+1]='_';

  int l=0,r=n+1;
  for(int i=q-1;i>=0;i--){
    if(d[i]=='L'){
      if(s[l+1]==t[i]) l++;
      if(s[r  ]==t[i]) r++;
    }else{
      if(s[r-1]==t[i]) r--;
      if(s[l  ]==t[i]) l--;
    }
    //cout<<l<<" "<<r<<endl;
  }
  cout<<r-l-1<<endl;
}


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

int main(){
    int x,n,c,d,min,answer;
    int *p;
    min=100;
    c=0;
    cin >> x >> n;
    p=new int[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    for(int i=-100; i<=101; i++){
        for(int j=0; j<n; j++){
            if(i==p[j]){
                c=1;
            }
        }
        if(c==0){
            d=abs(x-i);
            if(d<min){
                min=d;
                answer=i;
            }
        }
        c=0;
    }
    cout << answer << endl;
    delete[] p;
    return 0;
}

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

using namespace std;

long long ans;
int l[100002], r[100002], n;

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> l[i] >> r[i];
  sort (l, l + n + 1);
  reverse(l, l + n + 1);
  sort (r, r + n + 1);
  for (int i = 0; i <= n; i++) {
    if (l[i] <= r[i]) break;
    ans += l[i] - r[i];
  }
  cout << ans * 2;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long MOD = 1000000007;
const long long INF = (1LL << 60);
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		double tmp = 1.0 / n;
		int now = i;
		while (now < k) {
			now *= 2;
			tmp /= 2;
		}
		ans += tmp;
	}
	cout << fixed << setprecision(100) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  input = input.trim().split('\n');
  var N = input[0];
  var As = input[1].split(' ').map(x=>BigInt(x));
  var prod = 1n
  if (As.indexOf(0n) != -1){
    prod = 0n
  }else{
    for (i=0;i<N;i++){
      prod *= As[i];
      if (prod > 10n ** 18n){
        prod = -1n;
        break;
      }
    }
  }
  console.log(prod.toString());
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));


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

using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define INF 1e9



int main(){
    int a,b; cin >> a >> b;
    a--; b--;
    bool h[3];
    rep(i, 3){
        h[i] = false;
    }
    
    h[a] = true;
    h[b] = true;
    
    rep(i,3){
        if(h[i] == false){
            cout << ++i << endl;
            return 0;
        }
    }


}




 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long N;cin>>N;
    string S[N];
    long long AC,WA,TLE,RE;
    AC=WA=TLE=RE=0;
    for(long long i=0;i<N;i++){
        cin>>S[i];
        if(S[i]=="AC"){
            AC++;
        }
        if(S[i]=="WA"){
            WA++;
        }
        if(S[i]=="TLE"){
            TLE++;
        }
        if(S[i]=="RE"){
            RE++;
        }
    }
    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE<<endl;
}


Measured memory_bytes: 6752
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int A,B,X;cin>>A>>B>>X;
    if(A-B==B-X){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

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

using namespace std;

typedef long long ll;

struct Point
{
    ll x,y;
    Point(){ x = y = 0.0; }
    Point(ll _x, ll _y) : x(_x), y(_y){}

    Point operator+ (Point p)
    {
        return Point(p.x + x, p.y + y);
    }

    Point operator- (Point p)
    {
        return Point(x - p.x, y - p.y);
    }

    ll operator* (Point p)
    {
        return p.x * x + p.y * y;
    }

    Point operator* (ll t)
    {
        return Point(x*t, y*t);
    }

    ll operator~ ()
    {
        return x * x + y * y;
    }

    ll operator% (Point p)
    {
        return x * p.y - y * p.x;
    }

};

bool intersect(Point a, Point b, Point p, Point q)
{
    Point v1=(b-a);
    Point v2=(q-p);
    double t,t1;
    if( v1 % v2 != 0 )
    {
        t = (double)(( p - a ) % v2) / (double)(v1 % v2);
        t1 = (double)(( a - p ) % v1) / (double)(v2 % v1);
        if( t >= 0.0 && t <= 1.0 && t1 >= 0.0 && t1 <= 1.0) return true;
        else return false;
    }
    else
    {
        if( v1 % v2 == 0 && (p - a) % v1 == 0 )
        {
            t = (double)((p - a)*v1) /  (double)(v1*v1);
            t1 = (double)((p+v2-a)*v1) / (double)(v1*v1);
            if( v1 * v2 < 0 )
            {
                if( t1 <= 1.0 && 0.0 <= t ) return true;
            }
            else
            {
//                cout <<fixed << setprecision(6)<< t << " " << t1 << " " << v1*v2 << endl;
                if( t <= 1.0 && 0.0 <= t1 ) return true;
            }
        }
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    Point p0,p1,p2,p3;
    Point vec, vec1;
    int q;
    cin >> q;
    while(q--)
    {
        cin >> p0.x >> p0.y >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
        cout << intersect(p0,p1,p2,p3) << '\n';
    }
    return 0;
}

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define INF 1e9
// constexpr ll INF = 1LL << 60;

struct UnionFind{
  vector<int> par, size;
  UnionFind(int n): par(n), size(n, 1){
    REP(i, n){
      par[i] = i;
    }
  }
  int root(int x){
    if(par[x] == x){
      return x;
    }
    return par[x] = root(par[x]);
  }
  bool same(int a, int b){
    return root(a) == root(b);
  }
  void unite(int a, int b){
    int aroot = root(a);
    int broot = root(b);
    if(aroot == broot) return;
    par[aroot] = broot;
    size[broot] += size[aroot];
  }
  int calSize(int x){
    return size[root(x)];
  }
};

int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> edges(M);
  REP(i, M){
    cin >> edges[i].first >> edges[i].second;
    edges[i].first--, edges[i].second--;
  }
  int ans = 0;
  REP(i, M){
    UnionFind uf(N);
    REP(j, M){
      if(i==j) continue;
      uf.unite(edges[j].first, edges[j].second);
    }
    if(uf.calSize(0) != N){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PPI;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())

#define INF 1e16

int n;
ll a[111111];

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  rep(i,n)cin>>a[i];
  ll sum=0;
  ll s1=0,s2=0;
  rep(i,n){
    if(i%2==0&&sum+a[i]<=0){
      s1+=-(sum+a[i])+1;
      sum=1;
    }else if(i%2==1&&sum+a[i]>=0){
      s1+=sum+a[i]+1;
      sum=-1;
    }else sum+=a[i];
  }
  sum=0;
  rep(i,n){
    if(i%2==1&&sum+a[i]<=0){
      s2+=-(sum+a[i])+1;
      sum=1;
    }else if(i%2==0&&sum+a[i]>=0){
      s2+=sum+a[i]+1;
      sum=-1;
    }else sum+=a[i];
  }
  cout<<min(s1,s2)<<endl;
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var ABK = Sarray();
            var A = ABK[0];
            var B = ABK[1];
            var K = ABK[2];
            if (B - A < 2 * K)
            {
                for (var i = A; i <= B; ++i)
                    WriteLine(i);
                return;
            }
            for (var i = A; i < A + K; ++i)
                WriteLine(i);
            for (var i = B - K + 1; i <= B; ++i)
                WriteLine(i);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int c = sc.nextInt();
        
        int[][] tab = new int[r+1][c+1];
        
        for(int i = 0; i < r+1; i++){
            for(int j = 0; j < c+1; j++){
                tab[i][j] = 0;
            }
        }
        
        for(int i = 0; i < r; i++){
            for(int j = 0; j < c; j++){
            	int nec =  sc.nextInt();
                tab[i][j] = nec;
                tab[i][c]+= nec;
                tab[r][j]+= nec;
                tab[r][c]+= nec;
            }
        }
        
         for(int i = 0; i < r+1; i++){
            for(int j = 0; j < c+1; j++){
                if(j == c){
                    System.out.printf("%d",tab[i][j]);
                }else{
                    System.out.printf(tab[i][j] + " ");
                }
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 49756
// Snippets
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! stdin {
    () => ({
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    })
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => (
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input.to_string()), $output);
            )*
        }
    )
}

// End Snippets

fn main() {
    println!("{}", solve(stdin!()));
}

fn solve(src: String) -> String {
    input!{
        source = src,
        n: usize,
        s: chars,
        k: usize,
    }
    let mut s = s;
    let star = s[k-1];
    for i in 0..n {
        if s[i] != star {
            s[i] = '*';
        }
    }
    s.iter().cloned().collect::<String>()
}

test! {
r"5
error
2"
=> "*rr*r",
r"6
eleven
5"
=> "e*e*e*",
r"9
education
7"
=> "******i**",
}


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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	ll n,h,w;
	cin >> n >> h >> w;
	ll tate[n];ll yoko[n];
	ll ans = 0;
	for (int i = 0;i < n;i++) {
		cin >> tate[i] >> yoko[i];
		if (tate[i] >= h && yoko[i] >= w) {ans++;}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <tuple>
#include <set>
#include <algorithm>
using namespace std;

int main() {
	int N, Q;
	scanf("%d %d", &N, &Q);
	vector<tuple<int, int, int>> event;
	for(int i = 0; i < N; i++) {
		int s, t, x;
		scanf("%d %d %d", &s, &t, &x);
		event.push_back(make_tuple(s-x, 1, x));
		event.push_back(make_tuple(t-x, -1, x));
	}
	
	vector<int> D(Q);
	for(int i = 0; i < Q; i++) scanf("%d", &D[i]);
	
	sort(event.begin(), event.end());
	multiset<int> st;
	int k = 0;  //何番目のイベントまで処理したか
	for(int i = 0; i < Q; i++) {
		while(k < event.size() && get<0>(event[k]) <= D[i]) {
			if(get<1>(event[k]) == 1) {
				st.insert(get<2>(event[k]));
			} else {
				auto it = st.find(get<2>(event[k]));
				if(it != st.end()) st.erase(it); //1つだけ削除
			}
			k++;
		}
		
		if(st.empty()) printf("-1\n");
		else printf("%d\n", *st.begin());
	}
	
	return 0;
}

Measured memory_bytes: 16236
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans = N;
		for(int i = 0; i <= N; i++) {
			int a = 0, b = i;
			while(b > 0) {
				a += b % 6;
				b /= 6;
			}
			b = N - i;
			while(b > 0) {
				a += b % 9;
				b /= 9;
			}
			ans = Math.min(ans, a);
		}
		System.out.println(ans);
	}

}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 3010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

int n, m;
int dp[MAXN][MAXN];
string s, t;
int main() {
    cin >> s >> t;
    n = s.size();
    m = t.size();

    string ans = "";

    rep(i, n) {
        for(int k=0; k<m; ++k) {
            if (s[i] == t[k]) {
                dp[i+1][k+1] = dp[i][k] + 1;
            } else {
                dp[i+1][k+1] = max(dp[i][k+1] , dp[i+1][k]);
            }
        }
    }

    int a=n, b=m;

    while (a>0 && b>0) {
        if (dp[a][b] == dp[a-1][b]) --a;
        else if (dp[a][b] == dp[a][b-1]) --b;
        else {
            --a; --b;
            ans = s[a] + ans;
        }
    }

    //cout << dp[n][m] << endl;
    cout << ans << endl;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ll> a(n);rep(i,n){cin>>a[i];}
#define repins(a,n) vector<string> a(n);rep(i,n){cin>>a[i];}
#define repind(a,n) vector<double> a(n);rep(i,n){cin>>a[i];}
#define in(a) ll a;cin>>a;
#define ins(a) string a;cin>>a;
#define ind(a) double a;cin>>a;
template<class T>
inline void out(T a){cout<<a<<endl; }
inline void out(double a){ printf("%.10f\n", a);} 
#define all(x) (x).begin(),(x).end()
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)
using vell = vector<ll>;
using ves = vector<string>;
using ved = vector<double>;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main()
{
	in(n);
	in(r);
	if(n<10){
		out(r+100*(10-n));
	}else{
		out(r);
	}
}

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

using namespace std;

int DP[100010];
int arr[100010];

int solve(int pos) {
    if (DP[pos]!=-1) {
        return DP[pos];
    }
    DP[pos] = min(solve(pos-1)+abs(arr[pos]-arr[pos-1]),solve(pos-2)+abs(arr[pos]-arr[pos-2]));
    return DP[pos];
}

int main () {
    int N;
    scanf("%d",&N);
    for (int i=0;i<N;i++) {
        scanf("%d",&arr[i]);
        DP[i]=-1;
    }
    DP[0]=0;
    DP[1]=abs(arr[0]-arr[1]);
    cout << solve(N-1);
    return 0;
}


Measured memory_bytes: 2560
import itertools
def rren(): return list(map(int, input().split()))
n,m=rren()
hl=[0] +rren()
al=[tuple(input().split()) for i in range(m)]
ans=[0]+[1]*n
for r in al:
    rl=int(r[0])
    rr=int(r[1])
    if hl[rl] == hl[rr]:
        ans[rr] = 0
        ans[rl] = 0
    elif hl[rl] > hl[rr]:
        ans[rr] = 0
    else:
        ans[rl] = 0
print(sum(ans))


Measured memory_bytes: 34468
read
cnt=0
A01=${REPLY:0:1}
A02=${REPLY:1:1}
A03=${REPLY:2:1}
A04=${REPLY:3:1}
A05=${REPLY:4:1}
A06=${REPLY:5:1}
A07=${REPLY:6:1}
A08=${REPLY:7:1}
A09=${REPLY:8:1}
A10=${REPLY:9:1}
A11=${REPLY:10:1}
A12=${REPLY:11:1}
A13=${REPLY:12:1}
A14=${REPLY:13:1}
A15=${REPLY:14:1}
A16=${REPLY:15:1}
[[ ${A01} = "C" ]] || cnt=$((cnt + 1))
[[ ${A02} = "O" ]] || cnt=$((cnt + 1))
[[ ${A03} = "D" ]] || cnt=$((cnt + 1))
[[ ${A04} = "E" ]] || cnt=$((cnt + 1))
[[ ${A05} = "F" ]] || cnt=$((cnt + 1))
[[ ${A06} = "E" ]] || cnt=$((cnt + 1))
[[ ${A07} = "S" ]] || cnt=$((cnt + 1))
[[ ${A08} = "T" ]] || cnt=$((cnt + 1))
[[ ${A09} = "I" ]] || cnt=$((cnt + 1))
[[ ${A10} = "V" ]] || cnt=$((cnt + 1))
[[ ${A11} = "A" ]] || cnt=$((cnt + 1))
[[ ${A12} = "L" ]] || cnt=$((cnt + 1))
[[ ${A13} = "2" ]] || cnt=$((cnt + 1))
[[ ${A14} = "0" ]] || cnt=$((cnt + 1))
[[ ${A15} = "1" ]] || cnt=$((cnt + 1))
[[ ${A16} = "6" ]] || cnt=$((cnt + 1))
echo $cnt


Measured memory_bytes: 1268
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<math.h>

using namespace std;

int main() {
	long long  a, b, k;
	cin >> a >> b >> k;

	if (a > k) { a -= k; }
	else {
		if (b > k - a)b -= (k - a);
		else b = 0;
		a = 0;
	}
	
	cout << a << " " << b << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        
		int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        int i, j, k;
        int[][] A = new int[n][m];
        int[][] B = new int[m][l];
        long [][] C = new long[n][l];
        for(i=0; i<n;i++){
			for(j=0; j<m; j++){
                A[i][j] = sc.nextInt();
            }
        }
         for(i=0; i<m;i++){
			for(j=0; j<l; j++){
                B[i][j] = sc.nextInt();
            }
        }
        for(i=0; i<n;i++){
			for(j=0; j<l; j++){
				for(k=0; k<m; k++){
                    C[i][j] += A[i][k]*B[k][j];
                }
                if(j==l-1) System.out.print(C[i][j]);
                else System.out.print(C[i][j] + " ");
            }
            System.out.println();
        }
    }
}
        


Measured memory_bytes: 53572
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;

// ll modexp(ll x, ll y, ll p)
// {
//    ll res = 1;      
//    x = x % p;   
//    while (y > 0)
//    {
//        if (y & 1)
//            res = (res * x) % p;
//        y = y >> 1; 
//        x = (x * x) % p;
//    }
//    return res;
// }

// ll sub_mod(ll a, ll b, ll m){
//    if (a >= b)
//        return a - b;
//    else
//        return m - b + a;
// }

// ll add_mod(ll a, ll b){
//    if (0 == b) 
//        return a;

//    b = mod - b;
//    if (a >= b)
//        return a - b;
//    else
//        return mod - b + a;
// }

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

int main()
{
// #ifndef ONLINE_JUDGE   
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	string s;
	cin>>s;
	for(ll i=0;i<s.length();++i)
		s[i]='x';
	cout<<s;
	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

from fractions import gcd
import math
from math import ceil,floor
import collections

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))


N=int(input())

print(math.ceil(N/2))


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

int main(){
  	int N, M, ans=0;
  	long pena=0;
  	cin >> N >> M;
  	vector<int> p(M);
  	vector<string> S(M);
  	
  	for(int i=0; i<M; i++){
      	cin >> p[i] >> S[i];
    }
  	
  	vector<bool> check(N);
  	vector<int> cnt(N);
  
  	for(int i=0; i<N; i++){
    	check[i] = true;
    }
  	
  	for(int i=0; i<M; i++){
    	if(S[i]=="AC"){
        	check[p[i]-1] = false;
        }else if(S[i]=="WA"&&check[p[i]-1]==true){
        	cnt[p[i]-1]++;
        }
    }
  	
  	/*for(int i=0; i<N; i++){
    	cout << "check[i]= " << check[i] 
          << " cnt[i]= " <<cnt[i] << endl;
    }*/
  	for(int i=0; i<N; i++){
    	if(check[i]==false){
        	ans++;
          	pena+=cnt[i];
        }
      	
    }
  
  	cout << ans << " " << pena << endl;
	return 0;
}

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

int main() {
  int N, T, minCost = 1001, tempT, tempC;
  cin >> N >> T;
  for (int i = 0; i < N; i++) {
    cin >> tempC >> tempT;
    if (tempT <= T) minCost = min(minCost, tempC);
  }
  if (minCost > 1000) {
    cout << "TLE";
  } else {
    cout << minCost;
  }
  return 0;
}

Measured memory_bytes: 256
S = input()

l = len(S)
pre = ''
flag = 0
count = 0

for i in range(l):
    if flag == 1:
        flag = 0
        continue

    try:
        tmp = S[i]
        if tmp == pre:
            flag = 1
            pre = tmp + S[i+1]
            count += 1
        else:
            pre = tmp
            count += 1
    except IndexError:
        pass

print(count)

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

class Program
{
    static void Main(string[] args)
    {
        var N = sc.ReadInt();
        var A = sc.ReadIntArray(N);

        var c = 0;
        var res = new int[N];
        var ok = true;
        for (int i = 0; i < N; i++)
        {
            c++;
            var index = -1;
            var k = 0;
            for (int j = 0; j < N; j++)
            {
                if (A[j] != -1) k++;
                if (A[j] == k)
                {
                    index = j;
                }
            }
            if (index == -1)
            {
                ok = false;
                break;
            }
            res[N - c] = A[index];
            A[index] = -1;
        }

        if (ok)
        {
            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(res[i]);
            }
        }
        else
        {
            Console.WriteLine(-1);
        }
    }

    static int MOD = (int)1e9 + 7;
    static int INF = (int)1e7 + 1;
    static long LINF = (long)1e13 + 1;
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 13140
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int M = Integer.parseInt(sc.get());
		List<Set<Integer>> graph = new ArrayList<>();
		List<Set<Integer>> reversed = new ArrayList<>();
		int root;
		{
			BitSet child = new BitSet(N);
			for (int i = 0; i < N; i++) {
				graph.add(new HashSet<>());
				reversed.add(new HashSet<>());
			}
			for (int i = 0; i < N - 1 + M; i++) {
				int A = Integer.parseInt(sc.get()) - 1;
				int B = Integer.parseInt(sc.get()) - 1;

				graph.get(A).add(B);
				reversed.get(B).add(A);

				child.set(B);
			}
			root = child.nextClearBit(0);
		}

		Queue<Integer> queue = new ArrayDeque<>();
		queue.add(root);
		int[] parent = new int[N];
		while (!queue.isEmpty()) {
			int remove = queue.remove();
			Set<Integer> children = graph.get(remove);
			for (Integer child : children) {
				reversed.get(child).remove(remove);
				if (!reversed.get(child).isEmpty()) continue;
				parent[child] = remove;
				queue.add(child);
			}
		}
		parent[root] = -1;
		for (int i : parent) {
			System.out.println(i + 1);
		}
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 112880
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    int x,y,z;
    x=a+b;
    y=a-b;
    z=a*b;
    int p=max(x,max(y,z));
    cout << p << endl;


    return 0;
}



Measured memory_bytes: 256
text = input()
s = list(text)
n = len(text)

i = 0


while i < n:
    if i % 2 == 0:
        if s[i] == "R" or s[i] == "U" or s[i] == "D":
            i += 1

        else:
            print("No")
            break


    elif i % 2 == 1:
        if s[i] == "L" or s[i] == "U" or s[i] == "D":
            i += 1
        else:
            print("No")
            break

if i == n:
    print("Yes")
else:
    None

Measured memory_bytes: 3060
n = [i+1 for i in range(int(input()))]
p = list(map(int, input().split()))

if n == p:
	print("YES")
	exit()

count = 0
for i, j in zip(n,p):
	if i != j:
		count += 1

if count == 2:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 3060
# Aizu Problem 0035: Is it Convex?
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def distance(p1, p2):
    return math.sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)

def is_to_the_left(p1, p2, p3):
    # determine whether point p3 is to the left from the line from p1 to p2
    position = (p2[0] - p1[0]) * (p3[1] - p1[1]) - (p2[1] - p1[1]) * (p3[0] - p1[0])
    return position < 0


def jarvis(points):
    # determine convex hull by Jarvis' algorithm:
    max_y = max([p[1] for p in points])
    pointOnHull = [p for p in points if p[1] == max_y][0]
    convex_hull = [pointOnHull]
    while len(convex_hull) == 1 or convex_hull[-1] != convex_hull[0]:
        p = convex_hull[-1]
        endpoint = points[0]
        for j in range(len(points)):
            if endpoint == pointOnHull or is_to_the_left(p, endpoint, points[j]):
                endpoint = points[j]
        pointOnHull = endpoint
        convex_hull.append(pointOnHull)
    return convex_hull[::-1]
    

def convex_hull(points):
    hull = jarvis(points)
    length = 0
    line2 = ""
    for i in range(len(hull) - 1):
        p1, p2 = hull[i], hull[i+1]
        line2 += "(" + str(p1[0]) + "," + str(p1[1]) + ") "
    line2 += "(" + str(hull[-1][0]) + "," + str(hull[-1][1]) + ")"
    print(line2)
    

while True:
    try:
        x1, y1, x2, y2, x3, y3, x4, y4 = [float(_) for _ in input().split(',')]
    except EOFError:
        break
    print("YES" if len(jarvis([[x1, y1], [x2, y2], [x3, y3], [x4, y4]])) == 5 else "NO")

Measured memory_bytes: 7600
#include <iostream>
#include <vector>
using namespace std;
#define MAX 10000000
typedef long long ll;

bool prime[MAX];

void calcPrime(){
	for( ll i = 2; i < MAX; i++ ) prime[i] = true;
	for( ll i = 2; i < MAX; i++ ){
		if( prime[i] ){
			for( ll j = i+i; j < MAX; j += i ) prime[j] = false;
		}
	}
}

int main(){
	calcPrime();
	int n;
	while( cin >> n, n ){
		int cnt = 0, sum = 0;
		for( ll i = 2; i < MAX; i++ ){
			if( prime[i] ){
				sum += i;
				if( n == ++cnt ) break;
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 10924
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  
  string s, t; cin >> s >> t;
  array<int, 26> counts{}, countt{};
  
  for (int i = 0; i < s.size(); i++)
    counts[s[i] - 'a']++;
  for (int i = 0; i < t.size(); i++) {
    if (counts[t[i] - 'a'] == 0) {
      cout << -1 << endl;
      return 0;
    }
    countt[t[i] - 'a']++;
  }
  
  int l = s.size();
  vector<int> idx;
  vector<array<int, 26>> next(l, array<int, 26>{});
  for (int i = 0; i < s.size(); i++) {
    if (countt[s[i] - 'a'] > 0) {
      idx.push_back(i);
    }
  }
  
  int m = idx.size();
  array<int, 26> dp{};
  for (int i = 0; i < 26; i++)
    dp[i] = 1 << 20;
  for (int i = m - 1; i >= 0; i--) {
    int j = idx[i];
    int c = s[j] - 'a';
    int old = dp[c];
    dp[c] = j;
    for (int k = 0; k < 26; k++) {
      next[j][k] = dp[k] - j;
      if (k == c) next[j][k] = min(old - j, l);
    }
  }
  
  for (int i = 0; i < m; i++) {
    int j = idx[i];
    for (int k = 0; k < 26; k++) {
      next[j][k] = min(next[j][k], l - j + dp[k]);
    }
  }
  
  ll ans = 0;
  int j = dp[t[0] - 'a'];
  ans += j + 1;
  for (int i = 0; i < t.size() - 1; i++) {
    int d = next[j][t[i + 1] - 'a'];
    ans += d;
    j = (j + d) % l;
  }
  cout << ans << endl;
  
  return 0; 
}

Measured memory_bytes: 11340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> mp;
ll a[2*1000005];
vector<ll> v;

int main()
{
	int n;
	cin >>n;
	ll sum=0,ans=0;
	for(int i=0;i<n;i++) cin >>a[i],mp[a[i]]++;
	for(auto x : mp)
	{
		ll res=x.second;
		if(res>=2) sum+=res*(res-1)/2,v.push_back(res);
	}
	for(int i=0;i<n;i++)
	{
		ll x=a[i];
		if(mp[x]>=2)
		{
			ll res=mp[x];
			cout <<sum-res*(res-1)/2+(res-1)*(res-2)/2<<endl;
		}
		else cout <<sum<<endl;
	}
}

Measured memory_bytes: 11640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
#define INF 1e9
#define INFL 1e12
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    int n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];


    int dp[100100]={};
    // rep(i, n) printf("%d ", a[i]); cout << endl;
    int m=100000;
    rep(i, n) chmin(m, a[i]);
    rep(i, m) dp[i] = -1;
    for(int i: a) dp[i] = 1;

    rep(i, k+1){
        if(dp[i]!=0) continue;
        for(int j :a){
            if(i-j>=0 && dp[i-j]==-1){
                dp[i] = 1;
                break;
            }
        }
        if(dp[i]==0) dp[i] = -1;
    }

    // rep(i, k+1) printf("%d ", dp[i]); cout << endl;

    if(dp[k]==1) printf("First\n");
    else printf("Second\n");
    return 0;
}

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

int main()
{
    int h,w,i,j;
    while(true){
        cin >> h >> w;
        if(h ==0 && w == 0)
            break;
        for(i = 0; i < h ;i++){
            for(j = 0; j < w; j++){
                if((j+i) % 2 == 0)
                    cout << '#';
                else
                    cout << '.';
            }
            cout << '\n';
        }
        cout << endl;
    }
}

Measured memory_bytes: 1152
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    const int MAX_N = 1e5;
    int N, x, a[MAX_N];
    cin >> N >> x;
    REP(i, N) {
        cin >> a[i];
    }
    ll res = 0;
    if (x < a[0]) {
        res = a[0] - x;
        a[0] = x;
    }
    FOR(i, 1, N, 1) {
        if (a[i - 1] + a[i] > x) {
            int t = a[i];
            a[i] = max(x - a[i - 1], 0);
            res += t - a[i];
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#define MAX 10000
#define NOT_FOUND -1

int linearSearch(int[],int);

int n;

int main(){
    int q,count = 0;
    int S[MAX],T[MAX];

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

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

    for(int i = 0;i < q;i++)if(linearSearch(S,T[i]) >= 0)count++;

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

    return 0;
}

int linearSearch(int A[n],int key){
    int i = 0;
    A[n] = key;
    while(A[i] != key){
        i++;
    }
    if(i == n)return NOT_FOUND;
    return i;
}


Measured memory_bytes: 2144
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
#define fst first
#define snd second
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

int main(){
    ll n, m, q; cin >> n >> m >> q;
    vvll p(n+1, vll(n+1, 0));
    rep(i, 0, m){
        ll a, b; cin >> a >> b;
        p[a][b]++;
    }
    vvll bcum(n+2, vll(n+1, 0));
    rrep(i, n, -1){
        rep(j, 1, n+1){
            bcum[i][j] = bcum[i][j-1] + bcum[i+1][j] - bcum[i+1][j-1] + p[i][j];
        }
    }
    
    rep(i, 0, q){
        ll l, r; cin >> l >> r;
        prtl(bcum[l][r]);
    }
}


Measured memory_bytes: 7608
from collections import deque
 
H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
maze = [input() for _ in range(H)]
 
INF = 10 ** 12
path = [[INF] * W for _ in range(H)]  # path: 各マスへの移動コスト
 
walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]
 
q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))
 
while q:
    x, y, s = q.popleft()
    for dx, dy in walk:  # 移動A
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s))  # 移動Aの場合はコスト0. キューの先頭に追加する.
    for dx, dy in warp:  # 移動B
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            q.append((nx, ny, s + 1))  # 移動Bの場合はコスト1. キューの最後尾に追加する.
    
ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)

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

namespace Nikkei2019_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var NAB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NAB[0];
            var A = NAB[1];
            var B = NAB[2];

            var max = Math.Min(A, B);
            var min = Math.Max(A + B - N, 0);
            Console.WriteLine(max + " " + min);
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int>t(N+1);
  vector<int>x(N+1);
  vector<int>y(N+1);
  vector<int>T(N);
  vector<int>X(N);
  vector<int>Y(N);
  
  t.at(0)=0;
  x.at(0)=0;
  y.at(0)=0;
  
  for(int i=1; i<N+1; i++){
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  
   for(int i=0; i<N; i++){
     T.at(i) = abs(t.at(i+1)-t.at(i));
     X.at(i) = x.at(i+1) - x.at(i);
     Y.at(i) = y.at(i+1) - y.at(i);
   }
  
  for(int i=0; i<N; i++){
    if(T.at(i)< abs(X.at(i))+abs(Y.at(i))){
      cout<<"No"<<endl;
      break;
    }
    else if(abs((abs(X.at(i))+abs(Y.at(i))-T.at(i)))%2==1){
         cout<<"No"<<endl;
      break;
       }
    else if(i==N-1){
      cout <<"Yes" <<endl;
    }
            
  }
}

Measured memory_bytes: 5512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long N = scan.nextLong();
		long A = scan.nextLong();
		long B = scan.nextLong();

		long ans = (N / (A+B)) * A;
		long rem =  N % (A + B) > A ? A: N%(A + B);

		System.out.println(ans + rem);

	}
}


Measured memory_bytes: 22996
N, = map(int, input().split())
M=10**9+7
n=N
_ALL=1<<n
def itercomb(n,k):
    if k==0:
        yield 0
    else:
        _a = (1<<k)-1
        yield _a
        while 1:
            _x = _a & -_a
            _y = _a + _x
            _a = (((_a & ~_y) // _x) >> 1) | _y
            if _a >= _ALL: break
            yield _a


xs = []
for _ in range(N):
    xs.append([1<<i for i, x in enumerate(input().split()) if int(x)])
d = [0]*(1<<N)
d[0] = 1
for i, y in enumerate(xs):
    for x in itercomb(N, i):
        for ai in y:
            if (not x&ai):
                d[x|ai] = (d[x] + d[x|ai])%M
print(d[-1])


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

int main(){
    int n,x;
    long long ans=0;
    int a[100000+3];

    cin >> n>>x;
    cin>>a[0];
    long long shot = a[0];
    if(shot >x){
        ans+=shot-x;
        a[0]-=shot-x;
        shot = x;
    }
    for(int i=1;i<n;i++){
        cin>>a[i];
        shot+=a[i];
        if (shot > x)
        {
            ans += shot - x;
            a[i] -= shot - x;
            shot = x;
        }
        shot-=a[i-1];
    }
    cout<<ans;

}


Measured memory_bytes: 640
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
using namespace std;

int main(){
  int n; cin >> n;
  int h[n]; int ans=0;
  for(int q=0;q<n;q++) {
    cin >> h[q];
  }
 if(n==1) cout << '1' <<endl;
  
 else{
  if(h[0]<=h[1]) ans++;
  
   for(int i=2;i<n;i++){
     int res=0;
     for(int j=0;j<i;j++){
       if(h[j] <= h[i]) res++;
     }
     if(res == i) ans++;
   }
   cout << ans+1 <<endl;
  }
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#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 PB push_back
#define ar2 array<int, 2>
typedef long long LL;
const int N = 2e5+5;
	
int pw2_i = 100, pw2_b_i = 200, zero_i = 600;
int cmp_i = 300, add_a_i = 400, add_b_i = 500;
int cmp2_i = 700;

vector<string> ans;

inline string cmp_s(int x, int y, int z){return "< "+to_string(x)+" "+to_string(y)+" "+to_string(z);}
inline string add_s(int x, int y, int z){return "+ "+to_string(x)+" "+to_string(y)+" "+to_string(z);}

void iadd(int flag, int x, int y, int cmp_i, int add_i){
	//a[y] += a[flag] ? a[x] : 0
	int backup = add_i + 5; //different from +1 in main function
	int backup_x = add_i + 6;
	ans.PB(cmp_s(0,0,backup));
	ans.PB(add_s(zero_i,x,backup_x));
	ans.PB(add_s(x,pw2_i,x));
	
	rrep(i,60,0){
		ans.PB(add_s(zero_i,backup,add_i));
		ans.PB(add_s(add_i,pw2_i+i,add_i));
		ans.PB(cmp_s(add_i,x,cmp_i));
		ans.PB(add_s(flag,cmp_i,cmp_i));
		ans.PB(cmp_s(pw2_i,cmp_i,cmp_i));
		
		rep(j,1,i) ans.PB(add_s(cmp_i,cmp_i,cmp_i));
		ans.PB(add_s(cmp_i,y,y));
		ans.PB(add_s(cmp_i,backup,backup));
	}
	
	ans.PB(add_s(zero_i,backup_x,x));
}

int main(){
	ans.PB(cmp_s(pw2_i,0,pw2_i));
	ans.PB(cmp_s(pw2_i+1,1,pw2_i+1));
	ans.PB(add_s(pw2_i+1,pw2_i,pw2_i));
	ans.PB(cmp_s(zero_i,pw2_i,pw2_i));
	ans.PB(add_s(0,pw2_i,0));
	rep(i,1,60) ans.PB(add_s(pw2_i+i-1, pw2_i+i-1, pw2_i+i));
	
	ans.PB(add_s(1,zero_i,pw2_b_i));
	rep(i,1,30) ans.PB(add_s(pw2_b_i+i-1, pw2_b_i+i-1, pw2_b_i+i));
	
	rrep(i,30,0){
		int backup_a = add_a_i + 1;
		ans.PB(add_s(zero_i,backup_a,add_a_i));
		ans.PB(add_s(add_a_i,pw2_i+i,add_a_i));
		ans.PB(cmp_s(add_a_i,0,cmp_i));
		iadd(cmp_i,pw2_b_i+i,2,cmp2_i,add_b_i);
		ans.PB(add_s(zero_i,pw2_i+i,add_a_i));
		iadd(cmp_i,add_a_i,backup_a,cmp2_i,add_b_i);
	}
	cout<<ans.size()<<endl;
	for(auto x:ans) cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 11532