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


int main(){
	string S,T,U;
	int A,B;
	cin >> S >> T >> A >> B >> U;
	if(S == U){
		cout << A-1 << " " << B << endl;
	}
	else{
		cout << A << " " << B-1 << endl;
	}

	return 0;
}


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

const int maxn =110;
const int INF = 1<<30;

int ans[maxn],tmp[maxn];

int main()
{
	//freopen("C.in","r",stdin);
	int n;
	scanf("%d",&n);
	for (int i=0;i<100;i++) ans[i] = INF;
	for (int i=1;i<=n;i++)
	{
		char str[100];
		scanf("%s",str);
		memset(tmp,0,sizeof(tmp));
		for (int j=0;j<(int)strlen(str);j++) tmp[str[j]-'a']++;
		for (int j=0;j<100;j++) ans[j] = min(ans[j], tmp[j]);
	}
	for (int i=0;i<='z'-'a';i++)
	{
		if (ans[i] == 0) continue;
		for (int j=1;j<=ans[i];j++) printf("%c",(char)(i+'a'));
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
point_dict1 = {}
point_dict2 = {}
for i in range(n):
    x, y = map(int, input().split())
    point_dict1[x + y] = (x, y)
    point_dict2[y - x] = (x, y)
min_point1 = min(point_dict1)
max_point1 = max(point_dict1)
min_point2 = min(point_dict2)
max_point2 = max(point_dict2)
print(max(max_point1 - min_point1, max_point2 - min_point2))

Measured memory_bytes: 141116
// C - Dice and Coin
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,K; cin>>N>>K;
	double ans = 0;
	for(int n=N; n; --n){
		double part_ans = 1./N;
		for(int k=n; k<K; k*=2) part_ans /= 2;
		ans += part_ans;
	}
	printf("%.12f\n",ans);
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
 
set_a = set(a)
cnt = [0] * (max(a)+1)
ans = 0
 
for i in a:
    cnt[i] += 1
 
if len(cnt) == 1:
    print(cnt[0])
elif len(cnt) == 2:
    print(sum(cnt))
else:
    for i in range(1, max(a)):
        ans = max(ans, cnt[i-1]+cnt[i]+cnt[i+1])
    print(ans)

Measured memory_bytes: 13964
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
from itertools import accumulate
import sys
import bisect

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

N = ii()

S = set()
for i in range(N):
    s = si()
    S.add(s)

print(len(S))



Measured memory_bytes: 31468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> s(5);
    vector<char> c(5);
    rep(i, m){
        cin >> s.at(i) >> c.at(i);
    }

    int ans = -1;

    rep(i, 1000){
        string tmp = to_string(i);
        bool flag = true;
        if(tmp.size() != n){
            continue;
        } 
        rep(i, m){
            if(tmp.at(s.at(i) - 1) != c.at(i)) flag = false;
        }
        if(flag){
            ans = stoi(tmp);
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
        String ans = "NG";
        for (int i = a; i <= b; i++) {
            if (i % k == 0) {
                ans = "OK";
                break;
            }
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 35792
#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<sstream>

using namespace std;

#define open  freopen("input.txt","r",stdin)
#define close  freopen ("output.txt","w",stdout)
#define db double
#define ll long long
#define lll unsigned long long
#define loop(i,a,n) for(int i=a;i<=n;i++)
#define sf scanf
#define sf1(a) sf("%d",&a)
#define sf2(a,b) sf("%d %d",&a,&b)
#define sf3(a,b,c) sf("%d %d %d",&a,&b,&c)
#define sf4(a,b,c,d) sf("%d %d %d %d",&a,&b,&c,&d)
#define sfd(a) sf("%lf",&a)
#define sfd2(a,b) sf("%lf %lf",&a,&b)
#define sfl1(a) sf("%lld",&a)
#define sfl2(a,b) sf("%lld %lld",&a,&b)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pf printf
#define pfi(x) pf("%d",x)
#define pfl(x) pf("%lld",x)
#define NL puts("")
#define bug pf("here is bug\n")
#define pft(tc) printf("Case %d:",tc++)
#define PI (2.0*acos(0.0))
//#define PI acos(-1.0)
#define mem(a,v) memset(a,v,sizeof a)
#define endl '\n'
#define pb push_back
#define xx first
#define yy second
#define mp make_pair
#define all(a) a.begin(),a.end()


template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a,T b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
template <class T> inline T lcm(T a,T b)
{
    return (a/gcd(a,b))*b;
}
template <class T> inline T modinverse(T a,T M)
{
    return bigmod(a,M-2,M);
}   // M is prime}
template <class T> inline T bpow(T p,T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}




//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={0,1,0,-1};int dy[]={1,0,-1,0}; //4 Direction

#define linf 3000000000000000000ll
#define inf 999999999
#define MX 1000000
#define mod (ll) 1000000007
#define eps 1e-6
#define ub upper_bound // return the right most index of x<val
#define lb lower_bound // return the right most index of x<=val



struct data
{
    int el1,el2,el3;
    data() {}
    data(int a,int b,int c)
    {
        el1=a,el2=b,el3=c;
    }
    bool friend operator<(data a,data b)
    {
        return  a.el1> b.el1;// sort decreasingly but increasingly for priority_queue
    }
};


int n,m,k;
ll N,M,K;

int a[100005];
int main()
{
    int t,tc=1;
    sf1(n);
    for(int i=1;i<=n;i++){
		sf1(a[i]);
	}
	sort(a+1,a+n+1);
	int res=99999999;
	for(int i=1;i<=10000;i++){
		res=min(res,abs(i-a[1])+abs(a[1]-a[n]));
		res=min(res,abs(i-a[n])+abs(a[1]-a[n]));
	}
	pfi(res);
    
	return 0;
}

/*



*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,r,c=0;
cin>>a>>b;
r=b;
while(r!=0){
    r/=10;
    c++;
}
while(c!=0){
    a*=10;
    c--;
}
int sum=a+b;
for(int i=1;i<=316;i++){
    if(i*i==sum){
        cout<<"Yes";
        return 0;
    }
}
cout<<"No";
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++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(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

vector<int> Eratosthenes( const int N )
{
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
    ll N;
    cin >> N;
    // vector<int> primes = Eratosthenes(N);
    ll ans = 0;
    // FOR(i, 1, N) {
    //     vector<ll> divs = divisor(i);
    //     ans += i * divs.size();
    // }

    for(ll x = 1; x <= N; x++) {
        ans += x * (N / x) * (N / x + 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    
    ll n,k = 0;
    cin >> n >> k;

    ll div = 0;
    int r = 0;

    for(int i = 1; ;i++ ){
        div = pow(k,i);
        if(n / div == 0){
            r = i ;
            break;
        }
    }

    cout << r << endl;
    
    return 0;
}

Measured memory_bytes: 384
a,b,c,x,y=map(int, input().split())
c*=2
ans=10**9
for cc in range(max(x,y)+1):
    tmp = cc * c
    tmp += max(0, x-cc)*a
    tmp += max(0, y-cc)*b
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int t;
  cin >> t;
  while(t--){
    vector<int> gate(9), jack(9);
    rep(i,9)cin >> gate[i];
    rep(i,9)cin >> jack[i];

    sort(jack.begin(),jack.end());
    int win = 0, lose = 0, cnt = 0;
    do{
      cnt++;
      int G = 0, J = 0;
      rep(i,9){
	if(gate[i] > jack[i])G += gate[i] + jack[i];
	else J += gate[i] + jack[i];
      }
      if(G > J)win++;
      if(G < J)lose++;
    }while(next_permutation(jack.begin(),jack.end()));

    cout << fixed << setprecision(5) << (double)win/cnt << " " << (double)lose/cnt << endl;
  }
}

Measured memory_bytes: 1280
#include<stdio.h>

static const int MAX = 500;

static const int INFTY = (1<<21);

int main(){
  int n,i,j;

  int M[MAX][MAX];
  int  k,c,u,v;
  int minv;
  int d[MAX];
  int vis[MAX];

  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;


    }
  }

  for ( i = 0; i < n; i++ ) {
    d[i] = INFTY;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for ( i = 0; i < n; i++ ){
      if ( minv > d[i] && !vis[i] ){
	u = i;
	minv = d[i];
      }
    }
    if ( u == -1 ) break;
    vis[u] = 1;

    for ( v = 0; v < n; v++ ){
      if ( !vis[v] && M[u][v] != INFTY ){
	if ( d[v] > d[u] + M[u][v] ){
	  d[v] = d[u] + M[u][v];
	}
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
    if((d[i]==INFTY)==1){
        d[i]=-1;
    }
    else {
        d[i]=d[i];
    }
  }

  return 0;
}


Measured memory_bytes: 2088
#include <stdio.h>
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define ll long long
ll city[100000];
int main(void){
    ll n,a,b;
    ll ans=0;
    scanf("%lld %lld %lld",&n,&a,&b);
    for(int i=0;i<n;i++)
        scanf("%lld",&city[i]);
    for(int i=0;i<n-1;i++){
        ll k=(city[i+1]-city[i])*a;
        if(k<b) ans += k;
        else ans += b;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] S = scanner.next().toCharArray();
    if (S[2] == S[3] && S[4] == S[5]) System.out.println("Yes");
    else {
      System.out.println("No");
    }
  }
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n;
int a[N];

bool check (int n) {
	bool a = false, b = false, c = false;
	while (n > 0) {
		if (n % 10 == 3) a = true;
		else if (n % 10 == 5) b = true;
		else c = true;
		n /= 10;
	}
	return (a && b && c);
}

int main() {

	FAST;

	cin >> n;
	queue <int> q;
	int ans = 0;
	q.push(33);
	q.push(35);
	q.push(37);
	q.push(53);
	q.push(55);
	q.push(57);
	q.push(73);
	q.push(75);
	q.push(77);
	while (!q.empty()) {
		int x = q.front();
		q.pop();
		intt a = 1LL * x * 10 + 3;
		intt b = 1LL * x * 10 + 5;
		intt c = 1LL * x * 10 + 7;
		if (a <= 1LL * n) {
			q.push(a);
			if (check(a)) ans ++;
		}
		if (b <= 1LL * n) {
			q.push(b);
			if (check(b)) ans ++;
		}
		if (c <= 1LL * n) {
			q.push(c);
			if (check(c)) ans ++;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_ABC153
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            WriteLine((s[0]-1)/s[1] + 1);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N-1);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    for(int i = 0; i < N; i++){
        cin >> B.at(i);
    }
    for(int i = 0; i < N-1; i++){
        cin >> C.at(i);
    }
    int ans = 0;
    for (int i = 0; i < N; i++){

        ans += B.at(A.at(i)-1);
        if (i >0 && A.at(i-1) == A.at(i) - 1){
            ans += C.at(A.at(i-1) - 1);
        } 
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long int ll;
int n,k;
int a[100005];
int b[100005];
vector<int> G[100005];
bool visited[100005];
ll ans=1;
ll mod=1e9+7;
void dfs(int v,int f,int s){
	visited[v]=true;
	ans*=(k-f-s);
	ans%=mod;
	for(auto p:G[v]){
		if(visited[p])continue;
		dfs(p,1,f);
		f++;
	}
}
int main(){
	cin >> n >>k;
	for(int i=0;i<n-1;i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	dfs(0,0,0);
	cout << ans%mod << endl;
}

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

using namespace std;


int main(){
	int n,k;
	cin >> n >> k;
	vector<double> v(n);
	for(int i = 0 ; i < n ; i++){
		cin >> v[i];
		v[i]++;
		v[i] /= 2;
	}
	vector<double> pref(n);
	pref[0] = v[0];
	for(int i = 1 ; i < n ; i++){
		pref[i] = pref[i-1] + v[i];
	}
	double ans = pref[k-1];
	for(int i = k   ; i < n ; i++){
		ans = max(ans,pref[i] - pref[i-k]);
	}
	cout << fixed;
	cout << setprecision(10);
	cout << ans << endl;
	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SKY ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int

void solve()
{
    int n,m,k;
    cin >> n >> m >> k;
    vector<pair<int,int>> v;
    map<int,int> mp1,mp2;
    set<int> st;
    for(int i = 0 ; i < k ; i++)
        st.insert(i);
    for(int i = 0 ; i < k ; i++)
    {
        int a,b;
        cin >> a >>b;
        //a--;
        //b--;
        v.pb({a,b});
        
        mp1[a]++;
        //mp1[b]++;
    }
    int x=0 ;
    int temp =0;
    for(auto it: mp1)
    {
        if(it.S>temp)
        {
            temp = it.S;
            x = it.F;
        }
    }
    //cout << x << "\n";
    int ans= 0;
    for(int it = 0 ; it< k ; it++)
    {
        //cout << it << " set\n";
        if(x==v[it].F)
        {
            //cout << v[it].F << " " << v[it].S << " hehe\n";
            ans++;
            mp2[it] = 1;
        }
    }
    for(auto it: mp2)
    {
        st.erase(it.F);
    }
    temp = 0 ;
    x= 0 ;
    mp1.clear();
    for(auto it: st)
    {
        mp1[v[it].S]++;
    }
    for(auto it: mp1)
    {
        if(it.S>temp)
        {
            temp = it.S;
            x= it.F;
        }
    }
    for(auto it: st)
    {
        if(v[it].S == x)
        {
            ans++;
        }
    }
    //cout << ans << "\n";
    st.clear();
    for(int i = 0 ; i < k ; i++)
        st.insert(i);
    mp1.clear();
    for(auto it: v)
    {
        mp1[it.S]++;
    }
    x=0 ;
    temp =0;
    int ans2=0;
    //mp1.clear();
    for(auto it: mp1)
    {
        if(it.S>temp)
        {
            temp = it.S;
            x = it.F;
        }
    }
    //cout << x << "\n";
    
    for(int it = 0 ; it< k ; it++)
    {
        //cout << it << " set\n";
        if(x==v[it].S)
        {
            //cout << v[it].F << " " << v[it].S << " hehe\n";
            ans2++;
            mp2[it] = 1;
        }
    }
    for(auto it: mp2)
    {
        st.erase(it.F);
    }
    temp = 0 ;
    x= 0 ;
    mp1.clear();
    for(auto it: st)
    {
        mp1[v[it].F]++;
    }
    for(auto it: mp1)
    {
        if(it.S>temp)
        {
            temp = it.S;
            x= it.F;
        }
    }
    for(auto it: st)
    {
        if(v[it].F == x)
        {
            ans2++;
        }
    }
    cout << max(ans2,ans) << "\n";
    
    
}
int32_t main()
{
    SKY;
    int T = 1;
    //cin >> T;
    for(int i = 1 ; i <= T ; i++)
    {
        solve();
    }
    return 0;
}
/*
 Umang Agrawal
 @skylag
 */


Measured memory_bytes: 59372
#  mod Nの取りうる値の上限はN-1なのでN-1回のループで解が出なければ-1でいい
#  modの値が同じになった場合ループになるためexitする

K = int(input())

mod = 7 % K

res = {}

i = 1

while not mod in res:
    if mod == 0:
        print(i)
        exit()

    res[mod] = 1
    mod = (mod * 10 + 7) % K
    i += 1

print(-1)

Measured memory_bytes: 92628
#include<bits/stdc++.h>
using namespace std;
#define TRACE
#define M 1000000007
#define oo 1000000000000000007
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define pb push_back
#define M6 5000009
#define M5 100009
#define pi 3.14159265
#define epsilon 1e-6

#ifdef TRACE
    #define trace1(x)                cerr << #x << ": " << x << endl;
    #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
    #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
    #define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
    #define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
    #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
#else
 
    #define trace1(x)
    #define trace2(x, y)
    #define trace3(x, y, z)
    #define trace4(a, b, c, d)
    #define trace5(a, b, c, d, e)
    #define trace6(a, b, c, d, e, f)
 
#endif

ll n,m,A[M6],F[M6];
int  main()
{   //ios_base::sync_with_stdio (0), cin.tie (0);
    //sieve();
    //init();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll tc=1,t=0,i,j,k,a,b,c,d,l,r;
    //cin>>tc;
    while(t++<tc){
//        cout<<"Case #"<<t<<": ";
        cin>>n;
        ll ans=0,cur=0;
        for(i=1;i<=n;i++) {
            cin>>A[i];
            if(A[i]<=A[i-1]) cur++;
            else {ans=max(ans,cur); cur=1;}
            //cout<<cur<<" ";
        }
        ans=max(ans,cur);
        cout<<ans-1;
    }
    return 0;
}

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

void print(string cards[40],int size){
  cout<<cards[0];
  for(int i=1;i<size;i++){
    cout<<" "<<cards[i];
  }
  cout<<endl;
}

bool check(string collect[40],string cards[40],int size){
  for(int i=0;i<size;i++){
    if(collect[i]!=cards[i]) return false;
  }
  return true;
}

int main(){
  int n;
  cin>>n;
  string cards1[40];
  string cards2[40];
  string cards3[40];

  for(int i=0;i<n;i++){
    cin>>cards1[i];
    cards3[i]=cards2[i]=cards1[i];
  }

  //bubble
  for(int i=0;i<n;i++){
    for(int j=n-1;j>=i;j--){
      if(cards2[j][1] < cards2[j-1][1]){
	swap(cards2[j],cards2[j-1]);
      }
    }
  }

  print(cards2,n);
  cout<<"Stable"<<endl;

  //selection
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(cards3[j][1] < cards3[minj][1]){
	minj=j;
      }
    }
    swap(cards3[i],cards3[minj]);
  }

  print(cards3,n);
  if(check(cards2,cards3,n))
    cout<<"Stable"<<endl;
  else 
    cout<<"Not stable"<<endl;
  //check

  return 0;
}

Measured memory_bytes: 1216
local n=io.read("n")
for i=1,3500 do
    for j=1,3500 do
        local a=n*i*j
        local b=(4*i*j-n*j-n*i)
        if b>0 and a%b==0 then
            local k=math.floor(a/b)
            print(i.." "..j.." "..k)
            return
        end
    end
end

Measured memory_bytes: 2716
#include<iostream>
#include<map>
using namespace std;
int main(){
  map<string,int> mp;
  int n;cin >> n;
  for(int i=0;i<n;i++){
  	string s;
    cin >> s;
    mp[s]++;
  }
  int m;cin >> m;
  for(int i=0;i<m;i++){
  	string s;
    cin >> s;
    mp[s]--;
  }
  int ans = 0;
  for(pair<string,int> p : mp) ans = max(ans,p.second);
  cout << ans << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
using namespace std;

int main(){
	int n,x[4]={};
	char b[3];
	while(scanf("%d,%s",&n,b)!=EOF){
		//if(n==0) break;
		if(b[0]=='A'&&b[1]=='B') x[2]++;
		else if(b[0]=='A') x[0]++;
		else if(b[0]=='B') x[1]++;
		else if(b[0]=='O') x[3]++;
	}
	rep(i,0,4){
		cout<<x[i]<<endl;
	}
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl a(n);
    map<ll, ll> mp;
    rep(i, n) {
        ll a;
        cin >> a;
        mp[a]++;
    }

    vl v;
    for(auto p : mp) {
        if(p.second >= 4) {
            rep(i, 2) {
                v.pb(p.first);
            }
        }
        else if(p.second >= 2) {
            v.pb(p.first);
        }
    }

    if(v.size() == 0) {
        out(0);
        re0;
    }
    
    sort(rall(v));

    out(v[0]*v[1]);
    re0;
}

Measured memory_bytes: 7296
n=int(input())
h=list(map(int,input().split()))
dp=[1010101010]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13924
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll r,g,b;
  cin >> r >> g>> b;
  r = r*100 + g*10 + b;
  if(r%4==0) cout <<"YES\n";
  else cout <<"NO\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
int main(void){
    string s,t; cin >> s >> t;
    int ans = 100000;
    for(int i=0;i<s.size()-t.size()+1;i++){
        int tmp=0;
        for(int j=0;j<t.size();j++){
            if(s[i+j]==t[j]) continue;
            tmp++;
        }
        ans = min(ans,tmp);
    }
    cout << ans << endl;
	return 0;
}



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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    int best = -1;
    int better = -1;

    for (int i = 0; i < n; ++i){
        cin >> a[i];
        if(a[i] > best) {
            better = best;
            best = a[i];
        }
        else if(a[i] > better) better = a[i];
    }

    for (int i = 0; i < n; ++i){
        if(a[i] == best) cout << better << endl;
        else cout << best << endl;
    }
}

Measured memory_bytes: 2432
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;
const int inf = 1e17+21;


int32_t main(){
    FAST;

   int n,m; cin >> n >> m;
   int roads[n+1] = {0};
   for(int x=0;x<m;x++){
       int u,v; cin >> u >> v;
        roads[u]++ , roads[v]++;
   }

   for(int x=1;x<=n;x++)
    cout << roads[x] << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
const double EPS=1e-10;

struct Vec{double x,y;};
struct Cer{double r;Vec cp;}W[100];


double D(Vec a){return hypot(a.x,a.y);}
double dot(Vec a,Vec b){return a.x*b.x+a.y*b.y;}
double det(Vec a,Vec b){return a.x*b.y-a.y*b.x;}

Vec F(Vec a,Vec b){Vec p={a.x-b.x,a.y-b.y};return p;}

double ch(Vec a,Vec b,Vec c)
{
	if(dot(F(b,a),F(c,a))<EPS)return D(F(c,a));
	if(dot(F(a,b),F(c,b))<EPS)return D(F(c,b));
	return fabs(det(F(b,a),F(c,a)))/D(F(b,a));
}

int N,M,i,j,f;
double m,d;

int main()
{
	for(;scanf("%d",&N),N;)
	{
		for(i=0;i<N;i++)
			scanf("%lf%lf%lf",&W[i].cp.x,&W[i].cp.y,&W[i].r);
		scanf("%d",&M);
		for(i=0;i<M;i++)
		{
			f=0;
			Vec t,s;
			scanf("%lf%lf%lf%lf",&t.x,&t.y,&s.x,&s.y);
			for(j=0;j<N;j++)
			{
				if(D(F(s,W[j].cp))<=W[j].r&&D(F(t,W[j].cp))<=W[j].r)continue;
				if(ch(t,s,W[j].cp)<=W[j].r)break;
			}
			puts(j==N?"Danger":"Safe");
		}
	}
	return 0;
}

Measured memory_bytes: 1060
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;
	cin >> n;
	vector<ll> dp(n+1);
	dp[0] = 2;
	dp[1] = 1;
	for(int i = 2; i <= n; i++) {
		dp[i] = dp[i- 1]+dp[i-2];
	}
	cout << dp[n] << endl;
	return 0;
}

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

int main(){
    int N,K;cin>>N>>K;
    vector<int> V(N);
    for (int i=0;i<K;i++){
        int d;cin>>d;
        for(int j=0;j<d;j++){
            int c;cin>>c;
            V[c-1]+=1;

        }
    }

  int ans=0;
    for(int i=0;i<N;i++){
        if(V[i]>0)ans+=1;
    }
    cout<<N-ans<<endl;
}

Measured memory_bytes: 3624
fun op(m: MutableMap<Long, Pair<Long, Long>>, sum: Long, b: Long, c: Long): Long {
  if (m[b] == null) return sum
  val (b_ct, b_sum) = m[b]!!
  if (m[c] == null) m[c] = (0L to 0L)
  val (c_ct, c_sum) = m[c]!!
  m[c] = (b_ct + c_ct to c_sum.toLong() + (b_ct.toLong() * c.toLong()))
  m.remove(b)
  return sum - b_sum + (b_ct * c)
}

fun main()
{
  readLine()!!.toLong()
  val initialAs = readLine()!!.split(' ').map{it.toLong()}
  val m = mutableMapOf<Long, Pair<Long, Long>>()
  for (a in initialAs) {
    if (m[a] == null) {
      m[a] = 0L to 0L
    }
    val (ct, sum) = m[a]!!
    m[a] = (ct+1 to sum+a)
  }
  var sum: Long = m.values.map{(_, sum) -> sum}.sum()

  val q = readLine()!!.toLong()
  for (x in 1..q) {
    val (b, c) = readLine()!!.split(' ').map{it.toLong()}
    sum = op(m, sum, b, c)
    //println("m: $m")
    println(sum)
  }
}


Measured memory_bytes: 81992
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define y0 y12345
#define y1 y54321
typedef unsigned long ul;
typedef long long ll;
//typedef pair<int, int> mpair;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
using namespace std;
/*
int n,m;
int h[10000];
ul t[10000];

ul dp(int p){
	if(t[p]!=-1)return t[p];
	ul res = 0;
	if(p==n-1){res=0;}
	else if(p==n-2){res = abs(h[n-1]-h[n-2]);}
	else {res=min(dp(p+1)+abs(h[p]-h[p+1]), dp(p+2)+abs(h[p]-h[p+2]));}
	return t[p]=res;
}*/

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	int n;
	cin>>n;
	int h[n];
	rep(i, n){
		cin>>h[i];
		//t[i] = -1;
	}
	vector<int> tab(n-1);
	//tab[n-1] = 0;
	tab[n-2] = abs(h[n-1]-h[n-2]);
	for(int i = n-3;i>=0;i--){
		tab[i] = min(tab[i+1]+abs(h[i]-h[i+1]), tab[i+2]+abs(h[i]-h[i+2]));
	}
	//rep(i, n)cerr<<tab[i]<<endl;
	cout << tab[0] << endl;

	return 0;
}


Measured memory_bytes: 1024
import sys
H,W,h,w=map(int,input().split())
if H%h==0 and W%w==0:
  print("No")
elif H%h!=0:
  print("Yes")
  p=100000*(h-1)-1
  q=-100000
  L=int(H/h)
  for l in range(L):
    for i in range(W):
      print(p, end = ' ')
    print("")
    for i in range(h-1):
      for i in range(W):
        print(q, end = ' ')
      print("")
  for i in range(W):
    print(p, end = ' ')
  print("")
  for i in range(H-L*h-1):
    for i in range(W):
      print(q, end = ' ')
else:
  print("Yes")
  p=100000*(w-1)-1
  q=-100000
  L=int(W/w)
  s=([p]+[q]*(w-1))*L+[p]+[q]*(W-L*w-1)
  for j in range(H):
    for i in range(W):
      print(s[i], end= " ")
    print("")

Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  int N, K;
  cin >> N >> K;
  vector<ll>pl;
  vector<ll>mn;
  int ze = 0;
  for (int i = 0; i < N; i ++) {
    ll a;
    cin >> a;
    if (a == 0) ze ++;
    if (a > 0) pl.push_back(a);
    if (a < 0) mn.push_back(-a);
  }
  if ((N - ze) < K) {
    cout << 0 << endl;
    return 0;
  }
  int f_pl, f_mn, s_pl, s_mn;
  s_pl = (int)pl.size();
  s_mn = (int)mn.size();
  sort(pl.begin(), pl.end());
  reverse(pl.begin(), pl.end());
  sort(mn.begin(), mn.end());
  reverse(mn.begin(), mn.end());
  f_mn = min(((K / 2) * 2) - 1, ((s_mn / 2) * 2) - 1);
  f_pl = K - f_mn - 2;
  //cout << f_pl << ' ' << f_mn << endl;
  ll ans = 1;
  ll m = 1e9 + 7;
  if (f_pl >= s_pl) {
    if (ze > 0) {
      cout << 0 << endl;
      return 0;
    }
    else {
      f_mn ++;
      f_pl --;
      for (int i = 0; i <= f_pl; i ++) {
        ans *= pl[i];
        ans %= m;
      }
      for (int i = 0; i <= f_mn; i ++) {
        ans *= mn[s_mn - i - 1];
        ans %= m;
      }
      ans = m - ans;
      ans %= m;
      cout << ans << endl;
      return 0;
    }
  }
  //cout << f_pl << ' ' << f_mn << endl;
  //cout << ans << endl;
  while (f_pl + 2 < s_pl && f_mn - 1 >= 0 && 
         ((pl[f_pl + 1] * pl[f_pl + 2]) > (mn[f_mn] * mn[f_mn - 1]))) {
    f_pl += 2;
    f_mn -= 2;
  }
  //cout << endl;
  for (int i = 0; i <= f_pl; i ++) {
    ans *= pl[i];
    ans %= m;
    //cout << pl[i] << endl;
  }
  //cout << f_pl << endl;
  for (int i = 0; i <= f_mn; i ++) {
    ans *= mn[i];
    ans %= m;
    //cout << ans << endl;
  }
  cout << ans << endl;
}



Measured memory_bytes: 5476
def count(xs, ys):
    """Returns a count of elements in xs which is also in ys.

    >>> count([1, 2, 3], [1, 3])
    2
    >>> count([1, 2, 3, 4, 5], [3, 4, 1])
    3
    """
    xset = set(xs)
    yset = set(ys)
    return len(xset & yset)


def run():
    _ = input()  # flake8: noqa
    s = [int(i) for i in input().split()]
    _ = input()  # flake8: noqa
    t = [int(j) for j in input().split()]

    print(count(s, t))


if __name__ == '__main__':
    run()



Measured memory_bytes: 6312
package main

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

const mod int64 = 1000000007

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,1000000)}
  n,m := input.NextInts()
  s := input.NextIntArray()
  t := input.NextIntArray()
  dp := make([][]int64,n+1)
  for i:=0;i<n+1;i++ { dp[i] = make([]int64,m+1) }
  for i:=1;i<n+1;i++ {
    for j:=1;j<m+1;j++ {
      if s[i-1] == t[j-1] {
        dp[i][j] = (1+dp[i][j-1]+dp[i-1][j])%mod
      } else {
        dp[i][j] = ((dp[i][j-1]+dp[i-1][j])%mod+(mod-dp[i-1][j-1])%mod)%mod
      }
    }
  }
  fmt.Println(dp[n][m]+1)
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts() (int,int) {
  s := strings.Split(i.NextLine()," ")
  n,_ := strconv.Atoi(s[0])
  m,_ := strconv.Atoi(s[1])
  return n,m
}
func(i *Input) NextIntArray() []int {
  s := strings.Split(i.NextLine()," ")
  a := make([]int,len(s))
  for i:=0;i<len(s);i++ { a[i],_ = strconv.Atoi(s[i]) }
  return a
}

