akhauriyash/Code-Regression huggingface dataset:
import sys
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    S = list(map(int, in_s()))
    N = len(S)
    K = in_n()

    one_i = -1
    for i in range(N):
        if S[i] == 1:
            one_i = i
        else:
            break

    if K <= one_i + 1:
        print(1)
    else:
        ind = min(N - 1, one_i + 1)
        print(S[ind])


if __name__ == '__main__':
    main()


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

int main() {
  int N,M;
  cin >> N;
  vector<string> s(N);
  
  for(int i = 0; i < s.size(); i++){
    cin >> s.at(i);
  }
  
  cin >> M;
  vector<string> t(M);
  for(int i = 0; i < t.size(); i++){
    cin >> t.at(i);
  }
  
  // 同じ文字列が何個あるか数えて、配列に格納
  vector<int> cnt(N);
  for(int i = 0; i < s.size(); i++){
    for(int j = 0; j < s.size(); j++){      
      if(s.at(i) == s.at(j)){
        cnt.at(i)++;
      }
    }
    
    for(int j = 0; j < t.size(); j++){
      if(s.at(i) == t.at(j)){
        cnt.at(i)--;
      }
    }
  }
  
  // 
  int ans = 0;
  for(int i = 0; i < cnt.size(); i++){
    if(ans < cnt.at(i)){
      ans = cnt.at(i);
    }
  }
  
  if(ans < 0){
    cout << 0 << endl;
  }else{
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 2147483647

struct Seg {
	int btms;//bottom size
	int trs;//tree size
	vector<int> tree;

};

Seg seg;
int n,q;

void init(int N) {
	int btmsiz = 1;
	while (btmsiz < N) (btmsiz <<= 1);
	seg.btms = btmsiz;
	seg.trs = 2 * seg.btms - 1;
	for (int i = 0; i < seg.trs; i++) 
		seg.tree.push_back(inf);
	return;
}

void update(int id, int x) {
	id += seg.btms - 1;
	seg.tree[id] = x;
	while (id) {
		id = (id - 1) / 2;
		seg.tree[id] = min(seg.tree[id * 2 + 1], seg.tree[id * 2 + 2]);
	}
	return;
}

int RMQ(int l, int r, int nl, int nr, int nid) {
	if (l<=nl && nr<=r) {//completely wrapped
		return seg.tree[nid];
	}
	else if (nr<=l || r<=nl) {//conpletely unwrapped
		return inf;
	}
	else {
		int tmp;
		tmp = min(RMQ(l, r, nl, (nl + nr) / 2, nid * 2 + 1), 
			RMQ(l, r, (nl + nr) / 2, nr, nid * 2 + 2));
		return tmp;
	}
}

int main() {
	cin >> n >> q;
	init(n);
	for (int i = 0; i < q; i++) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com) {//find
			cout << RMQ(x, y + 1, 0, seg.btms, 0) << endl;
		}
		else {//update
			update(x, y);
		}
	}
	return 0;
}



Measured memory_bytes: 3916
class UF():
  def __init__(self, N):
    self._parent = [n for n in range(0, N)]
    self._size = [1] * N

  def find_root(self, x):
    if self._parent[x] == x: return x
    self._parent[x] = self.find_root(self._parent[x])
    return self._parent[x]

  def unite(self, x, y):
    gx = self.find_root(x)
    gy = self.find_root(y)
    if gx == gy: return

    if self._size[gx] < self._size[gy]:
      self._parent[gx] = gy
      self._size[gy] += self._size[gx]
    else:
      self._parent[gy] = gx
      self._size[gx] += self._size[gy]

  def size(self, x):
    return self._size[self.find_root(x)]

  def samegroup(self, x, y):
    return self.find_root(x) == self.find_root(y)

  def groupnum(self):
    N = len(self._parent)
    ans = 0
    for i in range(N):
      if self.find_root(i) == i:
        ans += 1
    return ans

n,m=map(int,input().split())
UF=UF(n)
for i in range(m):
  x,y,z=map(int,input().split())
  UF.unite(x-1,y-1)
print(UF.groupnum())

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

int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  rep(i, N) cin >> D.at(i);
  sort(D.begin(), D.end());
  cout << D.at(N/2)-D.at(N/2-1) << endl;
}

Measured memory_bytes: 640
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
t,a = iim()
H = iil()
mdif = 10**9
ans = 0
for i,item in enumerate(H):
    tem = t - item*0.006
    if abs(tem - a) < mdif:
        ans = i+1
        mdif = abs(tem - a)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

