akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    string s;
    cin >> s;
    ll n = s.length();
    if (n == 1) {
        cout << 1 << endl;
    }

    // n>=2
    pair<ll, string> dp[n][2];
    dp[0][0] = make_pair(1, s.substr(0, 1));
    dp[0][1] = make_pair(0, "");
    if (s[0] == s[1]) {
        dp[1][0] = make_pair(dp[0][1].first, s.substr(1, 1));
    } else {
        ll num = max(dp[0][0].first, dp[0][1].first);
        dp[1][0] = make_pair(num + 1, s.substr(1, 1));
    }
    dp[1][1] = make_pair(1, s.substr(0, 2));

    repd(i, 2, n) {
        if (dp[i - 1][0].second == s.substr(i, 1)) {
            dp[i][0] = make_pair(dp[i - 1][1].first + 1, s.substr(i, 1));
        } else {
            ll num = max(dp[i - 1][0].first, dp[i - 1][1].first);
            dp[i][0] = make_pair(num + 1, s.substr(i, 1));
        }

        if (dp[i - 2][1].second == s.substr(i - 1, 2)) {
            dp[i][1] = make_pair(dp[i - 2][0].first + 1, s.substr(i - 1, 2));
        } else {
            ll num = max(dp[i - 2][1].first, dp[i - 2][0].first);
            dp[i][1] = make_pair(num + 1, s.substr(i - 1, 2));
        }
    }

    /* rep(i, n) { cout << dp[i][0].first << " "; } */
    /* cout << endl; */
    /* rep(i, n) { cout << dp[i][1].first << " "; } */
    /* cout << endl; */

    ll ans = max(dp[n - 1][0].first, dp[n - 1][1].first);
    cout << ans << endl;
}



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

int main() {
	int n, i, k = 0;
	vector<pair<int, int>> v;

	cin >> n;
	while (n--) {
		cin >> i;
		v.push_back({i, ++k});
	}

	sort(v.begin(), v.end());
	for (auto i : v) cout << i.second << " ";
	cout << "\n";
}

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

int main(){
	int n, x;
	int l[101] = { 0 };
	int length;
	for (int i = 0; ; i++){
		cin >> n >> x;
		if (n == 0 && x == 0){
			length = i;
			break;}
		for (int j = 0; j < n; j++){
			for (int k = 0; k < n; k++){
				for (int m = 0; m < n; m++){
					if (j != k&&j != m&&k != m) {
						if (j + k + m + 3 == x){
							l[i] += 1;
						}
					}
				}
			}
		}
	}
	for (int i = 0; i < length; i++){
		cout << l[i]/6 << endl;
	}
	char c;
	cin >> c;
}

Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n,m; cin >> n >> m;
	vvl G(n);
	rep(i,m){
		ll u,v; cin >> u >> v; u--; v--;
		G[u].push_back(v);
	}
	ll s,t; cin >> s >> t; s--; t--;
	vvl d(n,vl(3,inf));
	queue<P> q;
	d[s][0] = 0;
	q.emplace(s,0);
	while(!q.empty()){
		P p = q.front(); q.pop();
		ll u = p.first;
		ll now = p.second;
		ll nxt = (p.second+1)%3;
		for(auto v : G[p.first]){
			if(d[v][nxt]!=inf) continue;
			d[v][nxt] = d[u][now] + 1;
			q.emplace(v,nxt);
		}
	}
	if(d[t][0]==inf) puts("-1");
	else cout << d[t][0] / 3 << endl;
}

Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		char[] s = sc.next().toCharArray();
		s[k-1] = Character.toLowerCase(s[k-1]);
		for (int i = 0; i<n; i++) {
			System.out.print(s[i]);
		}
	}
}

Measured memory_bytes: 21076
a=[]
b=[]

for i in range(0,6):
  a.append(int(input()))
ans=0
for j in range(0,4):
  for k in range(j+1,5):
    if a[k]-a[j]>a[5]:
      ans+=1
    
if ans==0:
  print("Yay!")
else:
  print(":(")

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

int gcd(int a,int b) {
  return (b? gcd(b,a%b):a);
}

