akhauriyash/Code-Regression huggingface dataset:
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define pb push_back
using ll = long long;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

signed main(){
  int N,K,Q;
  cin >> N >> K >> Q;
  vector<int> Point;
  int threshold = K- Q;
  REP(i,N){
    Point.pb(0);
  }
  int temp;
  REP(i,Q){
    cin >> temp;
    Point[temp-1]++;
  }
  if(threshold>0){
    REP(i,N){
      cout << "Yes" <<endl;
    }
  }else if(threshold==0){
    REP(i,N){
      if(Point[i] <= 0)cout << "No" <<endl;
      else cout << "Yes" <<endl;
    }
  }else if(threshold<0){
    REP(i,N){
      Point[i] += threshold;
      if(Point[i] <= 0)cout << "No" <<endl;
      else cout << "Yes" <<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1524
#include <iostream>
using namespace std;
int a[10000];
int c[100][100];
int main(void) {
  int h, w, n;
  cin >> h >> w >> n;
  int p = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[p] == 0) p++;
      c[i][j] = p + 1;
      a[p]--;
    }
  }
  for (int i = 0; i < h; i++) {
    if (i % 2 == 0) {
      for (int j = 0; j < w; j++) {
        cout << c[i][j] << " ";
      }
    } else {
      for (int j = w - 1; j >= 0; j--) {
        cout << c[i][j] << " ";
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

LL dp[505][505] = {0};
LL n,k,a[505],ans = INF;

int main(){
	memset(dp,0x3f,sizeof(dp));
	cin >> n >> k;
	for(LL i = 1;i <= n;i ++){
		cin >> a[i];
		dp[i][0] = 0;
	} dp[0][0] = 0;
	for(LL j = 1;j <= n - k;j ++){
		for(LL i = 0;i <= n;i ++){
			for(LL l = i + 1;l <= n;l ++){
				dp[i][j] = min(dp[i][j],dp[l][j - 1] + max(0LL,a[l] - a[i]));	
			}
		}
	}
	cout << dp[0][n - k] << endl;
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
int main(){
    long long int N; cin>>N;
    long long int sum=0,FB=0;
    for(ll i=1;i<=N;i++){
        sum=sum+i;
        if(i%3==0||i%5==0){
            FB=FB+i;
        }
    }
    cout<<sum-FB;
    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin >> n >> m;
    if(n==1)
    {
        cout << m;
        return 0;
    }
    vector <int> dp;
    for(int i=1;i<=sqrt(m);i++)
    {
        if(m%i==0)
        {
            if(m/i==i)
                dp.push_back(i);
            else
            {
                dp.push_back(i);
                dp.push_back(m/i);
            }
        }
    }
    sort(dp.begin(),dp.end());
    for(int i=1;i<dp.size();i++)
    {
        if(dp[i]>(m/n))
        {
            cout << dp[i-1];
            return 0;
        }
    }
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
int x[100001];
ll dp[1<<20];
int n_;
ll query(int a,int b,int k=0,int l=0,int r=n_){
	if(a<=l && r<=b)return dp[k];
	if(r<=a || b<=l)return 0;
	ll vl=query(a,b,k*2+1,l,(l+r)/2);
	ll vr=query(a,b,k*2+2,(l+r)/2,r);
	return max(vl,vr);
}

void update(int k,ll a){
	k+=n_-1;
	dp[k]=a;
	while(k>0){
		k=(k-1)/2;
		dp[k]=max(dp[k*2+1],dp[k*2+2]);
	}
}

int main(void){
	scanf("%d",&n);
	n_=1;
	while(n_<n)n_*=2;
	ll sum=0;
	for(int i=0;i<n;i++){
		scanf("%d",&x[i]);
		sum+=(ll)x[i];
	}
	for(int i=0;i<n;i++){
		ll val=query(0,x[i]-1);
		update(x[i]-1,(ll)x[i]+val);
	}
	printf("%lld\n",sum-dp[0]);
	return 0;
}

Measured memory_bytes: 2996
from collections import deque
inf = 10 ** 7
N, M = map(int, input().split())
P = [list(map(int,input().split())) for i in range(M)]
a = [[] for i in range(N)]
for i in P:
    a[i[0]-1].append(i[1]-1)
    a[i[1]-1].append(i[0]-1)
path = [-1] * N
path[0] = 0
checked = [False] * N
stack = deque([(0,0)])
while (len(stack) != 0):
    kk = stack.popleft()
    now = kk[0]
    pre = kk[1]
    if  not checked[now]:    
        nextP = a[now]
        checked[now] = True
        path[now] = pre
        for i in nextP:
            stack.append((i,now))
if False in checked:
    print("No")
else:
    print("Yes")
    for i in path[1:]:
        print(i + 1)





Measured memory_bytes: 86576
s=input()
q=int(input())
m=0
from collections import deque
s=deque(s)
for i in range(q):
  l=list(map(str,input().split()))
  if l[0]=="1":
    m+=1
    m%=2
  else:
    if m==0:
      if l[1]=="1":
        s.appendleft(l[2])
      else:
        s.append(l[2])
    else:
      if l[1]=="1":
        s.append(l[2])
      else:
        s.appendleft(l[2])
s=list(s)
if m==1:
  s=s[::-1]
print("".join(s))



Measured memory_bytes: 13908
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, a;
    cin >> n >> a;
    if(n % 500 == 0){
        cout << "Yes" << endl;
    }
    else if(a >= n){
        cout << "Yes" << endl;
    }
    else if(n % 500 <= a){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3


M = 10 ** 9 + 7


def compute(n):
    return (pow(10, n, M) - 2 * pow(9, n, M) + pow(8, n, M)) % M


def main():
    n = int(input())
    res = compute(n)
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9168
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int ans=0;
        for(int i=0;i<n;i++)if(sc.next().equals("E869120"))ans++;
        System.out.println(ans);
        
    }
    
}


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

int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++){
      for(int k = 0; k <= c; k++){
        if(500 * i + 100 * j + 50 * k == x) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using ll =long long;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  int n;
  cin>> n;
  vector<ll> h(n);
  vector<int> sign(n);
  for(int i; i<n;i++){
    cin >> h[i];
  }
  int ans=0,count =0;
  for(int i=0; i<n-1; i++){
    if(h[i+1]-h[i]<=0){
      sign[i]=0;
    }
    else{
      sign[i]=1;
    }
  }
  for(int i=0; i<n-1;i++){
    if(sign[i]==0 ){
      count++;
    }
    if(sign[i]==1 || i==n-2 ){
      ans =max(ans,count);
      count =0;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1408
import bisect
primes = [0, 0] + [1]*32767
for i in range(2, 182):
    if primes[i]:
        for j in range(i*i, 32769, i):
            primes[j] = 0

prime_value = [i for i in range(2, 32769) if primes[i]]
while True:
    n = int(input())
    if n == 0:
        break
    x = bisect.bisect_left(prime_value, n//2)
    y = bisect.bisect_left(prime_value, n)
    values = prime_value[x:y]
    print(sum(1 for v in values if primes[n-v]))

Measured memory_bytes: 7884
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for (int i = 0; i <= a; i++)
    {
        for (int j = 0; j <= b;j++){
            for (int k = 0; k <= c;k++){
                if(500*i+100*j+50*k==x){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
vector<vector<int>> G(100000);
vector<bool> visit(100000, false);
vector<int> prenum(100000), parent(100000, -1), lowest(100000);
int timer = 1;

void dfs(int u, int prev) {
	prenum[u] = lowest[u] = timer++;
	visit[u] = true;
	for (int v : G[u]) {
		if (!visit[v]) {
			parent[v] = u;
			dfs(v, u);
			lowest[u] = min(lowest[u], lowest[v]);
		}
		else if (v != prev) {
			lowest[u] = min(lowest[u], prenum[v]);
		}
	}
}

int main() {
	cin.tie(0);ios::sync_with_stdio(false);
	int V, E; cin >> V >> E;
	set<pair<int, int>> Ans;
	for (int i = 0; i < E;i++) {
		int s, t; cin >> s >> t;
		G[s].emplace_back(t);
		G[t].emplace_back(s);
	}
	dfs(0, -1);

	//u:??? v:???
	//prenum[u] < lowest[v]

	for (int i = 0; i < V;i++) {
		for (int v : G[i]) {
			if (prenum[i] < lowest[v]) {
				if (i <= v) { Ans.insert(make_pair(i, v)); }
				else { Ans.insert(make_pair(v, i)); }
			}
		}
	}

	for (auto p : Ans) {
		cout << p.first << " " << p.second << endl;
	}
}

Measured memory_bytes: 7776
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    int n;
    while(cin >> n){
        if(n == 0)return 0;
        int ans = 0;
        for(int a = 0;a <=n;a++){
            for(int b = a;b <= n;b++){
                if(b-a < 2)continue;
                if(((b+1)*b)/2 - ((a+1)*a)/2 == n){
                    ans++;
                }
            }
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

#define N 10000

int isprime(int);

int main(){

  int i,j,n,count=0;
  int num[N];
  
  scanf("%d",&n);

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

  for(i=0; i<n; i++){
    
    if(isprime(num[i])==1) count++;

    }

  printf("%d\n",count);
  
  return 0;
}

int isprime(int x){

  int i;
  
  if(x == 2) return 1;

  if(x<2 || x%2==0) return -1;

  i=3;

  while (i<=sqrt(x)){
    
    if (x%i==0) return -1;

    i=i+2;
  }
  
  return 1;
  
}

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

using namespace std;
int a, b;
int main() {
    cin >> a >> b;

    for (int i=1; i<=1000;i++) {
        if ((floor(i * 0.08) == a) && (floor(i * 0.1)==b)) {cout << i << endl; return 0;}
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

type graph struct {
	path []int
	height int
	// flag bool // pathに存在するもので自分より高いものがあればtrue
}
var graphs []graph
// var wg sync.WaitGroup
var count int
func main() {
	var N,M int
	fmt.Scan(&N,&M)
	graphs = make([]graph,N)
	for i:= 0; i<N; i++ {
		var h int
		fmt.Scan(&h)
		graphs[i].height = h
		graphs[i].path = []int{}
		// graphs[i].flag = false
	}
	for i:= 0; i<M; i++ {
		var a,b int
		fmt.Scan(&a,&b)
		graphs[a-1].path = append(graphs[a-1].path,b-1)
		graphs[b-1].path = append(graphs[b-1].path,a-1)
	}
	count = 0
	for i:=0; i<N; i++ {
		// wg.Add(1)
		goFor(i)
	}
	// wg.Wait()
	fmt.Println(count)
}

func goFor (i int) {
	paths := graphs[i].path
	height := graphs[i].height
	bestHeight := true // 一番高いのならtrue
	for _, value := range paths {
		if height <= graphs[value].height {
			bestHeight = false
			break
		}
	}
	if bestHeight {
		// fmt.Println(graphs[i],"ベスト")
		count++
	}
}


Measured memory_bytes: 12100
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        //int n = stdIn.nextInt();
        //int a = stdIn.nextInt();
        //int b = stdIn.nextInt();
        //int c = stdIn.nextInt();
        String s = stdIn.next();
        char c[] = s.toCharArray();
        //String ss[] = new int[s.length()];
        
        boolean flag = true;
        
        for(int i = 0; i < s.length(); i++){
            if(i % 2 == 0){
                if(c[i] == 'L'){
                    flag = false;
                    break;
                }
            }else{
                if(c[i] == 'R'){
                    flag = false;
                    break;
                }
            }
        }
        
        if(flag){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        
        // if(s.equals("Sunny")){
        //     System.out.println("Cloudy");
        // }else if(s.equals("Cloudy")){
        //     System.out.println("Rainy");
        // }else{
        //     System.out.println("Sunny");
        // }
        
        //int count = 0;
        
        //for(int i = 0; i < s.length(); i++){
            //ss[i] = c
        //}
        
        //System.out.println();
    }
    
}


Measured memory_bytes: 25300
#include <iostream>

using namespace std;
int n,i,p[51],j,ok=1,ok1=1;
int main()
{
    cin>>n;
    for(i=1; i<=n; ++i)
        cin>>p[i];
    for(i=1; i<n; ++i)
        if(p[i]>p[i+1])
        {
            ok=0;
            j=i;
            break;
        }
    if(ok) cout<<"YES";
    else
    {
        for(i=n; i>j; --i)
            if(p[i]<p[j])
                if(p[i]<p[j-1] || p[j]<p[i-1])
                {
                    cout<<"NO";
                    ok1=0;
                    break;
                }
                else
                {
                    swap(p[i],p[j]);
                    break;
                }
        if(ok1)
        {
            ok=1;
            for(i=1; i<n; ++i)
                if(p[i]>p[i+1])
                {
                    cout<<"NO";
                    ok=0;
                    break;
                }
            if(ok) cout<<"YES";
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

using namespace std;

void solve()
{
	int N;
	cin >> N;
	vector<int> a(N);
	long long int all = 0;
	for (int i = 0; i < N; ++i)
	{
		cin >> a[i];
		all += a[i];
	}
	long long int minVal = 1e18;
	long long int sum = 0;
	for (int i = 0; i < N - 1; ++i)
	{
		sum += a[i];
		minVal = min(minVal, abs(2 * sum - all));
	}
	cout << minVal << endl;
}

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

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

typedef struct {
	long long int x;
	long long int v;
} xv;

using namespace std;

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

	int N;
	long long int C;
	vector<xv> input;
	vector<long long int> table;
	vector<long long int> f1;
	vector<long long int> f2;
	vector<long long int> g;
	vector<long long int> h;

	cin >> N >> C;

	input.resize(N+1);
	table.resize(N+1);
	f1.resize(N+1);
	f2.resize(N+1);
	g.resize(N+1);
	h.resize(N+1);

	input[0].x = input[0].v = 0;
	for (int i = 1; i <= N; i++) {
		cin >> input[i].x >> input[i].v;
	}

	table[0] = 0;
	f1[0] = 0;
	f2[0] = 0;
	for (int i = 1; i <= N; i++) {
		table[i] = table[i-1] + input[i].v;
		f1[i] = f1[i-1] + input[i].v + input[i-1].x - input[i].x;
		f2[i] = f2[i-1] + input[i].v + 2 * input[i-1].x - 2 * input[i].x;
	}

	g[0] = f1[0];
	h[0] = f2[0];
	for (int i = 1; i <= N; i++) {
		g[i] = max(g[i-1], f1[i]);
		h[i] = max(h[i-1], f2[i]);
	}

	long long int max = 0;
	for (int b = 0; b <= N; b++) {
		long long int p1, p2, p;

		if (b == 0) {
			p1 = g[N];
			p2 = h[N];
		} else {
			p1 = g[b-1] + table[N] - table[b-1] - 2 * (C - input[b].x);
			p2 = h[b-1] + table[N] - table[b-1] - (C - input[b].x);
		}

		if (p1 > p2) {
			p = p1;
		} else {
			p = p2;
		}

		if (max < p) {
			max = p;
		}
	}

	cout << max << endl;

	return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;

int main() {
	string S;
	cin >> S;
	if (S == "AAA")cout << "No" << endl;
	else if (S == "BBB")cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
S=input()
total1=0
total2=0
for i in range(len(S)):
    if i%2==0:
        if S[i]=="1":
            total1+=1
    elif i%2==1:
        if S[i]=="0":
            total1+=1
for i in range(len(S)):
    if i%2==0:
        if S[i]=="0":
            total2+=1
    elif i%2==1:
        if S[i]=="1":
            total2+=1
print(min(total1,total2))

Measured memory_bytes: 40304
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    rep(i, h) {
        cout << s[i] << endl;
        cout << s[i] << endl;
    }
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#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 RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    REP(i, N) {
        cin >> x[i] >> y[i];
    }
    vector<int> a(N);
    REP(i, N) a[i] = i;
    double result = 0;
    ll factorial = 0;
    do {
        double L = 0;
        REP(i, N - 1)
            L += sqrt(pow(x[a[i]] - x[a[i + 1]], 2) + pow(y[a[i]] - y[a[i + 1]], 2));
        result += L;
        factorial++;
    } while (next_permutation(all(a)));
    PRINT(factorial);
    result /= factorial;
    cout << setprecision(10) << result << endl;
    return 0;
}


Measured memory_bytes: 256
def D():
    n, m = map(int, input().split())
    a, b, c = [], [], []
    dist = [[float('inf') if i != j else 0 for j in range(n)] for i in range(n)]

    for _ in range(m):
        in_a, in_b, in_c = map(int, input().split())
        a.append(in_a - 1)
        b.append(in_b - 1)
        c.append(in_c)

    for i in range(m):
        dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i])
        dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i])

    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])

    ans = m
    for i in range(m):
        shortest = False
        for j in range(n):
            if dist[j][a[i]] + c[i] == dist[j][b[i]]:
                shortest = True
                break
        if shortest:
            ans -= 1

    print(ans)


if __name__ == '__main__':
    D()

Measured memory_bytes: 45148
#include <stdio.h>
#define max(x, y) ((x)<(y) ? (y) : (x))

int d[] = {1, 0, -1, 0, 1};

int main(){
  int h, w;  scanf("%d %d", &h, &w);
  int field[22][22] = {0};
  for(int i=0; i<h; i++){
    char s[22];  scanf("%s", s);
    for(int j=0; j<w; j++)
      if(s[j] == '.')
	field[i+1][j+1] = 1;
  }

  int ans = 0;
  for(int i=1; i<=h; i++)
    for(int j=1; j<=w; j++){
      if(!field[i][j])  continue;
      int table[22][22] = {0};  table[i][j] = 1;
      int queue[470][2], qsize = 470, front = 0, rear = 0, nowh, noww;
      queue[rear][0] = i, queue[rear][1] = j, rear++;
      while(front != rear){
	nowh = queue[front][0], noww = queue[front][1], front++;
	for(int di=0; di<=4; di++){
	  int newh = nowh+d[di], neww = noww+d[di+1];
	  if(field[newh][neww] && !table[newh][neww]){
	    queue[rear][0] = newh, queue[rear][1] = neww, rear++;
	    table[newh][neww] = table[nowh][noww] + 1;
	    ans = max(ans, table[newh][neww]);
	  }
	}
      }
    }

  printf("%d\n", ans-1);

  return 0;
}


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

int idx[100000],idy[100000];
int sum[100000];

int main(){
	int h,w,d;scanf("%d%d%d",&h,&w,&d);
	rep(i,h)rep(j,w){
		int a;scanf("%d",&a);a--;
		idx[a]=i;idy[a]=j;
	}
	rep(i,h*w){
		if(i>=d)sum[i]=sum[i-d]+abs(idx[i]-idx[i-d])+abs(idy[i]-idy[i-d]);
	}
	int q;scanf("%d",&q);
	rep(i,q){
		int l,r;scanf("%d%d",&l,&r);r--;l--;
		printf("%d\n",sum[r]-sum[l]);
	}
}

Measured memory_bytes: 2176
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 24 15:49:31 2019

@author: Owner
"""
import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy


def chmin(dp, b): #dp配列参照渡し、bは数値
    
    return True

N = int(input())

h = [0]*N
h[:] = map(int, input().split())

dp = [np.inf]*N

for n in range(N):
    if n == 0:
        dp[n] = 0
    elif n== 1:
        dp[n] = abs(h[n] - h[n-1])
    else:
        dp[n] = min(dp[n-2] + abs(h[n]-h[n-2]), dp[n-1] + abs(h[n]-h[n-1]))
    #print(dp)
print(dp[N-1])

Measured memory_bytes: 25560
#include <iostream>
#include <string.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN = 1e4 + 5;
const int INF = 0x3f3f3f3f;
#define DEBUG(x) cout << (x) << '\n'

int f[MAXN];
void calc(int x, int y, int z){
    ll a = (x + y + z) * (x + y + z) - x * y - x * z - y * z;
    if(a <= 10000) f[a]++;
}
void run(){
    int n, ans = 0; cin >> n;
    for(int i = 1; i <= 100; i++)
    for(int j = 1; j <= 100; j++)
    for(int k = 1; k <= 100; k++)
        calc(i, j, k);
    for(int i = 1; i <= n; i++) DEBUG(f[i]);
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
//    ios::sync_with_stdio(false);

   run(); return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <cstdio>

#define tmp1 ( a[n>>1] )
#define tmp2 ( a[(n>>1)+1] )

using namespace std;

typedef long long ll;
const int Maxn = 200010;
int n;
ll sum , ans1 , ans2 , ans3;
ll a[Maxn];

template < typename T >
inline T Abs(T x) {
	return x > 0 ? x : -x;
}

int main() {
	
	scanf("%d",&n);
	for(register int i=1; i<=n; i++) {
		scanf("%lld",&a[i]);
		a[i] -= (ll)i;
		sum += a[i];
	}
	sum /= (ll)n;
	
	sort(a+1,a+n+1);
	
	for(register int i=1; i<=n; i++) {
		ans1 += Abs(a[i]-sum);
		ans2 += Abs(a[i]-tmp1);
		ans3 += Abs(a[i]-tmp2);
	}
	
	cout << min(ans3,min(ans1,ans2)) << endl;
		
	return 0;
	
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
from collections import deque
import bisect

n = int(input())
a = list(map(int,input().split()))

links = [[] for _ in range(n+1)]
for _ in range(n-1):
    v,w = map(int, input().split())
    links[v].append(w)
    links[w].append(v)

inf = 10**10
lis = [inf] * n
inf_ind = 0
parent = [-1]*(n+1)
operate = [0] * (n+1)
ans = [-1]*(n+1)
d = deque()
d.append(1)
while(d):
    now = d.popleft()
    if(operate[now]==0):
        p = parent[now]
        if(p!=-1):
            d.appendleft(now)
        for child in links[now]:
            if(child != p):
                parent[child] = now
                d.appendleft(child)

        a_now = a[now-1]
        ind = bisect.bisect_left(lis,a_now)
        operate[now] = (ind,lis[ind],a_now)
        lis[ind] = a_now
        if(inf_ind == ind):
            inf_ind += 1
        ans[now] = inf_ind
    else:
        ind,before,after = operate[now]
        lis[ind] = before
        if(before == inf):
            inf_ind -= 1
    # print(lis)

for i in ans[1:]:
    print(i)

Measured memory_bytes: 157072
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  if ((b - a) & 1) {
    cout << "Borys" << endl;
  } else {
    cout << "Alice" << endl;
  }
  return 0;
}


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

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vector<P> factorize(ll x) {
  vector<P> res;
  for (int i = 2; i * i <= x; ++i) {
    if(x % i) continue;
    res.emplace_back(i, 0);
    while (x % i == 0) {
      res.back().second++;
      x /= i;
    }
  }
  if(x > 1) res.emplace_back(x, 1);
  return res;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n;
  ll m;
  cin >> n >> m;
  combination comb(2000000);
  auto f = factorize(m);


  mint ans = 1;
  rep(i, f.size()) {
    ll r = f[i].second;
    ans *= comb(n + r - 1, r);
  }
  cout << ans << endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;



int main(){

    int n,d;
    cin>>n>>d;

    vvi x(n,vi(d));
    rep(i,n)rep(j,d)cin>>x[i][j];
    int ans=0;

    rep(i,n-1)repa(j,i+1,n){
        int dis=0;
        rep(k,d)dis+=(x[i][k]-x[j][k]) * (x[i][k]-x[j][k]);
        int a=1;
        while(true){
            if(a*a == dis)ans++;
            if(a*a >= dis)break;
            a++;
        }
    }

    cout<<ans<<"\n";

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
typedef pair<int, int> pii;
// LatexBegin
struct Dinic { LL flow;
  struct Node : vector<int> { int d, p; };
  struct Edge { int u, v; LL c; };
  vector<Node> N; vector<Edge> E;
  void init(int n) {
    E.clear(); N.clear(); N.resize(n); flow = 0;
  }
  void addEdge(int u, int v, LL c) { int m = E.size();
    E.push_back({u, v, c}); N[u].push_back(m++);
    E.push_back({v, u, 0}); N[v].push_back(m++);
  }
  void run(int s, int t) {
    flow = 0; while (bfs(s, t)) flow += dfs(s,t,INF);
  }
  bool bfs(int s, int t) {
    for (auto &v : N) v.d = -1, v.p = 0;
    queue<int> q; q.push(s); N[s].d = 0;
    while (q.size()) { int u = q.front(); q.pop();
      for (auto &e : N[u]) { int v = E[e].v;
        if (!~N[v].d && E[e].c)
          q.push(v), N[v].d = N[u].d + 1;
      }
    }
    return ~N[t].d;
  }
  LL dfs(int u, int t, LL a) {
    if (u == t || !a) return a; LL flow = 0;
    for (int &p = N[u].p; p < N[u].size() ; p++) {
      auto e = N[u][p], v = E[e].v;
      if (N[u].d + 1 != N[v].d) continue;
      LL f = dfs(v, t, min(a, E[e].c));
      E[e].c -= f; E[e ^ 1].c += f; flow += f; a -= f;
      if (!a) break;
    }
    return flow;
  }
} solver;
// LatexEnd
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    vector<vector<char>> G(n, vector<char>(m));
    for (auto &vv : G)
        for (auto &v : vv)
            cin >> v;
    solver.init(1 + n * m + 1);
    for (int i = 0 ; i < n ; i++) {
        for (int j = 0 ; j < m ; j++) {
            if ((i + j) % 2)
                solver.addEdge(0, 1 + (i * m + j), 1);
            else
                solver.addEdge(1 + (i * m + j), 1 + n * m, 1);
            for (int d = 0 ; d < 4 ; d++) {
                int nx = i + dx[d];
                int ny = j + dy[d];
                if (nx < 0 || nx >= n || ny < 0 || ny >= m)
                    continue;
                if (G[i][j] != '.' || G[nx][ny] != '.')
                    continue;
                if ((i + j) % 2)
                    solver.addEdge(1 + i * m + j, 1 + nx * m + ny, 1);
                else
                    solver.addEdge(1 + nx * m + ny, 1 + i * m + j, 1);
            }
        }
    }
    solver.run(0, 1 + n * m);
    cout << solver.flow << '\n';
    auto E = solver.E;
    for (int i = 0 ; i < E.size() ; i += 2) {
        if (E[i].u == 0 || E[i].v == 1 + n * m)
            continue;
        if (E[i].c)
            continue;
        int u = E[i].u - 1, v = E[i].v - 1;
        if (u > v) swap(u, v);
        pii x = {u / m, u % m};
        pii y = {v / m, v % m};
        if (x.F == y.F) {
            G[x.F][x.S] = '>';
            G[y.F][y.S] = '<';
        } else {
            G[x.F][x.S] = 'v';
            G[y.F][y.S] = '^';
        }
    }
    for (int i = 0 ; i < n ; i++) {
        for (int j = 0 ; j < m ; j++)
            cout << G[i][j];
        cout << '\n';
    }
}

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

int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  string ans = "NG";
  for (int i = A; i <= B; i++) {
    if (i % N == 0) {
      ans = "OK";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include<iostream>
using std::cout;
using std::cin;
using std::endl;

int main()
{
  int n, k;
  cin >> n >> k;
  
  int sum = 0;
  for (int i = 0; i < n; i ++)
  {
    int tmp;
    cin >> tmp;
    
    if (tmp > k - tmp) sum += (k - tmp) * 2;
    else sum += tmp * 2;
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define pai 3.14159265358979323846264338327950238
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
bool used[100100];
int ans[100100];
vector<int>v[100100];
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n,m;
	cin>>n>>m;
	rep(i,m)
	{
		int a,b;
		cin>>a>>b;
		a--,b--;
		v[a].pb(b);
		v[b].pb(a);
	}
	queue<int> q;
	q.push(0);
	while(!q.empty())
	{
		int p=q.front();
		q.pop();
		rep(i,v[p].size())
		{
			if(!used[v[p][i]])
			{
				used[v[p][i]]=1;
				ans[v[p][i]]=p;
				q.push(v[p][i]);
			}
		}
	}
	rep(i,n-1)
	{
		if(!used[i+1])
		{
			cout<<"No\n";
			return 0;
		}
	}
	cout<<"Yes\n";
	rep(i,n-1)cout<<ans[i+1]+1<<endl; 
	return 0;
}



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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

ll gcd( ll m, ll n )
{
	if (n == 0) return m;
	else return gcd(n, m%n);
}//gcd
 
//*********************************************************
// 最小公倍数（Least Common Multiple）を返す。
// 引数に０がある場合は０を返す。
//*********************************************************
ll lcm( ll m, ll n )
{
	ll g = gcd(m, n);
	return (m / g * n); // lcm = m * n / gcd(m,n)
}//lcm

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

    int N, K;
    cin>>N>>K;
    ll cd = 1;
    vector<ll> A(N);
    cin>>A[0];
    cd = A[0];
    for (int n = 1; n < N; n++) {
        cin>>A[n];
        cd = gcd(cd, A[n]);
    }
    for (auto a : A) {
        if (a >= K && (a - K) % cd == 0) {
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;

    return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val (x, y) = readIntegerList()
    if (y * 2 < x || x * 2 < y || (x + y) % 3 != 0) {
        println(0)
        return
    }

//    y = -x + b
//    b = y1 + x1
//    y = -x + x1 + y1
//    -----------
//    y = x / 2
//    -2x + 2x1 + 2y1 = x
//    x = 2 * (x1 + y1) / 3
//    y = (x1 + y1) / 3
    val lowX = 2 * (x + y) / 3
    val lowY = (x + y) / 3
    val cX = lowX / 2
    val cY = y - lowY
    val table = Combination(1000000, 1000000007)
    println(table.value(cX, cY))

}

/** n <= 1000000 */
class Combination(n: Int, private val MOD: Long) {
    private val fact = Array(n + 1) { 0L }
    private val ifact = Array(n + 1) { 0L }

    /** O(n) */
    init {
        fact[0] = 1L
        for (i in 1..n) {
            fact[i] = (fact[i - 1] * i) % MOD
        }
        ifact[n] = inverse(fact[n], MOD)
        for (i in n downTo 1) {
            ifact[i - 1] = (ifact[i] * i) % MOD
        }
    }

    /** O(1) */
    fun value(n: Int, k: Int): Long {
        if (k < 0 || k > n) {
            return 0
        }

        val tmp = (fact[n] * ifact[k]) % MOD
        return (tmp * ifact[n-k]) % MOD
    }

    /** O(log(m)) */
    private fun pow(n: Long, m: Long, MOD: Long): Long {
        var ret = 1L
        var x = n
        var k = m
        while (k > 0) {
            if ((k and 1L) == 1L) {
                ret = (ret * x) % MOD
            }
            x = (x * x) % MOD
            k = k shr 1
        }

        return ret
    }

    /** O(log(MOD)) */
    private fun inverse(n: Long, MOD: Long) = pow(n, MOD - 2L, MOD)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 120320
# coding: utf-8
# Your code here!
s=list(input())
count=0

for i in range(len(s)):#偶数ならグー　奇数ならパーになる
    if s[i]=='g':
        s[i]=0
    else:
        s[i]=1
    if i&1^s[i]==1 and i&1==1:
        count+=1
    elif i&1^s[i]==1 and s[i]&1==1:
        count-=1
    else:
        pass

print(count)


Measured memory_bytes: 4008
import numpy as np
h,w = map(int,input().split())
S = np.array([list(input()) for _ in range(h)])=="."
D = np.zeros((h,w),dtype = int)
U = np.zeros((h,w),dtype = int)
L = np.zeros((h,w),dtype = int)
R = np.zeros((h,w),dtype = int)
for i in range(h):
  U[i]= (U[i-1]+1)*S[i]
  D[-i-1]= (D[-i]+1)*S[-1-i]
for i in range(w):
  L[:,i]= (L[:,i-1]+1)*S[:,i]
  R[:,-1-i]= (R[:,-i]+1)*S[:,-i-1]
print(np.max(U+D+R+L)-3)


             

Measured memory_bytes: 219832
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
    ll A,B;cin>>A>>B;
    if(A<B)cout<<"a < b";
    else if(A==B)cout<<"a == b";
    else cout<<"a > b";
    cout<<"\n";
    return 0;
}



Measured memory_bytes: 3028
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAXN = 1000002;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
#define fill(x,y) memset(x,y,sizeof(x))
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll mul(ll x, ll y)
{
    return (x * 1ll * y) % MOD2;
}

ll fastpow(ll x, ll y)
{
    ll z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}
struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.first != b.first) {
      return a.first > b.first;
    }
    return a.second >b.second;
  }
};
int main(int argc, char** argv)
{   sws ;
   // tcase
    {
     ll n ;
     cin>>n ;
     if(n>=30)
     cout<<"Yes\n" ;
     else
     cout<<"No\n" ;
    }
return 0 ;
}

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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int max_intersection=0;
    for (int i=1;i<n;i++){
        vector<char> v;
        vector<char> left(s.begin(), s.begin()+i);
        vector<char> right(s.begin()+i, s.end());
        sort(left.begin(), left.end());
        left.erase(unique(left.begin(), left.end()), left.end());
        sort(right.begin(), right.end());
        right.erase(unique(right.begin(), right.end()), right.end());

        auto point = set_intersection(left.begin(), left.end(), right.begin(), right.end(), back_inserter(v));
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
        if (v.size() >= max_intersection){
            max_intersection = v.size();
        }
    }
    cout << max_intersection << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'

function main(input) {
    const x = Number(input.split('\n')[0].split(' ')[0]);
    // let r = Number(input.split('\n')[0].split(' ')[1]);
    // let d = Number(input.split('\n')[0].split(' ')[2]);
    let ans;
    if (x >= 400 && x < 600) {
        ans = 8;
    } else if (x >= 600 && x < 800) {
        ans = 7;
    } else if (x >= 800 && x < 1000) {
        ans = 6;
    } else if (x >= 1000 && x < 1200) {
        ans = 5;
    } else if (x >= 1200 && x < 1400) {
        ans = 4;
    } else if (x >= 1400 && x < 1600) {
        ans = 3;
    } else if (x >= 1600 && x < 1800) {
        ans = 2;
    } else if (x >= 1800 && x < 2000) {
        ans = 1;
    }
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29680
#include<bits/stdc++.h>
#define mx 100000
#define pb push_back
#define siz(v) v.size()
typedef unsigned long long ull;
typedef long long  ll;
using namespace std;

int main()
{
 	ios_base::sync_with_stdio(0);
 	cin.tie(0); cin.tie(0);
	
	ll a,b;
	cin >> a >> b;
	cout << a * b;
	






 return 0;
 }


Measured memory_bytes: 3640
n = int(input())
s = [input() for i in range(n)]

s.sort()
#print(s)
l = []
ans_count = 0
count = 1
S = s[0]
for i in range(1,n):
    if S == s[i]:
        count += 1
        if i == n-1:
            l.append([S,count])
            ans_count = max(ans_count,count)
    else:
        l.append([S,count])
        S = s[i]
        ans_count = max(ans_count,count)
        count = 1
        if i == n-1:
            l.append([S,count])
            ans_count = max(ans_count,count)
#print(l)
#print(ans_count)
ans = []
for i in l:
    if i[1] == ans_count:
        ans.append(i[0])
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 41432
#include <stdio.h>
#include <stdbool.h>

char s[13][7];
int order[32] = {0, 1, 2, 3, 0, 3, 2, 1, 2, 1, 0, 3, 2, 3, 0, 1,
                 3, 0, 1, 2, 3, 2, 1, 0, 1, 0, 3, 2, 1, 2, 3, 0};
int nds[32] = {4, 0, 7, 3, 6, 1, 5, 2, 5, 2, 6, 1, 7, 3, 4, 0,
               3, 4, 0, 7, 1, 5, 2, 6, 2, 6, 1, 5, 0, 7, 3, 4};
int ds[8] = {1, 3, 1, 3, 0, 2, 0, 2};
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
char ls[8] = {'R', 'L', 'R', 'L', 'U', 'D', 'U', 'D'};
int i, j;

bool doesWallExist(int x, int y, int d){
    // printf("%d, %d, %d, %d, %d: ", x, y, d, x+(dx[d]-1)/2, 2*y+(dy[d]-1)/2);
    if(s[2*y+dy[d]][x+(dx[d]-1)/2] == '1'){
        //puts("o");
        return true;
    }
    //puts("x");
    return false;
}

int main(){
    for(i=0;i<13;i++){
        for(j=0;j<7;j++){
            s[i][j] = '0';
        }
    }

    for(i=2;i<=10;i++){
        int ub = i%2?5:4;
        for(j=0;j<ub;j++){
            scanf("%c", &s[i][j+1]);
        }
        scanf("%*c");
    }

    bool f = false;
    int x = 1, y = 1, d = 0;
    while(!(x == 1 && y == 1 && f)){
        if(!f){f = true;}

        // printf("%d, %d, %d\n", x, y, d);
        putchar(ls[d]);
        x += dx[ds[d]]; y += dy[ds[d]];

        for(i=0;i<4;i++){
            if(doesWallExist(x, y, order[d*4+i])){
                d = nds[d*4+i];
                break;
            }
        }
    }
    puts("");

    /* for(int i=0;i<13;i++){ */
    /*     for(int j=0;j<7;j++){ */
    /*         putchar(s[i][j]); */
    /*     } */
    /*     puts(""); */
    /* } */

    return 0;
}

Measured memory_bytes: 524
N = int(input())
A = [list(map(int,input().split())) for _ in range(N-1)]
A.insert(0,0)
B = [0 for _ in range(N+1)]
for i in range(1,N):
    C1,S1,F1 = A[i]
    T = S1
    for j in range(i+1,N):
        C2,S2,F2 = A[j]
        if T+C1>=S2:
            dt = (T+C1)%F2
            if dt>0:
                T += F2-dt+C1
            else:
                T += C1
        else:
            T = S2
        C1 = C2
        S1 = S2
        F1 = F2
    T += C1
    B[i] = T
for i in range(1,N+1):
    print(B[i])

Measured memory_bytes: 40688
N,M=map(int,input().split())
a_l=[]
b_l=[]
for i in range(N):
    a_l.append(list(input()))
for i in range(M):
    b_l.extend(input())
count=0
for t in range (N-M+1):
    for k in range(N-M+1):
        tmp=[]
        for i in range(M):
            for j in range(M):
                tmp.append(a_l[t+i][k+j])
        if tmp == b_l:
            print('Yes')
            exit()
        else:
            continue
print('No')


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int N, M, Q;
int a[50], b[50], c[50], d[50];

int A[10];

int eval() {
    int ret = 0;
    for(int i = 0; i < Q; i++) {
        if(A[b[i] - 1] - A[a[i] - 1] == c[i]) ret += d[i];
    }
    return ret;
}

//深さ　前に埋めた数字
int dfs(int dpt, int num) {
    if(dpt == N) {
        return eval();
    }

    int ret = -1;
    for(int i = num; i <= M; i++) {
        A[dpt] = i;
        ret = max(ret, dfs(dpt + 1, i));
    }

    return ret;
}

int main() {
    cin >> N >> M >> Q;
    for(int i = 0; i < Q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    cout << dfs(0, 1) << endl;
    return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;
using P = pair<int,int>;
using ll =long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
//                A,C,H,M,R
const int d[5] = {0,2,7,12,17};

int main(){
    int n;
    cin >> n;
    vector<set<string>> se(5);
    rep(i,n){
        string s;
        cin >> s;
        rep(j,5){
            if((int)(s[0] - 'A')==d[j]){
                se[j].insert(s);
                break;
            }
        }
    }
    ll ans = 0;
    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++){
                ans += (ll)se[i].size() * (ll)se[j].size() * (ll)se[k].size();
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9600