int main(){
	int a[30] = {}, b;
	
	REP(i, 28){
		cin >> b;
		a[b - 1] = 1;
	}
	
	REP(i, 30){
		if(!a[i]){
			cout << i + 1 << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
sa = input()
sb = input()
sc = input()

head = sa[0]
sa = sa[1:]

while (len(sa) >= 0 and len(sb) >= 0 and len(sc) >= 0):
    if head == "a" and len(sa) == 0:
        print("A")
        break
    elif head == "a":
        head = sa[0]
        sa = sa[1:]
    elif head == "b" and len(sb) == 0:
        print("B")
        break
    elif head == "b":    
        head = sb[0]
        sb = sb[1:]
    elif head == "c" and len(sc) == 0:
        print("C")
        break
    elif head == "c":
        head = sc[0]
        sc = sc[1:]

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second
using ll = long long;
using P = pair<ll ,ll>;
using Tu = tuple<ll, ll, ll>;
const ll INFLL = 1LL<<60LL;
const ll INF = 1LL<<60LL;
const ll MOD = 1e9+7;



using ld = long double;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

ll powmod(ll a, ll n){
  if(n == 0)
    return 1;
  ll x = powmod(a, n/2);
  if(n % 2)
    return x * x % MOD * a % MOD;
  else
    return x * x % MOD;
}

ll inv(ll x){
  return powmod(x, MOD-2);
}

vector<ll> fact;
vector<ll> ifact;

ll comb(ll n, ll r){
  return fact[n] * ifact[n-r] % MOD * ifact[r] % MOD;
}

int main(){
  ll H, W, A, B;
  cin >> H >> W >> A >> B;
  fact.assign(H + W + 10, 1);
  ifact.assign(H + W + 10, 1);
  for(ll i = 1;i < fact.size();i++){
    fact[i] = (fact[i-1] * i) % MOD;
    ifact[i] = inv(fact[i]);
  }
  ll all = comb(H - 1 + W - 1, H - 1);
  for(int y=H-A;y<H;y++){
    ll now = comb(y + B - 1, y);
    ll rest = comb(H - 1 - y + W - 1 - (B - 1) - 1, H - 1 -y);
    //cout << now << " " << rest << endl;
    all = (all - (now * rest % MOD) + MOD) % MOD;
  }
  cout << all << endl;
}


Measured memory_bytes: 3328
n = int(input())
li = list(map(int, input().split()))
res = -1
for i in range(101):
  sum = 0
  if i == 0:
    pass
  else:
    for j in range(n):
      sum = sum + (li[j]-i)**2
    if res == -1:
      res = sum
    elif res > sum:
      res = sum
print(res)

Measured memory_bytes: 3060
module ABC126

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_B
  private :: extract_data
  private :: is_month
  private :: write_format

  ! constants for this <module>
  integer(INT32), parameter, private :: len_string_max = 4_INT32

  ! variables for this <module>
  character(len=len_string_max, kind=1), private :: given_string
  integer(INT32),                        private :: data_first
  integer(INT32),                        private :: data_second

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_B

    ! STEP.01
    ! read out the given string
    read(unit=INPUT_UNIT, fmt='(A)') given_string

    ! STEP.02
    ! convert the given string to two integers
    call extract_data

    ! STEP.03
    ! judge & output the format of the given data
    if ( is_month(data_first) )  then
      if ( is_month(data_second) ) then
        call write_format('AMBIGUOUS')
      else
        call write_format('MMYY')
      end if
    else
      if ( is_month(data_second) ) then
        call write_format('YYMM')
      else
        call write_format('NA')
      end if
    end if

    ! STEP.END
    return

  end subroutine task_B

  subroutine extract_data

    read(unit=given_string(1:2), fmt='(I2)') data_first
    read(unit=given_string(3:4), fmt='(I2)') data_second

    return

  end subroutine extract_data

  pure function is_month (val) result(stat)

    ! arguments for this <function>
    integer(INT32), intent(in) :: val

    ! return value of this <function>
    logical :: stat

    stat = 1_INT32 .le. val .and. val .le. 12_INT32
    return

  end function is_month

  subroutine write_format (format)

    ! arguments for this <subroutine>
    character(len=*, kind=1), intent(in) :: format

    write(unit=OUTPUT_UNIT, fmt='(A)', advance='yes') format
    return

  end subroutine write_format

end module ABC126


program main

  ! <module>s to import
  use, non_intrinsic :: ABC126

  ! require all variables to be explicitly declared
  implicit none

  call task_B

end program main

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<int, int>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
using namespace std;
const ll inf = 1e9 + 5;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

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

    vector<int> dp(n, inf);
    dp[0] = 0;
    for (int i=0; i<n; i++)
        for (int j : {i+1, i+2})
            if (j < n)
                dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
    cout << dp[n-1] << '\n';
    return 0;
}


Measured memory_bytes: 1024
n=int(input())
al=[chr(97+ i) for i in range(26)]
def f(n):
    ans=""
    while n>0:
        ans+=str(al[n%26-1])
        
        if n%26==0:
            n//=26
            n-=1
        else:n//=26    
    return ans[::-1]
print(f(n))

Measured memory_bytes: 9180
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		String[] in = null;
		int a, b;

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		String line = null;
		try {
			while((line = input.readLine()) != null) {
				in = line.split(" ");
				a = Integer.valueOf(in[0]);
				b = Integer.valueOf(in[1]);
				System.out.println(String.valueOf(a+b).length());
			}
		} catch (NumberFormatException e) {
			System.out.println(line + "は整数でないものが含まれる");
		} catch (IOException e) {
			System.out.println("入出力例外");
		}
	}

}