int main() {
  int n,m;
  cin>>n>>m;
  string S,T;
  cin>>S>>T;
  int g=gcd(n,m);
  int s=n/g,t=m/g;
  for (int i=0; i<g; i++) {
    if (S[s*i]!=T[t*i]) {
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<(ll)n/g*m<<endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
char c[105];
int k;
int main()
{
	cin>>k>>c;
	int i=0;
	for(i=0;i<k;i++)
	{
		if(c[i]==0)
		{
			cout<<endl;
			return 0;
		}
		else
		{
			cout<<c[i];
		}
	}
	if(c[k]!=0)
	cout<<"...";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3640
package main

import "fmt"

func removeDuplicate1(args []string) []string {
	results := make([]string, 0, len(args))
	encountered := map[string]bool{}
	for i := 0; i < len(args); i++ {
		if !encountered[args[i]] {
			encountered[args[i]] = true
			results = append(results, args[i])
		}
	}
	return results
}

func main() {
	var n int
	fmt.Scan(&n)

	var freebies []string

	for i := 0; i < n; i++ {
		var str string
		fmt.Scan(&str)
		freebies = append(freebies, str)
	}

	freebies = removeDuplicate1(freebies)

	fmt.Println(len(freebies))
}


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

typedef long long ll;

int main()
{
	ll w, h, x, y;
	scanf("%lld %lld %lld %lld", &w, &h, &x, &y);

	double res = w * h * 0.5;
	printf("%lf ", res);

	if (2 * x == w && 2 * y == h)
		printf("1");
	else 
		printf("0");

	return 0;
}

Measured memory_bytes: 128
N, A, B = gets.chomp.split.map(&:to_i)
ans = 0

for i in 1..N do
  sum = 0
  n = i
  while n > 0 do
    sum += n % 10
    n = n / 10
  end
  ans += i if A <= sum && sum <= B
end

puts ans


Measured memory_bytes: 1788
N = int(input())
aArr = input().split(" ")
bArr = input().split(" ")

aArr= [int(i) for i in aArr]
bArr= [int(i) for i in bArr]

res = 0

for i in range(N):
  if(bArr[i] < aArr[i]):
    res += bArr[i]
  else:
    res += aArr[i]
    if((bArr[i] - aArr[i]) < aArr[i+1]):
      res += bArr[i] - aArr[i]
      aArr[i+1] -= bArr[i] - aArr[i]
    else:
      res += aArr[i+1]
      aArr[i+1] = 0

print(res)

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

int main()
{
    int N;
    cin >> N;
    int Ai, xij, yij;
    vector<unsigned int> X0(N, 0);
    vector<unsigned int> X1(N, 0);
    for(int i=0;i<N;i++){
        cin >> Ai;
        for(int j=0;j<Ai;j++){
            cin >> xij >> yij;
            if(yij==0) X0[i] |= 1 << (xij-1);
            if(yij==1) X1[i] |= 1 << (xij-1);
        }
    }

    int res = 0;
    unsigned int bit = 0;
    while(bit < (1<<N)){
        bool isBad = false;
        for(int i=0; i<N; i++){
            if((bit & (1<<i)) == 0) continue;
            if((X0[i] & bit) > 0) isBad = true;
            if((X1[i] & (~bit)) > 0) isBad = true;
        }
        if(!isBad){
            res = max(res, __builtin_popcount(bit));
        }

        bit++;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef long long LL;
const int N = 300000 + 10;
int n;
LL a[N];
LL x[N], y[N], LG[N];

LL cac1(int l,int r) {
    return x[r] - x[l-1];
}
LL cac2(int l,int r) {
    return y[r] ^ y[l-1];
}

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

    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        x[i] = x[i-1] + a[i];
        y[i] = y[i-1] ^ a[i]; 
    }
    //printf("%lld %lld\n", cac1(1,4), cac2(1,4));

    LL ans=0;
    for(int i=1;i<=n;i++) {
        int L = i, R = n+1;
        while (R - L > 1) {
            int mid = (L+R)>>1;
            if (cac1(i, mid) == cac2(i, mid))
                L = mid;
            else
                R = mid;
        }
        //printf("%d %d\n", i, L);
        ans += (L-i+1);
    }

    cout<<ans<<endl;
}





























Measured memory_bytes: 6784
#include<vector>
#include <iostream>
#include<string>
#include <complex>

using namespace std;

int main(){
    int a[5];

    for(int i = 0;i < 5; i++){
        cin >> a[i];
    }

    int t = 0;
    int k = 0;
    int min = 9;
    int tar = 0;

    for(int i = 0; i < 5; i++){
        if(min > a[i]%10 && a[i] % 10 != 0){
            min = a[i]%10;
            tar = i;
        }
    }

    for(int i = 0; i < 5; i++){
        t += a[i];
        while(k < t && i != tar){
            k += 10;
        }
        t = k;
    }

    cout << t+a[tar] << endl;
}

Measured memory_bytes: 256
s = str(input())
 
cnt = 0
for i in range(0, len(s)):

    if i % 2 == 0:
        if s[i] == "L":
            cnt = 1
            break

    else:
        if s[i] == "R":
            cnt = 1
            break

if cnt == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()


struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n, m;
    cin >> n >> m;
    int a, b, c;
    vector<int> v;
    for(int i = 0; i < n; i++) {
        cin >> a;
        v.bash(a);
    }
    vector<pii> t;
    for(int i = 0; i < m; i++) {
        cin >> b >> c;
        t.bash(pii(c, b));
    }

    sort(ALL(t), greater<pii>());

    for(int i = 0, c = 0; i < m and c < n; i++) {
        for(int j = 0; j < t[i].second and c < n; j++) {
            v.bash(t[i].first);
            c++;
        }
    }

    sort(ALL(v), greater<int>());

    ll ans = 0;

    for(int i = 0; i < n; i++) ans += v[i];

    cout << ans << endl;

  
    return 0;
}



Measured memory_bytes: 2164
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	string s, t;
	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());

	bool ok = s < t;
	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

string s;

void input(){
    cin >> s;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    string ans = "";
    int n = s.size();
    for(int i=0;i<n;i++){
        if(s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
        else if(!ans.empty())ans.pop_back();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include<cstring>
#include <math.h>
typedef long long ll;
using namespace std;
using namespace std;
const int MAXN = 2e5+7;
int a[]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    int n;
    cin>>n;
    cout<<a[n-1];
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S, T):

    for i in range(len(S)):
        s_ = S[len(S)-i:] + S[:len(S)-i]
        if s_ == T:
            return 'Yes'
    return 'No'


def main():
    S = read_str()
    T = read_str()
    print(slv(S, T))


if __name__ == '__main__':
    main()


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

using namespace std;

char s[100040];

int main()
{
    scanf("%s",s);
    int a=strlen(s),b=0;
    for(int i=0;s[i];i++)
        if(s[i]-'0')b++;
    if(2*b>a)cout<<2*(a-b);
    else cout<<2*b;
    return 0;
}





Measured memory_bytes: 384
// finish date: 2018/01/23
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N;
    cin >> N;
    vi a(100001, 0);
    int in;
    rep(i, N) {
        cin >> in;
        a[in]++;
    }
    int ma = -INF;
    FOR(i, 2, 100001) ma = max(ma, a[i - 2] + a[i - 1] + a[i]);
    cout << ma << endl;

    return 0;
}



Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

struct Cake{
    int x;
    int y;
    int wi;
    int hi;
};
Cake cake[200],newcake[200];

int S[200];

int n,w,d,p[200],s[200];

void solve(){
    cake[0].x = cake[0].y = 0;
    cake[0].wi = w;
    cake[0].hi = d;

    for(int i = 0;i < n;i++){
        int c = 0;
        for(int j = 0;j <= i;j++){
            if(p[i] != j){
                newcake[c++] = cake[j];
                continue;
            }
        }
        for(int j = 0;j <= i;j++){
            if(p[i] != j)
                continue;
            Cake a,b;

            int start = s[i] % ( 2 * (cake[j].wi + cake[j].hi));
            if(start > cake[j].wi + cake[j].hi){
                if(start < cake[j].wi * 2 + cake[j].hi){
                    start %= cake[j].wi + cake[j].hi;
                    start = cake[j].wi - start;
                }else{
                    start %= cake[j].wi + cake[j].hi;
                    start -= cake[j].wi;
                    start = cake[j].wi + cake[j].hi - start;
                }
            }

            a.x = cake[j].x;a.y = cake[j].y;
            if(start < cake[j].wi){
                a.wi = start;a.hi = cake[j].hi;
                b.x = start + cake[j].x;b.y = cake[j].y;b.wi = cake[j].wi - start;b.hi = cake[j].hi;
            }else {

                a.hi = start - cake[j].wi;a.wi = cake[j].wi;
                b.y = start - cake[j].wi + cake[j].y;b.x = cake[j].x;b.hi = cake[j].hi - start + cake[j].wi;b.wi = cake[j].wi;
            }

            if(a.wi * a.hi > b.wi * b.hi){
                Cake c = a;
                a = b;
                b = c;
            }


            newcake[c++] = a;
            newcake[c++] = b;
        }
        memcpy(cake,newcake,sizeof(cake));
    }
    REP(i,n + 1){
        S[i] = cake[i].hi * cake[i].wi;
    }
    sort(S,S + n + 1);
    REP(i,n)
        printf("%d ",S[i]);
    printf("%d\n",S[n]);

}

bool input(){
    scanf("%d%d%d",&n,&w,&d);
    if(n == 0 && w == 0 && d == 0)
        return false;

    REP(i,n){
        scanf("%d%d",&p[i],&s[i]);
        p[i]--;
    }
    return true;
} 

int main(){
    while(input()){
        solve();
    }
}

Measured memory_bytes: 3172
function convertArray(S) {
    var current = "1";
    var count = 0;
    SDIV = []
    Array.prototype.forEach.call(S, function (s) {
        if (current == s) {
            count++;
        } else {
            SDIV.push(count);
            count = 1;
            current = (current == "0") ? "1" : "0";
        }
    });
    SDIV.push(count);
    if (SDIV.length % 2 == 1) {
        SDIV.push(0);
    }

    SDIV.push(0);
    SDIV.push(0);
    return SDIV;
}

// (SADD.length / 2) - 1 > K は保証
function integrateArray(SDIV, K) {
    var SITG = [];
    var first = 0;

    if (K == 0) {
        for (var i = 0; i < SDIV.length / 2; i++) {
            SITG.push(SDIV[i * 2]);
        }
        return SITG;
    }

    for (var i = 0; i < 2 * K + 1; i++) {
        first += SDIV[i];
    }
    SITG.push(first);
    // console.log((SDIV.length / 2) - K - 1);

    for (var step = 1; step < (SDIV.length / 2) - K; step++) {
        // console.log(SITG.length - 1,
        //     step*2 - 2 ,
        //     step*2 - 1 ,
        //     (step+K)*2 - 1 ,
        //     (step+K)*2);
        SITG.push(
            SITG[SITG.length - 1]
            - SDIV[step * 2 - 2]
            - SDIV[step * 2 - 1]
            + SDIV[(step + K) * 2 - 1]
            + SDIV[(step + K) * 2]
        );
    }
    return SITG;

}

function Main(input) {
    var N = parseInt(input[0])
    var K = parseInt(input[1])
    var SDIV = convertArray(input[2]); // [1の数, 0の数, 1の数...]で入る。偶数要素。
    // console.log(SDIV);
    if ((SDIV.length / 2) - 1 < K) {
        console.log(N);
        return;
    }
    var SITG = integrateArray(SDIV, K);
    var max = 0;
    SITG.forEach(element => {
        max = Math.max(max, element);
    });
    console.log(max);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));


Measured memory_bytes: 15052
import itertools
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [str(i) for i in range(10) if i not in a]
anslist = b + list(itertools.product(b,b))
anslist += list(itertools.product(b,b,b))
anslist += list(itertools.product(b,b,b,b))
anslist += list(itertools.product(b,b,b,b,b))
anslist += list(itertools.product(b,b,b,b,b,b))
anslist = [int("".join(i)) for i in anslist ]
#print(anslist)
#print(b)
anslist.sort()
for i in anslist:
    if i >= n:
        print(i)
        exit()

Measured memory_bytes: 87796
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 1e5 + 10, MOD = 1e9 + 7;
char s[2*N];
bool a[2*N];
vector<int> le, ri;
bool flag = 1;

int main() {
    int n;
    scanf("%d", &n);
    scanf("%s",s);
    for (int i = 0; i < 2 * n; i++) {
        if (s[i] == 'B') a[i] = 1;
        else a[i] = 0;
    }
    int inv = 0;
    for (int i = 0; i < 2 * n; i++) {
        if ((inv ^ a[i]) == 1) {
            le.push_back(i);
        } else {
            ri.push_back(i);
        }
        inv ^= 1;
    }
    flag = le.size() == ri.size();
    if (flag) {
        int ans = 1;
        for (int i = n - 1; i >= 0; i--) {
            ans = 1LL * ans * (i + 1 - (upper_bound(ri.begin(), ri.end(), le[i]) - ri.begin())) % MOD;
        }
        for (int i = 1; i <= n; i++) {
            ans = 1LL * ans * i % MOD;
        }
        printf("%d\n", ans);
    } else puts("0");
    return 0;
}


Measured memory_bytes: 2040
S = input()
T = input()

S_list = [c for c in S]
T_list = [c for c in T]

if S[0] == T [0] and S[1] == T [1] and S[2] == T [2]:
  print(3)
  exit()
elif (S[0] == T [0] and S[1] == T [1]) or (S[0] == T [0] and S[2] == T [2]) or (S[2] == T [2] and S[1] == T [1]):
  print(2)
  exit()
elif S[0] != T [0] and S[1] != T [1] and S[2] != T [2]:  
  print(0)
  exit()
print(1)
  

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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
        var W = input[0];
        var H = input[1];
        var N = input[2];

        var grid = new int[W + 10, H + 10];

        for (var i = 0; i < N; i++)
        {
            var elems = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
            var x = elems[0];
            var y = elems[1];
            var a = elems[2];

            if (a == 1)
            {
                for (int j = 0; j < x; j++)
                {
                    for (int k = 0; k < H; k++)
                    {
                        grid[j, k] += 1;
                    }
                }
            } else if (a == 2)
            {
                for (int j = x; j < W; j++)
                {
                    for (int k = 0; k < H; k++)
                    {
                        grid[j, k] += 1;
                    }
                }
            } else if (a == 3)
            {
                for (int j = 0; j < W; j++)
                {
                    for (int k = 0; k < y; k++)
                    {
                        grid[j, k] += 1;
                    }
                }
            } else if (a == 4)
            {
                for (int j = 0; j < W; j++)
                {
                    for (int k = y; k < H; k++)
                    {
                        grid[j, k] += 1;
                    }
                }
            }
        }

        var count = 0;
        for (var i = 0; i < W; i++)
        {
            for (var j = 0; j < H; j++)
            {
                if (grid[i, j] == 0) count++;
            }
        }
        
        Console.WriteLine(count);
    }
}


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

