akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define in(n) for(int i=0;i<n;i++)
#define inj(n) for(int j=0;j<n;j++)
#define it n int
#define ll long long 
#define ull unsigned ll
#define int ll int
#define S second 
#define F first 
#define globalbool 2000000
using namespace std;
int solve(int n,int A[],int dp[],int &sz)
{
    if(n==0)
        return 0;
    if(n<0)
        return INT_MAX;
    if(dp[n]!=-1)
        return dp[n];
    return dp[n]=min(solve(n-1,A,dp,sz)+abs(A[n]-A[n-1]),solve(n-2,A,dp,sz)+abs(A[n]-A[n-2]));
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n;
    cin>>n;
    int A[n];
    int dp[n+1];
    memset(dp,-1,sizeof(dp));
    in(n)
        cin>>A[i];
    int B[n-1];
    for(int i=0;i<n-1;i++)
    {
        B[i]=abs(A[i]-A[i+1]);
    }
    cout<<solve(n-1,A,dp,n);
}

Measured memory_bytes: 6528
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args){

		solve_abcPpc_c();
	}
  
  	public static void solve_abcPpc_c(){

		Scanner sc = new Scanner(System.in);
		String ans = "No";
		
		/*
		double a = Math.sqrt((double)sc.nextLong());
		double b = Math.sqrt((double)sc.nextLong());
		double c = Math.sqrt((double)sc.nextLong());
		
		if(c - a - b > 0){
			ans = "Yes";
		}
		*/
		
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		
		long d = c - a - b;
		
		if((d > 0) && (d * d > 4 * a * b)){
			ans = "Yes";
		}
		
		System.out.println(ans);

		sc.close();

	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <cassert>

using namespace std;

const int DICE_SIZE = 6;

//?????????
//??±?\????????????¢???????????¨?????§?????????
class dice {
  //?????????,?????¢,??±??¢,?\???¢,?????¢,?????¢?????°???
  int values[DICE_SIZE];
public:
  dice ();
  virtual ~dice ();
  int &operator[](int i){
    assert(0 <= i && i < DICE_SIZE);
    return values[i];
  };
  void docmd(string str);
  void docmd(char c);
private:
  int indexs[4][4];
  char *cmdChar;
  void move_forward(int *indexs);
};
dice::dice(){
  int westindex[4] = {1, 3, 6, 4};
  int northindex[4] = {1, 2, 6, 5};
  cmdChar = new char[4]{'W', 'E', 'N', 'S'};
  for(int i = 0; i < 4; i++){
    indexs[0][i] = westindex[i] - 1;//W
    indexs[1][i] = westindex[4 - i - 1] - 1;//E
    indexs[2][i] = northindex[i] - 1;//N
    indexs[3][i] = northindex[4 - i - 1] - 1;//S
  }
}
dice::~dice(){
  delete [] cmdChar;
}

void dice::docmd(string str){
  for(int i = 0; i < str.length(); i++){
  //  cout << "docmd(str[i])" << str[i] << endl;
    docmd(str[i]);
  }
}

void dice::docmd(char c){
  for(int i = 0; i < 4; i++){
    if (c == cmdChar[i]){
    //  cout << cmdChar[i] << endl;
      move_forward(indexs[i]);
      return;
    }
  }
  assert(false);//????????¨???????????????
}
void dice::move_forward(int *indexs){
  int temp = values[indexs[0]];
  values[indexs[0]] = values[indexs[1]];
  values[indexs[1]] = values[indexs[2]];
  values[indexs[2]] = values[indexs[3]];
  values[indexs[3]] = temp;
}

int main(int argc, char const *argv[]) {
  dice d;
  for(int i=0; i < DICE_SIZE; i++){
    int n;
    cin >> n;
    d[i] = n;
  }
  string commandstr;
  cin >> commandstr;
  d.docmd(commandstr);
  int topnum = d[0];
  cout << topnum << endl;
  return 0;
}

Measured memory_bytes: 3168
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
l = len(s)

ans = 10**18
for i in range(l-2):
    ans = min(ans, abs(753-int(s[i:i+3])))
    
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int R,G,B,n;
    cin >> R >> G >> B >> n;
    ll answer = 0;
    for(int r = 0;r <= n;r+=R){
        for(int g = 0;g <= n;g+=G){
            if(n-(r+g) >= 0 && (n-(r+g))%B == 0)answer++;
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <complex>

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

using namespace std;

typedef long double ld;
typedef complex<ld> P;
typedef vector<P> VP;
const ld eps = 1e-8, pi = acos(-1.0);

ld dot (P a, P b) { return real(conj(a) * b); }
ld cross (P a, P b) { return imag(conj(a) * b); }

class L{
public:
  P a, b;
  L (P aa, P bb) { a = aa; b = bb; }
  L (ld ax, ld ay, ld bx, ld by) { a = P(ax, ay); b = P(bx, by); }
};

P incenter(VP tri) {
  ld l[3];
  REP(i,3) l[i] = abs(tri[(i+1)%3] - tri[(i+2)%3]);
  ld p = l[0]+l[1]+l[2];
  P ic;
  REP(i,3) ic += l[i]/p*tri[i];
  return ic;
}

P proj(L l, P p) {
  ld t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + t * (l.a - l.b);
}

ld dist_lp(L l, P p) {
  return abs(p - proj(l, p));
}

int main() {
  while(1){
    VP tri;
    REP(i,3){
      ld x,y;
      cin>>x>>y;
      tri.emplace_back(x,y);
    }
    if (tri[0] == tri[1]) break;
    P ic = incenter(tri);
    P lb = tri[0], ub = ic;
    ld d = 0, d1 = 0, d2 = 0;
    while (abs(lb - ub) > eps) {
      P mid = (lb + ub) / (ld)2.0;
      d = dist_lp(L(tri[0], tri[1]), mid);
      P lb1 = tri[1], ub1 = ic;
      while (abs(lb1 - ub1) > eps) {
        P mid1 = (lb1 + ub1) / (ld)2.0;
        d1 = dist_lp(L(tri[0], tri[1]), mid1);
        if (abs(mid - mid1) - d < d1) {
          ub1 = mid1;
        } else {
          lb1 = mid1;
        }
      }
      P lb2 = tri[2], ub2 = ic;
      while (abs(lb2 - ub2) > eps) {
        P mid2 = (lb2 + ub2) / (ld)2.0;
        d2 = dist_lp(L(tri[0], tri[2]), mid2);
        if (abs(mid - mid2) - d < d2) {
          ub2 = mid2;
        } else {
          lb2 = mid2;
        }
      }
      if (abs(lb2 - lb1) < d1 + d2) {
        lb = mid;
      } else {
        ub = mid;
      }
    }
    cout << setprecision(10) << fixed << d << ' ' << d1 << ' ' << d2 << endl;
  }
  return 0;
}

Measured memory_bytes: 1304
#include <stdio.h>

int main(void) {
    int a, b,i;
    i = 0;
    while (1)
    {
        scanf("%d%d", &a, &b);
        if (a == 0 && b == 0) break;
        if ( a > b ){
            printf("%d %d\n", b, a);
        }else{
            printf("%d %d\n", a, b);
        }
    }
    return 0;
}



Measured memory_bytes: 2052
n, m = map(int, input().split())

a = []
b = []

for i in range(n):
	a.append(list(map(int, input().split())))

for i in range(m):
	b.append(int(input()))

for i in range(n):
	ans = 0
	for j in range(m):
		ans += a[i][j] * b[j]
	print(ans)



Measured memory_bytes: 6008
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int n;
int main(){
	int Min = 1 << 30;
	int Max = -1;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		int a;
		scanf("%d", &a);
		Min = min(Min, a);
		Max = max(Max, a);
	}
	printf("%d\n", Max - Min);
	return 0;
}


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

int main()
{
	int n,k,i;
	long long int sum=0;
	int arr[300000];
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&arr[i]);
	}
	sort(arr+1,arr+1+n);
	if(n>k)
	{
		for(i=1;i<=n-k;i++)
		{
			sum=sum+arr[i];
		}
	}
	else
		sum=0;
	cout << sum;
	return 0;
}

	


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
typedef tuple<int,int,int> TP;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    ll N,P;
    cin >> N >> P;
    string S;
    cin >> S;
    if(P == 2) {
        ll ret = 0;
        for(ll i = 0;i < N;i++) {
            if((S.at(i) - '0') % 2 == 0) {
                ret += i + 1;
            }
        }
        cout << ret << endl;
    }
    else if(P == 5) {
        ll ret = 0;
        for(ll i = 0;i < N;i++) {
            if((S.at(i) - '0') % 5 == 0) {
                ret += i + 1;
            }
        }
        cout << ret << endl;
    }
    else {
        reverse(S.begin(),S.end());
        map<ll,ll> ma;
        ll cnt = 0;
        for(int i = 0;i < N;i++) {
            ma[cnt]++;
            cnt += (S.at(i) - '0') * RS(10,i,P);
            cnt %= P;
        }
        ma[cnt]++;
        ll ret = 0;
        for(auto x:ma) {
            ret += x.second * (x.second - 1) / 2;
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 1028
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>

using namespace std;

const int mod = 1000000007;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    string s1, s2;
    cin >> n >> s1 >> s2;
    int last = -1;
    long long ans = 1;
    for (int i = 0; i < n; i++){
        if (s1[i] == s2[i]){
            if (last == 1)
                ans *= 2;
            else
            if (last == -1)
                ans *= 3;
            last = 1;
        }else{
            if (last == -1)
                ans *= 6;
            else
            if (last == 1)
                ans *= 2;
            else
                ans *= 3;
            i++;
            last = 2;
        }
        ans %= mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
from sys import exit
# A,B,C = [int(n) for n in input().split()]
N = int(input())
# a = [int(input()) for _ in range(N)]
S = str(input())
L = len(S)
# T = str(input())
# exit()
print("Yes" if (L - S.count("R")) < L/2 else "No")


Measured memory_bytes: 2940
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

    string s; cin>>s;
    set<char> st;
    for(int i=0; i<3; i++) st.emplace(s[i]);

    cout << (st.size() == 2 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb emplace_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 31000000
// #define M 19
 
#define mod  100007
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef int ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll mul(ll a, ll b) { return (long long) a*b%mod;}
inline ll add(ll a, ll b) { return a+b < mod? a+b: a+b-mod;}
inline void Mul(ll &a, ll b) { a = (long long) a*b%mod;}
inline ll bp(ll a, ll p){
	ll ret;
	for(ret = 1; p; p>>=1, Mul(a, a)) (p & 1) && (Mul(ret, a), 1);
	return ret;
}

static inline void read(ll &result) {
    bool minus = false;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' and ch <= '9') break;
        ch = getchar();
    }
    (ch == '-')? minus = true: result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' or ch > '9') break;
        result = (result<<3)+ (result<<1) + (ch - '0');
    }
    if(minus) result=-result;
}


int main(){
	fastio;
	string s; cin>>s;
	(s[2] == s[3] and s[4] == s[5])? cout<<"Yes\n": cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod=1e9+7;
ll inf=1e18;

//2*10^5*26

int main(void){
	bool ok=true;
	ll a[30];
	rep(i,30)a[i]=-1;
	string s,t;
	cin>>s>>t;
	rep(i,s.size()){
		ll p = s[i]-'a';
		if(a[p]==-1){
			a[p] = t[i]-'a';//sのこの文字は，tのこの文字
		}else if(a[p]!=t[i]-'a'){
			ok=false;
		}
	}
	set<ll> b;
	rep(i,26){
		if(a[i]!=-1){
			if(b.count(a[i])==0){
				b.insert(a[i]);
			}else{
				ok=false;
			}
		}
	}
	if(ok){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int n;

vector<long long int> v;

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		long long int a;
		scanf("%lld", &a);
		v.push_back(a);
	}
	long long int maxt = 0;
	long long int cnt = 0;
	for (int i = 0; i < v.size(); i++){
		if (i == 0){
			cnt += v[i] - 1;
			maxt = 1;
			continue;
		}
		if (v[i] <= maxt){
			continue;
		}
		if (v[i] == maxt + 1){
			maxt= maxt + 1;
			continue;
		}
		cnt += v[i] / (maxt+1);
		if (v[i] % (maxt + 1)==0){
			cnt--;
		}
	}
	printf("%lld\n", cnt);
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
using namespace std;
bool linesearch(int x,int a,int* fi){
    for(int i=0;i<a;i++){
        if(x==fi[i])return true;
    }
    return false;
}


int main(){
    int a,b;
    int ans=0;
    cin>>a;
    int fi[a];
    for(int i=0;i<a;i++)cin>>fi[i];
    cin>>b;
    for(int i=0;i<b;i++){
        int x;
        cin>>x;
        
        if( linesearch(x,a,fi))ans++;
        
    }

    cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 3144
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
ans = 0
for i in range(0,N) :
    A = list(map(int,input().split()))
    Sum = C
    for (x,y) in zip(A,B):
        Sum += (x*y)
    if Sum > 0 :
        ans += 1
print(ans)

Measured memory_bytes: 3060
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    n = I()
    a = LI()
    f = defaultdict(int)
    for i in a:
        f[i-1] += 1
        f[i] += 1
        f[i+1] += 1
    print(max(f.values()))
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 62680
// In the name of God
#include <bits/stdc++.h>

using namespace std;
#define Size(x) ((int)(x).size())
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int INF = 1e9 + 10;
const int MN = 1e5 + 10;

int n , m;
vector<int>adj[MN];
bool mk[MN];
int par[MN];
vector<int>ans, Tmp;

int dfs(int s)
{
	mk[s] = true;
	int my = -1;
	for(int i=0;i<Size(adj[s]);++i) if(!mk[adj[s][i]]){
		par[adj[s][i]] = s;
		my = dfs(adj[s][i]);
	}
	if(~my) return my;
	return s;
}

int main()
{
	ios_base :: sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);
	cin >> n >> m;
	int x,y;
	for(int i=0;i<m;++i){
		int a,b;cin>>a>>b;--a,--b;
		adj[a].pb(b) , adj[b].pb(a);
		x = a , y = b;
	}
	memset(mk , 0 , sizeof mk);
	mk[x] = true;
	int v = dfs(y);
	while(v != y){
		ans.pb(v);
		v = par[v];
	}
	ans.pb(y);
	memset(mk , 0 , sizeof mk);
	for(auto xt:ans) mk[xt] = true;
	v = dfs(x);
	while(v != x){
		Tmp.pb(v);
		v = par[v];
	}
	Tmp.pb(x);
	while(!Tmp.empty()) ans.pb(Tmp.back()) , Tmp.pop_back();
	cout << Size(ans) << '\n';
	for(auto xt:ans) cout << xt+1 << ' ';cout << '\n';
	return 0;
}


Measured memory_bytes: 11128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

string s;

int filter(int bit, int a, int b, int c, int d, int e, int f, int g) {
  int mask = 0;
  mask |= (bit >> a & 1) << 0;
  mask |= (bit >> b & 1) << 1;
  mask |= (bit >> c & 1) << 2;
  mask |= (bit >> d & 1) << 3;
  mask |= (bit >> e & 1) << 4;
  mask |= (bit >> f & 1) << 5;
  mask |= (bit >> g & 1) << 6;
  return s[mask] - '0';
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> s, s != "#") {
    bool yes = true;
    for (int i = 0; i < 1 << 19; i++) {
      int bit = 0;
      bit |= (filter(i, 0, 1, 2, 4, 6, 7, 9) << 4);
      bit |= (filter(i, 1, 3, 4, 6, 8, 9, 11) << 6);
      bit |= (filter(i, 2, 4, 5, 7, 9, 10, 12) << 7);
      bit |= (filter(i, 4, 6, 7, 9, 11, 12, 14) << 9);
      bit |= (filter(i, 6, 8, 9, 11, 13, 14, 16) << 11);
      bit |= (filter(i, 7, 9, 10, 12, 14, 15, 17) << 12);
      bit |= (filter(i, 9, 11, 12, 14, 16, 17, 18) << 14);
      yes &= (bit >> 9 & 1) == filter(bit, 4, 6, 7, 9, 11, 12, 14);
    }
    cout << (yes ? "yes" : "no") << endl;
  }  

  return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

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

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve()
{
    LL A, B, N;
    cin >> A >> B >> N;
    LL x = min(N, B - 1);
    LL ans = (A * x) / B - A * (x / B);

    std::cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m; cin >> n >> m;
    int _n = n;
    map<int,int> mapper;
    while(n--){
        int sz; cin >> sz;
        while(sz--){
            int curr; cin >> curr;
            mapper[curr]++;
        }
    }
    int ans = 0;
    for(auto i : mapper) ans += (i.second == _n);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	
	vector<vector<int>> A(3, vector<int>(3));
	for(int i=0; i<3;i++){
		for (int j=0; j<3; j++){
			cin >>A.at(i).at(j);
		}
	}
	int N;
	cin >>N;
	vector<int> b(N);
	for(int i=0; i<N; i++){
		cin >>b.at(i);
	}
	
	for(int i=0; i<N; i++){
		for(int j=0; j<3; j++){
			for(int k=0; k<3; k++){
				if(b.at(i)==A.at(j).at(k)){
					A.at(j).at(k)=0;
					continue;
				}
			}
		}
	}
	
	bool flag = 0;
	for(int i=0; i<3; i++){
		
		if(A.at(i).at(0)==0&&A.at(i).at(1)==0&&A.at(i).at(2)==0){
		flag=1;
		}
		
	}
	for(int i=0; i<3; i++){
		
		if(A.at(0).at(i)==0&&A.at(1).at(i)==0&&A.at(2).at(i)==0){
		flag=1;
		}
		
	}
	if(A.at(0).at(2)==0&&A.at(1).at(1)==0&&A.at(2).at(0)==0){
		flag=1;
	}
	if(A.at(0).at(0)==0&&A.at(1).at(1)==0&&A.at(2).at(2)==0){
		flag=1;
	}
	
	if(flag){
		cout <<"Yes" <<endl;
	}
	else{
		cout <<"No" <<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()
 
int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}
 
typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;

int main(){
      string A;
      string B;
      string C;
      cin >> A >> B >> C;
      char next = A[0];
      int acnt = 1,bcnt = 0,ccnt = 0;
      for(int i=0;i<300;i++){      
            if(next=='a'){
                  if(acnt>=A.size()){cout << 'A';return 0;}
                  else next = A[acnt++];
            }else if(next=='b'){
                  if(bcnt>=B.size()){cout << 'B';return 0;}
                  else next = B[bcnt++];
            }else if(next=='c'){ 
                  if(ccnt>=C.size()){cout << 'C';return 0;}
                  else next = C[ccnt++];
            }
      }
      return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			long n = in.nextLong();
			long digit = Long.MAX_VALUE;
			for (long i = 1; i * i <= n; i++) {
				if (n % i == 0) {
					long j = n / i;
					String tmp1 = String.valueOf(i);
					String tmp2 = String.valueOf(j);
					long ans = Math.max(tmp1.length(), tmp2.length());
					digit = Math.min(digit, ans);
				}
			}
			out.println(digit);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pi acos(-1)
int main()
{
    int c=0,c1=0,c2=0,c3=0;
int t; cin>>t; while(t--){
string s;
    cin>>s;
 
    if(s=="AC")
    {
        c++;
    }
     if(s=="WA")
    {
        c1++;
    }
     if(s=="TLE")
    {
        c2++;
    }
     if(s=="RE")
    {
        c3++;
    }
}
   cout<<"AC x "<<c<<endl;
   cout<<"WA x "<<c1<<endl;
   cout<<"TLE x "<<c2<<endl;
   cout<<"RE x "<<c3<<endl;
}

Measured memory_bytes: 3636
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[0 for _ in range(3)] for _ in range(n+1)]
for i in range(n):
  for j in range(3):
    for k in range(3):
      if j == k:
        continue
      dp[i+1][k] = max(dp[i+1][k], dp[i][j]+abc[i][k])

print(max(dp[n]))


Measured memory_bytes: 47328
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[50], B[50];
bool dp[51];
// O(A^2N)
bool ok(long long mask) {
  rep(i, N) {
    rep(x, 51) dp[x] = false;
    dp[A[i]] = true;
    for (int k=50; k>=0; k--) if ((mask>>(k-1))&1) {
      for (int x=0; x<=50; x++) dp[x%k] |= dp[x];
    }
    //if (!dp[B[i]]) cout<<"mask="<<bitset<50>(mask)<<": "<<A[i]<<"->"<<B[i]<<": impossible\n";
    if (!dp[B[i]]) return false;
  }
  return true;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  long long mask = (1LL<<50)-1;
  if (!ok(mask)) {
    cout << -1 << "\n";
    return 0;
  }
  // O(A^3N)
  for (int k=49; k>=0; k--) {
    if (ok(mask^(1LL<<k))) mask ^= 1LL<<k;
  }
  cout << 2LL*mask << "\n";
  return 0;
}


Measured memory_bytes: 256
def main():
    n, q = map(int, input().split())

    # 頂点のリスト、ポイント、走査済みか
    graph = [[[], 0, False] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        graph[a-1][0].append(b-1)
        graph[b-1][0].append(a-1)

    for i in range(q):
        p, x = map(int, input().split())
        graph[p-1][1] += x

    queue = [0]
    while queue:
        q = queue.pop()
        graph[q][2] = True
        for v in graph[q][0]:
            if graph[v][2]:
                continue
            graph[v][1] += graph[q][1]
            queue.append(v)

    for i in range(n):
        print(graph[i][1], end=' ')


if __name__ == '__main__':
    main()


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const char EOL = '\n';

void solve();

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

void solve() {
    int n;
    cin >> n;
    vector<int> l(n);
    REP(i, n) cin >> l[i];
    sort(ALL(l));
    ll ans = 0;
    REP(i, n - 2) FOR(j, i + 1, n - 1) FOR(k, j + 1, n) {
        if (l[k] < l[i] + l[j]) ans++;
    }
    cout << ans << EOL;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int m,d;
int main(){
	int i,j,k,ans=0;
	cin>>m>>d;
	for(i=4;i<=m;i++)
	{
		for(j=2;j<=9;j++)
		{
			for(k=2;k<=9;k++)
			{
				if(j*10+k<=d&&j*k==i)
				{
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

	sort(all(a));
	reverse(all(a));
	int alice = 0;
	int bob = 0;
	rep(i, n)
	{
		if(i % 2 == 0)
			alice += a[i];
		else
			bob += a[i];
	}

	fprintf(stderr, "Alice: %d\nBob: %d\n", alice, bob);
	cout << alice - bob << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var s string
  dream := [4]string{"maerd", "remaerd", "esare", "resare"}

  fmt.Scan(&s)

  tmp := ""
  for i := 0; i < len(s); i++ {
    tmp += s[len(s)-i-1:len(s)-i]

    for j := 0; j < 4; j++ {
      if dream[j] == tmp {
        tmp = ""
      }
    }
  }

  if tmp == "" {
    fmt.Println("YES")
  } else {
    fmt.Println("NO")
  }

}


Measured memory_bytes: 7680
#include<cstdio>
#include<iostream>

using namespace std;

int main(void) {
	int n, t[100], m, p[100], x[100], sum = 0;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> p[i] >> x[i];
		cout << sum - t[p[i]-1] + x[i] << "\n";
		
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

int rec(int n, int k)
{
    if(n==k)
        return 1;
    if(k==1)
        return n;
    return rec(n-1, k-1)+rec(n-1, k);
}

 
int main() {
	long long n, m, ans = 0;
	cin >> n >> m;
	if(n > 1) ans += rec(n, 2);
	if(m > 1) ans += rec(m, 2);
	cout << ans;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using MY=pair<int, int>;
 
int main(){
  int N; cin >> N;
  vector<MY> gardman(N);
  for (int i=0;i<N;i++){
    cin >> gardman.at(i).second >> gardman.at(i).first;
  }
  sort(gardman.begin(), gardman.end());
  long long t=0;
  for (int i=0;i<N;i++){
    t+=gardman.at(i).second;
    if (t>gardman.at(i).first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

// #define ANS  //for answer
#define CMP  //for compe
#ifdef CMP
using namespace std;
#else
#endif

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x, (x)
#define ncv(x) #x, ":", (x)
#define ncvc(x) #x, ":", (x), ","
#define GETIN2MACRO(_1, _2, NAME, ...) NAME
#define GETIN3MACRO(_1, _2, _3, NAME, ...) NAME
#define GETIN4MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define GETIN5MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME
#define GETIN6MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define GETIN7MACRO(_1, _2, _3, _4, _5, _6, _7, NAME, ...) NAME
#define INPUT1(n) \
  ll n;           \
  cin >> n
#define INPUT2(a, b) \
  ll a, b;           \
  cin >> a >> b
#define INPUT3(n, a, b) \
  ll n, a, b;           \
  cin >> n >> a >> b
#define INPUT4(n, m, a, b) \
  ll n, m, a, b;           \
  cin >> n >> m >> a >> b
#define INPUT(...)                                         \
  GETIN4MACRO(__VA_ARGS__, INPUT4, INPUT3, INPUT2, INPUT1) \
  (__VA_ARGS__)
#define INPUTARR(n, a) \
  ll n;                \
  cin >> n;            \
  ll a[n];             \
  REP(i, n) { cin >> a[i]; }
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>
void pPRINT(std::ostream& ost, const T t, const U... u) {
  ost << t << " ";
  pPRINT(ost, u...);
}
template <class... T>
void PRINT(const T... t) { pPRINT(std::cout, t...); }
template <class... T>
void PRINTl(const T... t) {
  pPRINT(std::cout, t...);
  std::cout << "\n";
}
template <class T>
void PRINTa(const T* const t, const ll size) {
  REP(i, size)
  PRINT(t[i]);
  PRINTl();
}
template <class T>
void PRINTal(const T* const t, const ll size) {
  REP(i, size)
  PRINTl(i, ":", t[i]);
}
#ifndef DBG
#define DEBUG(...)
void init() {}
#else
#define DEBUG(...)                                                     \
  {                                                                    \
    PRINT("##DEBUG##", "file :", __FILE__, ", line :", __LINE__, "["); \
    PRINT(__VA_ARGS__);                                                \
    PRINTl("]");                                                       \
  }
void init() {
  DEBUG("INIT");
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

// search max depth
ll dfs(vector<vector<ll>>& tree, ll parent, ll now, ll depth) {
  ll d = depth;
  for (auto i : tree[now]) {
    if (i == parent) continue;
    d = max(d, dfs(tree, now, i, depth + 1));
  }
  return d;
}

void solve();

int main(int argc, char* argv[]) {
  DEBUG("MAIN");
  init();
  solve();

  return 0;
}

void solve() {
  DEBUG("SOLVE START");

  //solve
  INPUT(x);
  while(1){
    ll i=2;
    ll prev=x;
    while(i*i<x){
      if(x%i==0){
        x++;
        break;
      }
      i++;
    }
    if(prev==x)break;
  }
  cout<<x;

  return;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<i64>();
    let _n = input[0];
    let k = input[1] as usize;
    let mut hs = read_vec::<i64>();
    hs.sort();
    let count: i64 = hs.iter().rev().skip(k).sum();
    println!("{}", count);

}

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

int main(){
    int N, M;
    cin >> N >> M;
    int sum , temp;
    sum = 0;
    temp = 0;
    vector<int> A(N, 0);

    for(int i = 0; i < N; i++){
        cin >> A.at(i);
        sum += A.at(i);
    }
    for(int i = 0; i < N; i++){
        if(A[i] * 4 * M >= sum){
            temp++;
        }
    }

    if(temp >= M){
         cout << "Yes" <<endl;
    }
    else{
        cout <<"No" <<endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
	// それぞれをbitで判定する
	three uint = 1
	five       = three << 1
	seven      = five << 1
	all        = seven | five | three
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

// 見様見真似実装
// https://drken1215.hatenablog.com/entry/2019/04/03/125400
// https://drken1215.hatenablog.com/entry/2020/05/04/190252

func main() {
	X := nextInt()
	var ans int
	dfs(0, 0, &ans, X)
	fmt.Println(ans)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func dfs(num int, used uint, ans *int, X int) {
	if num > X {
		return
	}
	if used == all {
		*ans++
	}
	// 実際に遷移を見るとわかりやすい
	// fmt.Println(num, used, *ans)
	// なんとなく3からのほうがしっくり来るのでそうしてるがどっちでもいい
	dfs(num*10+3, used|three, ans, X)
	dfs(num*10+5, used|five, ans, X)
	dfs(num*10+7, used|seven, ans, X)
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a + b == c + d) {
        cout << "Balanced" << endl;
        return 0;
    }
    cout << ((a + b < c + d) ? "Right" : "Left") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	string S; cin >> S;
	int ans = INF;
	for (int i = 0; i < S.size() - 2; ++i) {
		int tmp = stoi(S.substr(i, 3));
		ans = min(ans, abs(753 - tmp));
	}
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n;
	cin>>n;
	vi d(n);
	rep(i, n) cin>>d[i];
	vl s(n+1);
	s[0] = 0LL;
	map<ll, int> m;
	int ans = 0;
	m[0LL] = 0;
	rep(i, n) {
		s[i+1] = s[i] + d[i];
		if(m.count(s[i+1])) ans = max(ans, i + 1 - m[s[i+1]]);
		else m[s[i+1]] = i+1; 
	}
	cout<<ans<<endl;
}

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

const int MAX_N = 1e5+20;
int Q;
int l[MAX_N], r[MAX_N];
vector<int> primes;
vector<int> v;
bool is_prime[MAX_N];

void init()
{
	memset(is_prime,true,sizeof(is_prime));
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<MAX_N;++i){
		if(is_prime[i]){
			primes.push_back(i);
			for(ll j=1LL*i*i;j<MAX_N;j+=i) is_prime[j]=false;
		}
	}
	for(int p : primes){
		if(binary_search(primes.begin(),primes.end(), (p+1)/2)){
			v.push_back(p);
		}
	}
}

void solve()
{
	init();
	for(int i=0;i<Q;++i){
		cout<<upper_bound(v.begin(),v.end(),r[i])-lower_bound(v.begin(),v.end(),l[i])<<'\n';
	}
}

int main()
{
	cin >> Q;
	for(int i=0;i<Q;++i) cin >> l[i] >> r[i];
	solve();
	return 0;
}

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

int main(){
    ll n,l;
    cin>>n>>l;
    string s[n];
    rep(i,n){
        cin>>s[i];
    }
    sort(s,s+n);
    rep(i,n){
        cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e15;
using Graph = vector<vector<int>>;

signed main() {
  for( int i = 1; i <= 5; i++ ){
    int A;
    cin >> A;
    if( A == 0 ){
      cout << i << endl;
    }
  }

}


Measured memory_bytes: 3588
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n < 1200)
	{
		printf("ABC");
	}
	else if(n < 2800)
	{
		printf("ARC");
	}
	else
	{
		printf("AGC");
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import combinations
n = int(input())
x = n if n % 2 else n+1
ans = []
for v, v2 in combinations(range(1, n+1), 2):
    if v+v2 == x:
        continue
    ans.append((v, v2))
print(len(ans))
for edge in ans:
    print(*edge)


Measured memory_bytes: 3996
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define AU(i,x)    for(auto i=x.begin(); i!=x.end(); ++i)
# define ALL(A) A.begin(),A.end()
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;
const int N=2005;
///Code begin..................................................................
inline LL Scan() {
    LL x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

char s[18];

int main()
{
    scanf("%s",s);
    s[3]='8';
    puts(s);
    return 0;
}


Measured memory_bytes: 256
# include <iostream>

using namespace std;



int main(){
  int N, M;
  int a, b, c, count;
  int d[100][100], dc[100][100];

  cin >> N >> M;
  
  // initialize graph
  for(int n1 = 0; n1 < N; n1++) {
    for(int n2 = 0; n2 < N; n2++) {
      d[n1][n2] = 1001;
      dc[n1][n2] = 0;
    }
  }

  // load the graph
  for(int m = 0; m < M; m++) {
    cin >> a >> b >> c;
    d[a-1][b-1] = c;
    d[b-1][a-1] = c;
    dc[a-1][b-1] = c;
    dc[b-1][a-1] = c;
  }
  
  for(int k = 0; k < N; k++) {
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) {
	d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  count = 0;
  for (int n1 = 0; n1 < N; n1++) {
    for (int n2 = n1+1; n2 < N; n2++) {
      if (d[n1][n2] - dc[n1][n2] < 0) {
	count ++;
      }
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  int Q;
  lint B=0,mini=0,size=0;
  pair<lint,lint> range;
  range.first=-INF,range.second=INF;
  multiset<lint> point;
  auto itr=point.begin();
  cin >> Q;
  rep(i,Q){
    lint q;
    cin >> q;
    if(q==1){
      lint x,y;
      cin >> x >> y;
      if(x<range.first || range.second<x) mini+=min(llabs(x-range.first),llabs(range.second-x));
      point.insert(x);
      size++;
      if(size==1) itr=point.begin();
      B+=y;
      if(x>=*itr && size%2!=0 && size!=1) itr++;
      if(x<*itr && size%2==0 && size!=0) itr--;
      if(size%2==0){
        range.first=*itr;
        itr++;
        range.second=*itr;
        itr--;
      }
      else{
        range.first=*itr;
        range.second=*itr;
      }
    }
    else{
      cout << range.first << " ";
      cout << mini+B << endl;
    }
  }
}

Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;

string str;

ll merge(int l, int r)
{
	ll sum=0;
	for (int i = l; i <= r; i++)
	{
		int t = str[i] - '0';
		sum = sum * 10;
		sum += t;
	}
	return sum;
}

int main()
{
	cin >> str;
	int n = str.size();
	str.insert(str.begin(), '=');
	ll res = 0;
	for (int i = 0; i < 1 << (n-1); i++)
	{
		int l = 1;
		for(int j = 0; j <= (n-2); j++)
		{
			if (i & 1 << j)
			{
				res += merge(l, j + 1);
				l = j + 2;
			}
		}
		res += merge(l, n);
	}
	cout << res << endl;
}




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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

//2値の最小公倍数
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

int main(){
    char a; cin >> a;
    if(a<'a') cout << "A" << endl;
    else cout << "a" << endl;
}

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

int main() {
	int n, mx = -1000000000, mn = 1000000000;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		mx = max(mx, a[i]);
		mn = min(mn, a[i]);
	}
	cout << abs(mx - mn) << endl;
	return 0;
}

Measured memory_bytes: 256
#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());
	 reverse(t.begin(), t.end());
	 if(s<t) cout << "Yes" << endl;
	 else cout << "No" << endl;


} 



Measured memory_bytes: 256