Measured memory_bytes: 24336
def comb(k,r):
  """kCpを求める"""
  if k<0 or r<0 or r>k: return 0
  elif k==0 or r==0: return 1
  else:
    return (X[k]*Y[r]*Y[k-r])
  
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
n = int(input())
a = list(map(int,input().split()))
p=10**9+7
ans=0
X=[1]  #階乗テーブル
for i in range(1,n+2):
  X+=[ (X[-1]*i) %p ]
Y=[1]*(n+2)  #階乗の逆元テーブル
Y[n+1]=power_func(X[n+1],p-2,p)
for i in range(n,-1,-1):
  Y[i]=Y[i+1]*(i+1) %p

#ダブりをみつける
check = [0]*n
for i in range(n+1):
  if check[a[i]-1]==1: dub = a[i]
  else: check[a[i]-1] = 1

indexes = [i for i, x in enumerate(a) if x == dub]
ind1, ind2  = indexes[0], indexes[1]

for i in range(1,n+2):
  ans = comb(n+1, i)
  if ind1 + n -ind2 +1 >= i:
    ans -= comb(ind1 + n -ind2, i-1)
  print(ans%p)

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;
const double PI = 3.1415926535897932384626433832;



double a,b,x;

bool safe(double ang) {
    double vol = a*a*b;
    double h = tan(ang)*a;
    if (h <= b) {
	double tri = (0.5*a*h)*a;
	return vol-tri >= x;
    } else {
	ang = PI/2 - ang;
	double y = b*tan(ang);
	double tri = 0.5*y*b*a;
	return tri >= x;
    }
}

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

    cin>>a>>b>>x;


    double lo = 0;
    double hi = PI/2;


    for (int iter=0; iter<1000; iter++) {
	double mid = (lo+hi)/2;
	if (safe(mid)) {
	    lo = mid;
	} else {
	    hi = mid;
	}
    }

    double deg = lo*180.0/PI;
    cout<<fixed<<setprecision(15)<<deg<<endl;
    return 0;
}


Measured memory_bytes: 4268
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a[100005] = {}, b[100005] = {};
    cin >> a[1]; b[a[1]] = 1;
    for (int i = 2; ; i++) {
        if (a[i - 1] % 2) a[i] = a[i - 1] * 3 + 1;
        else a[i] = a[i - 1] / 2;
        if (b[a[i]]) {
            cout << i;
            return 0;
        }
        b[a[i]] = 1;
    }
}


Measured memory_bytes: 1024
from sys import stdin
rs = stdin.readline
ri = lambda : int(rs())
ril = lambda : list(map(int, rs().split()))

