akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/

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

#define nil 1000000005

#define N 100002
struct edge{
    int to,dis;
};
int n,m;
vector<edge>e[N];
int used[N];



int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int l,r,d;cin>>l>>r>>d;
        e[l].push_back(edge{r,d});
        e[r].push_back(edge{l,-d});
    }
   
    
    for(int i=1;i<=n;i++){
        used[i]=nil;
    }
    int checked=1;
    while(checked<=n){
        queue<int>q;
        q.push(checked);
        used[checked]=0;
        while(!q.empty()){
            int sta=q.front();q.pop();
            for(auto x:e[sta]){
                if(used[x.to]==nil){
                used[x.to]=x.dis+used[sta];
                q.push(x.to);
                }else{
                    if(used[x.to]!=x.dis+used[sta]){
                        cout<<"No"<<endl;
                        return 0;
                    }
                }
            }
        }
        while(used[checked]!=nil&&checked<=n)checked++;
    }
    cout<<"Yes"<<endl;
    
    
    return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
#define int long long 
int32_t main()
{
    int k,a,b;
    cin>>k>>a>>b;
    int ans=1;
    if((b-a)>2){
        int diff=a-1;
        ans+=diff;
        k-=diff;
        if(k>0){
            int op=k/2;
            k-=op*2;
            ans+=op*(b-a);
            ans+=k;
        }
    }else ans+=k;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
s = input()
z = input()
alpha = "abcdefghijklmnopqrstuvwxyz"
s_alpha = [[] for _ in range(26)]
z_alpha = [[] for _ in range(26)]
for num, i in enumerate(s):
    pos = alpha.index(i)
    s_alpha[pos].append(num)
for num, i in enumerate(z):
    pos = alpha.index(i)
    z_alpha[pos].append(num)
s_alpha.sort()
z_alpha.sort()
if s_alpha == z_alpha:
    print("Yes")
else:
    print("No")


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

using namespace std;

const int maxn = 102;
int n, ans, a[maxn];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++)
	{
	    int cnt = 1;
	    for (int j = i + 1; j <= n; j++)
	        if (a[i] != a[j]) break;
	        else cnt++;
	    ans += cnt / 2;
	    i = cnt + i - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(),(a).end()

int main()
{
  string s;
  ll k;
  cin >> s >> k;

  rep(i,k){
    if(s.at(i)!='1'){
      cout<<s.at(i)<<endl;
      return 0;
    }
  }

  cout << 1 << endl;

  return 0;
}

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

const int INF = 2.1e9;

//Graph/Template
template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

//Graph/WarshallFloyd
template<class T>
void warshallFloyd(Matrix<T> &G){
	for(int k = 0;k < G.size();k++){
		for(int i = 0;i < G.size();i++){
			for(int j = 0;j < G.size();j++){
				if(G[i][k] == INF || G[k][j] == INF) continue;
				G[i][j] = min(G[i][j],G[i][k] + G[k][j]);
			}
		}
	}
}

signed main(){
	int n,m;
	scanf("%d %d",&n,&m);
	Matrix<int> G(n,vector<int>(n,INF));
	for(int i = 0;i < n;i++) G[i][i] = 0;
	for(int i = 0;i < m;i++){
		int s,t,d;
		scanf("%d %d %d",&s,&t,&d);
		G[s][t] = min(G[s][t],d);
	}
	warshallFloyd(G);
	for(int i = 0;i < n;i++){
		if(G[i][i] < 0){
			printf("NEGATIVE CYCLE\n");
			return 0;
		}
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			if(j) printf(" ");
			if(G[i][j] == INF) printf("INF");
			else printf("%d",G[i][j]);
		}
		printf("\n");
	}
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
 char a, b;
  cin >> a >> b;
  if(a == 'H'){
    if(b == 'H'){
    	cout << "H" << endl;
    }
    else{
    	cout << "D" << endl;
    }
  }
  else{
    if(b == 'H'){
    	cout << "D" << endl;
    }
    else{
    	cout << "H" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [int(input()) for i in range(n)]

#print(l)

go = 0
ans = -1

for i in range(n):
	#print('----')
	#print(i)
	go = l[go]-1
	#print(go)

	if go == 1:
		if ans < 0:
			ans = i +1

#print('-----')
print(ans)



Measured memory_bytes: 7084
#include <stdio.h>
#include <stdlib.h>



int main()
{
    long int n;
    long int a,b;
    long int s,s1,s2;
    scanf("%ld %ld %ld",&n,&a,&b);
    //
    if(a>b||n<1||(n==1&&a!=b)||a>1000000000||b>1000000000||n>1000000000)
        printf("0");
    else
    {
        s1=a*(n-1)+b;
        s2=a+b*(n-1);
        s=s2-s1+1;
        printf("%ld",s);
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() 
{
	int a[3];
	int b=0,c=0;
	for(int i=0;i<3;i++)
	{
		cin>>a[i];
		if(a[i]==5)
			b++;
		else if(a[i]==7)
			c++;
	}
	if(b==2&&c==1)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S; cin >> S;
    string s1 = "";
    string s2 = "";
    int N = S.size();
    REP(i,N) {
        s1 += (char)('0' + (i%2 == 0));
        s2 += (char)('0' + (i%2 != 0));
    }
    int ans1 = 0, ans2 = 0;
    REP(i,N) {
        ans1 += (s1[i] != S[i]);
        ans2 += (s2[i] != S[i]);
    }
    cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mem(ara,n) memset(ara,n,sizeof ara)
#define loop(i,j,n) for(i=j;i<n;i++)
#define rloop(i,j,n) for(i=n;i>=j;i--)
#define INF 2147483647
#define ll long long
#define pii pair<int,int>
#define eps 1e-9
#define mii map<int,int>
#define vi vector<int>
#define all(n) n.begin(),n.end()
#define inf INF
#define INFLL 9223372036854775807
using namespace std;
int main()
{
    int tc,t,i,j,k,n,m;
    pii pp[100005];
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>m;
        pp[i-1]={m,i};
    }
    sort(pp,pp+n);
    for(i=0;i<n;i++)cout<<pp[i].ss<<" ";cout<<endl;

}


Measured memory_bytes: 4376
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
vector<ll> nolonb(51,0); //the number of layers of LEVEL n burger

ll f(ll n, ll x){
    if(n==0 && x==1) return 1;

    if(x<=0){
        cout << "BUG" << endl;
        return -1;
    }

    if(x==1) return 0;
    else if(x<=1+nolonb.at(n-1)) return f(n-1,x-1);
    else if(x==2+nolonb.at(n-1)) return f(n-1,x-2)+1;
    else if(x<=nolonb.at(n)-1) return f(n-1,nolonb.at(n-1))+1+f(n-1,x-2-nolonb.at(n-1));
    else if(x==nolonb.at(n)) return 1+2*f(n-1,nolonb.at(n-1));

    cout << "BUG" << endl;
    return -1;
}


int main(){
    ll n,x; cin >> n >> x;
    nolonb.at(0) = 1;
    for(int i=1;i<=50;i++) nolonb.at(i) = 3 + 2*nolonb.at(i-1);
  
    //rep(i,51) cout << nolonb.at(i) << " " ; 
    cout << f(n,x) << endl;
}

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

int main() {
  string C1, C2;
  cin >> C1 >> C2;
  string c1 = C1;
  string c2 = C2;
  reverse(C1.begin(), C1.end());
  reverse(C2.begin(), C2.end());
  if (C1 == c2 && C2 == c1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    if(judge_parin(s)) {
      System.out.println("NO");
    } else {
      System.out.println("YES");
    }
  }
  public static boolean judge_parin(String s) {
    int a_c = 0, b_c = 0, c_c = 0;
    int gap = 0;
    char[] list = s.toCharArray();
    for(int i = 0; i < list.length; i++) {
      if(list[i] == 'a') {
        a_c++;
      } else if(list[i] == 'b') {
        b_c++;
      } else {
        c_c++;
      }
    }
    gap = max(a_c, b_c, c_c) - min(a_c, b_c, c_c);
    if(gap > 1) {
      return true;
    } else {
      return false;
    }
  }
  public static int max(int a, int b, int c) {
    int max = a;
    if(b > max) max = b;
    if(c > max) max = c;
    return max;
  }
  public static int min(int a, int b, int c) {
    int min = a;
    if(b < min) min = b;
    if(c < min) min = c;
    return min;
  }
}


Measured memory_bytes: 26832
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
using namespace std;


int main(){
    long long n;
    cin >> n;
    cout << (1 + n - 1) * (n - 1) / 2 << endl;
    return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  
  int k = (a + b) / 2;
  
  if( a + b == 2 * k ) {
    cout << k << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 100000000000;
int main(){
    ll a,b,q;
    cin >> a >> b >> q;
    vector<ll> s(a+2);
    vector<ll> t(b+2);
    s[0] = t[0] = -INF;
    s[a+1] = t[b+1] = INF;
    for(int i = 1;i <= a;i++)cin >> s[i];
    for(int i = 1;i <= b;i++)cin >> t[i];
    for(int i = 0;i < q;i++){
        ll x;
        cin >> x;
        ll ls,rs,lt,rt;
        rs = lower_bound(s.begin(),s.end(),x)-s.begin();
        ls = s[rs-1];
        rs = s[rs];
        rt = lower_bound(t.begin(),t.end(),x)-t.begin();
        lt = t[rt-1];
        rt = t[rt];
        ll ans;
        ans = abs(x-min(lt,ls));
        ans = min(ans,max(rs,rt)-x);
        ans = min(ans,rs-lt+min(rs-x,x-lt));
        ans = min(ans,rt-ls+min(rt-x,x-ls));
        //cout << ls <<" " << rs <<" " << lt <<" " << rt << endl;
        //cout << "ans:" << ans << endl;
        cout << ans << endl;
    }
    //cin >> a;
}

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.contains("7")) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35688
#include <cstdio>
#include <queue>


std::queue<int> q;
typedef struct{
	bool isVisited;
	int degree;
	int distance;
	int *neighbors;
} node;

void bfs(node* nodes){
	int id;
	while (!q.empty()){
		id = q.front();
		q.pop();
		for (int i=0; i<nodes[id].degree; i++){
			if (!nodes[nodes[id].neighbors[i]].isVisited){
				nodes[nodes[id].neighbors[i]].distance = nodes[id].distance+1;
				q.push(nodes[id].neighbors[i]);
				nodes[nodes[id].neighbors[i]].isVisited=true;
			}
		}
	}
}

int main(){
	int n, d, r, id;
	node *nodes;

	scanf("%d", &n);
	nodes = new node[n+1];
	for (int i=0; i<n;i++){
		nodes[i].isVisited=false;
		scanf("%d %d", &r, &d);
		nodes[i].degree=d;
		nodes[i].neighbors = new int[d];
		nodes[i].distance=-1;
		
		for (int j=0;j<d;j++){
			scanf("%d", &id);
			nodes[i].neighbors[j] = id-1;
		}
	}
	q.push(0);
	nodes[0].isVisited=true;
        nodes[0].distance=0;
	bfs(nodes);
	for (int i=0; i<n;i++){
		printf("%d %d\n", i+1, nodes[i].distance);
		delete []nodes[i].neighbors;
	}
	delete []nodes;
	return 0;
}

Measured memory_bytes: 2724
#include <iostream>
#include <string>

using namespace std;
 
int main(void){
    string str;
    int m, h, str_size;
    while(1){
        cin >>str;
        if(str=="-"){
            break;
        }
        str_size=str.size();
        cin >> m;
        for(int i=0; i<m; i++){
            cin >> h;
            str=str.insert(0, str.substr(h));
            str.erase(str_size);
        }
        cout << str <<endl;
    }
    return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main(){
  ll x,y,c;
  cin >> x >> y;
  ll s=x;
  c=0;
  while(s<=y){
    s=2*s;
    c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>

using namespace std;
int main(int argc, const char * argv[]) {
    
    int a, b;
    cin >> a >> b;

    cout << a*b-(a+b-1) << endl;
    return 0;
}

Measured memory_bytes: 764
n,m,c = map(int,input().split())
B = list(map(int,input().split()))
ans=0
for i in range(n):
    A = list(map(int,input().split()))
    sc = sum( a*b for (a,b) in zip(A,B) )+c
    if sc>0:
        ans+=1
print(ans)

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int k;
    long long h[200100];
    cin >> n >> k;
    for(int i = 0; i < n; i++) cin >> h[i];
    sort(h, h+n);
    long long total = 0;
    for(int i = 0; i < n-k; i++) total += h[i];
    cout << total << endl;
}

Measured memory_bytes: 5144
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=(1<<18)+5;
int n,a[N],m;
int f[N],g[N];
int read(){
	int x=0,w=1;
	char ch=0;
	while (ch<'0' || ch>'9'){
		  if (ch=='-') w=-1;
		  ch=getchar();
	}
	while (ch<='9' && ch>='0'){
		  x=(x<<1)+(x<<3)+ch-'0';
		  ch=getchar();
	}
	return x*w;
}
int main() {
	n=read();
	m=1<<n;
	for (int i=0;i<m;i++) a[i]=read();
	for (int i=1;i<m;i++)
		for (int j=i;j>=0;j=(j-1)&i) {
			if (a[j]>f[i]){ 
				g[i]=f[i];
				f[i]=a[j];
			} 
			else g[i]=max(g[i],a[j]);
			if (j==0) break;
		}
	int s=0;
	for (int i=1;i<m;i++) {
		s=max(s,f[i]+g[i]);
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 6016
#include <stdio.h>
int main(){
    int m,f,r,score[100]={0},saisi[100]={0},i=0,j;
    for(;;){
        scanf("%d %d %d",&m,&f,&r);
        if(m==-1 || f==-1){
            score[i]=-1;
        }else{
            score[i]=m+f;
            saisi[i]=r;
        }
        if(m==-1 && f==-1 && r==-1){
            break;
        }
        //printf("%d",score[i]);//test
        i++;
    }
    for(j=0; j<i; j++){
        if(score[j]==-1){
            printf("%c\n",'F');
        }else if(score[j] >=80){
            printf("%c\n",'A');
        }else if(65<=score[j]){
            printf("%c\n", 'B');
        }else if(50<=score[j]){
            printf("%c\n",'C');
        }else if(30<=score[j]){
            if(saisi[j]>=50){
                printf("%c\n", 'C');

            }else{
                printf("%c\n",'D');
            }
        }else{
            printf("%c\n",'F' );
        }
    }
    return 0;
}

Measured memory_bytes: 600
package main

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

func main() {
	n := readInt()

	fmt.Println(n * n * n)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin>>s;
    int k;
    cin>>k;
    int i = 0;
    while(s[i] == '1') i++;
    if (k <= i) cout << 1 << endl; else cout << s[i] << endl;
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd

n = int(raw_input())
L = map(int, raw_input().split())

D1 = [0]*n
D2 = [0]*n

for i in xrange(1, n):
    D1[i] = gcd(D1[i-1], L[i-1])

for i in xrange(n-2, -1, -1):
    D2[i] = gcd(D2[i+1], L[i+1])

M = [None]*n

for i in xrange(n):
    M[i] = gcd(D1[i], D2[i])

print max(M)

Measured memory_bytes: 45848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
ll dp[maxn][3];
char op[maxn][10];
int a[maxn];
int n;
ll f(int i, int j)
{
	if(~dp[i][j]) return dp[i][j];
	ll ret = a[i] * ((j & 1) ? -1 : 1);
	if(i == n) return dp[i][j] = ret;
	if(op[i][0] == '+')
	{
		if(j > 0) ret += max(f(i + 1, j - 1), f(i + 1, j));
		else ret += f(i + 1, j);
		return dp[i][j] = ret;
	}
	else
	{
		if(j == 0) ret += f(i + 1, j + 1);
		else if(j == 1) ret += max(f(i + 1, j), f(i + 1, j + 1));
		else ret += f(i + 1, j);
		return dp[i][j] = ret;
	}
}
int main()
{
	memset(dp, -1, sizeof dp);
	scanf("%d", &n);
	scanf("%d", &a[1]);
	for(int i = 2; i <= n; ++i) scanf("%s%d", op[i - 1], &a[i]);
	printf("%lld\n", f(1, 0));
	return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

template<class T>
map<T, int> factorize2(T n) {
    map<T, int> res;
    for (long long i = 2; (i * i) <= n; i++) {
        if (n % i) continue;
        res[i] = 0;
        while((n % i) == 0) {
            n /= i;
            res[i]++;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

struct mint {
    const int mod = 1e9 + 7;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll mod = 1e9 + 7;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    map<ll, ll> fac;
    rep(i, n) {
        auto tmp = factorize2(a[i]);
        for(auto x : tmp) {
            fac[x.first] = max(fac[x.first], (ll)x.second);
        }
    }
    mint val = 1;
    for(auto x : fac) {
        rep(i, x.second) {
            val *= x.first;
        }
    }
    mint ans = 0;
    rep(i, n) {
        ans += val / a[i];
    }
    cout << ans.x << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

template<class T> inline bool chmax(T& a, T b) { if (a <= b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

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

	int n; cin >> n;
	vector<int> a(n,0);
	rep(i, n-1) { int b; cin >> b; a[b - 1]++; }
	rep(i, n) cout << a[i] << endl;
}


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

int main(){
  int X,N;
  map<int,vector<int>>p;
  cin >> X >> N;
  for(int i=0;i<N;i++)
  {
    int j;
    cin >> j;
    p[abs(X-j)].push_back(j);
  }
  int d[2]={-1,1};
  for(int l=0;l<100;l++){
    if(p[l].size()==2) continue;
    if(p[l].size()==0){
      cout << X - l << endl;
      return 0;
    }

    for(int m:p[l])
    {
      for(int n:d)
      {
        int r=l*n+X;
        if(m!=r)
        {
          cout << r << endl;
          return 0;
        }
      }	
    }
  }
}


Measured memory_bytes: 3568
n=int(input())
sgs=['']
while len(sgs[-1])<=10:
  tmp=[]
  for s in sgs:
    for t in (list('357')+['']):
      tmp.append(t+s)
  sgs+=tmp
  sgs=list(set(sgs))
  sgs.sort()
sgs2=[]
for i in sgs:
  if len(set(list(i)))==3:
    sgs2.append(i)
sgs2.sort()
ans=0
for i in sgs2:
  if int(i)<=n:
    ans+=1
print(ans)

Measured memory_bytes: 47332
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <unordered_map>
using namespace std;

typedef double D;
const double EPS = 1e-8;

struct P {
  D x, y;
  P() { }
  P(D x_, D y_) : x(x_), y(y_) { }
};

struct C {
  P p;
  D r;
  C() { }
  C(P p_, D r_) : p(p_), r(r_) { }
  C(D x_, D y_, D r_) : p(x_, y_), r(r_) { }
};

int sig(double a, double b) {
  if(a < b - EPS) return -1;
  if(a > b + EPS) return +1;
  return 0;
}

bool iCC(C a, C b) {
  D dx = a.p.x - b.p.x;
  D dy = a.p.y - b.p.y;
  D d2 = dx*dx + dy*dy;
  return sig(d2, (a.r + b.r)*(a.r + b.r)) < 0;
}

int N;
C circle[24];
int color[24];
bool overlap[24][24];

unordered_map<int, int> memo;
int solve(int S) {
  if(memo.count(S)) return memo[S];
  int top = 0;
  for(int i = 0; i < N; ++i) {
    if(((S >> i) & 1) == 0) continue;
    bool ok = true;
    for(int j = 0; j < i; ++j) {
      if(((S >> j) & 1) == 0) continue;
      if(overlap[i][j]) {
        ok = false;
        break;
      }
    }
    if(ok) {
      top |= (1 << i);
    }
  }
  int res = 0;
  for(int i = 0; i < N; ++i) {
    for(int j = i + 1; j < N; ++j) {
      if(((top >> i) & 1) && ((top >> j) & 1) && color[i] == color[j]) {
        int B = S;
        B &= ~(1 << i);
        B &= ~(1 << j);
        res = max(res, 2 + solve(B));
      }
    }
  }
  return memo[S] = res;
}

int main() {
  while(true) {
    memo.clear();
    cin >> N;
    if(N == 0) break;
    for(int i = 0; i < 24; ++i)
      for(int j = 0; j < 24; ++j)
        overlap[i][j] = false;
    for(int i = 0; i < N; ++i) {
      cin >> circle[i].p.x >> circle[i].p.y >> circle[i].r >> color[i];
      color[i]--;
    }
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < i; ++j) {
        if(iCC(circle[i], circle[j])) {
          overlap[i][j] = true;
        }
      }
    }
    cout << solve((1 << N) - 1 ) << endl;
  }
}

Measured memory_bytes: 42120
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().run();
	}
	char[][] map;
	int dir;
	int x;
	int y;
	int h;
	int w;
	public void run(){
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		int n;
		char[] op;
		for(int data = 0;data < t;data++){
			h = scan.nextInt();
			w = scan.nextInt();
			map = new char[h][w];
			for(int i = 0;i < h;i++){
				map[i] = scan.next().toCharArray();
			}
			n = scan.nextInt();
			op = scan.next().toCharArray();
			boolean fl = false;
			for(int i = 0;i < h;i++){
				for(int j = 0;j < w;j++){
					if(map[i][j] == '^'){
						dir = 0; x = j; y = i;
						fl = true;
						break;
					}else if(map[i][j] == '<'){
						dir = 3; x = j; y = i;
						fl = true;
						break;
					}else if(map[i][j] == '>'){
						dir = 2; x = j; y = i;
						fl = true;
						break;
					}else if(map[i][j] == 'v'){
						dir = 1; x = j; y = i;
						fl = true;
						break;
					}
				}
				if(fl){
					break;
				}
			}
			for(int i = 0;i < n;i++){
				switch(op[i]){
				case 'U': up(); break;
				case 'D': down(); break;
				case 'R': right(); break;
				case 'L': left(); break;
				case 'S': shoot(); break;
				default: break;
				}
			}
			for(int i = 0;i < h;i++){
				for(int j = 0;j < w;j++){
					System.out.print(map[i][j]);
				}
				System.out.println();
			}
			if(data != t-1){
				System.out.println();
			}
		}
	}
	public void up(){
		dir = 0;
		if(y != 0){
			if(map[y-1][x] == '.'){
				map[y--][x] = '.';				
			}
		}
		map[y][x] = '^';
	}
	public void down(){
		dir = 1;
		if(y != h-1){
			if(map[y+1][x] == '.'){
				map[y++][x] = '.';
			}
		}
		map[y][x] = 'v';
	}
	public void right(){
		dir = 2;
		if(x != w-1){
			if(map[y][x+1] == '.'){
				map[y][x++] = '.';
			}
		}
		map[y][x] = '>';
	}
	public void left(){
		dir = 3;
		if(x != 0){
			if(map[y][x-1] == '.'){
				map[y][x--] = '.';
			}
		}
		map[y][x] = '<';
	}
	public void shoot(){
		if(dir == 0){
			for(int i = y;i >= 0;i--){
				if(map[i][x] == '#'){
					break;
				}else if(map[i][x] == '*'){
					map[i][x] = '.';
					break;
				}
			}
		}else if(dir == 1){
			for(int i = y;i < h;i++){
				if(map[i][x] == '#'){
					break;
				}else if(map[i][x] == '*'){
					map[i][x] = '.';
					break;
				}
			}
		}else if(dir == 2){
			for(int i = x;i < w;i++){
				if(map[y][i] == '#'){
					break;
				}else if(map[y][i] == '*'){
					map[y][i] = '.';
					break;
				}
			}
		}else if(dir == 3){
			for(int i = x;i >= 0;i--){
				if(map[y][i] == '#'){
					break;
				}else if(map[y][i] == '*'){
					map[y][i] = '.';
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 28864
#include <bits/stdc++.h>
using namespace std;
#define int long long
inline void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = 238; int n, m = 62, a[N], k[N]; char ch[N]; 
signed main() {
	int T; read (T);
	while (T--) {
		read (n); int ok = 1;
		for (int i = 0; i <= 100; ++i) k[i] = 0;
		for (int i = 1; i <= n; ++i) read (a[i]);
		scanf ("%s", ch + 1);
		for (int i = n; i >= 1; --i) {
			for (int j = 0; j <= m; ++j) 
				if ((a[i] >> j) & 1) a[i] ^= k[j];
			if (ch[i] == '1') {
				if (a[i]) { ok = 0; break; }
			} else {
			  	for (int j = 0; j <= m; ++j)
					if ((a[i] >> j) & 1) { k[j] = a[i]; break; }
			}
		} ok ? puts ("0") : puts ("1");
	} return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(void){
	int a,b,n,s,i;

	while(scanf("%d %d %d",&a,&b,&n)!=EOF){
		s=0; 
		for(i=0;i<n;i++){
			a*=10;
			s+=a/b%10;
			a%=b;
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 1024
// clang-format off
#include <cassert>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <set>
#include <queue>
#include <cmath>

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b)-1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)

#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define pii pair<int, int>
#define vi vector<int>

using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T>& p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T>& vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
constexpr ll MOD = 1000000007;


int keta(ll n)
{
    int k = 0;
    while(n > 0){
        n /= 10;
        k++;
    }
    return k;
}

int main(){

    ll N;
    cin >> N;
    const ll sq = (ll)(sqrt(N));
    for(ll i = sq ; i > 0; i--){
        if(N % i == 0){
            cout <<  keta(N/i) << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define MOD 1000000007
//#define MOD 998244353
//define MOD 1000000007000000
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int memo=0;
    ll ans=1;
    Rep(i,1,n){
        if(a[i-1]==a[i]){

        }
        else if(a[i-1]<a[i]){
            if(memo==0){
                memo=1;
            }
            else if(memo==1){

            }
            else if(memo==-1){
                memo=0;
                ans++;
            }
        }
        else if(a[i-1]>a[i]){
            if(memo==0){
                memo=-1;
            }
            else if(memo==1){
                memo=0;
                ans++;
            }
            else if(memo==-1){
                
            }
        }
        //cout<<i<<" "<<ans<<endl;
    }
    cout<<ans<<endl;


}


Measured memory_bytes: 1024
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    var ts = Number(chunk);
    var s = ts % 60;
    var tm = (ts - s) / 60;
    var m = tm % 60;
    var th = (tm - m) / 60;
    var h = th;
    console.log('%d:%d:%d', h, m, s);
});

Measured memory_bytes: 7648
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

n=int(input())
a=[]
temp=int(input())
a.append(temp)
g=temp

for _ in range(n-1): #O(nlogt)
    temp=int(input())
    a.append(temp)
    gc=gcd(max(g,temp),min(g,temp))
    g=g*(temp//gc)

print(g)

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

int n,m;
int WA[105000];
bool AC[105000];

void solve(){
  cin >>n >>m;
  int WAnum = 0;
  int ACnum = 0;
  for(int i = 1; i<=n; i++){
    WA[i]=0;
    AC[i]=false;
  }
  while(m--){
    int p; 
    string s;
    cin >>p >>s;
    if(AC[p]) continue;
    if(s == "AC") {
      AC[p] = true;
      ACnum++;
      WAnum += WA[p];
    } else if(s == "WA"){
      WA[p]++;
    }
  }
  cout << ACnum << " " << WAnum << endl;
  return;
}

int main(){
  solve();
  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int area=1;
		int length=0;
		while(scan.hasNext()){
			
			int num = scan.nextInt();
			area*=num;
			length+=num*2;
		}
		System.out.println(area+" "+length);
	}
}

Measured memory_bytes: 17164
#include <iostream>
#include<string>
#include <cassert>
#include <algorithm>
#include <functional>
#include<stdio.h>

using namespace std;

int main() {
	int N;
	int sum=0
		;
	int i = 0;
	int tako[200];
	cin >> N;
	for (i = 0; i < N; ++i) {
		cin >> tako[i];
	}
	for (i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (i != j) {
				sum+=tako[i] * tako[j];
			
			}
			else if (i == j) {

			}
		}
	}
	cout << sum/2;



}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

ll factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
    }
    return ans;
}

ll extended_factorial(ll N){
    ll ans = 1;
    llRep(i,N){
        ans *= i;
        ans %= (ll)(1e9+7);
    }
    return ans;
}

vector<ll> Eratosthenes(ll N){
    bool arr[N+1];
    //initialization
    arr[0] = false;
    arr[1] = false;
	for(ll i = 2; i < N+1; i++){
		arr[i] = true;
	}
    //eratosthenes
	for(ll i = 2; i <= sqrt(N); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) <= N; j++){
				arr[i *(j + 2)] = false;//not prime number
			}
		}
	}
    vector<ll> prime;
    llRep(i,N){
        if (arr[i]==true){
            prime.push_back(i);
        }
    }
    return prime;
}

char alphabet[] = {
    'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
};


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

    ll divide = 10;
    if (N<divide){
        cout << N << endl;
        return 0;
    }
    ll cnt=0;
    while(1){
        cnt += (divide-divide/10);
        if (N<divide*10){
            cout << cnt << endl;
            return 0;
        }else if (N<divide*100){
            cnt += ((N-divide*10)+1);
            cout << cnt << endl;
            return 0;
        }else{
            divide *= 100;
        }
    }
    return 0;
}


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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  
  int count = 0;
  for (int i = l; i < r + 1; i++) {
    if (i % d == 0) {
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3632
# abc 153
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

H, N = map(int, readline().split())
A = list(map(int, readline().split()))

A.sort(reverse=True)

for a in A:
    H -= a

if H <= 0:
    print('Yes')
else:
    print('No')


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

int main()
{
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

    if (x >= W || y >= H) cout << "No" << endl;
    else if (x-r < 0 || x+r > W) cout << "No" << endl;
    else if (y-r < 0 || y+r > H) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O2")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 

//USE AT YOUR OWN RISK
lli tmod(lli x,lli m=mod){return (x%m+m)%m;}

template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<tmod(a[i])<<c;
	cout<<"\n";
}

//make sure x is below mod
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}


// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }


int main() 
{ 
    // fact[0]=1;
    // f(i,1,2000001)fact[i]=(i*fact[i-1])%mod;
    
    fastio;
    int t;
    // cin>>t;
    t=1;
    int temp=t;
	while(t--){
        // cout<<"Case #"<<temp-t<<": ";
        int n;
        cin>>n;
        string s;cin>>s;
        lli ans=0;
        f(i,0,n-1){
            map <char,int> mp;
            mp[s[i]]++;
            mp[s[i+1]]++;
            f(j,i+2,n){
                mp[s[j]]++;
                if(s[i]!=s[j]){
                    int x='R'+'G';
                    x=x+'B';
                    x=x-s[i];
                    x=x-s[j];
                    ans+=mp[x];
                    if((i+j)%2==0 && x==s[(i+j)/2])ans--;
                }
            }
        }
        cout<<ans<<"\n";
    }   
    return 0; 	
}


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

int main(){
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    int h[n];
    for(int i=0;i<n;i++)
        cin >> h[i];
    int dp[n];
    dp[0] = 0;
    
    for(int i=1;i<min(k,n);i++){
        dp[i] = INT_MAX;
        for(int j=0;j<i;j++)
            dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
    }
    
    for(int i=k;i<n;i++){
        dp[i] = INT_MAX;
        for(int j=i-k;j<i;j++)
            dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
    }
    cout << dp[n-1];
}

Measured memory_bytes: 4408
K,X = map(int,input().split())

ans = []

shift = -K+1
for i in range(2*K-1):
    if X+shift< -1000000 or X+shift > 1000000:
        continue
    ans.append(X+shift)
    shift += 1
    
for s in ans:
    print(s,end=" ")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
using pp=pair<int,pair<int,int>>;
#define MAX 200003
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  int X,Y;
  cin>>X>>Y;
  int ans=0;
  if(X==1){
    ans+=300000;
  }else if(X==2){
    ans+=200000;
  }else if(X==3){
    ans+=100000;
  }

  if(Y==1){
    ans+=300000;
  }else if(Y==2){
    ans+=200000;
  }else if(Y==3){
    ans+=100000;
  }

  if(X==1&&Y==1){
    ans+=400000;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3552
n = int(input())
h = [int(item) for item in input().split()]

max_h = 0 
count = 0
for i, item in enumerate(h):
    if i == 0:
        max_h = item
        count += 1
    else:
        if item >= max_h:
            max_h = item
            count += 1
print(count)

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

int n, a[200010];
ll mod;
string s;

long long extgcd(long long a,long long b,long long& x,long long& y)
{
  long long d = a;
  if(b != 0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }
  else
    x = 1,y = 0;
  return d;
}

long long mod_inv(long long a,long long m)
{
  long long x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

void solve() {
  ll ans = 0;
  if( mod == 2 || mod == 5 ) {
    rep(i,n) if( ( mod == 2 || mod == 5 ) && (s[i]-'0') % mod == 0 ) ans += (ll)( i + 1 );
  } else {
    vector<ll> a(n);
    ll pw10 = 1;
    for(int i=n-1;i>=0;--i) {
      a[i] = ( ( (s[i]-'0') * pw10 ) % mod + ((i+1<n)?a[i+1]:0) ) % mod;
      ( pw10 *= 10LL ) %= mod;
    }
    map<ll,ll> mp;
    rep(i,n) ++mp[a[i]];
    for(int i=n-1;i>=0;--i) {
      int v = ((i+1<n)?a[i+1]:0);
      if( mp.count(v) ) ans += mp[v];
      --mp[a[i]];
    }
  }
  cout << ans << endl;
}

int main() {
  cin >> n >> mod;
  cin >> s;
  solve();
  return 0;
}


Measured memory_bytes: 2564
from bisect import bisect_left
N, K = map(int, input().split())
Points = [list(map(int, input().split())) for i in range(N)]


# 座標圧縮
def point_compress(points):
    x_points = sorted([x for x, y in points])
    y_points = sorted([y for x, y in points])
    points_compressed = []
    for x, y in points:
        points_compressed.append([bisect_left(x_points, x), bisect_left(y_points, y)])
    return points_compressed


Points_compressed = point_compress(Points)


class Ruisekiwa2D:
    def __init__(self, h, w):
        self.H = h
        self.W = w
        self.G = [[0] * w for _ in range(h)]

    def load(self, points):
        # 問題によってイメージしやすいよう書き換えてください
        for x, y in points:
            self.G[x][y] += 1

    def load_imos(self, points):
        # pointsは[[左上h, 左上w, 右下h, 右下w], ...]であること
        for i1, j1, i2, j2 in points:
            self.G[i1][j1] += 1  # 左上
            if j2 + 1 < self.W:  # 右上
                self.G[i1][j2+1] -= 1
            if i2 + 1 < self.H:
                self.G[i2+1][j1] -= 1  # 左下
            if j2 + 1 < self.W and i2 + 1 < self.H:  # 右下
                self.G[i2+1][j2+1] += 1

    def calc(self):
        for y in range(self.W):
            for x in range(1, self.H):
                self.G[x][y] += self.G[x-1][y]

        for y in range(1, self.W):
            for x in range(self.H):
                self.G[x][y] += self.G[x][y-1]

    def get(self, i1, j1, i2, j2):
        if i1 > i2 or j1 > j2 or i1 < 0 or j1 < 0 or i2 < 0 or j2 < 0:
            return 0
        elif i1 > 0 and j1 > 0:
            return self.G[i2][j2] - self.G[i1-1][j2] - self.G[i2][j1-1] + self.G[i1-1][j1-1]
        elif i1 <= 0 < j1:
            return self.G[i2][j2] - self.G[i2][j1-1]
        elif j1 <= 0 < i1:
            return self.G[i2][j2] - self.G[i1 - 1][j2]
        else:
            return self.G[i2][j2]


# 二次元累積和
R2D = Ruisekiwa2D(N, N)
R2D.load(Points_compressed)
R2D.calc()


ans = float('inf')
for yi in range(N):
    for yj in range(N):
        for xi in range(N):
            for xj in range(N):
                cx1, cx2 = Points_compressed[xi][0], Points_compressed[xj][0]
                cy1, cy2 = Points_compressed[yi][1], Points_compressed[yj][1]

                x1, x2 = Points[xi][0], Points[xj][0]
                y1, y2 = Points[yi][1], Points[yj][1]

                # 二次元累積和で高速に長方形内部に含まれる点の数を数える
                inside = R2D.get(cx1, cy1, cx2, cy2)
                if inside >= K:
                    ans = min(ans,  abs(x2 - x1) * abs(y2 - y1))

print(ans)


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

int main(){
int n,k,q;
cin>>n>>k>>q;
vector<int>a(n);
rep(i,q){
    int b;
    cin>>b;
    a[b-1]++;
}
rep(i,n){
if(k-q+a[i]>0){
   cout<<"Yes"<<endl;
}
else{
   cout<<"No"<<endl;
}
}

}

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

int main()
{
int N;scanf("%d",&N);
int K;scanf("%d",&K);
vector<int> x(N);int ans=0;
for(int i=0;i<N;i++)scanf("%d ",&x[i]);
for(int i=0;i<N;i++)ans+=min(x[i],abs(K-x[i]))*2;
printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <iostream>
#define REP(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;

ll sum1,sum2,cost1,cost2;
int main() {
	int n; cin >> n;
	REP(i,n) {
    int cur; cin >> cur;
		sum1 += cur, sum2 += cur;
		if (i&1) {
			if (sum1<=0) cost1 += 1-sum1, sum1 = 1;
			if (sum2>=0) cost2 += sum2+1, sum2 = -1;
		} else {
			if (sum1>=0) cost1 += sum1+1, sum1 = -1;
			if (sum2<=0) cost2 += 1-sum2, sum2 = 1;
		}
	}
	cout << min(cost1, cost2) << endl;
}

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

vector<pair<ll,ll>>PF(ll n)
{
	vector<pair<ll,ll>>v;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			ll cnt=0;
			while(n%i==0)
			{
				n/=i;
				cnt++;
			}
			v.push_back(make_pair(i,cnt));
		}
	}
	if(n!=1)v.push_back(make_pair(n,1));
	return v;
}


int main()
{
	ll n,t[1005]={},MOD=1000000007,ans=1;
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		vector<pair<ll,ll>>w=PF(i);
		for(ll j=0;j<w.size();j++)
		{
			t[w[j].first]+=w[j].second;
		}
	}
	for(ll i=1;i<=n;i++)
	{
		if(t[i])ans=ans*(t[i]+1)%MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
int main(){
 
    int i, j;
    double n, p, x[100], y[100], d[4] = {0};
 
    scanf("%lf", &n);
    for(i = 0; i < n; i++){
        scanf("%lf", &x[i]);
    }
    for(i = 0; i < n; i++){
        scanf("%lf", &y[i]);
    }
 
 
    for(i = 1; i <= 3; i++){
        p = i;
        for(j = 0; j < n; j++){
            d[i - 1] += pow(fabs(x[j] - y[j]), p);
        }
 
        d[i - 1] = pow(d[i - 1], 1 / p);
 
        printf("%.11lf\n", d[i - 1]);
    }
 
 
    d[3] = 0;
    for(i = 0; i < n; i++){
        if(d[3] < fabs(x[i] - y[i])){
            d[3] = fabs(x[i] - y[i]);
        }
    }
    printf("%.11lf", d[3]);
 
 
    return 0;
}


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

const int INF = 1e+9 * 2;
double eps = 1e-10;

int main() {
	long double v;
	while(cin >> v){
		double y = 4.9 * pow(v / 9.8, 2.0);
		for(int i = 1; ; ++i){
			if(5 * i - 5 >= y){
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1232