Measured memory_bytes: 33920
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int n;
    cin>>n;
    vector<vector<int>> a(n, vector<int>(3));
    for(int i = 0; i<n; i++)
    {
        for(int j = 0; j<3; j++)
            cin>>a[i][j];    
    }
        
        
    vector<vector<int>> dp(n, vector<int>(3, -1));
    dp  = a;
    
    for(int i = 1; i<n; i++)
    {
        for(int j = 0; j<3; j++)
        {
            int mx = INT_MIN;
            for(int k = 0; k<3; k++)
            {
                if(k != j)
                    mx = max(mx, dp[i-1][k]);
            }
            dp[i][j] = a[i][j] + mx;
        }
    }
    // for(auto i : dp)
    // {
    //     for(auto j : i)
    //         cout<<j<<" ";
    //     cout<<"\n";
    // }
    
    
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<"\n";
	return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

vector<vector<char>> f(vector<vector<char>> const &a, int h, int w) {
  vector<vector<char>> b;
  rep(i,0,w-1) {
    vector<char> col;
    rep(j,0,h-1) {
      col.push_back(a.at(j).at(i));
    }
    b.push_back(col);
  }
  return b;
}

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> h;
  rep(i,0,H-1) {
    char a;
    vector<char> row;
    rep(j,0,W-1) {
      cin >> a;
      row.push_back(a);
    }
    h.push_back(row);
  }

  rep(i,0,H-1) {
    bool skip_h = true;
    rep(j,0,W-1) {
      if (h[i][j] == '#') skip_h = false;
    }
    if (skip_h) {
      h.erase(h.begin()+i);
      i--;
      H--;
    }
  }

  h = f(h, H, W);

  rep(i,0,W-1) {
    bool skip_v = true;
    rep(j,0,H-1) {
      if (h[i][j] == '#') skip_v = false;
    }
    if (skip_v) {
      h.erase(h.begin()+i);
      i--;
      W--;
    }
  }

  h = f(h, W, H);

  cout << endl;
  for (auto p : h) {
    for (char i : p) cout << i;
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1e9+7;
using mint = Fp<MOD>;

// ある点iまでの右左のA,B,C,?の個数

signed main() {
	string S;
	cin >> S;
	int N = (int)S.size();
	// i番目まで見て, 0: 左が決まっていない, 1: Aが決まった, 2: Bが決まった, 3: Cが決まった
	vector<vector<mint>> dp(N+1, vector<mint>(4, 0));

	// 初期化
	dp[0][0] = 1;
	for(int i=1;i<=N;i++) {
		if(S[i-1] == '?') {
			for(int j=0;j<=3;j++) {
				dp[i][j] += (mint(3) * dp[i-1][j]);
			}
		} else {
			for(int j=0;j<=3;j++) {
				dp[i][j] += dp[i-1][j];
			}
		}
		if(S[i-1] == 'A' || S[i-1] == '?') dp[i][1] += dp[i-1][0];
		if(S[i-1] == 'B' || S[i-1] == '?') dp[i][2] += dp[i-1][1];
		if(S[i-1] == 'C' || S[i-1] == '?') dp[i][3] += dp[i-1][2];
	}
	cout << dp[N][3] << endl;
}

Measured memory_bytes: 7424
#include<stdio.h>
#include<string.h>

#define M 1000007/* your task*/
#define NIL (-1)
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return -1;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return key%L; }