def main():
    N = ri()
    c = rs()
    x = 0
    y = c.count('R')

    for e in c:
        if x == y:
            break
        elif e == 'W':
            x += 1
        else:
            y -= 1

    print(y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9356
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string a,b,c;
    cin>>a>>b>>c;
    if(a.back()==b.front() and b.back()==c.front()){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
const int N= 3e5;
int Mod = 1e9+7 ;
long long cum [N];

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    char C[H][W];

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> C[i][j];
        }
    }

    int ans = 0;
    int count;
    for (int ibit = 0; ibit < (1 << H); ++ibit) {
        for (int jbit = 0; jbit < (1 << W); ++jbit) {
            count = 0;

            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    if( ( ibit & (1<<i) ) || ( jbit & (1<<j) ) ) continue;
                    if( C[i][j]=='#' ) count++;
                }
            }
            if( count == K ) ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  string S;
  cin>>S;
  int ans=0;
  int count=0;
  for(int i=0;i<(int)S.size();i++){
    if(i==0){
      if(S.at(i)=='A' || S.at(i)=='G' || S.at(i)=='C' || S.at(i)=='T'){
        count++;
        ans=max(count,ans);
      }
    }
    else{
      if(S.at(i)=='A' || S.at(i)=='G' || S.at(i)=='C' || S.at(i)=='T'){
        count++;
        ans=max(count,ans);
      }
      else{
        ans=max(count,ans);
        count=0;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3608
n, x = map(int, input().split())
l_list = []
l_list.append(0)
l_list[1:] = list(map(int, input().split()))
ans = 1
d = 0
for i in range(1, n+1):
  d = d + l_list[i]
  if d > x:
    break
  ans += 1

print(ans)

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

const int MOD = 1e9+7;

int fac(int a ){
  if( a == 0 ){ return 1LL;}
  else{ return ( a*fac(a-1) )%MOD;}
}

signed main(void){
  
  int N; cin >> N;
  string S; cin >> S;
  vector<bool> vec(2*N,false);
  // false　がL、trueがRにそれぞれ対応
  
  int ans = 1LL;
  
  int left = 1; int right = 0;
  
  for(int i = 1; i < 2*N; i++){
    if( S[i-1] != S[i] ){ vec[i] = vec[i-1];}
    else{ vec[i] = !vec[i-1];}
    
    if( vec[i] ){ right++;}
    else{ left++;}
    
  }
  
  if( !vec[2*N-1] || left != right ){ cout << 0 << endl; return 0;} //このような塗り方は不可能
  if( S.front() == 'W' || S.back() == 'W' ){ cout << 0 << endl; return 0;} 
  
  int l = 0;
  
  for(int i = 0; i < 2*N; i++){
    if(!vec[i]){ l++;}
    else{ ans *= l;  l--;}
    
    ans %= MOD;
  }
  
  cout << ( ans*fac(N) )%MOD<< endl;
  
  return 0;
}

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

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

	vector<int> a(n), b(n), c(n);

	vector<int> temp;
	{
		int pre = -2;
		for (int i = 0; i < n; ++i) {
			cin >> a[i];
			if (pre == (a[i] - 1)) {
				temp.push_back(pre - 1);
			}
			pre = a[i];
		}
	}
	int ret = 0;
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
		ret += b[i];
	}
	for (int i = 0; i < n-1; ++i) {
		cin >> c[i];
	}

	for (int t : temp) {
		ret += c[t];
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i, j;
    int h, w;
    
    while(scanf("%d %d", &h, &w), h > 0 && w > 0){
        for(i = 0; i < h; ++i){
            for(j = 0; j < w; ++j){
                putchar('#');
            }
            
            putchar('\n');
        }
        
        putchar('\n');
    }
    
    return 0;
}


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

int main(void){
	int ans=0;
	while(1){
		string s;
		cin >> s;
		if(cin.eof())break;
		int n=s.size();
		bool ok=true;
		rep(i,n/2) if(s[i]!=s[n-1-i]) ok=false;
		ans+=ok;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1188
// https://atcoder.jp/contests/abc169/tasks/abc169_e
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int const maxn = 2e5;
int A[maxn], B[maxn];

int main() {
    int N;
    cin >> N;
    rep(i, N) cin >> A[i + 1] >> B[i + 1];
    sort(A + 1, A + N + 1);
    sort(B + 1, B + N + 1);
    if (N % 2 == 1) {
        cout << B[(N + 1) / 2] - A[(N + 1) / 2] + 1 << '\n';
    } else {
        cout << (B[N / 2] + B[N / 2 + 1] - A[N / 2] - A[N / 2 + 1]) + 1 << '\n';
    }
}


Measured memory_bytes: 5136
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    al = [chr(i) for i in range(97, 97 + 26)]
    s = str(readline().rstrip().decode('utf-8'))
    k = int(readline())
    ans = collections.defaultdict(int)
    for alv in al:
        for i, v in enumerate(s):
            if alv == v:
                for j in range(i + 1, i + k + 1):
                    ans[s[i:j]]
        if len(ans) > k:
            break
    print(sorted(ans.items())[k-1][0])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39792
#include <iostream>

using namespace std;

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

    for (int i = 0; i < m / 2; i++) {
        cout << i + 1 << " " << m - i + (m + 1) % 2 << endl;
    }
    for (int i = 0; i < m / 2 + m % 2; i++) {
        cout << i + m + (m + 1) % 2 + 1 << " " << 2 * m - i + 1 << endl;
    }
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,M;
  cin>>N>>M;
  VL A(M),B(M),C(M);
  rep(i,M) cin>>A[i]>>B[i]>>C[i];
  VVL D(N,VL(N));
  rep(i,N) rep(j,N) if(i!=j) D[i][j]=1001001001001001001;
  rep(i,M){
    D[A[i]-1][B[i]-1]=C[i];
    D[B[i]-1][A[i]-1]=C[i];
  }
  rep(k,N) rep(i,N) rep(j,N) D[i][j]=min(D[i][j],D[i][k]+D[k][j]);
  int ans=M;
  rep(k,M){
    int F=0;
    rep(i,N) rep(j,N) if(D[i][j]==D[i][A[k]-1]+D[B[k]-1][j]+C[k]) F=1;
    if(F) ans--;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int x,k,d;
	cin >> x >> k >> d;
	int steps = abs(x)/d;
	if(steps >= k){
		cout << (abs(x) - k*d) << "\n";
		return 0;
	}
	k -= steps;
	int vac = abs(x)%d;
	if((k%2) == 0){
		cout << vac;
	}else{
		cout << abs(vac - d);
	}
}
//.........

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main(){
    int n,x;
    int count = 0;
    while(true){
        cin >> n >> x;
        if(n == 0 && x == 0) return 0;
        int count = 0;
        for(int i = 1; i <= n; i++){
            for(int j = i + 1; j <= n; j++){
                for(int k = j + 1; k <= n; k++){
                    if(i + j + k == x)count++;
                }
            }
        }
            print(count);
    }
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    string S, I, J;
    cin >> S;
    cin >> I;
    cin >> J;
    for(int i = 0; i < 3; ++i){
        if(i == 0)
            cout << S[i];
        else if(i == 1)
            cout << I[i];
        else
            cout << J[i];
    }
    return 0;
}

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

using namespace std;

template <typename A, typename B>string to_string(pair<A, B> p);

template <typename A, typename B, typename C> string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D> string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {return '"' + s + '"';}

string to_string(const char* s) {return to_string((string) s);}

string to_string(bool b) {return (b ? "true" : "false");}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p) {return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}

template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p) {return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

typedef unsigned long long ull;
typedef long long int lli;
typedef pair <int,int> ii;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long MOD = 1e9 + 7;
	long s; cin >> s;
	vector <long> dp(s+1);
	dp[0] = 1; 
	long x = 0;
	for (int i = 1; i < s + 1; i++){
		for (int j = 0; j < (i-3) + 1; j++){
			dp[i] += dp[j];
			dp[i] %= MOD;
		}
	}	
	cout << dp[s];
    return 0;
}

Measured memory_bytes: 3660
# coding: utf-8
import itertools

N, M = list(map(int, input().split(" ")))
k = []
for _ in range(M):
    k.append(list(map(int, input().split(" "))))
p = list(map(int, input().split(" ")))

bits = itertools.product(["on", "off"], repeat=N)

def tento(bit, k, p):
    for i, pi in enumerate(p):
        ki = list(k[i])
        tmp = 0
        for kij in ki[1:]:
            if bit[kij-1] == "on":
                tmp += 1
        if tmp % 2 != pi:
            return False
    return True

res = 0
for bit in bits:
    if tento(bit, k, p):
        res+=1
print(res)

Measured memory_bytes: 9232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

int main() {
  char s[222];
  cin >> s;
  int n = strlen(s);
  for(int i=n-2;i>=0;i-=2){
    if(strncmp(s,s+i/2,i/2)==0){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3652
#include <iostream> // cout, endl, cin
#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

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repk(i,k,n) for (ll i = k; i <= (int)(n); i++)
#define MAX 10000
typedef long long ll;

using namespace std;

int cnt,ans;

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

    vector<ll> H(N);
    ll max=0;
    rep(i,N){
        cin >> H.at(i);
        if(i!=0){
            if(H.at(i-1) >= H.at(i)){
                cnt++;
            }
            else{
                if(max<cnt) max = cnt;
                cnt = 0;
            }
        }
        if(i == N-1){
            if(max<cnt) max = cnt;
            cnt = 0;
        }
    }

    cout << max << endl;

    return 0;
}

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

template<class T, class E, class C = std::less<T>>
struct SkewHeap {
    using F = function<T(T, E)>;
    using G = function<E(E, E)>;
    using value_type = T;
    using operation_type = E;
private : 
    C compare;
    const F f;
    const G g;
    const E ie;
    int sz;

    struct node_data {
    public : 
        value_type val;
        operation_type add;
        unique_ptr<node_data> left_node, right_node;
        node_data(const value_type &val, const operation_type &add) :
            val(val), add(add), left_node(nullptr), right_node(nullptr) { }
    };

    using node_type = unique_ptr<node_data>;

    node_type root;

public : 
    SkewHeap() : f([](const T &a, const E &b) { return (a + b); }),
                 g([](const E &a, const E &b) { return (a + b); }),
                 ie(E()) { }

    SkewHeap(const F &f, const G &g, const E &ie) : f(f), g(g), ie(ie), root(nullptr), sz(0) { }

    node_type propagate(node_type node) {
        if (node == nullptr) return (move(node));
        if (node->add == ie) return (move(node));
        if (node->left_node) {
            node->left_node->add = g(node->left_node->add, node->add);
        }
        if (node->right_node) {
            node->right_node->add = g(node->right_node->add, node->add);
        }
        node->val = f(node->val, node->add);
        node->add = ie;
        return move(node);
    }

    node_type meld(node_type a, node_type b) {
        if (not a) return b;
        if (not b) return a;
        if (compare((b->val), (a->val))) a.swap(b);
        a = propagate(move(a));
        a->right_node = meld(move(a->right_node), move(b));
        a->left_node.swap(a->right_node);
        return a;
    };

    int size() const noexcept {
        return size_t(sz);
    }

    bool empty() const noexcept {
        return (sz == 0);
    }

    void insert(const value_type &x) {
        root = propagate(move(root)); sz++;
        root = meld(move(root), make_unique<node_data>(move(node_data(x, ie))));
    }

    value_type& top() {
        assert(not empty());
        root = propagate(move(root));
        return (root->val);
    }

    value_type pop() {
        const value_type top_value = top(); sz--;
        root = meld(move(root->left_node), move(root->right_node));
        return top_value;
    }

    void add(const operation_type &x) noexcept {
        if (root) root->add = g(root->add, x);
    }

    void meld(SkewHeap &skew) {
        sz += skew.sz; skew.sz = 0;
        root = meld(move(root), move(skew.root));
    }

};

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

    SkewHeap<int, int, greater<int>> skew;

    for (int i = 0; i < n; i++) {
        int e;
        cin >> e;
        skew.insert(e);
    }

    for (int i = 0; i < m; i++) {
        int e = skew.pop();
        skew.insert(e / 2);
    }

    long long ans = 0;
    while (skew.size()) ans += skew.pop();

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(X) (X).begin(),(X).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    map<ll, ll> mp;
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    ll all = 0;
    for(int i = 1; i <= n; ++i){
      all+=(mp[i]*(mp[i]-1))/2;
    }
    rep(i,n) {
        ll ans = 0;
        ans = all - (mp[a[i]]-1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 15872
var n,a,b,s,i,x,m:Longint;
begin
	read(n,a,b);
	for i:=1 to n do begin
		x:=i;
		m:=0;
		while x>0 do begin
			m:=m+x mod 10;
			x:=x div 10;
		end;
		if (a<=m)and(m<=b)then s:=s+i;
	end;
	writeln(s);
end.


Measured memory_bytes: 128
import java.io.IOException;
import java.util.Scanner;
public class Main {
    public static void main (String args[]) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	StringBuilder sb = new StringBuilder();
    	StringBuilder sa = new StringBuilder();
    	while(true){

    		int a = sc.nextInt();
    		String op = sc.next();
    		int b = sc.nextInt();
    		if(op.equals("?")){
    			break;
    		}else{
    	        if(op.equals("+")){
    	        	int i = a+b;
	                sb.append(i).append("\n");
    	        }
                if(op.equals("-")){
                	int i = a-b;
	                sb.append(i).append("\n");
    	        }
                if(op.equals("*")){
                	int i = a*b;
	                sb.append(i).append("\n");
    	        }
                if(op.equals("/")){
	                  int i = a/b;
	                  sb.append(i).append("\n");
                }
    		}
    	}
    	System.out.print(sb);
    }

}

Measured memory_bytes: 26180
N,K=map(int,input().split())
ans = 0
#でた目をiとし出た目ごとに処理する
for i in range(1,N+1):
    count = 0
    kakuritu = 1/N
    while i < K :
        i = i *2
        kakuritu = kakuritu /2
    
    ans += kakuritu

print(ans)


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


int main() {
  ll n;
  cin>>n;
  vector<ll> a(n);
  vector<ll> b(n,0);

  rep(i,n)cin>>a[i];
  ll cnt=0;
  for(ll i=n-1;i>=0;i--){
    ll now=i;
    ll s=0;
    while(now<=n-1){
      s+=b[now];
      now+=(i+1);
    }
    if ((s+a[i])%2==1){
      b[i]=1;cnt++;
    }
  }
  cout<<cnt<<endl;
  rep(i,n){
    if (b[i]==1){
      cout<<i+1<<endl;
    }
  }

}


Measured memory_bytes: 6380
main :: IO ()
main = putStr . solve =<< map read . words <$> getLine

solve :: [Int] -> String
solve [x, y]
    | elem x g1 && elem y g1 = "Yes"
    | elem x g2 && elem y g2 = "Yes"
    | elem x g3 && elem y g3 = "Yes"
    | otherwise = "No"

g1 :: [Int]
g1 = [1, 3, 5, 7, 8, 10, 12]

g2 :: [Int]
g2 = [4, 6, 9, 11]

g3 :: [Int]
g3 = [2]

Measured memory_bytes: 508
dat = raw_input()
(W,H,N) = dat.split(" ")
W = int(W)
H = int(H)
N = int(N)

data = [[0 for y in range(H)] for x in range(W)]

for a in range(0,N):
  dat = raw_input()
  (x,y,a) = dat.split(" ")
  x = int(x)
  y = int(y)
  a = int(a)
  if a == 1:
    for a in range(0,x):
      for b in range(0,H):
        data[a][b] = 1
  elif a == 2:
    for a in range(x,W):
      for b in range(0,H):
        data[a][b] = 1
  elif a == 3:
    for a in range(0,W):
      for b in range(0,y):
        data[a][b] = 1
  elif a == 4:
    for a in range(0,W):
      for b in range(y,H):
        data[a][b] = 1
ans = 0
for x in data:
  ans += x.count(0)

print ans


Measured memory_bytes: 2696
//atcoder 002 E Candy Piles 博弈论 
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100010];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a+1, a+n+1);
	reverse(a+1, a+n+1);//逆转元素，从大到小
	bool flag = 0; 
	for (int i = 1; i <= n; i++) 
	if (i+1 > a[i+1]) {
		for (int j = i+1; a[j] == i; j++) flag ^= 1;
		flag |= (a[i]-i) & 1;
		if (flag) printf("First\n");else printf("Second\n");
		return 0;
	} 
}

Measured memory_bytes: 4164
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var k string
	var d int
	fmt.Sscan(getNextLine(scanner), &k)
	fmt.Sscan(getNextLine(scanner), &d)
	lk := len(k)
	dp := make([][][]int, lk+1)
	for i := 0; i <= lk; i++ {
		dp[i] = make([][]int, 2)
		for j := 0; j < 2; j++ {
			dp[i][j] = make([]int, d)
		}
	}

	counts := lk * 2 * d
	dp[0][0][0] = 1
	for i := 0; i < counts; i++ {
		i1, i2, i3 := indexes(i, lk, 2, d)
		for n := 0; n < 10; n++ {
			if i2 == 1 || n < int(k[i1]-'0') {
				dp[i1+1][1][(i3+n)%d] = (dp[i1+1][1][(i3+n)%d] + dp[i1][i2][i3] + 1000000007) % 1000000007
				continue
			}
			dp[i1+1][0][(i3+n)%d] = (dp[i1+1][0][(i3+n)%d] + dp[i1][i2][i3] + 1000000007) % 1000000007
			break
		}
	}
	fmt.Println((dp[len(k)][0][0] + dp[len(k)][1][0] - 1 + 1000000007) % 1000000007)
}

func indexes(i int, a int, b int, c int) (int, int, int) {
	return (i / (b * c)) % a, (i / c) % b, i % c
}


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

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

    int x = 1900 * M + 100 * (N - M);
    cout << pow(2, M) * x << endl;
}

