akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>

#ifdef GONGKUNPENG
#include <cassert>
#define _GG 1
#else
#define _GG 0
#endif

#define uint unsigned
#define ll long long
#define ull unsigned long long
#define vector std::vector
#define ms(a, v) memset(a, v, sizeof(a))
#define ufor(i, n) for (int i = 1; i < n; ++i)
#define sfor(i, n) for (int i = 1; i <= n; ++i)
#define tfor(i, n) for (int i = 0; i < n; ++i)
using std::max;
using std::min;
using std::sort;
using std::swap;

#define _GIO 1

#if _GIO
struct _gio {
#define BFSZ 1 << 18
#define blank(x) (x == ' ' || x == '\t' || x == '\n' || x == '\r')

  char rcha;
  bool rneg;
#if _GG
#else
  char ruf[BFSZ], wuf[BFSZ], *r1, *r2, *w1;
#endif

  _gio() {
    rcha = ' ';
#if _GG
#else
    r1 = r2 = ruf, w1 = wuf;
#endif
  }

  ~_gio() {
#if _GG
#else
    fwrite(wuf, 1, w1 - wuf, stdout);
#endif
  }

  inline void flush() {
#ifdef _GG
#else
    fwrite(wuf, 1, w1 - wuf, stdout), w1 = wuf;
#endif
  }

  inline int readc() {
#if _GG
    return getchar();
#else
    return (r1 == r2 && (r2 = (r1 = ruf) + fread(ruf, 1, BFSZ, stdin), r1 == r2)
                ? -1
                : *r1++);
#endif
  }

  template <typename T, typename... Args>
  void read(T &x, Args &... args) {
    read(x), read(args...);
  }

  inline void read() {}

  inline void read(char *s) {
    while (blank(rcha)) rcha = readc();
    while (!blank(rcha) && rcha > 0) *s++ = rcha, rcha = readc();
    *s = '\0';
  }

  inline void readl(char *s) {
    while (blank(rcha)) rcha = readc();
    while (rcha != '\n' && rcha > 0) *s++ = rcha, rcha = readc();
    *s = '\0';
  }

  template <typename T>
  inline void read(T &x) {
    x = rcha = rneg = 0;
    while (!isdigit(rcha) && rcha != '-') rcha = readc();
    rcha == '-' && (rneg = true, rcha = readc());
    while (isdigit(rcha)) x = (x << 3) + (x << 1) - 48 + rcha, rcha = readc();
    rneg && (x = -x);
  }

  inline void writec(char c) {
#if _GG
    putchar(c);
#else
    (w1 - wuf == BFSZ) && (fwrite(wuf, 1, BFSZ, stdout), w1 = wuf);
    *w1++ = c;
#endif
  }

  template <typename T, typename... Args>
  void write(const T &x, const Args &... args) {
    write(x), write(args...);
  }

  template <typename T, typename... Args>
  void writel(const T &x, const Args &... args) {
    write(x), write(args...);
    writec('\n');
  }

  inline void write() {}

  inline void write(const char &c) { writec(c); }

  template <typename T>
  void write(T x) {
    if (x < 0) {
      writec('-');
      write(-(long long)(x));
      return;
    }
    if (x > 9) write(x / 10);
    writec(x % 10 ^ 48);
  }

  inline void write(const char *s) {
    while (*s) writec(*s++);
  }
#undef BFSZ
} io;
#endif

const int INF = 0x3f3f3f3f;
const int MAXN =
#ifdef GONGKUNPENG
    15
#else
    1000005
#endif
    ;