int find(char str[]){
  int key = (int)(getKey(str)&0x7fffffff);
  return (H[h1(key)][h2(key)]=='\0'?0:1);
}

int insert(char str[]){
  int key = (int)(getKey(str)&0x7fffffff);
  H[h1(key)][h2(key)] = 't';
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14260
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long a[n+1];
    a[0] = 2; a[1] = 1;
    for(int i = 2; i < n+1; i++){
        a[i] = a[i-1]+a[i-2];
    }
    cout << a[n] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin>>n;
	while(n--)
	{
		int a,b;
		cin>>a>>b;
		int tmp=sqrt((long long)a*b);
		if((long long)tmp*(tmp+1)<(long long)a*b)
		{
			cout<<tmp*2-1<<endl;
			continue;
		}
		int ans=(tmp-1)*2;
		if((long long)tmp*tmp==(long long)a*b&&a!=b)
			--ans;
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

const int N = 100010;

int n, a[N], b[N];

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a + 1, a + n + 1);
  set <int> s;
  for (int i = 1; i <= n; i += 2) {
    s.emplace(a[i]);
  }
  for (int i = 1; i <= n; i += 2) {
    s.erase(b[i]);
  }
  cout << s.size() << '\n';
  return 0;
}



Measured memory_bytes: 6752
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val l = sc.nextLong()
    val r = sc.nextLong()
    println(problem133c(l, r))
}