Measured memory_bytes: 4160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextLong();
		sc.close();

		var sb = new StringBuilder();
		while (n > 0) {
			sb.append((char) ('a' + ((n - 1) % 26)));
			n = (n - 1) / 26;
		}
		sb.reverse();
		System.out.println(sb.toString());
	}
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];

  int sum = 0;
  ll ans = 0;
  map<int, int> cnt;
  ++cnt[0];
  for (int i = 0; i < n; ++i) {
    sum += a[i];
    sum %= m;
    ans += cnt[sum];
    ++cnt[sum];
  }
  cout << ans << endl;
}


Measured memory_bytes: 6556
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5+7;
int n,x,res;
int get(int x){
  int ret = 0;
  while (x%2==0) {
    ret++;
    x/=2;
  }
  return ret;
}
int main(){
   std::cin >> n;
   while (n--) {
     std::cin >> x;
     res+=get(x);
   }
   std::cout << res << '\n';
}


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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

//計算量はsqrt(N)
template<typename T>
vector<T> Divisors(T n)
{
    vector<T> result;

    T boundary = sqrt(n);

    for (T i = 1; i <= boundary; i++) {
        if (n % i == 0) {
            result.push_back(i);
            if(i != (n / i) && i * i != n)
                result.push_back(n/i);
        }
    }
    sort(result.begin(),result.end());
    return result;
}


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

    map<ll,ll> mp;
    FOR(i,0,20000){
      FOR(j,i,20000){
        ll x = i*i + j*j;
        if(x>20000) break;
        mp[x]++;
      }
    }

    ll n;
    cin>>n;
    FOR(i,0,n){
      ll a,b;
      cin>>a>>b;
      ll x = a*a + b*b;
      vector<ll> div = Divisors(x);
      char res = 'P';
      FOR(j,1,div.size()-1){
        ll p = div[j];
        ll q = x/p;
        if(mp[p] + mp[q] >= 2) res = 'C';
//        cout<<p<<" "<<mp[p]<<" & "<<q<<" "<<mp[q]<<endl;

      }
      cout<<res<<endl;
    }
}



Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    string S;
    cin >> S;
    int n = S.size();
    int white = -1;
    LL res = 0;
    for (int i = n-1; i >= 0; i--) {
        if (S[i] == 'W' and white == -1) white = i;
        if (white != -1 and S[i] == 'B') res += white - i, white--;
    }
    cout << res << "\n";
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mkmap;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<vi> vv;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const ll mod=1000000007;
const int sz=1000001;
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(i=a;i<b;++i)
#define rrep(i,a,b) for(i=a;i>=b;--i)
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db(x) cout << (#x) << " = " << x << endl;

inline ll mult(ll a, ll b) {return (((a % mod) * (b % mod)) % mod);}

int fun(vector<pair<vector<int>,int> > &a,int i){
    if(a[i].S!=-1) return a[i].S;
    int mx=0;
    for(auto p:a[i].F){
        mx=max(mx,fun(a,p));
    }
    return a[i].S=mx+1;
}

int main(){
    fast;
    int t,tt,tti,n,m,x,y,z,i,j,k,temp,count,o,e,f,ans,sum,l,r,mx,mn;
    ll lx,ly,lz,ltemp;
    double fx,fy,fz;
    string s;
    
    cin>>n>>m;
    vector<pair<vector<int>,int> > a(n,{vector<int>(),-1});
    rep(i,0,m){
        cin>>x>>y;
        x--;
        y--;
        a[x].first.push_back(y);
    }
    mx=0;
    rep(i,0,n){
        mx=max(mx,fun(a,i)-1);
    }
    cout<<mx;
}

/*
    
*/

Measured memory_bytes: 11508
/*
    nah nah nah
*/
#include <bits/stdc++.h>
#define ll long long
#define fir first
#define sed second
#define i64 int64_t
#define pii pair< int,int >
using namespace std;
ifstream fi("");
ofstream fo("");

int main(){
string s;
cin>>s;
int c=0;
for (int i = 0;i<s.size()/2;i++)
    if (s[i]!=s[s.size()-1-i]) c++;
cout<<c;

}


Measured memory_bytes: 256
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define leadzero(a) __builtin_clz(a) // count leading zeroes
#define trailzero(a) __builtin_ctz(a) // count trailing zeroes
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln endl
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inp freopen("input.txt", "r", stdin)
#define outp freopen("output.txt", "w", stdout)
#define dbgm(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
typedef long long int  ll;
typedef long double  ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM = 100001, MOD = 1e9+7, EPS = 1e-9;
int t,n,m,k,x,y;
int main(){
	fastio;
	cin>>n;
	ll w;
	cin>>w;
	ll val[LIM] = {0};
	forn(i,LIM) val[i] = -1;
	val[0] = 0;
	forn(i,n){
		ll x,y;
		cin>>x>>y;
		for(int i=LIM-1;i>=0;i--){
			if(val[i]!=-1){
				val[i+y] = min(val[i+y],val[i]+x);
				if(val[i+y]==-1) val[i+y] = val[i]+x;
			}
		}
	}
	int ans = 0;
	forn(i,LIM){
		if(val[i]<=w && val[i]!=-1) ans = max(ans,i);
	}
	cout<<ans<<ln;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    int X;

    cin >> X;

    if(X < 3){
        cout << 1 << endl;
        return 0;
    }

    int i = 2;
    int m = 0;

    while(i*i <= X){
        int j = i;
        while(j <= X){
            j *= i;
        }

        m = max(j/i,m);
        i++;
    }

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
import math
N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
def cul_dis(x, y):
	sum = 0
	for i in range(len(x)):
		sum += (x[i]-y[i])**2
	return math.sqrt(sum)
cnt = 0
for i in range(len(X))[:-1]:
	for j in range(len(X))[i+1:]:
		dis = (cul_dis(X[i], X[j]))
		if (dis.is_integer()):
			cnt += 1
print(cnt)


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


ll fac[200005] = {}, inv[200005] = {}, finv[200005] = {};
const int mod = 1e9 + 7;

void cominit(int n) {
    int i;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (i = 2; i <= n + 2; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

ll com(int n, int r) {
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * finv[r] % mod * finv[n - r] % mod;
}

int main(void) {
    int h, w, a, b, i, j;
    ll ans;

    cin >> h >> w >> a >> b;

    cominit(max(h - a + b - 1, w + a - b - 1));

    ans = 0;
    i = h - a - 1;
    j = b;
    while (i >= 0 && j < w) {
        ans = (ans + com(i + j, i) * com(h - i + w - j - 2, h - i - 1) % mod) % mod;
        i--;
        j++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4352
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		int M[] = new int[10];
		for(int a = 0;a<10;a++){
			M[a] = scan.nextInt();
		}
		int No1 = M[0];
		int No2 = M[1];
		int No3 = M[2];
		if(No1 < No2){
			No1 = M[1];
			No2 = M[0];
		}
		if(No1 < No3){
			No3 = No2;
			No2 = No1;
			No1 = M[2];
		}else if(No2 < No3){
			No3 = No2;
			No2 = M[2];
		}
		for(int b = 3;b<10;b++){
			if(No1 < M[b]){
				No3 = No2;
				No2 = No1;
				No1 = M[b];
			}else if(No2 < M[b]){
				No3 = No2;
				No2 = M[b];
			}else if(No3 < M[b]){
				No3 = M[b];
			}
		}
		System.out.println(No1 + "\n" + No2 + "\n" + No3);
	}
}

Measured memory_bytes: 17172
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e10;
const ll MOD = 1000000007;

int main() {
    int n,q;
    string s;
    cin >> n >> q >> s;
    int count[100005] = {0};
    rep(i,n-1){
        if (s[i] == 'A' && s[i+1] == 'C') count[i+1]++;
    }
    rep(i,n-1) count[i+1] += count[i];
    int l,r;
    rep(i,q){
        cin >> l >> r;
        PRINT(count[r-1]-count[l-1]);
    }
}

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

int main() {
    string w, t;
    cin >> w;
    int count = 0;
    while (true) {
        cin >> t;
        if (t == "END_OF_TEXT") break;
        for (int i = 0; i < t.size(); i++) {
            if (65 <= t[i] && t[i] <= 90) t[i] += 32;
        }
        
        if (t == w) count++;
    }
    
    cout << count << endl;
}



Measured memory_bytes: 3192
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void){
  int a,b;
  scanf("%d%d",&a,&b);

  if(a >= 13){
    cout << b;
  }else if(a >= 6){
    cout << b/2;
  }else{
    cout << 0;
  }

  return 0;
}

Measured memory_bytes: 256