akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
  int ans, res, tmp, atmp, rtmp, a[4], r[4], hit, blow, i, j;

  while(1){
    scanf("%d%d", &ans, &res);
    if(ans==0 && res==0){
      break;
    }
    tmp=1000;
    atmp=rtmp=0;
    for(i=0; i<4; i++){
      a[i]=ans/tmp-atmp*10;
      atmp=ans/tmp;
      r[i]=res/tmp-rtmp*10;
      rtmp=res/tmp;
      tmp=tmp/10;
      //printf("%d %d\n", a[i], r[i]);
    }
    hit = blow = 0;
    for(i=0; i<4; i++){
      if(a[i]==r[i]){
	hit++;
      }
      for(j=0; j<4; j++){
	if(a[i]==r[j]){
	  blow++;
	}
      }
    }
    printf("%d %d\n", hit, blow-hit);
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
using namespace std;
int INF = 100000000;
int main(){
  int n, M = 1000000;
  vector<int> A(M,INF), A_odd(M,INF);
  int t = 1, k = 3;
  A[0] = 0;
  A_odd[0] = 0;
  while(t < 1000000){
    for(int k = 0; k+t < M; ++k){
      A[k+t] = min(A[k]+1,A[k+t]);
      if(t%2) A_odd[k+t] = min(A_odd[k]+1,A_odd[k+t]);
    }
    ++k;
    t *= k;
    t /= (k-3);
  }
  while(cin >> n, n){
    cout << A[n] << " " << A_odd[n] << endl;
  }
  return 0;
}

Measured memory_bytes: 10552
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
typedef long long ll;
using namespace std;

// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
// 変数 modの数
const int mod = 1000000007;
struct mint {
ll x; // typedef long long ll;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll sum(ll l, ll r) {
    return (l+r)*(r-l+1)/2;
}

int main() {
    // 10^100が非常に大きい数のため，選ぶ個数(k)が違ったら必ず違う数になる
    // 10^100を無視して端数で考えることができる
    // 選ぶ個数を一旦固定して考えて作れる個数をカウントして
    // 合わせた合計を出力する
    int n, k;
    cin >> n >> k;
    mint ans;
    for (int i = k; i <= n+1; ++i) {
        ll l = sum(0,i-1), r = sum(n-i+1,n);
        ans+= r-l+1;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

#define INF (1LL << 60)
#define MOD 1000000009

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    string S;
    cin >> S;
    sort(ALL(S));
    if(S[0] == S[1] && S[2] == S[3] && S[1] != S[2]) _PR("Yes");
    else _PR("No");

    return 0;
}

/*



*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin>>n;
    vector<int> a(1<<n);
    for(int i=0;i<1<<n;i++){
        cin>>a[i];
    }
    vector<pair<int,int>> dp1(1<<n);
    for(int i=0;i<1<<n;i++){
        dp1[i]=make_pair(a[i],i);
    }
    vector<pair<int,int>> dp2(1<<n,make_pair(-INF,-INF));
    for(int i=0;i<1<<n;i++){
        for(int j=0;j<n;j++){
            if(i&(1<<j))continue;
            int to=i+(1<<j);
            if(dp1[to]<dp1[i]){
                dp2[to]=dp1[to];
                dp1[to]=dp1[i];
            }
            else if(dp1[to]==dp1[i]);
            else if(dp2[to]<dp1[i]){
                dp2[to]=dp1[i];
            }
            if(dp1[to]<dp2[i]){
                dp2[to]=dp1[to];
                dp1[to]=dp2[i];
            }
            else if(dp1[to]==dp2[i]);
            else if(dp2[to]<dp2[i]){
                dp2[to]=dp2[i];
            }
        }
    }
    int ans=-INF;
    for(int k=1;k<1<<n;k++){
        ans=max(ans,dp1[k].first+dp2[k].first);
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
int cnt[2][105];

int main() {
	int n;
	cin >> n;
	vector<int>t(n), x(n), y(n);
	rep(i, n) {
		cin >> t[i] >> x[i] >> y[i];
	}
	bool flag = true;
	int resx = 0, resy = 0;
	rep(i, n) {
		if (abs(x[i] - resx) + abs(y[i] - resy) > t[i] || (x[i] + y[i]) % 2 != t[i] % 2)flag = false;
		resx = x[i];
		resy = y[i];
	}
	if (flag)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 1408
"use strict";

const DEBUG_MODE = false;
const rawInput = DEBUG_MODE
  ? "1 1"
  : require("fs")
      .readFileSync("/dev/stdin", "utf8")
      .trim();
const YEAR = 2018;

const process = inputRaw => {
  const input = inputRaw.split(" ");
  const month = input[0];
  const day = input[1];

  console.log(day < month ? month - 1 : month);
};

process(rawInput);


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

int main()
{
    int a, b, c, k, sum=0;
    cin >> a >> b >> c >> k;

    if(k>a)
    {
        sum+=a, k-=a;
        if(k>b) k-=b, sum-=k;
    }
    else sum=k;
    cout << sum;
}


Measured memory_bytes: 3612
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a1 = Integer.parseInt(sc.next());
    int a2 = Integer.parseInt(sc.next());
    int a3 = Integer.parseInt(sc.next());
    int b1 = Integer.parseInt(sc.next());
    int b2 = Integer.parseInt(sc.next());
    int b3 = Integer.parseInt(sc.next());
    int c1 = Integer.parseInt(sc.next());
    int c2 = Integer.parseInt(sc.next());
    int c3 = Integer.parseInt(sc.next());
    
    boolean flg = true;
    if(
        a1-a2 != b1-b2 || a1-a3 != b1-b3 ||
        a1-a2 != c1-c2 || a1-a3 != c1-c3 || 

        a1-b1 != a2-b2 || a1-b1 != a3-b3 || 
        a1-c1 != a2-c2 || a1-c1 != a3-c3
    ){
        System.out.println("No");
    }else{
        System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 23636
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strings"
)

var H, W int

func main() {
	fmt.Scan(&H, &W)
	reader := bufio.NewScanner(os.Stdin)
	//reader.Split(bufio.ScanWords)

	S := make([][]string, H)

	left := [2100][2100]int{}
	right := [2100][2100]int{}
	up := [2100][2100]int{}
	down := [2100][2100]int{}

	// 入力
	for i := 0; i < H; i++ {
		reader.Scan()
		S[i] = strings.Split(reader.Text(), "")
	}

	// left
	for i := 0; i < H; i++ {
		var cnt int
		for j := 0; j < W; j++ {
			if S[i][j] == "#" {
				cnt = 0
				left[i][j] = 0
			} else {
				cnt++
				left[i][j] = cnt
			}
		}
	}
	// right
	for i := 0; i < H; i++ {
		var cnt int
		for j := W - 1; 0 <= j; j-- {
			if S[i][j] == "#" {
				cnt = 0
				right[i][j] = 0
			} else {
				cnt++
				right[i][j] = cnt
			}
		}
	}
	// up
	for j := 0; j < W; j++ {
		var cnt int
		for i := 0; i < H; i++ {
			if S[i][j] == "#" {
				cnt = 0
				up[i][j] = 0
			} else {
				cnt++
				up[i][j] = cnt
			}
		}
	}
	// down
	for j := 0; j < W; j++ {
		var cnt int
		for i := H - 1; 0 <= i; i-- {
			if S[i][j] == "#" {
				cnt = 0
				down[i][j] = 0
			} else {
				cnt++
				down[i][j] = cnt
			}
		}
	}

	var ans int
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if S[i][j] != "#" {
				ans = max(ans, left[i][j]+right[i][j]+up[i][j]+down[i][j]-3)
			}
		}
	}
	fmt.Println(ans)
}

/*  ----------------------------------------  */

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type LR struct {
	L int
	R int
}

// type LR []int

// func (a SortBy) Len() int           { return len(a) }
// func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
// func (a SortBy) Less(i, j int) bool { return a[i] < a[j] }


Measured memory_bytes: 213376
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b;
  cin>>a>>b;
  vector<int> c(b);
  rep(i,b)
    cin>>c[i];
  sort(all(c));
  int d=0;
  rep(i,b-1){
    d=max(d,c[i+1]-c[i]);
  }
    d=max(d,a-c[b-1]+c[0]);
  out(a-d);
  
}


Measured memory_bytes: 1792
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)
        cout<<(n-2)*(b-a)+1<<endl;
    else
        cout<<0<<endl; 
 } 

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int n;
long long a[200001], sum;
int main(int argc, char *argv[]) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]);
        sum += a[i];
    }
    int left = 1;
    long long l1 = a[1];
    long long l2 = a[2];
    int right = 3;
    long long r1 = a[3];
    long long r2 = sum - a[1] - a[2] - a[3];
    while (r1 < r2) {
        ++right;
        r1 += a[right];
        r2 -= a[right];
    }
    if (right > 3) {
        long long prer1 = r1 - a[right];
        long long prer2 = r2 + a[right];
        if (r1 - r2 > prer2 - prer1) {
            --right;
            r1 = prer1;
            r2 = prer2;
        }
    }
    long long minl = min(l1, l2);
    long long maxl = max(l1, l2);
    long long minr = min(r1, r2);
    long long maxr = max(r1, r2);
    long long t = max(maxl, maxr) - min(minl, minr);
    if (t == 0) {
        printf("0\n");
        return 0;
    }
    long long ans = t;
    for (int i = 4; i < n; ++i) {
        l2 += a[i - 1];
        if (l1 < l2) {
            int j;
            for (j = left + 1; j < i; ++j) {
                l1 += a[j];
                l2 -= a[j];
                if (l1 >= l2) {
                    break;
                }
            }
            if (l1 < l2) {
                left = i - 1;
                minl = l1;
                maxl = l2;
            }
            else {
                long long prel1 = l1 - a[j];
                long long prel2 = l2 + a[j];
                if (prel2 - prel1 < l1 - l2) {
                    left = j - 1;
                    l1 = prel1;
                    l2 = prel2;
                    minl = l1;
                    maxl = l2;
                }
                else {
                    left = j;
                    minl = l2;
                    maxl = l1;
                }
            }
        }
        else {
            minl = l2;
            maxl = l1;
        }
        r1 -= a[i - 1];
        if (r1 < r2) {
            int j;
            for (j = right + 1; j < n; ++j) {
                r1 += a[j];
                r2 -= a[j];
                if (r1 >= r2) {
                    break;
                }
            }
            if (r1 < r2) {
                right = n - 1;
                minr = r1;
                maxr = r2;
            }
            else {
                long long prer1 = r1 - a[j];
                long long prer2 = r2 + a[j];
                if (prer2 - prer1 < r1 - r2) {
                    right = j - 1;
                    r1 = prer1;
                    r2 = prer2;
                    minr = r1;
                    maxr = r2;
                }
                else {
                    right = j;
                    minr = r2;
                    maxr = r1;
                }
            }
        }
        else {
            minr = r2;
            maxr = r1;
        }
        t = max(maxr, maxl) - min(minr, minl);
        if (t == 0) {
            printf("0\n");
            return 0;
        }
        ans = min(t, ans);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
int dy[]={0,0,1,-1,1,-1,1,-1};
int dx[]={1,-1,0,0,1,-1,-1,1};

signed main(){
  int ans=0;

  set<int>st;
  for(int i=1;i<=1000;i++)st.insert(i*i);
  int n,d;
  cin>>n>>d;
  int a[n][d];
  r(i,n)r(j,d)cin>>a[i][j];
  r(i,n)r(j,n)if(i<j){
    int sum=0;
    r(k,d)sum+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
    if(st.count(sum))ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <fstream>

#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

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

ll LCM(ll a, ll b) {
    return a/GCD(a,b)*b;
}

class CCatSnukeAndAVoyage {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n,m; in>>n>>m;
        set<ll> from,to;

        rep(i,m){
            ll a,b;in>>a>>b;
            if(a==1) from.insert(b);
            else if (b==n) to.insert(a);
        }
        for(auto i: to){
            if(from.count(i)){
                out<<"POSSIBLE"<<endl;
                return;
            }
        }
        out<<"IMPOSSIBLE"<<endl;
	}
};


int main() {
	CCatSnukeAndAVoyage solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n; cin >> n;
  vector<vi> f(n, vi(10));
  for (auto &i : f)
  for (auto &j : i) {
    cin >> j;
  }
  vector<vi> p(n, vi(11));
  for (auto &i : p)
  for (auto &j : i) {
    cin >> j;
  }
  int ans = -2e9;
  for (int i = 1; i < (1 << 10); i++) {
    vector<int> c(n);
    for (int j = 0; j < n; j++)
    for (int k = 0; k < 10; k++) {
      if (f[j][k] && get_bit(i, k)) c[j]++;
    }
    int cal = 0;
    for (int j = 0; j < n; j++) {
      cal += p[j][c[j]];
    }
    ans = max(ans, cal);
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

int main(){

  int W, H, x, y, r;

  cin >> W >> H >> x >> y >> r;

  if ((x>=r) && (y>=r) && (x<=W-r) && (y<=H-r))
    cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3092
#include <iostream>
using namespace std;
typedef long long ll;
ll n, mx, a[105];

void f(ll p) {
	ll i, s, b[105];
	if(p==n+1) {
		s = 0;
		for(i=1; i<=n; i++) s += a[i];
		mx = max(mx, s);
		return;
	}
	if(a[p]<0) {
		for(i=1; i<=n; i++) b[i] = a[i];
		for(i=p; i<=n; i+=p) a[i] = 0;
		f(p+1);
		for(i=1; i<=n; i++) a[i] = b[i];
	}
	f(p+1);
}

int main() {
	ll i, j, s;
	cin>>n;
	for(i=1; i<=n; i++) cin>>a[i];
	for(i=n; i>n/6; i--) {
		s = 0;
		for(j=i; j<=n; j+=i) s += a[j];
		if(s<=0) for(j=i; j<=n; j+=i) a[j] = 0;;
	}
	f(1);
	cout<<mx;
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;

/* https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/4/ALDS1_4_A
input:
5
1 2 3 4 5
3
3 4 1
output:
3

input2:
3
3 1 2
1
5
output2:
0

input3:
5
1 1 2 2 3
2
1 2
output3:
2

 */
int search(int A[], int n, int key) {
    A[n] = key;
    int i = 0;
    while(A[i] != key) i++;
    return i != n;
}
int main() {
    int n, q;
    int S[10000];
    // int T[500];
    int key;
    int ans = 0;

    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", &key);
        if(search(S, n, key)) ans++;
    }

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

    return 0;
}



Measured memory_bytes: 2728
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

main {
  string s;
  while (cin >> s, s != "-") {
    int n = s.size();
    s += s;
    int m;
    cin >> m;
    vi a(m);
    cin >> a;
    int x = accumulate(all(a), 0) % n;
    cout << string(s.begin() + x, s.begin() + x + n) << endl;
  }
}

Measured memory_bytes: 3116
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;



const double EPS=1e-9;

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

const ll INF = (1LL<<31LL) - 1;
/*
??Segment Tree
??区間に対する処理を O(log(n)) で行う
??下の例は RMQ
?
??コンストラクタ : binary_heap( 要素数 )
*/
struct seg_t {
	int size;
	vector<int> data;
	int pool_size;
	vector<int> pool;
	seg_t(int n) {
		int i = 1;
		while(i * i < n) i++;
		size = i * i;
		pool_size = i;
		data.assign(size, INF);
		pool.assign(pool_size, INF);
	}
	void update(int k, int x) {
		data[k] = x;
		int pool_k = k / pool_size;
		pool[pool_k] = INF;
		for(int i = pool_k * pool_size; i < (pool_k + 1) * pool_size; i++) {
			pool[pool_k] = min(pool[pool_k], data[i]);
		}
	}
	int minimum(int a, int b) {
		int pool_a = a / pool_size;
		int pool_b = b / pool_size;
		if(pool_a == pool_b) {
			int minvalue = INF;
			for(int i = a; i < b; i++) {
				minvalue = min(minvalue, data[i]);
			}
			return minvalue;
		}
		else {
			int minvalue = INF;
			for(int i = a; i < (pool_a + 1)*pool_size; i++) {
				minvalue = min(minvalue, data[i]);
			}
			for(int i = pool_a + 1; i < pool_b; i++) {
				minvalue = min(minvalue, pool[i]);
			}
			for(int i = pool_b*pool_size; i < b; i++) {
				minvalue = min(minvalue, data[i]);
			}
			return minvalue;
		}
	}
};
int main(){
	int n,q;
	cin >> n >> q;
	seg_t r(n);
	for(int i = 0; i < q; i++) {
		int c, x, y;
		scanf("%d %d %d", &c, &x, &y);
		if(c == 0) r.update(x,y);
		else {
			printf("%d\n", r.minimum(x, y + 1));
		}
	}
	return 0;
}

Measured memory_bytes: 1524
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main() {
	int N;
	cin >> N;
	bool can = false;
	for (int i = 0; i <= N / 4; i++) {
		for (int j = 0; j <= N / 7; j++) {
			if (N == 4 * i + 7 * j)can = true;
		}
	}
	if (can)cout << "Yes";
	else cout << "No";
}

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

bool is_ok(const vector<vector<pair<int, int>>>& vvp, int x, int y)
{
  for (const auto& p : vvp.at(y)) {
    if ((x & (1 << p.first)) != (p.second << p.first)) {
      return false;
    }
  }
  return true;
}

int main()
{
  int n;
  cin >> n;
  vector<vector<pair<int, int>>> vvp(n);
  for (int x = 0; x < n; x++) {
    int a;
    cin >> a;
    for (int y = 0; y < a; y++) {
      int xij, yij;
      cin >> xij >> yij;
      xij--;
      vvp.at(x).emplace_back(xij, yij);
    }
  }
  vector<bool> ans(n, true);
  int res = 0;
  for (int x = 0; x < pow(2, n); x++) {
    int cnt = 0;
    int y = 0;
    for (y = 0; y < n; y++) {
      if ((x & (1 << y)) == 0) {
        continue;
      }
      cnt++;
      if (!is_ok(vvp, x, y)) {
        break;
      }
    }
    if (y == n) {
      res = max(res, cnt);
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 512
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int L[101] = {0};
int nL[101] = {0};
int main()
{
	int N = 0;
	scanf("%d", &N);
	int i = 0;
	for (i = 0; i < N; i++) {
		scanf("%d", &L[i]);
	}

	qsort(L, N, sizeof(int), sort_inc);
	int j = 0, k = 0;
	ll ans = 0;
	for (i = 0; i < N-2; i++) {
		for (j = i+1; j < N-1; j++) {
			if (L[i] == L[j]) {
				continue;
			}
			for (k = j+1; k < N; k++) {
				if (L[j] == L[k]) {
					continue;
				}
				if ((L[i] + L[j]) > L[k]) {
					ans++;
//					printf("%d %d %d\n", L[i], L[j], L[k]);
				}
			}
		}
	}
	printf("%lld\n", ans);
	//yesno(ans);
	//okng(ans);
	return 0;
}


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

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(input())
    ai = list(map(int, input().split()))
    assert len(ai) == n
    cnt = [0 for i in range(100002)]
    for a in ai:
        for b in [a, a + 1, a + 2]:
            cnt[b] += 1
    print(max(cnt))

main()


Measured memory_bytes: 14888
#include <iostream>
#include <cmath>

using namespace std;

int haming(int x){

  while(1){

    int flag = 0;

    if( x % 5 == 0 ){
      x /= 5;
      flag++;
    }
    if( x % 3 == 0 ){
      x /= 3;
      flag++;
    }
    if( x % 2 == 0 ){
      x /= 2;
      flag++;
    }

    if( x != 1 && flag == 0 ) return 0;
    if( x == 1 && flag > 0 ) return 1;

  }
}

int main(void){

  int m,n;

  while(1){

    cin >> m;
    if( m == 0 ) break;
    cin >> n;

    int h = 0;
    for( int i = m ; i <= n ; i++ ){
      if( i == 1 ) h++;
      else h +=  haming(i);
    }
    cout << h << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
/* Coached by rainboy and Dukkha */
#include <stdio.h>
#include <string.h>

#define N 8000
#define C 8000

int solve(int *aa, int n, int b) {
	static char dp[N + 1][C + 1];
	int i, a, c;

	a = 0;
	for (i = 0; i < n; i++)
		a += aa[i];
	if ((a + b) % 2)
		return 0;
	c = (a + b) / 2;
	if (c < 0)
		return 0;
	for (i = 0; i <= n; i++)
		for (a = 0; a <= c; a++)
			dp[i][a] = 0;
	dp[0][0] = 1;
	for (i = 0; i < n; i++)
		for (a = 0; a <= c; a++)
			if (dp[i][a]) {
				dp[i + 1][a] = 1;
				if ((b = a + aa[i]) <= c)
					dp[i + 1][b] = 1;
			}
	return dp[n][c];
}

int main() {
	static char s[N + 1];
	static int xx[N], yy[N];
	int x, y, n, i, nx, ny, k, isx;

	scanf("%s%d%d", s, &x, &y);
	n = strlen(s);
	i = 0;
	while (i < n && s[i] == 'F')
		i++;
	x -= i;
	isx = 1, k = nx = ny = 0;
	while (i <= n) {
		if (i == n || s[i] == 'T') {
			if (k) {
				if (isx)
					xx[nx++] = k;
				else
					yy[ny++] = k;
				k = 0;
			}
			isx ^= 1;
		} else
			k++;
		i++;
	}
	printf(solve(xx, nx, x) && solve(yy, ny, y) ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 22272
/*
 * Range.cpp
 *
 *  Created on: 2014/07/21
 *      Author: WanWan1985
 */
#include <iostream>
using namespace std;

int main(void) {

	int a, b, c = 0;
	cin >> a >> b >> c;

	if ((a < b) && (b < c)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

int n, l;
vector<string> s;
vector<vector<string>> sor;

void so(int keta) {
	for (int i = 0; i < 26; i++)
		sor[i].push_back("A");
	for (int i = 0; i < 26; i++) {
		for (int j = 0;; j++) {
			if (sor[i][0][0] == 'A') {
				sor[i].erase(sor[i].begin());
				break;
			}
			sor[sor[i][0][keta] - 'a'].push_back(sor[i][0]);
			sor[i].erase(sor[i].begin());
		}
	}

	return;
}

int main() {

	cin >> n >> l;
	sor.resize(26);
	s.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		sor[s[i][l - 1] - 'a'].push_back(s[i]);
	}
	for (int i = 2; i <= l; i++) {
		so(l - i);
	}
	for (int i = 0; i < 26; i++) {
		for (auto q : sor[i]) {
			cout << q;
		}
	}
	cout << endl;
	//cin >> n;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s, n, t, m, p;
bool minutes[7 * 24 * 60];
int wbits, tbits;
double ck(int start){
  int cnt = 0;
  for(int i = 0; i < m; i++, start += t){
    bool flag = true;
    for(int j = 0; j <= s; j++){
      if(!minutes[(start + j) % (7 * 24 * 60)]){
        flag = false;
        break;
      }
    }
    cnt += flag;
  }
  return( 1.0 - pow( 1.0 - 1.0/p, (double)cnt * n));
}
int todays(int i){
  return(i / (24 * 60));
}
bool totime(int i){
  return((i/360+1)&4>>1);
}
int main(){
  string weekday, time ;
  while( cin >> s >> n >> t >> weekday >> time >> p >> m, m){
    if(weekday == "All") wbits = (1 << 7) - 1;
    else wbits = 1 ;
    if(time == "Night") tbits = 1;
    else if(time == "Day") tbits = 2;
    else tbits = 3; 
    double ans = 0.0;
    for(int i = 7 * 24 * 60 - 1; i >= 0; i--){
      minutes[i] =  wbits >> todays(i) & 1 && (tbits >>totime(i)) & 1;
    }
    for(int i = 24 * 60 - 1; i >= 0; i--){
      ans = max( ans, ck(i));
    }
    cout << fixed << setprecision(16) << ans << endl;
  }
}

Measured memory_bytes: 1340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

int G[500][500];


void solve(int a,int b,int ctr){
  if(a==b)return;
  int n=b-a+1;
  rep(i,a,a+n/2){
    rep(j,a+n/2,b+1){
      G[i][j]=ctr;
      G[j][i]=ctr;
    }
  }
  solve(a,a+n/2-1,ctr+1);
  solve(a+n/2,b,ctr+1);
  return;
}
  
int main(){
  int n;cin>>n;
  solve(0,n-1,1);
  rep(i,n){
    rep(j,i+1,n){
      if(j>i+1)cout<<" ";
      cout<<G[i][j];
    }
    cout<<endl;
  }
}
    
    





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

using namespace std;

int main() {

	long long a,b;
	cin >> a >> b;
//	string s;
//	cin >> s;

	for (int i = 1; i <= 1000; i++) {
		if ((int)((double)i*0.08) == a && (int)((double)i*0.1) == b) {
			cout << i << endl;
			return 0;
		}
	}
	cout << "-1" << endl;

}

Measured memory_bytes: 256
// Author by Md. Jashim Uddin_RMSTU

#include<bits/stdc++.h>
using namespace std;
#define     sf(a)           scanf("%d",&a)
#define     sff(a,b)        scanf("%d %d",&a,&b)
#define     sfff(a,b,c)     scanf("%d %d %d",&a,&b, &c)
#define     pb              push_back
#define     ll              long  long int
#define     fast            ios_base :: sync_with_stdio(false);cin.tie(0)
#define     pi              2*acos(0)
#define     sp              fixed<<setprecision
#define     lcm(a,b)        (a*b)/gcd(a,b)
#define     gcd(a,b)        _gcd(a,b)

#define     forn(i,n)       for(int i=1;i<=n;i++)
#define     min3(a,b,c)     min(a,min(b,c)
#define     M             32000

int main()
{
    string s,str,ss;
    cin>>s;
   int len = s.size();
   ll m = (len-1)/2;
   ll n = (len+3)/2;
   for(int i=0;i<m;i++)
    ss+=s[i];
   for(int i=n-1;i<len;i++)
    str+=s[i];
   if(ss==str) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;



return 0;

}


Measured memory_bytes: 256
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 200010;
char a[5*MAXN];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  string s;
  cin >> s;
  int q;
  cin >> q;
  int rev = 0;
  int l = MAXN;
  int r = l+s.size()-1;
  for(int i=0;i<s.size();i++){
    a[i+l]=s[i];
  }
  while(q--){
    int type;
    cin >> type;
    if(type==1){
      rev^=1;
    }
    else{
      int f;
      char c;
      cin >> f >> c;
      f--;
      if(rev){
        f^=1;
      }
      if(!f){
        a[--l]=c;
      }
      else {
        a[++r]=c;
      }
    }
  }
  if(!rev)
  for(int i=l;i<=r;i++){
    cout << a[i];
  }
  else {
    for(int i=r;i>=l;i--){
      cout<<a[i];
    }
  }
  cout << endl;
  
return 0;
}
///....


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

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

int main() {

    int d, g; cin >> d >> g;
    vector<int> p(d);
    vector<int> c(d);
    for (int i = 0; i < d; ++i) {
        cin >> p[i] >> c[i];
    }

    int ans = INF;

    for (int bit = 0; bit < (1 << d); ++bit) {
        int sum = 0;
        int cnt = 0;
        for (int i = 0; i < d; ++i) {
            if (bit & (1 << i)) {
                sum += 100 * (i + 1) * p[i] + c[i];
                cnt += p[i];
            }
        }

        if (sum >= g) {
            ans = min(ans, cnt);
        } else {
            for (int i = d - 1; i >= 0; --i) {
                if (!(bit & (1 << i))) {
                    for (int j = 1; j < p[i]; ++j) {
                        sum += 100 * (i + 1);
                        cnt++;
                        if (sum >= g) {
                            ans = min(ans, cnt);
                            break;
                        }
                    }
                    break;
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
import java.io.*;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			String[] split = str.split(" ",0);
			int w = Integer.parseInt(split[0]);
			int h = Integer.parseInt(split[1]);
			int x = Integer.parseInt(split[2]);
			int y = Integer.parseInt(split[3]);
			int r = Integer.parseInt(split[4]);

			if ((x - r >= 0) && (x + r <= w) && (y - r >= 0) && (y + r <= h)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}

		} catch (Exception e) {
			System.out.println("??¨??????");
		}

	}
}

Measured memory_bytes: 24380
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more scores.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int mod = 1e9 + 7;

inline int Mod(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y, x -= x >= mod ? mod : 0; }
inline int fsp(int x, int k = mod - 2) {
	int s = 1;
	while(k) {
		if(k & 1) s = 1LL * s * x % mod;
		x = 1LL * x * x % mod, k >>= 1;
	} return s;
}

int F[610];
int pw[610];
int fac[610];
int ifac[610];

int to[610];
int cnt[610];
int f[610][610];

int main() {
	fac[0] = pw[0] = 1;
	for(int i = 1; i <= 600; i++)
		fac[i] = 1LL * fac[i - 1] * i % mod;
	ifac[600] = fsp(fac[600]);
	for(int i = 600; i >= 1; i--)
		ifac[i - 1] = 1LL * ifac[i] * i % mod;
	int iv = fsp(2);
	for(int i = 1; i <= 600; i++)
		pw[i] = 1LL * pw[i - 1] * iv % mod;
	for(int i = 0; i <= 600; i += 2)
		F[i] = 1LL * fac[i] * ifac[i >> 1] % mod * pw[i >> 1] % mod;

	int Case = 1;
	while(Case--) {
		int n = ri, m = ri;
		for(int i = 1; i <= m; i++) {
			int u = ri, v = ri;
			to[u] = v, to[v] = u;
		} n <<= 1;

		for(int i = 1; i <= n; i++) cnt[i] = cnt[i - 1] + (!to[i]);

		for(int i = 1; i <= n; i++)
			for(int j = i + 1; j <= n; j += 2) {
				int flag = 0;
				for(int k = i; k <= j && !flag; k++)
					flag |= to[k] && (to[k] < i || to[k] > j);
				if(flag) continue;
				int &G = f[i][j] = F[cnt[j] - cnt[i - 1]];
				for(int k = i + 1; k < j; k++)
					G = (G + 1LL * (mod - f[i][k]) * F[cnt[j] - cnt[k]]) % mod;
			}

		int res = 0;
		for(int i = 1; i <= n; i++)
			for(int j = i + 1; j <= n; j += 2)
				res = (res + 1LL * F[cnt[n] - cnt[j] + cnt[i - 1]] * f[i][j]) % mod;
		cout << res << endl;

		for(int i = 1; i <= n; i++) to[i] = 0;
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				f[i][j] = 0;
	}
	return 0;
}

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

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

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    vector<string> str;

    while(1){
        string s;
        cin >> s;
        if(s == "0") break;
        str.push_back(s);
    }

    int sum;
    for(int i = 0;i < str.size();i++){
        sum = 0;
        for(int j = 0;str[i][j] != '\0';j++){
            sum += str[i][j]-'0';
        }
        cout << sum << endl;
    }

    return 0;
}



Measured memory_bytes: 3172
S = input()
T = input() #部分文字列

# print(S, T)

# S をTの長さ - 1番地から初めてSの最後の番地までループさせ、１文字づつ一致を検索しカウントする
start_idx = 0
fix_words = 0
for i in range(len(T) - 1, len(S)):
  part = S[start_idx:i + 1]
  # print(part)
  
  tmp_fix_words = 0
  for q in range(len(part)):
    if part[q] == T[q]:
      tmp_fix_words += 1
  
  fix_words = max(tmp_fix_words, fix_words)
  # print(fix_words)
  
  start_idx += 1
  
print(len(T) - fix_words)

Measured memory_bytes: 9120
n=int(input())
d= [list(map(int, input().split())) for i in range(n)]
cnt=0
for i in range(n):
    if d[i][0]==d[i][1]:
        cnt+=1
        if cnt==3:
            print('Yes')
            exit()
    else:
        cnt=0
print('No')

Measured memory_bytes: 62460
n=int(input())
S=input()
R={}
G={}
B={}
r=0
g=0
b=0
for i in range(n):
    if S[i] == 'R':
        R[i] = None
    elif S[i] == 'G':
        G[i] = None
    else:
        B[i] = None
cnt=len(R)*len(G)*len(B)
for b in B:
    for g in G:
        if (b+g)/2 in R:
            cnt-=1
for b in B:
    for r in R:
        if (b+r)/2 in G:
            cnt-=1
for r in R:
    for g in G:
        if (r+g)/2 in B:
            cnt-=1
print(cnt)

Measured memory_bytes: 68324
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>

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

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

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;

bool comp(vll a,vll b){
    return a[1]>b[1];
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N,M;
    cin>>N>>M;
    vll A(N);
    vvll BC(M,vll(2));
    for(ll i=0;i<N;i++)cin>>A[i];
    for(ll i=0;i<M;i++)cin>>BC[i][0]>>BC[i][1];
    
    sort(A.begin(),A.end());
    sort(BC.begin(),BC.end(),comp);
    
    ll i,b=0;
    ll ans=0;
    for(i=0;i<N &&b<M;b++){
        bool ok=true;
        for(ll j=0;j<BC[b][0];j++){
            if(A[i]<BC[b][1]){
                ans+=BC[b][1];
                //printf("+%lld\n",BC[b][1]);
                i++;
                if(i>=N){
                    ok=false;
                    break;
                }
            }else{
                ok=false;
                break;
            }
        }
        if(!ok)break;
    }
    for(;i<N;i++)ans+=A[i];
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 6528
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++)
	{
		if (i & 1) continue;
		putchar(str[i]);
	}
	puts("");
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <map>
#include <set>

#define ll long long
#define il inline
const ll inf = 1e17;

namespace io {

#define in(a) a = read()
#define out(a) write(a), putchar(' ')
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 100010

ll n, m, Q;
ll s[N], t[N], a[N], b[N];

int main() {
//	freopen("1.in", "r", stdin);
	in(n),in(m),in(Q);
	for(int i = 1; i <= n; ++i) s[i] = read(), a[i] = -s[i];
	for(int i = 1; i <= m; ++i) t[i] = read(), b[i] = -t[i];
	//s神社 t寺庙 
	sort(s + 1, s + n + 1); sort(t + 1, t + m + 1);
	sort(b + 1, b + m + 1); sort(a + 1, a + n + 1);
	while(Q--) {
		ll x = read();
		ll ans = inf;
		s[0]=t[0]=a[0]=b[0] = -inf; 
		s[n+1]=t[m+1]=a[n+1]=b[m+1]=inf;
		ll t1 = *lower_bound(s+1, s+n+1, x), t2 = -(*lower_bound(a+1,a+n+1,-x)),
			t3= *lower_bound(t+1,t+m+1, x), t4 = -(*lower_bound(b+1,b+m+1, -x));
		s[0]=t[0]=a[0]=b[0] = -2ll*inf;
		s[n+1]=t[m+1]=a[n+1]=b[m+1]=2ll*inf;
		ll t5 = *lower_bound(s+1, s+n+1, t2), t6 = -(*lower_bound(a+1,a+n+1,-t1))
			,t7 = *lower_bound(t+1,t+m+1, t4), t8 = -(*lower_bound(b+1,b+m+1, -t3));
		
		if(min(abs(t1 - x), abs(t3 - x)) + abs(t1 - t3) < ans) ans = min(abs(t1 - x), abs(t3 - x)) + abs(t1 - t3);
		if(min(abs(t1 - x), abs(t4 - x)) + abs(t1 - t4) < ans) ans = min(abs(t1 - x), abs(t4 - x)) + abs(t1 - t4);
		if(min(abs(t2 - x), abs(t3 - x)) + abs(t2 - t3) < ans) ans = min(abs(t2 - x), abs(t3 - x)) + abs(t2 - t3);
		if(min(abs(t2 - x), abs(t4 - x)) + abs(t2 - t4) < ans) ans = min(abs(t2 - x), abs(t4 - x)) + abs(t2 - t4);
		
		ans=min(ans,min(abs(x-t3),abs(x-t6))+abs(t3-t6));
		ans=min(ans,min(abs(x-t4),abs(x-t5))+abs(t4-t5));
		ans=min(ans,min(abs(x-t1),abs(x-t8))+abs(t1-t8));
		ans=min(ans,min(abs(x-t2),abs(x-t7))+abs(t2-t7));
		
		printf("%lld\n", ans);
	}
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll s[n+1];
	s[0]=0;
	for(int i=1; i<=n; i++){
		ll a;
		cin >> a;
		s[i]=s[i-1]+a;
	}

	ll ans=LLONG_MAX;
	for(int i=1; i<n; i++){
		ans=min(ans, abs(2*s[i]-s[n]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792