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

#define infile "../test/sample-2.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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

int d[200][200];

int solve(){
  int n,m,R;cin>>n>>m>>R;
  vi r(R);
  rep(i, R){ cin>>r[i];r[i]--; }
  sort(all(r));


  rep(i, 200) rep(j, 200){
    if (i==j) continue;
    else d[i][j] = INF;
  }

  int a,b,c;
  rep(i, m){
    cin>>a>>b>>c;
    a--;b--;
    d[a][b] = c; d[b][a] = c;
  }

  rep(k, n){
    rep(i, n){
      rep(j, n){
        chmin(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }

  dump_2d(d, n, n);

  int ans = INF;
  do{
    int tmp = 0;
    rep(i, 1, R){
      dump(r);
      dump(i, i-1, r[i], r[i-1]);
      tmp += d[r[i]][r[i-1]];
    }
    chmin(ans, tmp);
  } while (next_permutation(all(r)));

  cout << ans << endl;

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


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

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

int l, r;

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

void solve() {
  int a = max(l,r), b = min(l,r);
  cout<<gcd(a,b)<<endl;
}

int main (int argc, char const* argv[]) {
  while (cin>>l>>r) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
import sys
N, T = map(int, input().split())
ans=[]
limit=0
count=1
 
for _ in range(N):
    c, t = map(int, input().split())
    if T>=t:
        ans.append([count,c])
        count+=1
    else:
        limit+=1
        if limit==N:
            print('TLE')
            sys.exit()
    
    ans=sorted(ans,key=lambda x:x[1])
 
print(ans[0][1])

Measured memory_bytes: 3064
// author : Kartikey Tewari
// date: 2020-02-09   20:35:33
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl '\n'
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int n;
    cin >> n;

    set<int> alpha;
    for (int i=0;i<=n-1;i++)
    {
        int t;
        cin >> t;
        alpha.insert(t);
    }

    if (alpha.size()==n)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 9600
package main

import (
  "fmt"
)

func main() {
  var a, b int
  fmt.Scan(&a, &b)
  if a == 0 {
    if b == 100 {
      fmt.Println(b+1)
    } else {
      fmt.Println(b)
    }
  } else if a == 1 {
    res := 100 * b
    if b == 100 {
      fmt.Println(res+100)
    } else {
      fmt.Println(res)
    }
  } else {
    res := 100 * 100 * b
    if b == 100 {
      fmt.Println(res+10000)
    } else {
      fmt.Println(res)
    }
  }
}

Measured memory_bytes: 512
import sys
def 解():
    iN,iM = [int(_) for _ in input().split()]
    a1 = [0]*iN
    aN = [0]*iN
    aAB = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
    for a,b in aAB:
        if a == 1:
            a1[b] = 1
        if b == iN:
            aN[a] = 1
    for i in range(iN):
        if a1[i] and aN[i]:
            print("POSSIBLE")
            exit()
    print("IMPOSSIBLE")
解()


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

int main(){
    int L,R,d;
    int ans=0;
    cin>>L>>R>>d;

    for(int i=L;i<=R;i++){
        if(i%d==0) ans++;
    } 

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3592
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod =1e+9+7;

int main(){
    ll n; cin>>n;
    ll ac=0,wa=0,tle=0,re=0;
    rep(i,n){
        string s;
        cin>>s;
        if(s=="AC")ac++;
        else if(s=="WA")wa++;
        else if(s=="TLE")tle++;
        else if(s=="RE")re++;
    }
    cout<<"AC x "<<ac<<endl; 
     cout<<"WA x "<<wa<<endl; 
      cout<<"TLE x "<<tle<<endl; 
       cout<<"RE x "<<re<<endl; 

}





























































































Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <vector>

#define N 10000001
using namespace std;

vector<int> v(N,0);


void solve(int n)
{
  for(int i=1;i<=n;i++)
  	  for(int j=i;j<=n;j+=i)
  	  		v[j]++;

      return;
}


using namespace std;

int main()
{

	int n;
	cin>>n;
	solve(n);

	long long ans=0;

	for(int i=1;i<=n;i++)
	{
		ans+=((long long)v[i])*i;
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 42192
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int main()
{
  string s; cin>>s;
  s += s;
  string p; cin>>p;
  rep(i,s.size()-p.size())
  {
    if(s.substr(i, p.size()) == p)
    {
      cout << "Yes" << "\n";
      return 0;
    }
  }
  cout << "No\n";
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
int mod;
template<typename T=int>
T gi() {
	T x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
string to_string(string s) { return '"'+s+'"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b?"true":"false"); }
template<typename A,typename B> string to_string(pair<A,B> p) {
	return "("+to_string(p.fi)+","+to_string(p.se)+")";
}
template<typename T> string to_string(T v) {
	int fst=1;string ret="{";
	for(auto x:v) {
		if(!fst) ret+=",";
		fst=0,ret+=to_string(x);
	}
	ret+="}";return ret;
}
void dbg_out() { cerr<<endl; }
template<typename Head,typename... Tail> void dbg_out(Head H,Tail... T) {
	cerr<<" "<<to_string(H);
	dbg_out(T...);
}
#define dbg(...) cerr<<"{"<<#__VA_ARGS__<<"}:",dbg_out(__VA_ARGS__)

template<typename T>
int qpow(int a,T b) {
	int ret=1;
	while(b) {
		if(b&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return ret;
}

const int N=1e6+10;

namespace dsu {

	int fa[N];

	int getf(int x) {
		return x==fa[x]?x:fa[x]=getf(fa[x]);
	}

	bool merge(int x,int y) {
		x=getf(x),y=getf(y);
		if(x==y) return 0;
		fa[y]=x; return 1;
	}

	void init(int n) {
		for(int i=0;i<n;i++) fa[i]=i;
	}

	bool connected(int x,int y) {
		return getf(x)==getf(y);
	}
	
}

int n,m,q,g=0,z,a[N],b[N],c[N];
bool ispw[2][N];

int id(int u,int p,int q) {
	return 6*u+2*q+p;
}

int main() {
	n=gi(),m=gi(),q=gi(),mod=gi();
	for(int i=1;i<=m;i++) {
		a[i]=gi()-1,b[i]=gi()-1,c[i]=gi();
		g=__gcd(g,abs(c[i]-c[1]));
	}
	if(!g) g=mod;
	mod=__gcd(mod,3*g);
	z=c[1]%g;
	dsu::init(6*n);
	for(int i=1;i<=m;i++) {
		int w=(c[i]-z)/g%3;
		for(int p=0;p<2;p++)
			for(int q=0;q<3;q++) {
				dsu::merge(id(a[i],p,q),id(b[i],p^1,(2*q+w)%3));
				dsu::merge(id(b[i],p,q),id(a[i],p^1,(2*q+w)%3));
			}
	}
	for(int i=0,j=z%mod;!ispw[i&1][j];i++,j=2ll*j%mod) ispw[i&1][j]=1;
	while(q--) {
		int s=gi()-1,t=gi()-1,r=gi();
		bool ans=0;
		for(int p=0;p<2;p++)
			for(int q=0;q<3;q++) {
				if(dsu::connected(id(t,0,0),id(s,p,q))) {
					if(ispw[p&1][(r+z-q*g+3*g)%mod]) ans=1;
				}
			}
		puts(ans?"YES":"NO");
	}
	return 0;
}


Measured memory_bytes: 12672
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
    int a,b,c,d; cin >> a >> b >> c >> d;
    if(c!=-1&&d!=-1){
        if(c>d){
            cout << "Alice" << endl;
        }
        else if(c<d){
            cout << "Bob" << endl;
        }
        else{
            cout << "Draw" << endl;
        }
    }
    else{
        if(a>b){
            cout << "Bob" << endl;
        }
        else if(a<b){
            cout << "Alice" << endl;
        }
        else{
            cout << "Draw" << endl;
        }
    }
}


Measured memory_bytes: 3120
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns #-}
module Main where

import Control.Arrow
import Control.Monad
import Control.Monad.ST
import Control.Monad.State.Strict
import Data.Char
import Data.Function
import Data.List
import Data.Maybe
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as C
import qualified Data.ByteString.Unsafe as B

type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
 
parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
 
parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

main :: IO ()
main = do
  !n <- readLn :: IO Int
  !mat <- U.unfoldrN (n-1) parseInt <$> C.getContents
  print $ U.head mat + U.sum (U.zipWith (min) mat (U.tail mat)) + U.last mat


Measured memory_bytes: 508
import java.util.Scanner;

public class Main {
	static Long num;
	static long mod = 1000000007;
	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in)) {
			int N = Integer.parseInt(sc.next());
			
			
			long maxManhattanPlus = Integer.MIN_VALUE;
			long minManhattanMin = Integer.MAX_VALUE;
			
			long maxManhattanMinuitPlus = Integer.MIN_VALUE;
			long minManhattanMinuitMin = Integer.MAX_VALUE;
			
			for(int j=0;j<N;j++) {
				int x = Integer.parseInt(sc.next());
				int y = Integer.parseInt(sc.next());				

				maxManhattanPlus = Math.max(maxManhattanPlus, x+y);
				minManhattanMin = Math.min(minManhattanMin, x+y);
				maxManhattanMinuitPlus = Math.max(maxManhattanMinuitPlus, x-y);
				minManhattanMinuitMin = Math.min(minManhattanMinuitMin, x-y);
			}
			long ans = Math.max(maxManhattanPlus-minManhattanMin,maxManhattanMinuitPlus-minManhattanMinuitMin);
			System.out.println(ans);
		}
	}
}

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

long long ans[87];
long long lucas(int n){
  if (n==0){
    return 2;
  }
  if (n==1){
    return 1;
  }
  if (ans[n]==0){
    ans[n]=lucas(n-1)+lucas(n-2);
    return ans[n];
  }
  if (ans[n]>0){
    return ans[n];
  }
}

int main(){
  int N;
  cin >> N;
  cout << lucas(N) << endl;
}


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


void divisibilityCheck(int arr[], int n) 
{ 

	// Storing all array elements in a hash 
	// and finding maximum element in the array 
	unordered_set<int> s; 
	int max_ele = INT_MIN; 
	for (int i = 0; i < n; i++) { 
		s.insert(arr[i]); 

		// Update the maximum element of the array 
		max_ele = max(max_ele, arr[i]); 
	} 

	
	unordered_set<int> res; 
	for (int i = 0; i < n; i++) { 

		// Check for non-zero values only 
		if (arr[i] != 0) { 

			// Checking the factors of current element 
			for (int j = arr[i] * 2; j <= max_ele; j += arr[i]) { 

				// If current factor is already part 
				// of the array then store it 
				if (s.find(j) != s.end()) 
					res.insert(j); 
			} 
		} 
	} 

	unordered_map<int, int> mp; 
	for (int i = 0; i < n; i++) 
		mp[arr[i]]++; 

	unordered_map<int, int>::iterator it; 
	vector<int> ans; 
	for (it = mp.begin(); it != mp.end(); it++) { 

		// If frequency is at least 2 
		if (it->second >= 2) { 
			if (res.find(it->first) == res.end()) { 

				int val = it->second; 

				
				while (val--) 
					ans.push_back(it->first); 
			} 
		} 

		
		if (res.find(it->first) != res.end()) { 
			int val = it->second; 

		
			while (val--) 
				ans.push_back(it->first); 
		} 
	} 

		cout << n - ans.size() << " "; 
} 

// Driver code 
int main() 
{ 
	int n;cin>>n;
	int arr[n+2];
	for(int i=0;i<n;i++)cin>>arr[i];
	
	divisibilityCheck(arr, n); 

	return 0; 
} 


Measured memory_bytes: 30732
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n,m;
    while(sf("%d %d",&n,&m)==2)
    {
        string s[n+5];
        for(int i=0;i<n;i++)cin>>s[i];

        bool f=false;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                if(s[i][j]=='#')
                {
                    if(i-1>=0 && s[i-1][j]=='#');
                    else if(i+1<n && s[i+1][j]=='#');
                    else if(j-1>=0 && s[i][j-1]=='#');
                    else if(j+1<m && s[i][j+1]=='#');
                    else
                    {
                        f=true;
                        break;
                    }
                }
            }
            if(f)break;
        }
        if(!f)puts("Yes");
        else puts("No");
    }
    return 0;
}
 









 




























Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
//#define int long long
//template
typedef pair<int,int> P;
//main
signed main(){
  int K;cin>>K;
  std::vector<P> e[K];
  for(int i=0;i<K;i++){
    e[i].push_back(P((i+1)%K,1));
    e[i].push_back(P(i*10%K,0));
  }
  std::vector<int> d(K,INF);
  d[1]=0;
  deque<int> que;
  que.push_front(1);
  while(que.size()){
    int p=que.front();que.pop_front();
    for(P q:e[p]){
      if(d[q.first]>d[p]+q.second){
        d[q.first]=d[p]+q.second;
        if(q.second)que.push_back(q.first);
        else que.push_front(q.first);
      }
    }
  }
  cout<<d[0]+1<<endl;
}

/*
解説AC
0~K-1のグラフを作るのはなんとなく考えたけど、10倍と+1だけでどんな数も作られることを考えてなかった
グラフを作ることを考察したら辺をどのように取ったらいいのかもっとしっかり考えるべきだった
01BFSは https://betrue12.hateblo.jp/entry/2018/12/08/000020 この記事がとてもわかりやすかった
とっても鮮やかで好きな問題
*/


Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
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 inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    string s;
    cin >> s;
    vector<int> ans(s.size());
    int now = 0;
    int last = 1;
    bool ri = true;
    rep2(i,1,s.size()) {
        char c = s[i];
        if(c == 'R') {
            if(ri) {
                now++;
                last++;
            } else {
                now = i;
                last = 1;
                ri = true;
            }
        } else {
            if(ri) {
                ans[now] += (last+1)/2;
                ans[now+1] += last/2+1;
                ri = false;
            } else {
                if((i-now)%2 == 0) ans[now]++;
                else ans[now+1]++;
            }
        }
    }
    rep(i,s.size()-1) cout << ans[i] << " ";
    cout << ans[s.size()-1] << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <limits>

#define INF_I std::numeric_limits<int>::max()
#define MAX_N 100000

int main(){
    int N;
    int L[MAX_N];
    scanf("%d", &N);
    std::fill(L, L + N + 1, INF_I);
    for(int i = 0; i < N; ++i){
        int A;
        scanf("%d", &A);
        *std::lower_bound(L, L + N + 1, A) = A;
    }
    printf("%ld\n", std::lower_bound(L, L + N, INF_I) - L);
    return 0;
}

Measured memory_bytes: 1420
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

 
int main() {
    ll n, ans = 0;
    string s;

    cin >> n >> s;

    for (int i = 0; i < n; i++) {
        if (i < 2) continue;
        if (s[i-2] == 'A' && s[i-1] == 'B' && s[i] == 'C') ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int[]> rList = new List<int[]>();
            rList.Add(ReadIntArray());
            rList.Add(ReadIntArray());
            rList.Add(ReadIntArray());
            var N = ReadInt();
            for (int i = 0; i < N; i++)
            {
                var hole = ReadInt();
                for (var j = 0; j < 3; j++)
                {
                    for (var k = 0; k < 3; k++)
                    {
                        if (rList[j][k] == hole)
                        {
                            rList[j][k] = -1;
                        }
                    }
                }
            }

            for (int i = 0; i < 3; i++)
            {
                if (rList[i].All(x => x == -1))
                {
                    Console.WriteLine("Yes");
                    return;
                }

                if (rList[0][i] == -1 && rList[1][i] == -1 && rList[2][i] == -1)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }

            if (rList[0][0] == -1 && rList[1][1] == -1 && rList[2][2] == -1 ||
                rList[0][2] == -1 && rList[1][1] == -1 && rList[2][0] == -1)
            {
                Console.WriteLine("Yes");
                return;
            }

            Console.WriteLine("No");
        }
        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 13524
n=int(input())
xy=[list(map(int, input().split())) for i in range(n)]

import itertools
import math
seq = range(n)
p=list(itertools.permutations(seq))

dis=0
for index,item in enumerate(p):
  for i in range(n-1):
    dis_tmp = 0
    dis_tmp += ( xy[item[i+1]][0] - xy[item[i]][0] ) ** 2
    dis_tmp += ( xy[item[i+1]][1] - xy[item[i]][1] ) ** 2
    dis += math.sqrt(dis_tmp)
dis /= (len(p))
print(dis)

Measured memory_bytes: 10020
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	m := make(map[byte]int, 0)
	ans := "Yes"
	for i := 0; i < len(s); i++ {
		m[s[i]]++
		if m[s[i]] > 2 || len(m) > 2 {
			ans = "No"
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>

using namespace std;

int main (void)
{
	int n,a[100][100],x[100],K,pp,ap;

	cin >> n;

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

	for (int j = 0; j < n; j++)
	{
		pp = 0;
		ap = 0;
		for (int k = 0; k <= j; k++)
		{
			pp += a[0][k];
		}
		for (int l = j; l < n; l++)
		{
			ap += a[1][l];
		}

			x[j] = pp + ap;
	}

	K = 0;

	for (int j = 0; j < n; j++)
	{
		if (K < x[j])
		{
			K = 0;
			K = x[j];
		}
	}
	cout << K << endl;
}




Measured memory_bytes: 256
#include<stdio.h>
main(){
  int n,ball[10]={},A=0,B=0;
  int i;

  scanf("%d",&n);
  
  while(n>0){

    for(i=0;i<10;i++){
      scanf("%d",&ball[i]);
    }

    for(i=0;i<10;i++){
      if((A>=B) && (A<ball[i])){
	A=ball[i];
      }
      else if(B<ball[i]){
	B=ball[i];
      }
      else{
	printf("NO\n");
	break;
      }
    }

    if(i==10){
      printf("YES\n");
    }

    A=0;
    B=0;
    n--;
  }
  return 0;
}
  

Measured memory_bytes: 580
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = INT()

if 0 < S%100 <= 12:
	if 0 < S//100 < 12:
		print("AMBIGUOUS")
	else:
		print("YYMM")
elif  0 < S//100 <= 12:
	print("MMYY")
else:
	print("NA")

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> board(h);
  for (int i = 0; i < h; i++) {
    cin >> board[i];
  }
  vector<vector<int>> dist(h, vector<int>(w, 1e9));
  deque<tuple<int, int, int>> deq;
  deq.emplace_front(0, 0, 0);
  while (deq.size()) {
    int x, y, d;
    tie(x, y, d) = deq.front();
    deq.pop_front();
    if (dist[x][y] != 1e9) continue;
    dist[x][y] = d;
    if (x + 1 < h && dist[x + 1][y] == 1e9) {
      if (board[x][y] == board[x + 1][y]) {
        deq.emplace_front(x + 1, y, d);
      } else {
        deq.emplace_back(x + 1, y, d + 1);
      }
    }
    if (y + 1 < w && dist[x][y + 1] == 1e9) {
      if (board[x][y] == board[x][y + 1]) {
        deq.emplace_front(x, y + 1, d);
      } else {
        deq.emplace_back(x, y + 1, d + 1);
      }
    }
  }
  int ans = (dist[h - 1][w - 1] + 1) / 2;
  if (board[0][0] == '#' && board[h - 1][w - 1] == '#') ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i
ary = gets.split.map(&:to_i)
a_sort = ary.sort
if ary == a_sort
  puts "YES"
  exit
end

swap = []
n.times do |i|
  swap.push(i) if ary[i] != a_sort[i]
end

if swap.size != 2
  puts "NO"
  exit
end

ary[swap[0]],ary[swap[1]] = ary[swap[1]],ary[swap[0]]

if ary == a_sort
  puts "YES"
else
  puts "NO"
end






Measured memory_bytes: 1788
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

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

  ll ans = N / 3;

  cout << ans << endl;

  return 0;
}


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

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

    int ans = 0;
    rep(i, n) {
        int a;
        cin >> a;

        if (i % 2 == 0 && a % 2 == 1)
            ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3576
n, a, b = map(str, input().split())
a = int(a)
b = int(b)
N = int(n)
sum = 0
for i in range(1, N + 1):
    k = 0
    num = list(str(i))
    for j in range(len(num)):
        k = k + int(num[j])
    if (k >= a) and (k <= b):
        sum += i
print(sum)


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

ll k0num[100005];

int main() {
  ll N,K;
  cin >> N >> K;
  vector< pair<ll,ll> > S;
  REP(i,N) {
    ll a,b;
    cin >> a >> b;
    S.emplace_back( b, a );
  }
  sort(S.begin(), S.end() );
  reverse(S.begin(), S.end() );
  ll aji = 0;
  ll kind = 0;
  REP(i,K) {
    aji += S[i].first;
    if (k0num[S[i].second] == 0 ) kind++;
    k0num[S[i].second]++;
  }
  int s0_idx = K-1;
  int s1_idx = K;
  ll total = aji + kind * kind;
  ll max_total = total;
  REP(i,K) {
    if ( (s0_idx < 0) || (s1_idx>=N) ) break;
    // S0の中で、一番小さくて、種類が2以上なものが交換候補
    while ((s0_idx >= 0) && (k0num[ S[ s0_idx ].second ] < 2)) s0_idx--;
    // S1の中で、一番大きくて、S0での種類が0なものが交換候補
    while ((s1_idx < N) && (k0num[ S[ s1_idx ].second ] != 0)) s1_idx++;
    if ( (s0_idx < 0) || (s1_idx>=N) ) break;
    kind++;
    aji = aji - S[ s0_idx ].first + S[ s1_idx ].first;
    total = aji + kind * kind;
//    cout << s0_idx << " " << s1_idx << " : " << aji << " " << kind << " " << total << endl;
    max_total = max( max_total, total );
    k0num[ S[ s0_idx ].second ]--;
    k0num[ S[ s1_idx ].second ]++;
    s0_idx--; s1_idx++;
  }
  cout << max_total << endl;;
}



Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int main() {
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n, m;
  cin >> n >> m;
  vector<int> arr(n * 2);
  for (int i = 0; i < n * 2; i++) {
    cin >> arr[i];
  }
  sort(arr.begin(), arr.end());
  int low = 0, high = n, pos = -1;
  while (low <= high) {
    int mid = (low + high) / 2;
    bool ok = true;
    for (int i = 0; i < mid; i++) {
      if (arr[n * 2 - mid - i - 1] + arr[n * 2 - mid + i] < m) {
        ok = false;
      }
    }
    if (ok) {
      pos = mid;
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < n - pos; i++) {
    ans = max(ans, arr[i] + arr[(n - pos) * 2 - i - 1]);
  }
  for (int i = 0; i < pos; i++) {
    ans = max(ans, arr[n * 2 - pos - i - 1] + arr[n * 2 - pos + i] - m);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

//100で何回割り切れるかを数える.
int func(int x){
    if(x % 100 != 0){
        return 0;
    }
    return func(x / 100) + 1;
}
int main(){
    int D, N, ans = 0;
    cin >> D >> N;
    for(int x = 1; ;x++){
        //100でD回割り切れるなら
        if(func(x) == D){
            ans++;
            if(ans == N){
                cout << x << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

int64_t solve(int64_t H, int64_t W){
  const int64_t S= H* W;

  vector<int64_t> cands;
  int64_t slice= min(H, W);
  cands.emplace_back(slice);

  vector<vector<int64_t>> cross(4);
  int cnt= 0;
  for(int Wcut= W/3; Wcut<= W/3+ 1; Wcut++){
    if(Wcut==0){
      cross.at(cnt).emplace_back(INT64_MAX);
      cnt++;
      continue;
    }
    else{
      cross.at(cnt).emplace_back(H* Wcut);
      int64_t Wremain= W- Wcut;
      cross.at(cnt).emplace_back(    (H/2)* Wremain);
      cross.at(cnt).emplace_back(((H+1)/2)* Wremain);

      int64_t Smax= *max_element(cross.at(cnt).begin(), cross.at(cnt).end());
      int64_t Smin= *min_element(cross.at(cnt).begin(), cross.at(cnt).end());
      cands.emplace_back(Smax- Smin);

      cnt++;
    }
  }
  for(int Hcut= H/3; Hcut<= H/3+ 1; Hcut++){
    if(Hcut==0){
      cross.at(cnt).emplace_back(INT64_MAX);
      cnt++;
      continue;
    }
    else{
      cross.at(cnt).emplace_back(Hcut* W);
      int64_t Hremain= H- Hcut;
      cross.at(cnt).emplace_back(Hremain* (    W/2));
      cross.at(cnt).emplace_back(Hremain* ((W+1)/2));
  
      int64_t Smax= *max_element(cross.at(cnt).begin(), cross.at(cnt).end());
      int64_t Smin= *min_element(cross.at(cnt).begin(), cross.at(cnt).end());
      cands.emplace_back(Smax- Smin);
  
      cnt++;
    }
  }

  return *min_element(cands.begin(), cands.end());
}

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

  int64_t ans= (H==2   && W==2  ) ? 1
              :(H%3==0 || W%3==0) ? 0
                                  : solve(H, W);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <numeric>
using namespace std;

typedef long long LL; typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,l[220];
    cin >> n;
    REP(i,2*n){
        cin >> l[i];
    }

    sort(l,l+2*n);
    int ans;
    REP(i,n){
        ans+=l[2*i];
    }
    cout << ans <<endl;
    return 0;
}


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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)

int main(){
  long long N,b,count;
  cin>>N;
  count=0;
  vector<long long> vec(N+1);
  rep(i,N+1) cin>>vec.at(i);
  rep(i,N){
    cin>>b;
    if(vec.at(i)+vec.at(i+1)>b){
      count+=b;
      vec.at(i+1)-=max(0LL,b-vec.at(i));
    }
    else{
      count+=vec.at(i)+vec.at(i+1);
      vec.at(i+1)=0;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int N = scan.nextInt();
        int H = scan.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        for(int i=0;i<N;++i){
            a[i] = scan.nextInt();
            b[i] = scan.nextInt();
        }
        int maxindex = 0;
        for(int i=0;i<N;++i){
            if(a[i] > a[maxindex]){
                maxindex =i;
            }
        }
        int bmax = b[maxindex];
        b[maxindex] =0;
        Arrays.sort(b);

        int ans = 0;
        int h = 0;
        int index = N-1;
        while(true){
            ++ans;
            if(h + Math.max(a[maxindex], Math.max(bmax, b[index])) >=H)break;
            h += Math.max(a[maxindex], b[index]);
            if(index >0)--index;
        }





        System.out.println(ans);
    }
}

Measured memory_bytes: 85332
#include<bits/stdc++.h>
#define ll long long
#define N 2005

using namespace std;
inline int Get() {int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}while('0'<=ch&&ch<='9') {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}return x*f;}

const ll mod=1e9+7;
ll ksm(ll t,ll x) {
	ll ans=1;
	for(;x;x>>=1,t=t*t%mod)
		if(x&1) ans=ans*t%mod;
	return ans;
}
int n,k;
ll fac[N*N],ifac[N*N];
void pre(int n) {
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	ifac[n]=ksm(fac[n],mod-2);
	for(int i=n-1;i>=0;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
}
ll C(int n,int m) {return fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
ll f[N][N];
int main() {
	pre(4e6);
	n=Get(),k=Get();
	if(k==1) {
		cout<<1;
	} else {
		f[0][0]=1;
		for(int i=1;i<=n;i++) {
			for(int j=0;j<i;j++) {
				if(!f[i-1][j]) continue ;
//				cout<<"i="<<i<<" j="<<j<<" f="<<f[i-1][j]<<" "<<C(i*(k-1)+j-1,k-2)<<"\n";
				(f[i][j]+=f[i-1][j]*C(i*(k-1)+j-1,k-2))%=mod;
			}
			for(int j=1;j<=i;j++) (f[i][j]+=f[i][j-1])%=mod;
		}
		cout<<f[n][n]*fac[n]%mod;
	}
	return 0;
}


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

int N, K;
int dp[2][2010][2010];

int count(int c, int y1, int x1, int y2, int x2) {
  if (y1 < 0 || y1 >= 2 * K || y2 < 0 || y2 >= 2 * K) {
    return 0;
  }
  if (x1 < 0 || x1 >= 2 * K || x2 < 0 || x2 >= 2 * K) {
    return 0;
  }
  if (y1 > y2 || x1 > x2) {
    return 0;
  }
  int res = dp[c][y2][x2];
  if (y1 > 0) {
    res -= dp[c][y1-1][x2];
  }
  if (x1 > 0) {
    res -= dp[c][y2][x1-1];
  }
  if (y1 > 0 && x1 > 0) {
    res += dp[c][y1-1][x1-1];
  }
  return res;
}

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int x, y;
    char c;
    cin >> x >> y >> c; 
    dp[c == 'W'][y % (2 * K)][x % (2 * K)] += 1;
  }
  for (int c = 0; c < 2; c++) {
    for (int y = 0; y < 2 * K; y++) {
      for (int x = 0; x < 2 * K; x++) {
        if (y > 0) {
          dp[c][y][x] += dp[c][y-1][x];
        }
        if (x > 0) {
          dp[c][y][x] += dp[c][y][x-1];
        }
        if (y > 0 && x > 0) {
          dp[c][y][x] -= dp[c][y-1][x-1];
        }
      }
    }
  }
  int res = 0;
  for (int c = 0; c < 2; c++) {
    for (int y1 = 0; y1 + K - 1 < 2 * K; y1++) {
      for (int x1 = 0; x1 + K - 1 < 2 * K; x1++) {
        int y2 = y1 + K - 1, x2 = x1 + K - 1;
        int cnt = 0;
        cnt += count(c, y1, x1, y2, x2);
        cnt += count(c, 0, 0, y1 - 1, x1 - 1);
        cnt += count(c, 0, x2 + 1, y1 - 1, 2 * K - 1);
        cnt += count(c, y2 + 1, 0, 2 * K - 1, x1 - 1);
        cnt += count(c, y2 + 1, x2 + 1, 2 * K - 1, 2 * K - 1);
        cnt += count(c^1, y2 + 1, x1, 2 * K - 1, x2);
        cnt += count(c^1, y1, x2 + 1, y2, 2 * K - 1);
        cnt += count(c^1, 0, x1, y1 - 1, x2);
        cnt += count(c^1, y1, 0, y2, x1 - 1);
        res = max(res, cnt);
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 31744
import java.util.Scanner;

public class Main {
		public static void main(String[] args)  {
				Scanner sc = new Scanner(System.in);
				int w = sc.nextInt();
				int h = sc.nextInt();
				int x = sc.nextInt();
				int y = sc.nextInt();
				int r = sc.nextInt();

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

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

int main(int argc, char const *argv[])
{
	long long l,r;
	cin>>l>>r;
	if (r-l>2020)
	{
		cout<<"0\n";
	}
	else
	{
		long long ans=2020LL;
		for (long long i = l; i < r; ++i)
		{
			for (long long j = i+1LL; j <= r; ++j)
			{
				ans=min(ans,(i*j)%2019LL);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
// A

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

ll modpow(int a, int b) { //aのb乗
	if (!b)return 1;
	if (b % 2)return modpow(a, b - 1) * a %mod;
	ll memo = modpow(a, b / 2);
	return memo * memo %mod;
}

int main(){
  ll N,A[300000];
  cin>>N;
  for (int i(0);i<N;i++) cin>>A[i];
  ll ans(0);
  for (int i(0);i<=60;i++){
    ll tmp(0),cnt0(0),cnt1(0);
    for (int j(0);j<N;j++){
      if (A[j]>>i & 1) cnt1++;
      else cnt0++;
    }
    //cout <<i <<  " "<<cnt0 << " " << cnt1 << endl;
		ll a = (cnt0*cnt1)%mod;
    tmp = a*modpow(2,i);
    tmp %= mod;
    ans += tmp;
    ans %= mod;
  }
  cout << ans << endl;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main() {
    ll n;cin >>n;
    vector<ll>a(n);
    vector<ll>b(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        b[i]=a[i]*2;
    }
    sort(all(a));
    sort(all(b));
    vector<ll>sum(n+1,0);
    for (int i = 0; i < n; ++i) {
        sum[i+1]=sum[i]+b[i];
    }
    a.push_back(a[n-1]);
    ll ans=0;
    for (int i = 0; i < n + 1; ++i) {
        if(sum[i]<a[i])ans=i;
    }
    cout <<n-ans<<endl;
    return 0;
}



Measured memory_bytes: 3328
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

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(|e| e.parse().ok().unwrap())
        .collect()
}

fn is_disallowed(i: usize, j: usize, k: usize, l: usize) -> bool {
    // disallowed:
    // AGC: 0 2 1
    // GAC: 2 0 1
    // ACG: 0 1 2
    // AXGC: 0 X 2 1
    // AGXC: 0 2 X 1

    // AGC: 0 2 1
    if i == 0 && j == 2 && k == 1 {
        return false;
    }
    if j == 0 && k == 2 && l == 1 {
        return false;
    }

    // GAC: 2 0 1
    if i == 2 && j == 0 && k == 1 {
        return false;
    }
    if j == 2 && k == 0 && l == 1 {
        return false;
    }
    // ACG: 0 1 2
    if i == 0 && j == 1 && k == 2 {
        return false;
    }
    if j == 0 && k == 1 && l == 2 {
        return false;
    }

    // AXGC: 0 X 2 1
    // AGXC: 0 2 X 1
    if i == 0 && k == 2 && l == 1 {
        return false;
    }
    if i == 0 && j == 2 && l == 1 {
        return false;
    }
    true
}

fn main() {
    let n = read::<usize>();
    let big_int: u64 = 1000_000_000 + 7;
    if n == 3 {
        println!("61");
        return;
    }

    let mut dp = vec![vec![vec![vec![vec![0u64; 4]; 4]; 4]; 4]; n];
    // 0: A, 1: C, 2: G, 3: T
    for i in 0..4 {
        for j in 0..4 {
            for k in 0..4 {
                for l in 0..4 {
                    if !is_disallowed(i, j, k, l) {
                        continue;
                    }
                    dp[0][i][j][k][l] = 1;
                }
            }
        }
    }

    for ni in 1..n - 3 {
        for i in 0..4 {
            for j in 0..4 {
                for k in 0..4 {
                    for l in 0..4 {
                        if !is_disallowed(i, j, k, l) {
                            continue;
                        }
                        dp[ni][i][j][k][l] += dp[ni - 1][0][i][j][k];
                        dp[ni][i][j][k][l] %= big_int;
                        dp[ni][i][j][k][l] += dp[ni - 1][1][i][j][k];
                        dp[ni][i][j][k][l] %= big_int;
                        dp[ni][i][j][k][l] += dp[ni - 1][2][i][j][k];
                        dp[ni][i][j][k][l] %= big_int;
                        dp[ni][i][j][k][l] += dp[ni - 1][3][i][j][k];
                        dp[ni][i][j][k][l] %= big_int;
                    }
                }
            }
        }
    }
    let mut ans = 0;
    for i in 0..4 {
        for j in 0..4 {
            for k in 0..4 {
                for l in 0..4 {
                    ans += dp[n - 4][i][j][k][l];
                    ans %= big_int;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;
using ll= long long;

long long mypow(long long k, long long n) {
    long long temp = 1;

    k = k % DIV;
    while (n) {
        if (n % 2) temp = temp * k % DIV;
        k = k * k % DIV;
        n = n / 2;
    }
    return temp % DIV;
}

int main() {
    ll N, K;
    cin >> N >> K;

    vector<ll> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    sort(A.begin(), A.end());

    ll temp = 1;
    ll ans = 0;    
    for (ll i = 0; i <= N - K; i++) {
        //cout << "temp=" << temp << endl;
        ll total = A[(K - 1) + i] - A[(N - K) - i] + DIV;
        total %= DIV;
        total = temp * total;
        total %= DIV;
        ans += total + DIV;
        ans %= DIV;
        total = (i + K) * mypow(i + 1, DIV - 2);
        total %= DIV;
        temp = temp * total;
        temp %= DIV;

    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		//４桁取得（abcd)
		int n = scan.nextInt();
		int a = n / 1000;
		int b = (n - a * 1000) / 100;
		int c = (n - a * 1000 - b * 100) / 10;
		int d = n - a * 1000 - b * 100 - c * 10;
		if (a == b) {
			System.out.println("Bad");
		} else if (b == c) {
			System.out.println("Bad");
		} else if (c == d) {
			System.out.println("Bad");
		} else {
			System.out.println("Good");
		}
		scan.close();
	}

}

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

int main(){
  int N ; 
  cin >> N ; 
  vector<long long> X(N) ; 
  vector<long long> P(N) ; 
  for(int i = 0 ; i < N ; i++) {
    cin >> X.at(i) ;
    P.at(i) = X.at(i) ; 
  }
  sort(X.begin(),X.end()) ;
  
  for(int i = 0 ; i < N ; i++){
    //cout << P.at(i) << " " << X.at((N-1)/2) << endl ; 
    if(P.at(i) <= X.at((N-1)/2) ) cout << X.at(N/2) << endl ; 
    else cout << X.at((N)/2 - 1) << endl ; 
  }
  
}

Measured memory_bytes: 6324
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9+7;

int main() {
	int x, a;
	cin >> x >> a;
	if (x < a) {
		cout << "0" << endl;
	}
	else {
		cout << "10" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import bisect

n=int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for k in b:
    pos1 = bisect.bisect_left(a,k)
    pos2 = bisect.bisect_right(c,k)
    ans += (pos1*(n-pos2))
print(ans)
 



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

int main(void){
	vector<vector<int>> c(3, vector<int>(3));
	rep(i, 3){
		rep(j, 3){
			cin >> c[i][j];
		}
	}
	if(c[0][0]-c[0][1] == c[1][0]-c[1][1]
	&&c[1][0]-c[1][1]==c[2][0]-c[2][1]
	&&c[0][1]-c[0][2] == c[1][1]-c[1][2]
	&&c[1][1]-c[1][2] == c[2][1]-c[2][2]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3564
N = int(input())
As = list(map(int, input().split()))

prev = As[0]
status = 0 #-1 減少　1増加
cnt = 1

for a in As[1:]:
    if status == 0: #未確定
        if prev > a:
            status = -1
        elif prev < a:
            status = 1
    elif status == 1 :  #単調非減少
        if prev > a:
            status = 0
            cnt += 1
    else:               #単調非増加
        if prev < a:
            status = 0
            cnt += 1
    prev = a

print(cnt)


Measured memory_bytes: 14228
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}


const int N=2e5+5;
int n,m,ans,a[N];
bool b[N];

bool check(int x){
	for(int i=1;i<=n;i++) b[i]=a[i]<=x;
	int flag=-1,mi=n;
	for(int i=2;i<=n;i++) if(b[i]==b[i-1]) if(abs(m-i)<mi){
		mi=abs(m-i);
		flag=b[i];
	}
	for(int i=n-1;i>=1;i--) if(b[i]==b[i+1]) if(abs(m-i)<mi){
		mi=abs(m-i);
		flag=b[i];
	}
	if(flag==-1) flag=b[1];
	return flag;
}

signed main(){
	m=read(n);n=n*2-1;
	for(int i=1;i<=n;i++) read(a[i]);
	int l=1,r=n;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	write(ans);
}

Measured memory_bytes: 1280
import Data.List

ans' q x = 
    let dt = sortBy c $ map (\e -> (head e, length e) ) $ group $ sort $ concat $ map tail x
        (d,n) = head dt
    in
        if dt == []
        then 0
        else if n >= q then d else 0
    where
        c (d0,n0) (d1,n1) =
            let cd = compare d0 d1
                cn = compare n1 n0
            in
                if cn /= EQ then cn else cd

ans ([0,0]:_) = []
ans ([n,q]:x) =
    let d = take n x
        r = drop n x
        a = ans' q d
    in
        a:(ans r)

main = do
    c <- getContents
    let i = map (map read) $ map words $ lines c :: [[Int]]
        o = ans i
    mapM_ print o



Measured memory_bytes: 5544
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    long X = sc.nextLong();
    long Y = sc.nextLong();

    sc.close();

    long count = 0;
    long value = X;

    while (value <= Y) {
      value = value * 2;
      count++;
    }

    System.out.println(count);

  }

}

Measured memory_bytes: 21844