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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	cout<<(n%k==0 ? 0 : 1)<<'\n';
	return 0;
}


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

int main(){
    unsigned long long int N,result,min;
    vector<unsigned long long int> a(5);
    cin >> N;
    for(int i=0;i<5;i++){
        cin >> a[i];
        if(i==0){
            min = a[i];
        }else{
            if(min > a[i]){
                min = a[i];
            }
        }
    }
    if(N%min==0){
        result = N/min+4;
    }else{
        result = N/min+5;
    }
    
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const S = input[0][0];

  return new Set(S.split("")).size === S.length ? "yes" : "no";
};

console.log(main(read()));


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

int main(){
    char a[51][51], b[51][51];
    int n, m, i, j, k, l;
    scanf("%d %d", &n, &m);
    for(i = 0; i < n; i++) scanf("%s", a[i]);
    for(i = 0; i < m; i++) scanf("%s", b[i]);
    int ans = 0;
    for(i = 0; i < n - m + 1; i++){
        for(j = 0; j < n - m + 1; j++){
            for(k = 0; k < m; k++){
                for(l = 0; l < m; l++){
                    if(a[i + k][j + l] != b[k][l]){
                        k = m;
                        break;
                    }
                    if(k == m - 1 && l == m - 1) ans = 1;
                }
            }
        }
    }
    if(ans) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
# include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 2e5+30;
LL a[maxn], b[maxn], ans=0;
int main()
{
    int n, l, r;
    scanf("%d",&n);
    for(int i=0; i<n; ++i) scanf("%lld",&a[i]);
    for(int i=0; i<n; ++i) scanf("%lld",&b[i]);
    for(int i=28; ~i; --i)
    {
        LL s = 1LL<<i, tmp=0;
        for(int j=0; j<n; ++j) a[j]&=(s<<1)-1, b[j]&=(s<<1)-1;
        sort(b,b+n);
        for(int j=0; j<n; ++j)
        {
            l = lower_bound(b,b+n,s-a[j])-b;
            r = lower_bound(b,b+n,(s<<1)-a[j])-b;
            tmp += r-l;
            l = lower_bound(b,b+n,(s<<1|s)-a[j])-b;
            r = lower_bound(b,b+n, (s<<2)-a[j])-b;
            tmp += r-l;
        }
        if(tmp&1) ans |= s;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string A,B,C;
  cin>>N>>A>>B>>C;
  int ans=0;
  for(int i=0;i<N;i++){
    int v=(A[i]==B[i])+(B[i]==C[i])+(C[i]==A[i]);
    if(v<3)v++;
    ans+=3-v;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3596
n = list(map(int,list(input())))
len_n = len(n)

dp = [[[0]*8 for i in range(2)] for j in range(len_n)]
base = [0,3,5,7]

for i in range(n[0]+1):
  temp = 0
  ans = 0

  
  if i == 3:
    temp = 1
    ans = 1
  elif i == 5:
    temp = 2
    ans = 1
  elif i == 7:
    temp = 4 
    ans = 1
  elif i == 0:
    temp = 0
    ans = 1
    
  dp[0][n[0] == i][temp] += ans 

for i in range(1,len_n):
  for j in range(2):
    for k in range(8):
      for l in base: 
        if (j == 1) and (n[i] < l):
          continue
          
        if (not(k == 0)) and (l == 0):
          continue
        
        temp = 0
        
        if l == 3:
          temp = 1
        elif l == 5:
          temp = 2
        elif l == 7:
          temp = 4
          
        dp[i][j & (n[i] == l)][k | temp] += dp[i-1][j][k]
        
print(dp[len_n-1][1][7] + dp[len_n-1][0][7])

Measured memory_bytes: 3064
#[N,K] = list(map(int,input().split()))
#A = list(map(int,input().split()))
#[A,B,C,D] = list(map(int,input().split()))
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]
#N = 3
#AB = [[334, 1000], [334, 1000], [334, 1000]]
AB.sort(key = lambda x:x[1])
sum_tmp = 0
idx = 0
for i in range(len(AB)):
    sum_tmp += AB[i][0]
    if sum_tmp > AB[i][1]:
        idx = 1
if idx == 0:
    print("Yes")
else:
    print("No")


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

int main() {
	ll n, ans = 0ll;
	cin >> n;
	if (n%2 == 1) {
		puts("0"); return 0;
	}
	n /= 2;
	while (n ) {
		ans += (n/=5);
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
n,m,q = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(m)]
B = [list(map(int, input().split())) for _ in range(q)]
l = [[0]*n for _ in range(n)]
for i in range(m):
    l[A[i][0]-1][A[i][1]-1] += 1
#print(l)

a = [[0]*n for _ in range(n)] #差に対して
for i in range(n):
    for j in range(n-i):
        if (j==0):
            a[i][j] = l[0][i]
        else:
            a[i][j] = a[i][j-1] + l[j][j+i]
#print(a)
        
ans = [[0]*n for _ in range(n)]
for i in range(n):
    for j in range(i,n):
        x = 0
        for k in range(j-i+1):
            #print(k)
            if (i!=0):
                x += a[k][j-k]-a[k][i-1]
            else:
                x += a[k][j-k]
        ans[i][j] = x
        #print(i,j,x)
#print(ans)
            

for i in range(q):
    print(ans[B[i][0]-1][B[i][1]-1])
       

Measured memory_bytes: 114904
#include<set>
#include<map>
#include<ctime>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>    
using namespace std;
#define LL long long
LL read(){
    LL f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
#define INF 0x3f3f3f3f
#define MAXN 100
int main(){
	LL n=read(),k=read(),ans=k;
	for(int i=2;i<=n;i++)
		ans*=(k-1);
	printf("%lld\n",ans);
	return 0;
}/**/


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int ar[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  if(a+b>c){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<((c-a-b)*(c-a-b)>4*a*b?"Yes":"No")<<endl;
}


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

int main(){
    int k; cin >> k;
    int lis[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << lis[k-1] << endl;
}

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

int main(){
    int n;
    cin >> n;
    int a, b, c;
    cin >> a >> b >> c;
    int res = 0;
    if((a- b)*(c-b) < 0) res ++;
    for(int i =0; i < n-3; i++){
        a = b;
        b = c;
        cin >> c;
        if((a- b)*(c-b) < 0) res ++;
    }
    cout << res << endl;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<int>> g(n + 26 + 2);
  for (int i = 'a'; i <= 'z'; i++) {
    s += (char)i;
    g[s.size()].push_back(n + 27);
  }
  vector<deque<int>> vec(255);
  for (int i = 1; i <= (int)s.size(); i++) {
    vec[s[i - 1]].push_back(i);
  }
  for (int i = 'a'; i <= 'z'; i++) {
    if (!vec[i].empty()) {
      g[0].push_back(vec[i][0]);
    }
  }
  vector<int> last(255);
  for (int i = 1; i <= (int)s.size(); i++) {
    vec[s[i - 1]].pop_front();
    for (int j = 'a'; j <= 'z'; j++) {
      if (!vec[j].empty()) {
        g[i].push_back(vec[j][0]);
      } 
    }
  }
  vector<int> dp(n + 28);
  for (int i = n + 26; i >= 0; i--) {
    dp[i] = 1e9;
    for (auto v : g[i]) {
      dp[i] = min(dp[i], dp[v] + 1);
    }
  }
  for (int i = 0; ; ) {
    if (dp[i] == 1) break;
    for (auto v : g[i]) {
      if (dp[v] == dp[i] - 1) {
        cout << s[v - 1];
        i = v;
        break;
      }
    }
  }
  return 0;
}


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

int main(){
	int n;
	cin>>n;
	vector<int> p(n,0);
	for(int i=0;i<n*(n-1)/2;i++){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--;
		b--;
		if(c>d)
			p[a]+=3;
		else if(c<d)
			p[b]+=3;
		else{
			p[a]++;
			p[b]++;
		}
	}
	vector<int> q(n);
	for(int i=0;i<n;i++)
		q[i]=i;
	sort(q.begin(),q.end(),[&](int a,int b){
		return p[a]>p[b];
	});
	vector<int> ans(n);
	int last=INT_MAX;
	for(int i=0;i<n;i++){
		if(last==p[q[i]])
			ans[q[i]]=ans[q[i-1]];
		else
			ans[q[i]]=i+1;
		last=p[q[i]];
	}
	for(int i=0;i<n;i++)
		cout<<ans[i]<<endl;
}

Measured memory_bytes: 3160
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

const int64 MOD = 1e9 + 7;

const int MAX = 2e5;
//const int MOD = 1e9 + 7;
int64_t fac[MAX] = {}, inv[MAX] = {}, finv[MAX] = {};

void make_table() {
  fac[0] = 1; fac[1] = 1;
  finv[0] = 1; finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; ++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;
  }
}

int64_t com(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  int64 n, k; cin >> n >> k;
  make_table();

  //int64 ans = 0;

  for (int i = 1; i <= k; ++i) {
    int64 ans = 0;
    (ans += com(n - k + 1, i) * com(k - 1, i - 1)) %= MOD;
    cout << ans << '\n';
  }


  return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

#define ll long long
const ll N = 1000000000000000;

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

    cout << a * min(n, (b - 1)) / b << endl;

    return 0;
}

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


void solve(std::string s){
    s.at(5) = ' ';
    s.at(13) = ' ';
    cout << s << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


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

int main(){

  ll n;
  cin >> n;
  ll power = 1;


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

    power *= i + 1;
    power %= 1000000007;

  }

  cout << power << endl;

}


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




int main(){
	//freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h,n,i,j;
	cin>>h>>n;
	int a[n+2],b[n+2];
	int dp[10003];
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for(i=0;i<n;i++){
		cin>>a[i]>>b[i];
		for(j=0;j<h;j++){
			dp[min(a[i]+j,h)]=min(dp[min(a[i]+j,h)],dp[j]+b[i]);
		}
	}
	cout<<dp[h];
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next()), p, q;
		int[][] map = new int[10][10];
		for(int i = 1; i <= n; i++){
			p = i;
			q = i % 10;
			while(p > 9){
				p /= 10;
			}
			map[p][q]++;
		}
		int cnt = 0;
		for(int i = 1; i <= n; i++){
			p = i;
			q = i % 10;
			while(p > 9){
				p /= 10;
			}
			cnt += map[q][p];
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define MAX 1000000
using namespace std;
int n,a[MAX+5],cnt;
map<int,int>rec;
int cmp(int a,int b)
{
	return a>b;
}
void run()
{
	scanf("%d",&n);
	for(int i=1; i<=n; i++)
	{
	scanf("%d",&a[i]);
	rec[a[i]]++;
    }
	sort(a+1,a+n+1,cmp); 
}
void solve()
{
for(int i=1; i<=n; i++)
{
	int target=1073741824;
	for(int j=30; j>=1; j--)
	{
	 if(rec[target-a[i]]&&rec[a[i]])
	 {
	 	if(target-a[i]==a[i]&&rec[a[i]]==1) continue; 
	 	rec[target-a[i]]--;
	 	rec[a[i]]--;
	 	cnt++;
	 	break;
	 }
	 target/=2;	
	}
}
}
int main()
{
	run();
	solve();
	printf("%d",cnt);
	return 0;
} 

Measured memory_bytes: 290816
import java.util.Scanner
import scala.math._
object Main {
  def main(args:Array[String]) {
    val sc = new Scanner(System.in)
    val n,w,h = sc.nextInt()
    val x = Array.fill(w)(false);
    val y = Array.fill(h)(false);
    for(i <- 1 to n) {
      val xi, yi, wi = sc.nextInt()
      for(j <- max(0, xi-wi) to min(w-1, xi+wi-1)) {
        x(j) = true
      }
      for(j <- max(0, yi-wi) to min(h-1, yi+wi-1)) {
        y(j) = true
      }
    }
    println(if(x.forall(_ == true) || y.forall(_ == true)) "Yes" else "No")
  }
}

Measured memory_bytes: 269228
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
n, k  = map(int, input().split())
l  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

l = sorted(l)
print(sum(l[:k]))


Measured memory_bytes: 9456
#include<bits/stdc++.h>
using namespace std;
#define re register
int q1[110][110],q2[110][110],link[110][110],fr[110],ito[110],n,m,k1[110];
bool vis[110];
inline bool cmp(re int a,re int b){return (a-1)/m<(b-1)/m;}
bool dfs(re int i1)
{
	for(re int i=1;i<=n;i++)if(link[i1][i]&&!vis[i])
	{
		vis[i]=1;
		if((fr[i]==0)||dfs(fr[i]))
		{
			fr[i]=i1;
			ito[i1]=link[i1][i];
			return 1;
		}
	}
	return 0;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(re int i=1;i<=n;i++)
	{
		for(re int j=1;j<=m;j++)scanf("%d",&q1[i][j]);
	}
	for(re int i1=1;i1<=m;i1++)
	{
		memset(link,0,sizeof(link));
		for(re int i=1;i<=n;i++)
		{
			for(re int j=1;j<=m;j++)
			{
				re int x=q1[i][j];
				if(x!=-1&&link[i][(x-1)/m+1]==0)link[i][(x-1)/m+1]=j;
			}
		}
		for(re int i=1;i<=n;i++)fr[i]=ito[i]=0;
		for(re int i=1;i<=n;i++)
		{
			memset(vis,0,sizeof(vis));
			dfs(i);
		}
		for(re int i=1;i<=n;i++)q2[i][i1]=q1[i][ito[i]],q1[i][ito[i]]=-1;
	}
	for(re int i=1;i<=n;i++)for(re int j=1;j<=m;j++)printf("%d%c",q2[i][j],(j==m?'\n':' '));
	for(re int j=1;j<=m;j++)
	{
		for(re int i=1;i<=n;i++)k1[i]=q2[i][j];
		sort(k1+1,k1+n+1,cmp);
		for(re int i=1;i<=n;i++)q2[i][j]=k1[i];
	}
	for(re int i=1;i<=n;i++)for(re int j=1;j<=m;j++)printf("%d%c",q2[i][j],(j==m?'\n':' '));
}

Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10**9)
n,m=map(int,input().split())

g=[[] for i in range(n)]
for i in range(m):
  v1,v2=map(int,input().split())
  v1-=1;v2-=1
  g[v1].append(v2)

dp=[-1]*n  
  
def dfs(i):
  if dp[i]!=-1:
    return dp[i]
  temp=0
  for nv in g[i]:
    temp=max(temp,dfs(nv)+1)
  dp[i]=temp  
  return temp  
    
res=0
for i in range(n):
  res=max(res,dfs(i))
print(res)


Measured memory_bytes: 154188
//
//  main.cpp
//  project for C++
//
//  Created by 伊藤博隆 on 2020/04/17.
//  Copyright © 2020 伊藤博隆. All rights reserved.
//

#include <iostream>
#include<set>
#include<string>
#include <sstream>
#include <algorithm>
#include <math.h>

using namespace std;
int C[3][3];
int A[3];
int B[3];
int main(){
    for (int i=0 ;i<3; i++) {
        for (int j=0; j<3; j++) {
            cin >> C[i][j];
            
        }
    }
    A[0] = 0;
    for(int i=1;i<3;i++){A[i] = C[i][0] - C[0][0];}
    for(int i=0;i<3;i++){B[i] = C[0][i];}
  
 
          
    if(C[0][0] == A[0] + B[0] && C[0][1] == A[0] + B[1] && C[0][2] == A[0] + B[2] && C[1][0] == A[1] + B[0] && C[1][1] == A[1] + B[1] && C[1][2] == A[1] + B[2] && C[2][0] == A[2] + B[0] && C[2][1] == A[2] + B[1] && C[2][2] == A[2] + B[2]){ cout << "Yes" << endl;}
    else{cout << "No" << endl;}
          
      
  
      
    

    return 0;
}




Measured memory_bytes: 888
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        char[] a=fsc.next().toCharArray();
        char[] b=fsc.next().toCharArray();
        char[] c=fsc.next().toCharArray();
        fsc.close();
        if(a[a.length-1]==b[0] && b[b.length-1]==c[0]){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n, p;
  cin >> n >> p;
  string s;
  cin >> s;
  ll ans = 0;
  if (10 % p == 0) {
    rep (i, n) {
      if((s[i] - '0') % p == 0) ans += i + 1;
    }
    cout << ans << endl;
    return 0;
  }
  int ten = 1;
  vector<int> d(n + 1);
  for (int i = n - 1; i >= 0; --i) {
    int a = (s[i] - '0') * ten % p;
    d[i] = (d[i + 1] + a) % p ;
    ten *= 10;
    ten %= p;
  }
  vector<int> count(p);
  for (int i = n; i >= 0; --i) {
    ans += count[d[i]];
    count[d[i]]++;
  }

  cout << ans << endl;

}

Measured memory_bytes: 1412
#include <stdio.h>
#define N 13
int main(){
  int i,j,n1,n2,n3,n4,n5;
  int data[N];
    while (scanf("%d,%d,%d,%d,%d",&n1,&n2,&n3,&n4,&n5)!=EOF){
      for (i=0;i<N;i++)
        data[i]=0;
      data[n1-1]++;data[n2-1]++;data[n3-1]++;data[n4-1]++;data[n5-1]++;
      int three=0,two=0,four=0,one=0,straight=0;
      for (i=0;i<N;i++){
        if (data[i]==4)
          four++;
        else if (data[i]==3)
          three++;
        else if (data[i]==2)
          two++;
        if (i<10)
          if (data[i%N]==1 &&
              data[(i+1)%N]==1 &&
              data[(i+2)%N]==1 &&
              data[(i+3)%N]==1 &&
              data[(i+4)%N]==1)
            straight++;
      }
      if (four==1)
        printf("four card\n");
      else if ((three==1) && (two==1))
        printf("full house\n");
      else if (straight==1)
        printf("straight\n");
      else if (three==1)
        printf("three card\n");
      else if (two==2)
        printf("two pair\n");
      else if (two==1)
        printf("one pair\n");
      else
        printf("null\n");
    }
  return 0;
}

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

int main() {
  int a;
  cin >> a;
  
  if (a == 0) {
    cout << 0 << endl;
  }
  else if (a == 111) {
    cout << 3 << endl;
  }
  else if (a == 101 || a == 110 || a == 11) {
    cout << 2 << endl;
  }
  else {
    cout << 1 << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define ind(a) scanf("%lf", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a));
//def   puts(a) printf("%s\n", a) 文字はこっち
//your code here!


int main(void){
    ll N, X, L[101], ans=0, sum=0;
    in(N); in(X);
    rep(i, N) in(L[i]);
    while(sum<=X){
        ans++;
        sum += L[ans-1];
    }
    put(ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <map>
#include <queue>
#include <cstring>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll a,b,c,d,e,f; cin >> a >> b >> c >> d >> e >> f;
	int p=(a%2+d%2+e%2)%3;
	if(a&&d&&e&&p==2)p--;
	cout << a+b+d+e-p << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s, t;
  cin >> s >> t;
  ll n = stoi(s + t);
  rep(i, 1e5) {
    if(i * i == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3644
n, m, X,Y = map(int,input().split())
x = list(int(i) for i in input().split())
y = list(int(i) for i in input().split())

x.sort()
y.sort()

if x[-1] < Y and y[0] >X and x[-1] < y[0]:
    print("No War")
else:
    print("War")

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


int main() {
    int n,k;
    cin>>n>>k;
    vector<int> snuke(n,0);
    rep(i,k){
        int d;
        cin>>d;
        rep(i,d){
            int a;
            cin>>a;
            a--;
            snuke[a]++;
        }
    }
    int ans=0;
    rep(i,n){
        if(snuke[i]==0) ans++;
    }

cout<<ans<<endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

vector<ll>relation[20], money(20, 1);

int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1;i <= n;++i) {
		if (i % 3 != 0 && i % 5 != 0)ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int min = a + b;
		if(b + c < min){
			min = b + c;
		}
		if(c + a < min){
			min = c + a;
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 35692
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}

int dp[100010];
vector<vector<int> > G;


int dfs(int v){
    if(dp[v]!=-1) return dp[v];
    int ret = 0;
    for(int nv : G[v]){
        chmax(ret,dfs(nv)+1);
    }
    return dp[v] = ret;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,M,x,y;
    cin >> N >> M;
    G.resize(N);
    REP(i,M){
        cin >> x >> y;
        --x; --y;
        G[x].push_back(y);
    }
    REP(i,N) dp[i] = -1;
    int ans = 0;
    REP(i,N) chmax(ans,dfs(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
s=list(map(int,input().split()))
if s[0]!=1 and s[1]!=1:
  if s[0]%2==0:
    a=int(s[0]//2)
    a=a*s[1]
    print(a)
  else:
    if s[1]%2==0:
      a=int(s[1]//2)
      a=a*s[0]
      print(a)
    else:
      b=int(s[0]//2)
      c=int(s[1]//2)
      a=(b+1)*(c+1)
      a=a+b*c
      print(a)
else:
  print(1)

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
    int n,a,b;
    
    cin>>n;
    
    vector<bool> arr(n+1);
    bool ans=false;
    for(int i=0;i<(n);++i){
      cin>>a>>b;
      arr[i]= (a==b);
    }
    
    for(int i=0;i<=(n-3);++i){
      if(arr[i] && arr[i+1] && arr[i+2]){
          ans=true;
          break;
      }     
    }
    
    if(ans){
        cout<<"Yes";
    } else{
        cout<<"No";
    }
    
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define N 1000000007
using namespace std;
#define MAX 500000
long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % N;
    inverse[i] = N - (inverse[N % i] * (N / i)) % N;
    finverse[i] = finverse[i - 1] * inverse[i] % N;
  }
}

long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % N * finverse[n - k] %
         N;
}

long long n, x, fin = 0;
vector<long long> s;
long long dp[202][100005] = {0};
long long solve();

int main() {
  smodfact();
  cin >> n >> x;
  s.resize(n);
  for(int i = 0; i < n; ++i) cin >> s[i];
  sort(s.begin(), s.end(), greater<long long>());
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  dp[0][x] = 1;
  fin = max(x, s[0]);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j <= fin; ++j) {
      long long now = j;
      dp[i + 1][j] = dp[i][j] * (n - i - 1) % N;
      if(j < s[i])
        while(now <= fin) {
          dp[i + 1][j] += dp[i][now];
          now += s[i];
        }
    }
  for(int i = 1; i < s[n - 1]; ++i) {
    ans += dp[n][i] * i % N;
    ans %= N;
  }
  return ans;
}

Measured memory_bytes: 168960
#include <iostream>
#include <stdio.h>
using namespace std;
#define ll long long int
int main()
{
  ll t;
  t=1;
  while(t--)
  {
  	ll a,b,c,d;
  	cin>>a>>b>>c>>d;
  	ll ans,temp;
  	ans=a*c;
  	temp=a*d;
  	ans=max(ans,temp);
  	temp=b*c;
  	ans=max(ans,temp);
  	temp=b*d;
  	ans=max(ans,temp);
  	cout<<ans<<"\n";
  }
}//main

Measured memory_bytes: 3668
N,H = map(int,input().split());
ab = [list(map(int,input().split())) for _ in range(N)]
ab.sort(key = lambda x:x[0],reverse = True)
swing = ab[0][0]
ans = 0
if H<= ab[0][1]:
    print(1)
else:
    ab.sort(key = lambda x:x[1],reverse = True)
    for i in range(N):
        if ab[i][1] >= swing:
          H -= ab[i][1]
          ans += 1 
        else:
            continue
        if H <= 0:
            break
    else:
        if H % swing == 0:
            ans += H//swing
        else:
            ans += H//swing +1
    print(ans)


Measured memory_bytes: 97348
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,M = inpl()
T = (N-M)*100 + 1900*M
k = 2**M
print(k*T)


Measured memory_bytes: 4204
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int r;
  cin >> r;
  cout << 3*r*r << endl;
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> P(N);
	for (int i = 0; i < N; i++)
	cin >> P.at(i);
	
	int total = 0, max = 0;
	
	for (int i = 0; i < N; i++) {
		total += P.at(i);
		if (max < P.at(i)) {
			max = P.at(i);
		}
	}
	
	total = total - max / 2;
	
	cout << total << endl;
}

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

using namespace std;

// a copies of b
// b copies of a


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

	if (a > b) swap(a, b);

	for (int i = 0; i < b; ++i)
		printf("%d", a);

	printf("\n");

	return 0;
}
 

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

using namespace std;
int main() {
	int n, k, m, ans = 0,count = 0;
	cin >> n >> k;
	vector<int> nums(n,0);
	set<int>s;
	for (int i = 0; i < n; i++) {
		cin >> m;
		nums[m - 1]++;
		s.insert(m);
	}

	sort(nums.begin(), nums.end());
	for (int i = 0;count < (int)s.size() - k; i++) {

		if (nums[i] != 0)ans += nums[i],count++;
		
	}
	cout << ans << endl;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

long long arr[MAX] , val[MAX] , pref[MAX] , suff[MAX] ;
long long bestpref[MAX] , bestsuff[MAX] ;
long long n , c ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>c ;
	for(int i = 1 ; i <= n ; ++i)
		cin>>arr[i]>>val[i] ;
	pref[0] = 0 ;
	arr[0] = 0 ;
	bestpref[0] = 0 ;
	for(int i = 1 ; i <= n ; ++i)
	{
		pref[i] = pref[i-1] - (arr[i] - arr[i-1]) + val[i] ;
		bestpref[i] = max(bestpref[i-1] , pref[i]) ;
	}
	suff[n+1] = 0 ;
	arr[n+1] = c ;
	bestsuff[n+1] = 0 ;
	for(int i = n ; i >= 1 ; --i)
	{
		suff[i] = suff[i+1] - (arr[i+1] - arr[i]) + val[i] ;
		bestsuff[i] = max(bestsuff[i+1] , suff[i]) ;
	}
	long long ans = 0ll ;
	for(int i = 0 ; i <= n ; ++i)
	{
		ans = max(ans , pref[i]) ;
		ans = max(ans , pref[i] - arr[i] + bestsuff[i+1]) ;
	}
	for(int i = n+1 ; i >= 1 ; --i)
	{
		ans = max(ans , suff[i]) ;
		ans = max(ans , suff[i] - (c - arr[i]) + bestpref[i-1]) ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a, b; 
	cin >> a >> b;
	int res = 0;
	for (int i = 0 ; i < a.size() ; i++) {
		if (a[i] != b[i]) res++;
	}
	cout << res << endl;
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    
    int N;cin>>N;
    vector<string> S(20);
    cout<<0<<endl;
    fflush(stdout);
    cin>>S[0];
    if(S[0]=="Vacant") ;
    else{
        cout<<N-1<<endl;
        fflush(stdout);
        cin>>S[1];
        if(S[1]=="Vacant") ;
        else{
            int left=0,right=N-1,now=2;
            bool flag=false;
            while(left<right){
                int mid=(left+right)/2;
                cout<<mid<<endl;
                fflush(stdout);
                cin>>S[now];
                if(S[now]=="Vacant"){
                    flag=true;
                    break;
                }
                if(S[now-2]==S[now]){
                    if((mid-left)%2==0){
                        left=mid;
                        swap(S[now],S[now-1]);
                        now++;
                    }else{
                        right=mid;
                        S[now-1]=S[now];
                        now++;
                    }
                }else{
                    if((mid-left)%2==1){
                        left=mid;
                        swap(S[now],S[now-1]);
                        now++;
                    }else{
                        right=mid;
                        S[now-1]=S[now-2];
                        now++;
                    }
                }
            }
            if(!flag){
                cout<<left<<endl;
                fflush(stdout);
            }
        }
    }
}


Measured memory_bytes: 852
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    int N[3];
    for (int i = 0; i < 3; ++i) {
        cin >> N[i];
    }

    sort(N, N + 3);

    int d1 = N[2] - N[0];
    int d2 = N[2] - N[1];

    int ans;
    if ((d1 - d2) % 2 == 0) {
        ans = (d1 - d2) / 2 + d2;
    } else {
        N[0]++, N[2]++;
        d1 = N[2] - N[0];
        d2 = N[2] - N[1];
        ans = (d1 - d2) / 2 + d2 + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()
S_num=[ord(S[i]) for i in range(len(S))]
S_str=''
for i in range(len(S)):
  S_num[i]=int(S_num[i])+N
  if S_num[i]>=91:
    S_num[i]=S_num[i]-26
  S_str+=chr(S_num[i])
print(S_str)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S seconnd
#define int ll
#define PB push_back

int n,m,x,y;
int a[100000];
int b[100000];

signed main(){
  cin>>n>>m>>x>>y;
  rep(i,n){
    cin>>a[i];
  }
  rep(i,m){
    cin>>b[i];
  }

  sort(a,a+n);
  sort(b,b+m);

  if(max(x,a[n-1])<min(y,b[0])){
    cout<<"No War"<<endl;
  }
  else{
    cout<<"War"<<endl;
  }

}

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

void bubbleSort(int[],int,int*);
static int n;
int a[100];

int main(){
	cin>>n;
	
	for (int i = 0; i <n; ++i)
	{
		cin>>a[i];
	}
	int sum=0;
	bubbleSort(a,n,&sum);
	for (int i = 0; i < n-1; ++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<a[n-1]<<endl;
	cout<<sum<<endl;
		

	
return 0;
}

void bubbleSort(int a[],int n, int* sum){
	int flag=1;
	
	while (flag){
		flag=0;
		for (int j = n-1; j>0; --j)
		{
			if (a[j]<a[j-1])
			{
				swap(a[j],a[j-1]);
				flag=1;
				*sum= *sum+1;
				
			}
		}
	}
}

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

int main()
{
    string s;
    int count, ans;

    count = ans = 0;

    cin >> s;

    for (int i = 0; i < 3; ++i)
    {
        if (s[i] == 'R')
        {
            ++count;
            if (ans < count)
            {
                ans = count;
            }
        }
        else
        {
            count = 0;
        }
    }

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


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b,w=0;scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d",&a,&b);
		if(a==b&&(++w)>=3)return puts("Yes"),0;
		if(a!=b)w=0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i!=n;i++)
#define int long long
#define MOD 1000000007

using namespace std;

signed main(){
	int n;
	cin >> n;
	vector<int> v(n);
	REP(i,n){
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	int a=v[n-1];
	int min=1145141919810;
	int ans;
	REP(i,n){
		if(abs(a-v[i]*2)<min){
			min=a-v[i]*2;
			ans=v[i];
		}
	}
	cout << a << " " << ans << endl;
}

Measured memory_bytes: 1024
//??£?????°????????¨??????
#include <iostream>
#include <vector>
using namespace std;

int n, m;
vector<int> et[100000];

bool visited[100000];	//?¨????????????°
int parent[100000];		//???
int lowest[100000];		//???????????????0?????\???????????§????????????0?????\????????£??????????????????????????????????????????????????????????°????
int prenum[100000];		//??????????????????
int timer;

void dfs(int u, int prev) {
	prenum[u] = timer;
	lowest[u] = timer;
	visited[u] = true;
	parent[u] = prev;
	timer++;
	
	for (int i = 0; i < et[u].size(); i++) {
		int v = et[u][i];
		if (!visited[v]) {
			dfs(v, u);
			lowest[u] = min(lowest[u], lowest[v]);
		}
		else if (v != prev) {
			//u --> v????????????
			lowest[u] = min(lowest[u], prenum[v]);
		}
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int src, dst;
		cin >> src >> dst;
		et[src].push_back(dst);
		et[dst].push_back(src);
	}
	
	//??¢??????????±???????
	timer = 0;
	for (int i = 0; i < n; i++) visited[i] = false;
	dfs(0, -1);
	
	static bool isArtP[100000] = {false};
	int rootChildNum = 0;
	
	for (int i = 1; i < n; i++) {
		if (prenum[parent[i]] <= lowest[i] && parent[i] != 0) {
			isArtP[parent[i]] = true;
		}
		if (parent[i] == 0) {
			rootChildNum++;
		}
	}
	
	if (rootChildNum >= 2) {
		cout << 0 << endl;
	}
	for (int i = 1; i < n; i++) {
		if (isArtP[i]) {
			cout << i << endl;
		}
	}
	return 0;
}

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


int main() {
    string S;
    cin >> S;
    int n = S.length();
    
    if (n < 4) {
        cout << "0\n";
        return 0;
    }
    
    ll dp[n + 1]{};
    int k = 1;
    ll a[2019]{};
    a[0] = 1;
    for (int i = 0; i < n; i++) {
        int j = n - i - 1;
        int c = S[j] - '0';
        dp[i + 1] = (dp[i] + c * k) % 2019;
        k = (k * 10) % 2019;
        a[dp[i + 1]]++;
    }
    ll ans = 0;
    for (int i = 0; i < 2019; i++) {
        ans += (a[i] * (a[i] - 1)) / 2;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5136
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a, b;
    top = 0;
    char s[100];

    while( scanf("%s", s) != EOF ){
        if ( s[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }else if( s[0] == '-'){
            b = pop();
            a = pop();
            push(a - b);
        }else if( s[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }else{
            push(atoi(s));
        }
    }

    printf("%d\n", pop());

    return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int H,W;
    cin>>H>>W;
    char str[H][W];
    int check[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>str[i][j];
            check[i][j]=0;
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(str[i][j]=='#'){
                if(str[i-1][j-1]=='.'&&i!=0&&j!=0) check[i-1][j-1]++;
                if(str[i-1][j]=='.'&&i!=0) check[i-1][j]++;
                if(str[i-1][j+1]=='.'&&i!=0&&j!=W-1) check[i-1][j+1]++;
                if(str[i][j-1]=='.'&&j!=0) check[i][j-1]++;
                if(str[i][j+1]=='.'&&j!=W-1) check[i][j+1]++;
                if(str[i+1][j-1]=='.'&&i!=H-1&&j!=0) check[i+1][j-1]++;
                if(str[i+1][j]=='.'&&i!=H-1) check[i+1][j]++;
                if(str[i+1][j+1]=='.'&&i!=H-1&&j!=W-1) check[i+1][j+1]++;
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(str[i][j]=='.')
            cout<<check[i][j];
            else cout<<'#';
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[200005],b[200005],c[200005],ans;
signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[a[i]]++;
	}
	for(int i=1;i<=n;i++)
		ans+=b[i]*(b[i]-1)/2;
	for(int i=1;i<=n;i++)
		cout<<ans-(b[a[i]]-1)<<endl;
	return 0;
}

Measured memory_bytes: 5376
#include<stdio.h>
int main()
{
	int a,b,c,r;
	while(scanf("%d%d%d",&a,&b,&c)==3)
	{
		r=0;
		while(c-->0)
		{
			a=a%b*10;
			r+=a/b;
			if((a%=b)==0)
				break;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 596
import itertools

W,H,N=map(int,input().split())
xya=[list(map(int,input().split())) for i in range(N)]
res=[[True for j in range(H)] for i in range(W)]
for j in range(H):
    for i in range(W):
        for k in range(N):
            if (i<xya[k][0] and xya[k][2]==1) or (i>=xya[k][0] and xya[k][2]==2) or (j<xya[k][1] and xya[k][2]==3) or (j>=xya[k][1] and xya[k][2]==4):
                res[i][j]=False
                break
res2=list(itertools.chain.from_iterable(res))

print(res2.count(True))


Measured memory_bytes: 9328
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	int n,m;
	cin >> n >> m;
	vector<int> good(n+1,1);
	vector<int> h(n+1);
	forn(i,1,n+1){
		cin >> h[i];
	}

	forn(i,0,m){
		int u,v;
		cin >> u >> v;
		if(h[u]>=h[v])
			good[v]=0;
		if(h[v]>=h[u])
			good[u] =0;
	}
	int count = 0;
	for(int i =1;i<=n;i++){
		if(good[i])count++;
	}
	cout << count << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}

Measured memory_bytes: 4048
n = int(input())
mod = 10**9+7
d = [{},{}]

def judge(s):
    if s[:3] == 'AGC' or s[:3] == 'GAC' or s[:3] == 'ACG' or s[0]+s[2:]=='AGC' or s[:2]+s[3]=='AGC':
        return False
    return True

d[0] = {'TTT':1}

for i in range(n):
    d[(i+1)%2] = {}
    for ne in 'AGCT':
        for elt in d[i%2]:
            if judge(ne+elt[:3]):
                if ne+elt[:2] in d[(i+1)%2]:
                    d[(i+1)%2][ne+elt[:2]] = (d[(i+1)%2][ne+elt[:2]]+d[i%2][elt])%mod
                else:
                    d[(i+1)%2][ne+elt[:2]] = d[i%2][elt]
res = 0
for e in d[n%2]:
    res = (res + d[n%2][e])%mod
print(res%mod)

        

Measured memory_bytes: 40176
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b = M()
print((b-a) * (b-a+1)//2 - b)

Measured memory_bytes: 68536
import java.util.Scanner;

/**
 * Created by zzt on 17-3-18.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int i = 1;
        int sum = 0;
        while (sum<x) {
            sum += i++;
        }
        System.out.println(i-1);
    }
}

Measured memory_bytes: 23124
N = int(input())
ans = [0]*(N+1)
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            num = x*x + y*y + z*z + x*y + y*z + z*x
            if num>N:
                break
            ans[num] = ans[num] + 1
for m in ans[1:]:
    print(m)


Measured memory_bytes: 9444
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int N;
    int K;
    int a[60];

    int ans=0;

    cin>>N>>K;
    for(int i=0;i<N;++i){
        cin>>a[i];
    }

    sort(a, a+N,greater<int>());

    for(int i=0;i<K;++i){
        ans+=a[i];
    }

    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
from itertools import accumulate
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
b_ = []
for bi in reversed(b):
    b_.append(n - bisect.bisect_right(c, bi))
b_ = list(accumulate(b_))[::-1]
for ai in a:
    idx_b = bisect.bisect_right(b, ai)
    if idx_b == n:
        break
    ans += b_[idx_b]
print(ans)

Measured memory_bytes: 25428
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
#include <math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  int N, D; cin >> N >> D;
  vector<vector<double>> x(N);
  int tmp;
  for(int i=0; i<N; i++){
    for(int j=0; j<D; j++){
      cin >> tmp;
      x[i].push_back(tmp);
    }
  }
  int ans = 0;
  double dist;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      dist = 0;
      for(int k=0; k<D; k++){
        dist += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
      }
      dist = sqrt(dist);
      if (ceil(dist) == dist){
        ans++;
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    n, y = map(int, input().split())

    for i in range(n + 1):
        for j in range(n - i + 1):
            if 9 * i + 4 * j == y // 1000 - n:
                print(i, j, n - (i + j))
                exit()

    print(-1, -1, -1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064