fun problem133c(l: Long, r: Long): Long {
    var min = Long.MAX_VALUE
    for (i in l..r) {
        for (j in i+1..r) {
            min = Math.min(min, (i * j) % 2019)
            if (min == 0L) return 0
        }
    }
    return min
}

Measured memory_bytes: 31008
#include<iostream>
using namespace std;
int main(){
	long long N,x;
  	long long int pos[100001];
    while(cin>>N>>x){
    	for(int i=0;i<N;i++){
        	pos[i]=0;
        }
    	long long sum=0;
    	for(int i=0;i<N;i++){
        	cin>>pos[i];
        }
      	for(int i=1;i<N;i++){
        	if(pos[i]+pos[i-1]>x){
              sum+=pos[i]-x+pos[i-1];
              if(x-pos[i-1]<0) pos[i]=0;
              else pos[i]=x-pos[i-1];
            }
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 1024
from collections import defaultdict
N = int(input())
List = list(map(int,input().split()))
dicL = defaultdict(int)
dicR = defaultdict(int)
for i in range(N):
  dicL[List[i]+i] += 1
  dicR[i - List[i]] += 1
counter = 0
for item in dicL:
  if item in dicR:
    counter += dicL[item]*dicR[item]
print(counter)

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

long long H, W;
map<char, long long>chcount;
long long fnum;
long long tnum;
long long onum;

int main(){
	cin >> H >> W;
	for(long long i = 0; i < H; i++){
		string S;
		cin >> S;
		for(long long j = 0; j < W; j++){
			chcount[S[j]]++;
		}
	}


	if(H%2 == 0){
		if(W%2 == 0){
			fnum = H*W/4;
		}else{
			fnum = H*(W-1)/4;
			tnum = H;
		}
	}else{
		if(W%2 == 0){
			fnum = W*(H-1)/4;
			tnum = W;
		}else{
			fnum = (W/2) * (H/2);
			tnum = H + W - 1;
			onum = 1;
		}
	}

	if(onum){
		for(auto co: chcount){
			if(co.second %2 == 1){
				chcount[co.first]--;
				onum = 0;
				break;
			}
		}
	}

	if(onum){
		cout << "No" << endl;
		return 0;
	}

	for(auto co: chcount){
		if(co.second %2 == 1){
			cout << "No" << endl;
			return 0;
		}
	}


	for(auto co: chcount){
		while(fnum && chcount[co.first] >= 4){
			chcount[co.first]-=4;
			fnum--;
		}
	}

	if(fnum > 0){
		cout << "No" << endl;
		return 0;
	}else{
		cout << "Yes" << endl;
		return 0;
	}






}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}


int main(){
    int x,y;
    cin >> x >> y;

    cout << x + y/2 << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    String line = sc.nextLine();
    line = sc.nextLine();
    String[] spl = line.split("");
    spl[k-1] = spl[k-1].toLowerCase();
//    System.out.println(spl[k-1]);
    line = "";
    for(int i = 0; i < n; i++){
//      System.out.println(spl[i]);
      line += spl[i];
    }
    System.out.println(line);
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (ll i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void print(const T& x) {cout << x << "\n";}
template<typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    ll n;
    cin >> n;
    vi a(n);
    ll s = 0;
    rep(i,n) {
        cin >> a[i];
        s += a[i];
        s %= MOD;
    }
    ll ans = 0;
    rep(i,n-1) {
        s -= a[i];
        if (s < 0) s += MOD;
        ans += a[i] * s;
        ans %= MOD;
    }
    print(ans);
}

Measured memory_bytes: 4756
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
 
int main()
{
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if(b-a <= k && c-a <= k && d-a <= k && e-a <= k && c-b <= k && d-b <= k && e-b <= k && d-c <= k && e-c <= k && e-d <= k ){
    cout << "Yay!";
  }else{
    cout << ":(";
  }
 
}


Measured memory_bytes: 384