int main() {
  int h1, a1, h2, a2, t = 1;
  io.read(h1, a1, h2, a2);
  while (h1 > 0 && h2 > 0) {
    if (t % 2)
      h2 -= a1;
    else
      h1 -= a2;
    ++t;
  }
  io.write(t % 2 ? "No\n" : "Yes\n");
  return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;



int main() {
  int a,b,c;
  cin >> a>>b >>c;
  if(a+b==c || b+c==a || a+c==b){cout << "Yes" << endl;}else{cout << "No" << endl;}
}

Measured memory_bytes: 3600
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    List<Integer> iList = new ArrayList<Integer>();

    iList.add(sc.nextInt());
    iList.add(sc.nextInt());
    iList.add(sc.nextInt());

    int fCount = 0;
    int sCount = 0;
    for (int i : iList) {
      if (i == 5) {
        fCount++;
      }
      if (i == 7) {
        sCount++;
      }
    }

    if (fCount == 2 && sCount == 1) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 22100
N = int(input())
D = []
is_Zorome = []
for _ in range(N):
  inputs = input().split(' ')
  D.append(inputs)
  if inputs[0] == inputs[1]:
    is_Zorome.append(True)
  else:
    is_Zorome.append(False)

answer = 'No'

for i in range(N-2):
  if is_Zorome[i] and is_Zorome[i+1] and is_Zorome[i+2]:
    answer = 'Yes'

print(answer)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N; cin >> N;
  long long ans = 0;
  for(long long  i = 1LL; i <= N; i++){
    if(i % 3 != 0 and i % 5 != 0)
      ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int MAX=3005;
vector<int> llist[MAX];
int n;
int visited[MAX],result[MAX],number[MAX];
void dfs(int v)
{
	bool win=false;
	for(int i=0;i<llist[v].size();++i){
		int u=llist[v][i];
		if(number[u]<number[v]){
			if(result[u]==0) dfs(u);
			if(result[u]==2){
				result[v]=1;
				return;	
			} 
		}
	}
	result[v]=2;
}
int main()
{
	int a,b,ans=0;
	cin>>n;
	for(int i=1;i<=n;++i) cin>>number[i];
	for(int i=1;i<n;++i){
		cin>>a>>b;
		llist[a].push_back(b);
		llist[b].push_back(a);
	}
	for(int i=1;i<=n;++i){
		if(result[i]==0) dfs(i);
	}
	for(int i=1;i<=n;++i) if(result[i]==1) cout<<i<<" ";
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main()
{
  int n,i,ans=0;	
  cin>>n;
  n*=2;
  for(i=1;i<=n;i++)
    cin>>a[i];
  sort(a+1,a+n+1);    
  for(i=1;i<=n;i+=2)
    ans+=a[i];
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

	    String s=gs();

	    int g=0;
	    int p=0;
	    int c=0;
	    
	    for (int i=1; i<s.length();i++) {
	    	if(s.charAt(i-1)!=s.charAt(i)) c++;
	    }

	    System.out.println(c);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 39308
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int cards[4][13], n, x;
    char ch;
    for(int i=0; i<4; i++){
        for(int j=0; j<13; j++){
            cards[i][j] = 0;
        }
    }
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%c", &ch);
        scanf("%c %d", &ch, &x);
        if(ch == 'S'){
            cards[0][x-1] = 1;
        }else if(ch == 'H'){
            cards[1][x-1] = 1;
        }else if(ch == 'C'){
            cards[2][x-1] = 1;
        }else if(ch == 'D'){
            cards[3][x-1] = 1;
        }
    }
    
    for(int j=0; j<13; j++){
        if(cards[0][j]!=1){
            printf("S %d\n", j+1);
        }
    }
    for(int j=0; j<13; j++){
        if(cards[1][j]!=1){
            printf("H %d\n", j+1);
        }
    }
    for(int j=0; j<13; j++){
        if(cards[2][j]!=1){
            printf("C %d\n", j+1);
        }
    }
    for(int j=0; j<13; j++){
        if(cards[3][j]!=1){
            printf("D %d\n", j+1);
        }
    }
    return 0;
}



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

int main(){
    vector<long long> v;
    long long n;
    long long x;
    long long temp;
    cin >> n;
    for(int i=0; i < n; i++){
        cin >> x;
        v.push_back(x);
    }
    for(int i=0; i < v.size()-1; i++){
        cout << v[i] << " ";
    }
    cout << v[v.size()-1] << endl;
    for(int i=0; i < n-1; i++){
        
        for(int j=i+1; j>0; j--){
            if(v[j-1]>v[j]){
                temp = v[j-1];
                v[j-1] = v[j];
                v[j] = temp;
                continue;
            }
            break;
        }
        for(int i=0; i < v.size()-1; i++){
            cout << v[i] << " ";
        }
        cout << v[v.size()-1] << endl;
    }

}



Measured memory_bytes: 3164
// Copyright 2017 Parallelc
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using T = LL;
T exgcd(T a, T b, T& x, T& y) {  // a solution of ax + by = gcd(a, b)
    if (b == 0) return x = 1, y = 0, a;
    T d = exgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
bool equ(T a, T b, T c, T& x, T& y) {  // solutions of ax + by = c || ax = c (mod b)
    T d = exgcd(a, b, x, y);
    if (d == 0) return !c;  // a == b == 0
    if (c % d) return false;
    x *= c / d, y *= c / d;  // a solution
    a /= d, b /= d;  // all solution: x = x + b * t, y = y - a * t; loop of x % b is d
    T tx = x;
    x = (x % b + b) % b, y += (tx - x) / b * a;  // solution of min{Z*}
    return true;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL a, b, c;
    cin >> a >> b >> c;
    LL x, y;
    if (equ(a, b, c, x, y)) cout << "YES\n";
    else cout << "NO\n";
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import fractions
N=int(input())
A=list(map(int,input().split()))
c=1
a=0
w=10**9+7
for A_ in A:
    c=c*A_//fractions.gcd(c,A_)
for A_ in A:
    a+=c//A_
print(int(a%w))

Measured memory_bytes: 6204
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int a[6], b[6];
  
  for (int i = 0; i < 3; i ++) {
    std::cin >> a[i] >> b[i];

    a[i + 3] = b[i];
    b[i + 3] = a[i];
  }

  std::vector<int> A(4);

  std::iota(ALL(A), 1);

  do {
    bool valid = true;
    
    for (int i = 0; i < 3; i ++) {
      bool v = false;
      
      for (int j = 0; j < 6; j ++)
        if (A[i] == a[j] && A[i + 1] == b[j]) {
          v = true;

          break;
        }

      if (! v) {
        valid = false;

        break;
      }
    }

    if (valid) {
      std::cout << "YES" << std::endl;

      return 0;
    }
  } while (std::next_permutation(ALL(A)));

  std::cout << "NO" << std::endl;
  
  return 0;
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

bool win(vi a,map<vi,bool>& memo)
{
	sort(all(a));
	if(memo.count(a)) return memo[a];
	int n=a.size();
	if(count(all(a),0)==n) return memo[a]=true;
	vi b=a; b[n-1]=0;
	if(!win(b,memo)) return memo[a]=true;
	rep(i,n) b[i]=max(a[i]-1,0);
	if(!win(b,memo)) return memo[a]=true;
	return memo[a]=false;
}

bool solve_small(vi a)
{
	map<vi,bool> memo;
	return win(a,memo);
}

int main()
{
	for(int n;cin>>n && n;){
		vi a(n);
		rep(i,n) cin>>a[i];
		sort(all(a),greater<int>());
		int i=0;
		while(i<n && i<a[i]) i++;
		i--;
		int x=a[i]-i,y=find_if(all(a),[&](int x){return x<=i;})-begin(a)-i;
		cout<<(x&y&1?"Second":"First")<<endl;
	}
}


Measured memory_bytes: 640
N=int(input())
S=input()
count=0
maxcount=0

for i in range(1,len(S)):
    F=S[:i]
    G=S[i:]

    X=set(F)

    count=0

    for j in X:
        if j in G:
            count=count+1

    maxcount=max(count,maxcount)

print(maxcount)


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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}

int atcoder(){
    int h,w,n,sr,sc;
    string s,t;
    Vi A,B;
    cin>>h>>w>>n>>sr>>sc>>s>>t;
    REP(i,0,n){
        switch(s[i]){
            case 'R' : A.push_back(1);
                break;
            case 'L' : A.push_back(2);
                break;
            case 'D' : B.push_back(1);
                break;
            case 'U' : B.push_back(2);
                break;
        }
        switch(t[i]){
            case 'R' : A.push_back(3);
                break;
            case 'L' : A.push_back(4);
                break;
            case 'D' : B.push_back(3);
                break;
            case 'U' : B.push_back(4);
            break;
        }
    }
    reverse(ALL(A));
    reverse(ALL(B));

    int L=1,R=w;
    REP(i,0,A.size()){
        switch(A[i]){
            case 1 : R--;
                break;
            case 2 : L++;
                break;
            case 3 : L=max(1,L-1);
                break;
            case 4 : R=min(w,R+1);
                break;
        }
        if(R<L){cout<<"NO"<<ENT;return 0;}
    }
    if(sc<L || R<sc){cout<<"NO"<<ENT;return 0;}

    int U=1,D=h;
    REP(i,0,B.size()){
        switch(B[i]){
            case 1 : D--;
                break;
            case 2 : U++;
                break;
            case 3 : U=max(1,U-1);
                break;
            case 4 : D=min(h,D+1);
                break;
        }
        if(D<U){cout<<"NO"<<ENT;return 0;}
    }
    if(sr<U || D<sr){cout<<"NO"<<ENT;return 0;}
    cout<<"YES"<<ENT;
    return 0;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    int n;
    cin >> n;

    vector<LL> v(5, 0);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s[0] == 'M') v[0]++;
        if (s[0] == 'A') v[1]++;
        if (s[0] == 'R') v[2]++;
        if (s[0] == 'C') v[3]++;
        if (s[0] == 'H') v[4]++;
    }

    int c=0;
    for (int i = 0; i < 5; i++) if (v[i] > 0) c++;

    // cout << "v" << endl;
    // printvector(v);
    // cout << endl;

    if (c < 3) {
        cout << 0 << endl;
    }else{
        LL total=0;
        for (int i = 0; i < 3; i++) {
            for (int j = i+1; j < 4; j++) {
                for (int k = j+1; k < 5; k++) {
                    // cout << i << "," << j << "," << k << endl;
                    if (v[i] * v[j] * v[k] > 0) {
                        total += v[i] * v[j] * v[k];
                    }
                }
            }
        }
        cout << total << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  ll A,V,B,W,T;
  cin >> A >> V >> B >> W >> T;
  
  if((V-W)*T>=abs(A-B)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
using namespace std;
int a[100000];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
          int mmin=999999999;
    for(int i=1; i<=n; i++)
        {
        int sum1=0,sum2=0,q=1,p=n,sum;
            while(1)
            {
                sum1+=a[q];
                if(q==i)
                {//printf("%d ",sum1);
                    break;
                }
                    q++;
            }
            while(1)
            {
                sum2+=a[p];
                if(p==i)
                {
                    sum2-=a[i];
                    break;
                }
                p--;
            }
            if(sum1>sum2)
            {
                int t;
                t=sum1;
                sum1=sum2;
                sum2=t;
            }
            sum=sum2-sum1;
            if(sum<mmin)
                mmin=sum;
                //printf("%d\n",mmin);
        }
        printf("%d\n",mmin);
        return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>
using namespace std;



#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const double EPS = 1e-8;
const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 500 * 100 + 47;
const int LEN = 20;
const int ALP = 128;

char S[MAX];
int P[MAX];

int main()
{
    //freopen("in.txt", "r", stdin);
    LL a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k & 1)swap(a, b);
    cout << a-b << endl;
    
    
    return 0;
}


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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O2")
//#pragma GCC optimization ("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif

const int N = 200005;
int n;
long double ara[N];
map<pll,LL>mp;

int32_t main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    FastRead
    cin >> n;
    FOR(i,1,n){
        cin >> ara[i];
        LL x = llround(ara[i] * 1000000000LL);
        int two = 0, five = 0;
        while(x % 2 == 0){
            two++;x/=2;
        }
        while(x % 5 == 0){
            five++;x/=5;
        }
        mp[mk(two,five)]++;
    }
    vector<pll>vec;
    for(auto x : mp){
        vec.push_back(x.first);
    }
    LL ans = 0;
    for(int i = 0;i < (int)vec.size();i++){
        int t1 = vec[i].ff;
        int f1 = vec[i].ss;
        LL c1 = mp[mk(t1,f1)];
        if(t1 * 2 >= 18 and f1 * 2 >= 18){
            ans = (ans + (c1 * (c1 - 1))/2);
        }
        for(int j = i + 1;j < (int)vec.size();j++){
            int t2 = vec[j].ff;
            int f2 = vec[j].ss;
            LL c2 = mp[mk(t2,f2)];
            if(t1 + t2 >= 18 and f1 + f2 >= 18){
                ans = (ans + c1 * c2);
            }
        }
    }
    cout << ans << "\n";
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 6892
import numpy as np
n,k=map(int, input().split())  #複数数値入力

arr = np.arange(1,n+1)
arr_x = np.ceil(np.log2(k) - np.log2(arr))
arr_x[np.where(arr_x <= 0)] = 0
prob = ((1/n) * (0.5 ** arr_x)).sum()

print(prob)

Measured memory_bytes: 21408
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n;

int main(){
	cin>>n;
	vvl dp(2,vl(3));
	dp[0][0]=1;
	for(int i=60;i>=0;i--){
		vvl DP(2,vl(3));
		int B=(n&1ll<<i?1:0);
		for(int j=0;j<3;j++) for(int I=0;I<2;I++) for(int J=0;J<2;J++){
			int t=2*j+I-J;
			if(!J&&t>1) t-=2;
			if(t<0||2<t) continue;
			(DP[1][t]+=dp[1][j])%=mod;
			if(B>=I) (DP[(B>I?1:0)][t]+=dp[0][j])%=mod;
		}
		dp=DP;
	}
	cout<<(dp[0][0]+dp[1][0])%mod<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int m = s.length(), n = t.length();
    // dp[i][j]:s[0,i),t[0,j)での最長共通部分列の長さ
    vector<vector<int>> dp(m + 1, vector<int>(n + 1, 0));
    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++) {
            dp[i][j] = dp[i - 1][j - 1];
            if (s[i - 1] == t[j - 1]) dp[i][j]++;
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            dp[i][j] = max(dp[i][j], dp[i][j - 1]);
        }
    }
    int x = m, y = n;
    string ans = "";
    while (x > 0 && y > 0) {
        if (dp[x][y] == dp[x - 1][y])
            x--;
        else if (dp[x][y] == dp[x][y - 1])
            y--;
        else {
            ans = s[x - 1] + ans;
            x--, y--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 35584
#include <cstdio>

int main()
{
  int in[3];

  scanf("%d %d %d", &in[0], &in[1], &in[2]);

  for (int i = 0; i < 3; i++)
  {
    for (int j = i+1; j < 3; j++ )
    {
      if (in[i] > in[j])
      {
        int t = in[i];
        in[i] = in[j];
        in[j] = t;
      }
    }
  }

  printf("%d %d %d\n", in[0], in[1], in[2]);

  return 0;
}


Measured memory_bytes: 2764
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
  int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int main(){
    ll a,b,c;cin>>a>>b;
    rep(i,a-1){
      cin>>c;
      b=gcd(b,c);
    }
    cout<<b;
}


Measured memory_bytes: 23808
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int f(int tmp) {
  if (tmp == -1) return 0;

  if ((tmp + 1) % 2) {
    return ((((tmp + 1) / 2) % 2) ^ tmp);
  } else {
    return ((tmp + 1) / 2) % 2;
  }
}

signed main() {
  int A, B;
  cin >> A >> B;
  cout << (f(A - 1) ^ f(B)) << endl;
  return 0;
}


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

int main() {
  int n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  bool flag = true;
  sort(a.begin(), a.end());
  rep(i,n-1) {
    if (a[i] == a[i+1]) {
      cout << "NO" << endl;
      flag = false;
      break;
    }
  }
  if (flag == true) cout << "YES" << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main()
{
	long long a[100];
	long long max, bat,temp, temp1;
	bat = 10;
	for (int i = 1; i <= 10; i++)
		cin >> a[i];
	
	for (int i = 1; i <= 11; i++)
	{
		max = 0;
		for (int j = 1; j <= bat; j++)
			if(a[j] > max)
			{
				max = a[j];
				temp1 = j;
			}
		
		temp = a[bat];
		a[bat] = a[temp1];
		a[temp1] = temp;
		bat--;
		
	}
	for (int i = 10; i > 7; i--)
		cout << a[i] << endl;
	
}

Measured memory_bytes: 1156
/*
AizuOnline A0044
Title primes Number II

*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int n;


int primes[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
	      101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,
	      211,223,227,229,233,239,241};


//
int isprime(int n)
{
  int i;
  for(i=0;i<sizeof(primes)/sizeof(int);i++)
    if(n == primes[i])
      return(-1);
  else if(n % primes[i] ==0)
      return(0);
  return(-1);
}
main()
{
  int i;


  while(EOF != scanf("%d",&n) && n)
    {
      for(i=n-1;i>=2;i--)
	{
	  if(isprime(i))
	    {
	      printf("%d ",i);
	      break;
	    }
	}
      for(i=n+1;i<=2*n-1;i++)
	{
	  if(isprime(i))
	    {
	      printf("%d\n",i);
	      break;
	    }
	}
      

    }

return(0);
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <cstdlib>
#include <typeinfo>

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

using namespace std;

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;
}

void trace(int A[], int N) {
  for (int i = 0; i < N; ++i) {
    if (i > 0) cout << " ";
    cout << A[i];
  }
  cout << endl;
}

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

const unsigned long long INF = 1LL << 60;

string str_tolower(string s) {
  transform(s.begin(), s.end(), s.begin(),
            [](unsigned char c) { return tolower(c); });
  return s;
}

////////////////////////////////////////////////////////////

string S;
int m;
int h;

int main() {
  while (true) {
    cin >> S;
    if (S == "-") break;

    cin >> m;
    string p;
    string s = S;
    for (int i = 0; i < m; ++i) {
      cin >> h;
      p = s.substr(0, h);
      s.erase(0, h);
      s.insert(s.length(), p);
    }
    cout << s << endl;
  }
}



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

int main() {
  int N, K, X;
  cin >> N >>K;
  X = 1;
  
  for (int i = 0; i < N; i++) {
    if (X <= K) {
      X = X*2;
    }
    else {
      X = X + K;
    }
  }
  
  cout << X << endl;

}


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

#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end()); 
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
#define mod 1000000007

//ffs = lsb, clz = l0's, ctz = r0's, popcount = 1's 
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
    fastio();
    ll n,m ; cin >> n >> m;
    ll dp[n + 1];
    for(int i = 0 ; i < n ;++i){
        dp[i] = 0;
    }
    dp[0] = 1;
    dp[1] = 1;
    for(int i = 0; i < m ; ++i){
        int x;  cin >> x;
        dp[x] = -1;
    } 
    
    for(int i = 2 ; i <= n ; ++i){
        if(dp[i] >= 0){
            if(dp[i-1] < 0  && dp[i-2] < 0 ){
                return cout << "0\n" , 0;
            }
            if(dp[i-1] < 0){
                dp[i-2] = dp[i-2] % mod;
                dp[i] = dp[i-2];
            }else if(dp[i-2] < 0){
                dp[i-1] = dp[i-1] % mod;
                dp[i] = dp[i-1];
            }else{
                dp[i-1] = dp[i-1] % mod;
                dp[i-2] = dp[i-2] % mod;
                dp[i] = dp[i - 1] + dp[i - 2];
            }
            dp[i] = dp[i] % mod;
        }
    }

    return cout << dp[n] % mod, 0 ;
}

Measured memory_bytes: 1024
N, M = input().split(" ")

N = int(N)
M = int(M)

if N == 0:
  N += 1

data = 0

double_check_s = []
double_check_c = []
ng_flag = 0

for i in range(0, M):
  
  s, c = input().split(" ")
  
  if N != 1 and s == "1" and c == "0":
    ng_flag += 1
  elif s in double_check_s:
    if c != double_check_c[double_check_s.index(s)]:
      ng_flag += 1
  else:
    data += 10 ** (N - int(s)) * int(c)
  
  double_check_s.append(s)
  double_check_c.append(c)
  
if ng_flag != 0:
  print(-1)
elif N != 1 and data // 10 ** (N - 1) == 0:
  print(data + 10 ** (N - 1))
else:
  print(data)

Measured memory_bytes: 3064
n=int(input())
a=[int(i) for i in input().split()]

if len(set(a))>=3:
  print('No')
elif len(set(a))==1:
  if a[0]==n-1 or 1 <= a[0] <=n//2:
    print('Yes')
  else:
    print('No')
else:
  m=max(a)
  s=min(a)
  c=sum([1 for i in a if i==m])
  if n-m+1<=c<=n-(m-(n-m)) and s==m-1:
    print('Yes')
  else:
    print('No')

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

#define ll long long
const int mod = 1e9 + 7;
ll int INF = 1e17;

int dp[3005][3005];
string s1, s2;

int kil(int idx1, int idx2)
{
  if(idx1 == s1.length() || idx2 == s2.length())
    return 0;

  if(dp[idx1][idx2] != -1)
    return dp[idx1][idx2];

  if(s1[idx1] == s2[idx2])
    dp[idx1][idx2] = max(dp[idx1][idx2], kil(idx1+1, idx2+1) + 1);
  else
  {
    dp[idx1][idx2] = max(dp[idx1][idx2], kil(idx1, idx2+1));
    dp[idx1][idx2] = max(dp[idx1][idx2], kil(idx1+1, idx2));
  }
  return dp[idx1][idx2];
}


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string res="";

  memset(dp, -1, sizeof dp);
  cin>>s1>>s2;
  kil(0, 0);

  int idx1=0, idx2=0;

  while(idx1 != s1.length() && idx2 != s2.length())
  {
    if(s1[idx1] == s2[idx2])
    {
      res += s1[idx1];
      idx1 += 1;
      idx2 += 1;
    }
    else
    {
      if(dp[idx1][idx2] == dp[idx1+1][idx2] && dp[idx1][idx2] != -1)
        idx1 += 1;
      else
        idx2 += 1;
    }
  }

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


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

	


int main(){
    int n,x; cin>>n>>x;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    int d=0;
    int ans=0;
    for(int i=0;i<n;i++){
        ans++;
        d+=v[i];
        if(d>x){break;}
    }
    if(d<=x){ans++;}
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int Q;
	long long int a, b1, b, s, ans;
	scanf("%d", &Q);
	for(int i=0; i<Q; i++){
		scanf("%lld %lld", &a, &b);
		if(a<b){
			b1=b;
			b=a;
			a=b1;
		}
		long long int s1=b-1, s2=a+1;
		while(s1!=s2){
			long long int smid=(s1+s2+1)/2;
			if(smid*smid<a*b){
				s1=smid;
			}else{
				s2=smid-1;
			}
		}
		s=s1;
	
		if(a==b){
			ans=2*(b-1);
		}else if(a==b+1){
			ans=2*b-2;
		}else if(a==b+2){
			ans=2*b-1;
		}else if(a==4 && b==1){
			ans=1;
		}else if(s*(s+1)<a*b){
			ans=2*s-1;
		}else{
			ans=2*s-2;
		}
		printf("%lld\n", ans);
	}
	return 0;

}

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

int main() {
  // 命令の行数を取得
  //TとAも取得
  int N, T, A;
  cin >> N >> T >> A;
  int min = 0;
  int min_index = 0;
  

  for(int i = 1; i <= N; i++){
    int num;
    cin >> num;
    
    //温度の計算
    int difference_t;
    difference_t = abs((T*1000 - (num * 6)) -A*1000 );
    //if(difference_t<0) difference_t = -difference_t;
    //cout << difference_t << endl;
    if(i ==1){
      min = difference_t;
      min_index = i;
    }
    /*
    if((i != 0) & (difference_t > max)){
      max = num;
    }
    */
    if((i != 1) & (difference_t < min)){
      min = difference_t;
      min_index = i;
    }
  }
  cout << min_index << endl;
  
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    while True:
        n,r = map(int,input().split())
        if n == 0:
            return
        ans = list(range(n,0,-1))
        for _ in range(r):
            p,c = map(int,input().split())
            p -= 1
            ans = ans[p:p + c] + ans[:p] + ans[p + c:]
        print(ans[0])
if __name__ == '__main__':
    main()


Measured memory_bytes: 5620
# FizzBuzz Sum
N = int(input())
ans = ((1+N) * N)/2 - ((3 + 3*(N//3)) * (N//3))/2 - ((5 + 5*(N//5)) * (N//5))/2 + ((15 + 15*(N//15)) * (N//15))/2
print(int(ans))

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    int last = -1;
    int count = 0;
    for(;0 < N;N /= 10) {
        int n = N%10;
        if(n == last) {
            count++;
        }else{
            count = 1;
        }
        if(3 <= count) {
            cout << "Yes" << endl;
            return 0;
        }
        last = n;
    }
    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
/// by ztx
/// blog.csdn.net/hzoi_ztx
#include <bits/stdc++.h>
#define  Rep(i,l,r) for(i=(l);i<=(r);i++)
#define  rep(i,l,r) for(i=(l);i< (r);i++)
#define  Rev(i,r,l) for(i=(r);i>=(l);i--)
#define  rev(i,r,l) for(i=(r);i> (l);i--)
#define _Rep(i,l,r) for(int i=(l);i<=(r);i++)
#define _rep(i,l,r) for(int i=(l);i< (r);i++)
#define _Rev(i,r,l) for(int i=(r);i>=(l);i--)
#define _rev(i,r,l) for(int i=(r);i> (l);i--)
#define Each(i,v)   for(i=v.begin();i!=v.end();i++)
#define r(x) read(x)
typedef long long ll;
typedef double lf;
typedef unsigned uint;
typedef std::pair<int,int> pii;
int CH, NEG;
template <typename TP>inline void read(TP& ret) {
    ret = NEG = 0; while (CH=getchar(), CH<'!');
    if (CH == '-') NEG = true, CH = getchar();
    while (ret = ret*10+CH-'0', CH=getchar(), CH>'!');
    if (NEG) ret = -ret;
}

#define kN 5010LL

int n;
char s[kN];
int ans = 0;

int f[kN][kN];
/*
对自己求最长公共子串，在对角线的两侧寻找答案
*/

int main() {
    r(n);
    scanf("%s", s+1);
    _rep(i,1,n) _Rep(j,i+1,n)
        if (s[i] == s[j]) {
            f[i][j] = f[i-1][j-1]+1;
            ans = std::max(ans, std::min(f[i][j], j-i));
        }
    printf("%d\n", ans);
    END: getchar(), getchar();
    return 0;
}

Measured memory_bytes: 96896
import math
from string import ascii_lowercase
 
line = input()
w, h, n = [int(x) for x in line.split()]
xl = 0
xr = w
yl = 0
yr = h
for i in range(n):
	line = input()
	x, y, t = [int(x) for x in line.split()]
	if (t == 1):
		xl = max(xl, x)
	elif (t == 2):
		xr = min(xr, x)
	elif (t == 3):
		yl = max(yl, y)
	else:
		yr = min(yr, y)
	
print(max(xr - xl, 0) * max(yr - yl, 0))

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

int main(){
  int N, K;
  cin >> N >> K;
  int ans = 0;
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    if((x * 2) < ((K - x) * 2)) ans += x * 2;
    else ans += (K - x) * 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	string S;
	cin >> S;
	
	for (int i = 2; i < S.length(); i += 2){
		int subLength = (S.length() - i) >> 1;
		string sub1 = S.substr(0, subLength);
		string sub2 = S.substr(subLength, subLength);
		if (sub1 == sub2){
			cout << (subLength << 1) << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vector<T>>;
using vl = vector<ll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl A(N);
    ld a = 0, d = INF;
    ll ans;
    rep(i, N) {
        cin >> A[i];
        a += A[i];
    }
    a /= N;
    rep(i, N) {
        if (abs(A[i] - a) < d) {
            d = abs(A[i] - a);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())

cnt=0
ans=0

for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        cnt+=1
    
    else:
        ans=max(ans,cnt)
        cnt=0

ans=max(ans,cnt)


if ans>=3:
    print('Yes')

else:
    print('No')

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

int a[3010];
long long dp[3010][3010];
int vis[3010][3010];
int n;

long long dfs(int l, int r){
	if (l == r) return n & 1 ? a[l] : -a[l];
	if (vis[l][r]) return dp[l][r];
	vis[l][r] = 1;
	int p = (n - (r - l + 1)) & 1;
	if (p == 0) dp[l][r] = max(dfs(l + 1, r) + a[l], dfs(l, r - 1) + a[r]);
	else dp[l][r] = min(dfs(l + 1, r) - a[l], dfs(l, r - 1) - a[r]);
	return dp[l][r];
}

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	printf("%lld\n", dfs(0, n - 1));
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = (int)2e5 + 9;
int dr[N];
char f[N];

int main(){
  fastIO;
  int n, k, c;
  cin >> n >> k >> c;
  for(int i = 1; i <= n; i ++ )
    cin >> f[i];
  int p = n;
  for(int i = n; i >= 1; i -- ){
    dr[i] = dr[i + 1];
    if(i <= p && f[i] == 'o'){
      dr[i] ++ ;
      p = i - c - 1;
    }
  }
  if(dr[1] != k){
    return 0;
  }
  p = 1;
  int cnt = 0;
  for(int i = 1; i <= n; i ++ ){
    if(i >= p && f[i] == 'o'){
      if(cnt + dr[i + 1] < k)
        cout << i << "\n";
      cnt ++ ;
      p = i + c + 1;
    }
  }
  return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		for(int i=0;i<5;i++){
			int a = sc.nextInt();
			if(a<40){
				a = 40;
			}
			sum += a;
		}
	    System.out.println(sum/5);
	}

}

Measured memory_bytes: 26156
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();
		
		HashMap<Integer, Integer> count = new HashMap<>();
		for(int i=0; i<N; i++) {
			int A = sc.nextInt();
			Integer countA = count.get(A);
			if(countA==null)
				countA=0;
			
			count.put(A, countA+1);
		}
		Integer[] value = count.values().toArray(new Integer[0]);
		Arrays.sort(value);
		int ans = 0;
		for(int i=0; i<value.length-K; i++)
			ans += value[i];
		
		System.out.println(ans);
				
		sc.close();
	}
}


Measured memory_bytes: 101080
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while(b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if(u < 0)
    u += MOD;
  return u;
}

int main() {
  int x, y, ex, ey, d;
  cin >> x >> y;
  ex = x;
  ey = ex * 2 + 3;
  for(ex; ex >= 0; ex -= 2) {
    ey -= 3;
    if(ey == y)
      break;
  }
  if(ex < 0) {
    cout << 0 << endl;
    return 0;
  }
  d = (x - ex) / 2;
  ll out, c = 1, d1 = 1, d2 = 1;
  for(int i = 0; i < d + ex; i++) {
    c *= i + 1;
    c %= MOD;
    if(i + 1 == ex)
      d1 = c;
    if(i + 1 == d)
      d2 = c;
  }
  out = c * modinv(d1) % MOD * modinv(d2) % MOD;
  cout << out << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll x,k,d;
	cin>>x>>k>>d;
	
	if (x<0) x=-x;
	
	if (x/d>=k){
		x-=k*d;
		cout<<x;
		return 0;
	}
	
	k-=x/d;
	x=x%d;
	
	if (k%2==0) cout<<x; else cout<<d-x;
}

Measured memory_bytes: 3684
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd

from collections import Counter


def solve(S: str):
    c = Counter(S)
    c.setdefault('1', 0)
    c.setdefault('0', 0)
    return 2 * min(c.values())


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = (next(tokens))  # type: str
    result = solve(S)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5332
function main(input) {
  const n = Number(input.trim());
  let result = 1;
  for (let i = 0; i < n; i++) {
    result *= i+1;
    result %= 10**9 + 7;
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define long long long
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;


signed main()
{
  int N, K;
  int T = 0;
  scanf("%d %d", &N, &K);

  for (int i = 0; i < K; ++i) {
    int n; scanf("%d", &n);
    T |= (1 << n);
  }

  for (int i = 0; i < (1 << N); ++i) {
    if ((i & T) != T) continue;

    printf("%d:", i);

    for (int j = 0; j < N; ++j) {
      if((i>>j) & 1) printf(" %d", j);
    }
    puts("");
  }

  return 0;
}




Measured memory_bytes: 3212