int main(){
	int s;
	cin>>s;
	int f=s;
	int div=0;
	while(s!=0){
		div+=s%10;
		s/=10;
	}
	if(f%div==0){
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;	

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
const int N=1e5+10;
namespace MAIN{
    inline bool cmp(const res &x,const res &y){
        return x>y;
    }
    int n,a[N];
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++)a[i]=read();
        sort(a+1,a+n+1,cmp);
        for(res i=1;i<=n;i++)
            if(i+1>a[i+1]){
                res j=i+1,ans=0;
                while(a[j]==i)ans^=1,j++;
                if((ans||((a[i]-i)&1)))puts("First");
                else puts("Second");
                return;
            }
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>

using namespace std;

int main(){
	long int n,a,b;
	scanf("%ld %ld %ld",&n,&a,&b);
	if((b-a)%2==0) printf("%ld\n",(b-a)/2);
	else if(a<n-b+1) printf("%ld\n",a+(b-a-1)/2);
	else printf("%ld\n",n-b+1+(b-a-1)/2);
	return 0;
}

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

int main()
{
    string s;
    cin >> s;

    vector<char> vect;
    for(int i=0; i<s.length(); i++){
        vect.push_back(s[i]);
    }
    vector<char> tmp = vect;
    sort(vect.begin(), vect.end());
    vect.erase(unique(vect.begin(), vect.end()), vect.end());

    string flag = "Yes";
    for(auto it=vect.begin(); it!=vect.end(); it++){
        size_t n_count=count(tmp.begin(),tmp.end(), *it);
        if(n_count%2==1){
            flag = "No";
            break;
        }
    }
    cout << flag;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

using lint = long long;
using plint = pair<double, lint>;

int N;
lint L;

deque<plint> deq;
double Qsum = 0;
lint Vnow = 0;

void trim()
{
    while (Vnow > L)
    {
        lint nuku = min(Vnow - L, deq.front().second);
        deq.front().second -= nuku;
        Vnow -= nuku;
        Qsum -= nuku * deq.front().first;
        if (deq.front().second == 0) deq.pop_front();
    }
}

void add(double tadd, lint vadd)
{
    if (deq.back().first < tadd) // 追加するほうが高温の場合、先頭から余剰分を抜いていく
    {
        deq.push_back(plint(tadd, vadd));
        Qsum += tadd * vadd;
        Vnow += vadd;
        trim();
    }
    else // 低温の場合、うしろとくっつけていく
    {
        if (deq.back().second + vadd >= L)
        {
            Qsum = deq.back().first * (L - vadd) + tadd * vadd;
            Vnow = L;
            deq.clear();
            deq.push_back(plint(Qsum / L, L));
        }
        else
        {
            double Qaddnew = deq.back().first * deq.back().second + tadd * vadd;
            lint vaddnew = deq.back().second + vadd;
            Qsum -= deq.back().first * deq.back().second;
            Vnow -= deq.back().second;
            deq.pop_back();
            add(Qaddnew / vaddnew, vaddnew);
        }
    }
}

void print()
{
    cout << setprecision(12) << Qsum / L << endl;
}
int main()
{
    cin >> N >> L;
    REP(_, N)
    {
        double t;
        lint v;
        cin >> t >> v;
        if (_ == 0)
        {
            deq.push_back(plint(t, v));
            Qsum = t * v;
            Vnow = v;
            print();
        }
        else
        {
            add(t, v);
            print();
        }
    }
}


Measured memory_bytes: 46624
#include <stdio.h>
#include <algorithm>
using namespace std;

typedef long long ll;

int main(void)
{
	ll a, b, c, d;

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

	ll v1 = a * c;
	ll v2 = b * d;
	ll v3 = b * c;
	ll v4 = a * d;

	printf("%lld", max(v1, max(v2, max(v3, v4))));

	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

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

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 8000008
using namespace std;

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

int calc(vector<int> a, int curr){
	int res = 0;
	rep (i, a.size()) res += (a[i] - curr) * (a[i] - curr);
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> a(N, 0);
	int lo = 100;
	int hi = -100;
	rep (i, N){
		cin >> a[i];
		lo = min(lo, a[i]);
		hi = max(hi, a[i]);
	} // end rep

	int res = INF;
	for (int i = lo; i <= hi; ++i){
		int curr = calc(a, i);
		res = min(res, curr);
	} // end for

	cout << res << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	int n, k;
	cin>>n>>k;
	ll dp[110][11000]={}, dp2[110][11000]={};
	dp2[n+1][0]=1;
	for(int i=n; i>=1; i--){
		for(int j=0; j<11000; j++){
			if(dp2[i+1][j]==0) continue;
			for(int l=0; l<=k; l++){
				if(l>i){
					(dp2[i][j]+=dp2[i+1][j])%=MOD;
					(dp[i][j]+=dp[i+1][j]+dp2[i+1][j]*(l+j))%=MOD;
				}else{
					(dp2[i][j+(l+j)/i]+=dp2[i+1][j])%=MOD;
					(dp[i][j+(l+j)/i]+=dp[i+1][j]+dp2[i+1][j]*((l+j)%i))%=MOD;
				}
			}
		}
	}
	ll ans=0;
	for(int i=0; i<11000; i++) ans+=dp[1][i];
	ans%=MOD;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

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

int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    long long g = gcd(a, b);
    vector<int> div;
    for (int i = 1; i * i <= g; i++) {
        if (g % i == 0) {
            div.push_back(i);
            if (i != g/i) { 
                div.push_back(g/i);
            }
        }
    }
    sort(div.rbegin(), div.rend());
    cout << div[k-1] << endl;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector <int> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	int prev = -1;
	int now = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (h[i] > prev) {
			now = 0;
		} else {
			now++;
		}
		prev = h[i];
		ans = max(ans, now);
	}
	cout << ans;
	return 0;
}


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

int main(){
    string s;
    cin >> s;
    int t = s.size();
    int f = ( t - 1 ) / 2;
    int l = ( t + 3 ) / 2;

    string fs;
    string ls;

    for ( int i = 0; i < f; ++i ) {
        fs += s[i];
    }

    for ( int i = l-1; i < t; ++i ) {
        ls += s[i];
    }

    if ( fs == ls ) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3592
#include <algorithm> // std::sort(begin,end), std::min, std::max
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>

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

template <typename T> // 0<1<2<3<4
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
template <typename T> // 0>1>2>3>4
using pq_dsc = priority_queue<T>;

int main(int argc, char const *argv[]) {

  int n;
  cin >> n;
  for (int i = 1; i < 10; i++) {
    for (int j = i; j < 10; j++) {

      if (i * j == n) {

        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

template <class T1>
class Operators
{
public:
    template <class T2>
    const T1 operator+(const T2& right) const{
        T1 ans = static_cast<const T1&>( *this );
        return ans += right;
    }
    template <class T2>
    const T1 operator-(const T2& right) const{
        T1 ans = static_cast<const T1&>( *this );
        return ans -= right;
    }
    template <class T2>
    const T1 operator*(const T2& right) const{
        T1 ans = static_cast<const T1&>( *this );
        return ans *= right;
    }
};

class Mod : public Operators<Mod>
{
private:
    static const int MOD = 1000000007;
    long long a;
public:
    Mod(){
        a = 0;
    }
    Mod(long long x){
        a = (x % MOD + MOD) % MOD;
    }
    Mod& operator+=(const Mod& x){
        a = (a + x.a) % MOD;
        return *this;
    }
    Mod& operator-=(const Mod& x){
        a = (a - x.a + MOD) % MOD;
        return *this;
    }
    Mod& operator*=(const Mod& x){
        a = (a * x.a) % MOD;
        return *this;
    }
    long long getValue(){
        return a;
    }
};

int main()
{
    int n, k;
    cin >> n >> k;
    if(k % 2 != 0){
        cout << 0 << endl;
        return 0;
    }
    k /= 2;

    vector<vector<Mod> > dp(1, vector<Mod>(k+1, 0));
    dp[0][0] = 1;
    for(int i=0; i<n; ++i){
        vector<vector<Mod> > nextDp(i+2, vector<Mod>(k+1, 0));
        for(int a=0; a<i+1; ++a){
            for(int b=0; b<=k; ++b){
                if(b + a <= k)
                    nextDp[a][b+a] += dp[a][b] * (a * 2 + 1);
                if(b + a + 1 <= k)
                    nextDp[a+1][b+a+1] += dp[a][b];
                if(a > 0 && b + a - 1 <= k)
                    nextDp[a-1][b+a-1] += dp[a][b] * a * a;
            }
        }
        dp = move(nextDp);
    }
    cout << dp[0][k].getValue() << endl;

    return 0;
}


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

int main()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    int a=1;
    rep(i,n/2){
        if(s[i]!=s[i+n/2]){
            a=0;
        }
    }
    if(n%2!=0) a=0;
    if(n==1) a=0;
    if(a==0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import math
import bisect


def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True


if __name__ == '__main__':
    q = int(input())
    array = [[int(x) for x in input().split()] for x in range(q)]
    nearby_2017 = [x for x in range(1, 100000, 2) if is_prime(x) and is_prime((x+1)/2)]
    for i, j in array:
        print(bisect.bisect_right(nearby_2017, j) - bisect.bisect_left(nearby_2017, i))



Measured memory_bytes: 22052
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

int N, L, R;
char S[105];

int main() {
  scanf("%d", &N);
  scanf("%s", S);
  
  int i = 0;
  while (i < N) {
    while (S[i] != '(' && i < N) {
      L++;
      i++;
    }
    int l = 1;
    i++;
    while (l > 0 && i < N) {
      if ( S[i] == ')') l--;
      else l++;
      i++;
    }
    if (i == N) R += l;
  }
  
  rep(i, 0, L) printf("(");
  printf("%s", S);
  rep(i, 0, R) printf(")");
  printf("\n");
  
  return 0;

}

Measured memory_bytes: 256
mod = 10**9 + 7
n = int(input())
s = input()

crr = 0
lst= []
for i in range(2*n):
    if s[i] == 'B':
        if crr%2 == 1:
            lst.append(-1)
            crr -= 1
        else:
            lst.append(1)
            crr += 1
    else:
        if crr%2 == 1:
            lst.append(1)
            crr += 1
        else:
            lst.append(-1)
            crr -= 1

if crr!=0 or lst[0]!=1 or lst[-1]!=-1:
    print(0)
    exit()

plus = []
pcnt = 0
minus = []
mcnt = 0
where = []
for i in range(2*n):
    if lst[i] == 1:
        pcnt += 1
    else:
        mcnt += 1
        where.append(i)
    plus.append(pcnt)
    minus.append(mcnt)

ans = 1
for i in where:
    ans *= plus[i] - minus[i] + 1
    ans %= mod

for i in range(1, n+1):
    ans *= i
    ans %= mod

print(ans)

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

int main() {
  int N, K;
  cin >> N >> K;
  K --;
  string S;
  cin >> S;
  if(S.at(K) == 'A'){
    S.at(K) = 'a';
  }
  else if (S.at(K) == 'B'){
    S.at(K) = 'b';
  }
  else S.at(K) = 'c';
  cout << S << endl;
}

Measured memory_bytes: 256
// includes, macros {{{
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <list>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <climits>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

#define eps (1e-10)
#define equals(a, b) (fabs((a)-(b)) < eps)

#define rep(i, s, e)    for (int i = (s); i < (int)(e); i++)
//#define pb(e) push_back(e)
//#define mp(a, b) make_pair(a, b)

// for debug
#define kita            cout << "kita\n"
#define print2(i, n)    cout << (i) << ": " << (n) << endl
#define print3(i, j, n)     cout << "(" << (i) << ", " << (j) << ") : " << (n) << endl
#define print4(i, j, n, m)  cout << "(" << (i) << ", " << (j) << ") : " << (n) << ", " << (m) << endl
#define print_mat(mat, h, w) for(int i=0;i<(h);i++){for(int j=0;j<(w);j++){cout << mat[i][j] << " ";}cout << endl;}
 
typedef long long ll;
typedef unsigned long long ull; // }}}

int main() {
    int n;
    vector<int> a;
    list<int> b;

    cin >> n;

    for(int i=0;i<n;i++){
        int aa;
        cin >> aa;
        a.push_back(aa);
    }

    for(int i=0;i<n;i++){
        if(i%2 == 0){
            b.push_back(a[i]);
        }else{
            b.push_front(a[i]);
        }
    }


    if(n%2 != 0){
        reverse(b.begin(), b.end());
    }

    bool flag = true;
    for(auto bb : b){
        if(!flag){
            cout << " ";
        }
        flag = false;
        cout << bb;
    }

    cout << endl;

    return 0;
}


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

S = input()

a = int(S[:2])
b = int(S[2:])
fa = 0
fb = 0

if 1<=a and a<=12:
    fa = 1

if 1<=b and b<=12:
    fb = 1

if fa==1 and fb==1:
    print("AMBIGUOUS")
elif fa==1 and fb==0:
    print("MMYY")
elif fa==0 and fb==1:
    print("YYMM")
else:
    print("NA")

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

int N, X;

int main() {
  int k;
  while (true) {
    cin >> N >> X;
    if (N == 0 && X == 0) break;

    int count = 0;
    for (int i=1; i<=N-1; i++) {
      for (int j=i+1; j<N; j++) {
        k = X - i - j;
        if (j < k && k <= N) count++;
      }
    }
    cout << count << endl;
  }
}



Measured memory_bytes: 3096
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <complex>
using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef vector<vector<string> > vss;
typedef pair<int, int> pii;
#define INF 0x7fffffff
//#define INFLL 0x7fffffffffffffff
#define INFLL LLONG_MAX
#define SIZE(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()
#define FOR(i,x) for(int i=0;i<x;i++)
#define FORic(i,y,x) for(int i=y;i<=x;i++)
#define FORdc(i,y,x) for(int i=y;i>=x;i--)
#define FILL(a,v) memset(a, v, sizeof(a))
#define PI 3.14159265358979323846

typedef complex<long double> P; /* _ */
typedef pair<P, long double> C; /* ~ */
struct L { P p, q; L(P p, P q) : p(p), q(q) {} }; /* üª */

const long double EPS = 0;

// complexÉå¬ÖWªKvÈê
namespace std{
	bool operator < (const P &a, const P &b){ return make_pair(real(a),imag(a)) < make_pair(real(b),imag(b)); }
}

// ~Ìð·»è
bool crossCircle(C c1, C c2){
	long double r1 = c1.second;
	long double r2 = c2.second;
	long double d = abs(c1.first-c2.first);
	if(d<r1||d<r2)
		return d-abs(r1-r2)>=EPS;
	return r1+r2-d>=-EPS;
}

// ~Ìð_ðÔ·(æÉð·»èK{)
pair<P,P> crossPoint(C c1, C c2){
	long double r1 = c1.second;
	long double r2 = c2.second;
	long double r3 = abs(c1.first-c2.first);
	long double rc = (r3*r3+r1*r1-r2*r2)/(2*r3);
	long double rs = sqrt(r1*r1-rc*rc);
	P dif = (c2.first-c1.first)/r3;
	P p1 = c1.first+dif*P(rc,rs);
	P p2 = c1.first+dif*P(rc,-rs);
	return make_pair(p1,p2);
}

int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		vector<P> all;
		FOR(i,n){
			string temp;
			cin>>temp;
			long double x = atof(temp.substr(0,temp.find(',')).c_str());
			long double y = atof(temp.substr(temp.find(',')+1).c_str());
			//cout<<x<<endl;
			//cout<<y<<endl;
			all.push_back(P(x,y));
		}
		if(n==1){
			cout<<1<<endl;
			continue;
		}
		int N = SIZE(all);
		vector<P> ten;
		FOR(i, N-1){
			FORic(j, i+1, N-1){
				C c1 = make_pair(all[i], 1.0);
				C c2 = make_pair(all[j], 1.0);
				if(crossCircle(c1,c2)){
					pair<P,P> temp;
					temp = crossPoint(c1,c2);
					ten.push_back(temp.first);
					ten.push_back(temp.second);
				}
			}
		}
		int ans = 0;
		FOR(k, SIZE(ten)){
			int count = 0;
			FOR(i, N){
				if(abs(all[i]-ten[k])<=1.0){
					count++;
				}
			}
			ans = max(ans, count);
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

#define putchar(c) putc_unlocked((c), stdout)
#define getchar() getc_unlocked(stdin)
char nextchar(void){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); return c; }
int32_t nextint(void){ char c=getc_unlocked(stdin); while(c!='-'&&(c<'0'||'9'<c)) c=getc_unlocked(stdin); int s=0; if(c=='-'){s=1;c=getc_unlocked(stdin);} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return s?-x:x; }
uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint64_t nextplong(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint32_t nextstr(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }
uint32_t nextstrln(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }

void printint(int x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); putc_unlocked('\n', stdout); }
void printlong(long x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[20]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); putc_unlocked('\n', stdout); }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

#define P 1000000007
char s[100001];
int d[100001][13];
int main(void){
	int n=nextstr(s);
	d[0][0]=1;
	for(int i=0; i<n; i++){
		int f=s[i]=='?'?-1:s[i]-'0';
		for(int j=0; j<10; j++){
			if(f<0||f==j){
				for(int k=0; k<13; k++){
					int l=(k*10+j)%13;
					d[i+1][l] = (d[i+1][l]+d[i][k])%P;
				}
			}
		}
	}
	printf("%d\n", d[n][5]);
}


Measured memory_bytes: 5376
a[1<<20];
n=1<<20;
main(i,c){
	*a=a[1]=1;
	for(;++i<n;)
		if(!a[i])
			for(c=2;c*i<n;)
				a[i*c++]=1;
	for(;scanf("%d",&n),n;printf("%d\n",c)){
		c=0;
		for(i=n;++i<=2*n;)
			a[i]||c++;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>

#define PI 3.14159265

int main(){
  int a,b,x;
  scanf("%d%d%d",&a,&b,&x);
  double val=180.0/PI;

  if(x<=a*a*b*0.5){
    double c=x*1.0/(a*b*0.5);
    printf("%lf\n",atan(b/c)*val);
    return 0;}
  else{
    double d=x*1.0/(a*a*0.5)-b;
    printf("%lf\n",atan((b-d)/a)*val);
    return 0;}
}


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

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

  vector<int> A(N), B(N);
  vector<int> C(N-1);

  for (int i=0; i<N; i++) {
    int a;
    cin >>a;
    A.at(i) =a;
  }
  for (int i=0; i<N; i++) {
    int  b;
    cin >>b;
    B.at(i) =b;
    
  }
  for (int i=0; i<N-1; i++) {
    int c;
    cin >>c;
    C.at(i) = c;
  }

  int man;
  for(auto x : B) {
    man += x;
  }
  for (int i=0; i<N-1; i++) {
    if (A.at(i)+1 == A.at(i+1)) {
      man += C.at(A.at(i)-1);
    }
  }
  cout << man <<endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 /*temp*/

main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a < b && b < c) cout << "Yes\n";
    else  cout << "No\n";
}

Measured memory_bytes: 3016
import java.util.Scanner;

public class Main {
	static void call(int n) {
		int i = 1;
		while (i <= n) {
			if (i % 3 == 0)
				System.out.print(" " + i);
			else if (i % 10 == 3)
				System.out.print(" " + i);
			else if (i / 10 != 0 && (i / 10) % 10 == 3)
				System.out.print(" " + i);
			else if (i / 100 != 0 && (i / 100) % 10 == 3)
				System.out.print(" " + i);
			else if (i / 1000 != 0 && (i / 1000) % 10 == 3)
				System.out.print(" " + i);
			i++;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int input = sc.nextInt();
		call(input);
		System.out.println();
	}
}

Measured memory_bytes: 28644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





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

    int H, W, D;
    cin >> H >> W >> D;
    
    map<int, pii> mp;
    rep(i, H) rep(j, W) {
        int A;
        cin >> A;
        mp[A] = pii{i, j};
    }
    
    int Q;
    cin >> Q;
    
    const int MAX_N = 300 * 300 + 1;
    int table[MAX_N];
    fill_n(table, MAX_N, 0);
    
    rep3(i, D + 1, MAX_N) {
        table[i] = table[i - D] + abs(mp[i].F - mp[i - D].F) + abs(mp[i].S - mp[i - D].S);
    }
    // outa(table, H * W + 1);
    rep(i, Q) {
        int L, R;
        cin >> L >> R;
        if (L <= D) {
            out(table[R]);
        } else {
            out(table[R] - table[L]);
        }
    }
}




Measured memory_bytes: 7168